feat(treesitter): Add Tree-sitter plugin for navigating source

Some movements, selection, etc. from Vim, usually don't work properly
when trying to detect the start/end of functions/classes scope and other
languages symbols when, for instance, language blocks are not
curly-bracket-based.

This Tree-sitter plugin aims to solve those issues using the AST of the
source file.
This commit is contained in:
Dionisio E Alonso 2024-04-10 22:36:52 -03:00
parent 465dfb7080
commit fd78a1fc25
3 changed files with 21 additions and 0 deletions

5
.gitmodules vendored
View File

@ -79,6 +79,11 @@
url = https://github.com/nvim-treesitter/nvim-treesitter.git
shallow = true
ignore = all
[submodule "nvim/pack/misc/start/nvim-treesitter-textobjects"]
path = nvim/pack/misc/start/nvim-treesitter-textobjects
url = https://github.com/nvim-treesitter/nvim-treesitter-textobjects.git
shallow = true
ignore = all
[submodule "vim/pack/misc/start/vim-gitgutter"]
path = vim/pack/misc/start/vim-gitgutter
url = https://github.com/airblade/vim-gitgutter.git

View File

@ -3,4 +3,19 @@ require'nvim-treesitter.configs'.setup {
highlight = { enable = true },
incremental_selection = { enable = true },
indent = { enable = true },
-- textobjects treesitter plugin
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
},
},
},
}

@ -0,0 +1 @@
Subproject commit 67ac27f859ee3f7584f3edef81d0942bb61d5344