1
0
mirror of https://github.com/pratiktri/dotfiles.git synced 2026-05-06 19:43:40 +05:30

fix(neovim): nvim-treesitter updates for neovim 0.12 & remove

nvim-ts-context-commentstring plugin
This commit is contained in:
Pratik Tripathy
2026-04-15 12:35:40 +05:30
parent 14fd2092ef
commit 2c4aa996e5
2 changed files with 126 additions and 107 deletions
+126 -94
View File
@@ -210,107 +210,139 @@ return {
-- Treesitter -- Treesitter
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
branch = "main",
lazy = false, lazy = false,
build = ":TSUpdate", build = ":TSUpdate",
init = function(plugin) init = function()
require("lazy.core.loader").add_to_rtp(plugin) -- Disable the plugin's own vimscript runtime
require("nvim-treesitter.query_predicates") vim.g.loaded_nvim_treesitter = 1
end, end,
dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" },
config = function() config = function()
vim.defer_fn(function() require("nvim-treesitter").setup({
require("nvim-treesitter.configs").setup({ auto_install = true,
ensure_installed = { })
"bash",
"css", local parsers = {
"dockerfile", "bash",
"go", "css",
"html", "dockerfile",
"javascript", "go",
"json5", "html",
"jsonc", "javascript",
"lua", "json5",
"markdown", "lua",
"markdown_inline", "markdown",
"python", "markdown_inline",
"regex", "python",
"rust", "regex",
"scss", "rust",
"sql", "scss",
"svelte", "sql",
"tsx", "svelte",
"typescript", "tsx",
"vue", "typescript",
"yaml", "vue",
"yaml",
}
local installed = require("nvim-treesitter").get_installed()
local to_install = vim.tbl_filter(function(p)
return not vim.tbl_contains(installed, p)
end, parsers)
if #to_install > 0 then
require("nvim-treesitter.install").install(to_install)
end
-- Auto-install when opening a new filetype
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("TSAutoInstall", { clear = true }),
callback = function(args)
local lang = vim.treesitter.language.get_lang(vim.bo[args.buf].filetype)
if not lang then
return
end
local ok = pcall(vim.treesitter.language.inspect, lang)
if not ok then
-- Parser not installed yet, install it
require("nvim-treesitter.install").install({ lang })
end
end,
})
-- FileType autocmd: wire up highlight + indent for every treesitter-capable buffer
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("TSEnable", { clear = true }),
callback = function(args)
local buf = args.buf
-- start() returns false if no parser is available, pcall catches missing parsers
if pcall(vim.treesitter.start, buf) then
-- Treesitter-based indentation
vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end,
})
-- Incremental selection is NATIVE in 0.12 (no plugin config)
-- 0.12 defaults: gnn (init), grn (expand node), grm (shrink), grc (scope)
-- Remap to your existing keys:
vim.keymap.set("n", "<C-space>", "gnn", { remap = true, desc = "Init treesitter selection" })
vim.keymap.set("x", "<C-CR>", "grc", { remap = true, desc = "Expand scope selection" })
vim.keymap.set("x", "<bs>", "grm", { remap = true, desc = "Shrink node selection" })
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
dependencies = { "nvim-treesitter/nvim-treesitter" },
config = function()
require("nvim-treesitter-textobjects").setup({
select = {
enable = true,
lookahead = true,
keymaps = {
["aa"] = { query = "@parameter.outer", desc = "Select around the parameter" },
["ia"] = { query = "@parameter.inner", desc = "Select inside the parameter" },
["af"] = { query = "@function.outer", desc = "Select around the function" },
["if"] = { query = "@function.inner", desc = "Select inside of the function" },
["ac"] = { query = "@class.outer", desc = "Select around the class" },
["ic"] = { query = "@class.inner", desc = "Select inside of the class" },
["al"] = { query = "@loop.outer", desc = "Select around the loop" },
["il"] = { query = "@loop.inner", desc = "Select inside of the loop" },
["as"] = { query = "@scope", query_group = "locals", desc = "Select around the scope" },
}, },
},
auto_install = true, move = {
indent = { enable = true }, enable = true,
goto_next_start = {
incremental_selection = { ["]f"] = { query = "@function.outer", desc = "Goto next function start" },
enable = true, ["]o"] = { query = "@loop.*", desc = "Goto next loop start" },
keymaps = { ["]a"] = { query = "@parameter.inner", desc = "Goto next parameter" },
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = "<C-CR>",
node_decremental = "<bs>",
},
}, },
goto_next_end = {
textobjects = { ["]F"] = { query = "@function.outer", desc = "Goto next function end" },
select = { ["]C"] = { query = "@class.outer", desc = "Goto next class end" },
enable = true, ["]O"] = { query = "@loop.*", desc = "Goto next loop end" },
lookahead = true, -- Automatically jump forward to textobj
keymaps = {
["aa"] = { query = "@parameter.outer", desc = "Select around the parameter" },
["ia"] = { query = "@parameter.inner", desc = "Select inside the parameter" },
["af"] = { query = "@function.outer", desc = "Select around the function" },
["if"] = { query = "@function.inner", desc = "Select inside of the function" },
["ac"] = { query = "@class.outer", desc = "Select around the class" },
["ic"] = { query = "@class.inner", desc = "Select inside of the class" },
["al"] = { query = "@loop.outer", desc = "Select around the loop" },
["il"] = { query = "@loop.inner", desc = "Select inside of the loop" },
["as"] = { query = "@scope", query_group = "locals", desc = "Select around the scope" },
},
},
move = {
-- Jump to next and previous text objects
-- ]a -> next argument
-- ]T -> next test
enable = true,
goto_next_start = {
["]f"] = { query = "@function.outer", desc = "Goto next inner function start" },
["]o"] = { query = "@loop.*", desc = "Goto next loop start" },
["]a"] = { query = "@parameter.inner", desc = "Goto next parameter" },
},
goto_next_end = {
["]F"] = { query = "@function.outer", desc = "Goto next outer function end" },
["]C"] = { query = "@class.outer", desc = "Goto next outer class end" },
["]O"] = { query = "@loop.*", desc = "Goto next loop end" },
},
goto_previous_start = {
["[f"] = { query = "@function.outer", desc = "Goto goto previous inner function start" },
["[o"] = { query = "@loop.*", desc = "Goto previous loop start" },
["[a"] = { query = "@parameter.inner", desc = "Goto previous parameter" },
},
goto_previous_end = {
["[F"] = { query = "@function.outer", desc = "Goto goto previous outer function start" },
["[C"] = { query = "@class.outer", desc = "Goto previous outer class start" },
["[O"] = { query = "@loop.*", desc = "Goto previous loop start" },
},
},
lsp_interop = {
enable = true,
border = "none",
floating_preview_opts = {},
},
}, },
}) goto_previous_start = {
end, 0) ["[f"] = { query = "@function.outer", desc = "Goto previous function start" },
["[o"] = { query = "@loop.*", desc = "Goto previous loop start" },
["[a"] = { query = "@parameter.inner", desc = "Goto previous parameter" },
},
goto_previous_end = {
["[F"] = { query = "@function.outer", desc = "Goto previous function end" },
["[C"] = { query = "@class.outer", desc = "Goto previous class end" },
["[O"] = { query = "@loop.*", desc = "Goto previous loop end" },
},
},
lsp_interop = {
enable = true,
border = "none",
floating_preview_opts = {},
},
})
end, end,
}, },
} }
@@ -172,19 +172,6 @@ return {
end, end,
}, },
-- Intelligent commenting on JSX
{
"JoosepAlviste/nvim-ts-context-commentstring",
opts = {
options = {
enable_autocmd = false,
},
},
config = function()
vim.g.skip_ts_context_commentstring_module = true
end,
},
-- Highlight colors -- Highlight colors
{ {
"brenoprata10/nvim-highlight-colors", "brenoprata10/nvim-highlight-colors",