marleyvim/nvim/lua/plugins/treesitter/nvim-treesitter.lua
2025-01-04 21:14:46 -08:00

73 lines
2.1 KiB
Lua

return {
'nvim-treesitter',
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()
vim.filetype.add({
extension = { rasi = 'rasi', rofi = 'rasi', wofi = 'rasi', env = 'conf' },
filename = { ['.env'] = 'conf' },
pattern = {
['.*/waybar/config'] = 'jsonc',
['.*/mako/config'] = 'dosini',
['.*/kitty/.+%.conf'] = 'kitty',
['.*/hypr/.+*.conf'] = 'hyprlang',
['%.env%.[%w_.-]+'] = 'conf',
},
})
-- Use the bash parser for kitty files.
vim.treesitter.language.register('bash', 'kitty')
---@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,
}