nvim: Fix treesitter textobjects

Was not installed correctly, and neither set up correctly. Now should be
fully working, with objects targeting Functions, Loops, Conditionals,
Statements and (nushell) Pipelines.
This commit is contained in:
Marty Oehme 2025-03-14 23:03:43 +01:00
parent 4d6270a9b0
commit 62b0188fcc
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 29 additions and 15 deletions
nvim/.config/nvim

View file

@ -58,6 +58,7 @@
"nvim-treesitter": { "branch": "master", "commit": "8b79cddc708cb8549562f0101f7f509ad7cebf97" },
"nvim-treesitter-context": { "branch": "master", "commit": "198720b4016af04c9590f375d714d5bf8afecc1a" },
"nvim-treesitter-endwise": { "branch": "master", "commit": "cb718aab7fa66e43187674e875713097492a6618" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "143856b1cee509a190cc8c17ddb0638002171235" },
"nvim-treesitter-textsubjects": { "branch": "master", "commit": "abcbb0e537c9c24800b03b9ca33bee5806604629" },
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },

View file

@ -5,6 +5,7 @@ return {
-- show current cursor context at top of buffer
-- improves commenting plugin above by using ts
dependencies = {
{ "nvim-treesitter/nvim-treesitter-textobjects" },
-- nice context on top of buffer
{ "nvim-treesitter/nvim-treesitter-context", opts = { max_lines = 3 } },
"JoosepAlviste/nvim-ts-context-commentstring",
@ -44,23 +45,35 @@ return {
end,
additional_vim_regex_highlighting = false,
},
incremental_selection = { enable = true },
textobjects = {
incremental_selection = {
enable = true,
-- TODO: CHECK IF ANY CONFLICTING WITH MINI AI!!
-- supported in other languages as well
["aF"] = "@function.outer",
["iF"] = "@function.inner",
["aL"] = "@loop.outer",
["iL"] = "@loop.inner",
["aC"] = "@conditional.outer",
["iC"] = "@conditional.inner",
["iS"] = "@statement.inner",
["aS"] = "@statement.outer",
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
textobjects = {
select = {
enable = true,
-- TODO: CHECK IF ANY CONFLICTING WITH MINI AI!!
-- supported in other languages as well
keymaps = {
["aF"] = { query = "@function.outer", desc = "function outer" },
["iF"] = { query = "@function.inner", desc = "function inner" },
["aL"] = { query = "@loop.outer", desc = "loop outer" },
["iL"] = { query = "@loop.inner", desc = "loop inner" },
["aC"] = { query = "@conditional.outer", desc = "conditional inner" },
["iC"] = { query = "@conditional.inner", desc = "conditional inner" },
["aS"] = { query = "@statement.outer", desc = "statement outer" },
["iS"] = { query = "@statement.inner", desc = "statement inner" },
-- Nushell only
["aP"] = "@pipeline.outer",
["iP"] = "@pipeline.inner",
-- Nushell only
["aP"] = { query = "@pipeline.outer", desc = "pipeline outer" },
["iP"] = { query = "@pipeline.inner", desc = "pipeline inner" },
},
},
},
indent = { enable = true },
autotag = { enable = true },