marleyvim/nvim/lua/plugins/treesitter/nvim-treesitter.lua
2024-12-08 16:53:53 -08:00

57 lines
1.6 KiB
Lua

return {
event = { 'BufReadPost', 'BufWritePost', 'BufNewFile', 'DeferredUIEnter' },
keys = {
{ '<C-space>', desc = 'increment selection' },
{ '<BS>', desc = 'decrement selection', mode = 'x' },
},
before = function()
require('lz.n').trigger_load('which-key.nvim')
end,
after = function()
---@diagnostic disable-next-line: missing-fields
require('nvim-treesitter.configs').setup({
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<C-space>',
node_incremental = '<C-space>',
scope_incremental = false,
node_decremental = '<BS>',
},
},
textobjects = {
move = {
enable = true,
goto_next_start = {
[']f'] = '@function.outer',
[']c'] = '@class.outer',
[']a'] = '@parameter.inner',
},
goto_next_end = {
[']F'] = '@function.outer',
[']C'] = '@class.outer',
[']A'] = '@parameter.inner',
},
goto_previous_start = {
['[f'] = '@function.outer',
['[c'] = '@class.outer',
['[a'] = '@parameter.inner',
},
goto_previous_end = {
['[F'] = '@function.outer',
['[C'] = '@class.outer',
['[A'] = '@parameter.inner',
},
},
},
})
require('which-key').add({
{ '<BS>', desc = 'decrement selection', mode = 'x' },
{ '<C-space>', desc = 'increment selection', mode = { 'x', 'n' } },
})
end,
}