Dotfiles/site-modules/core/files/vim/plugin/treesitter.lua
Ade Attwood 6cbd7eb9ae feat(vim): add nvim-treesitter-textobjects
I have been wanting to play with this plugin for a long time now. I have
a minimal config that will give me most of what I need. Moving
parameters and arguments is a big one. Also selecting parameters, this
will also include the type definition so its much more powerful than
selecting words.

Jumping to functions has also been included, right now I am not sure how
much that will be used. My muscle memory is very used to <C-d> and <C-u>
for paging.
2024-06-14 18:03:07 +01:00

49 lines
1.2 KiB
Lua

require("nvim-treesitter.configs").setup {
auto_install = true,
playground = { enable = true },
indent = { enable = true },
rainbow = { enable = true },
highlight = {
-- `false` will disable the whole extension
enable = true,
additional_vim_regex_highlighting = false,
},
textobjects = {
select = {
enable = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["aa"] = "@parameter.outer", -- this is also arguments
["ia"] = "@parameter.inner", -- this is also arguments
["ab"] = "@block.outer",
["ib"] = "@block.inner",
["ac"] = "@comment.outer",
["ic"] = "@comment.inner",
},
},
move = {
enable = true,
set_jumps = true,
goto_next_start = {
["]f"] = "@function.outer",
},
goto_previous_start = {
["[f"] = "@function.outer",
},
},
swap = {
enable = true,
swap_next = {
["L"] = "@parameter.inner",
},
swap_previous = {
["H"] = "@parameter.inner",
},
},
},
}
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.foldenable = false