nvim/lua/plugins/treesitter.lua

116 lines
3.1 KiB
Lua
Raw Permalink Normal View History

2022-10-09 19:20:47 +02:00
local M = {
2022-10-09 22:40:29 +02:00
run = ":TSUpdate",
event = "User PackerDefered",
module = "nvim-treesitter",
requires = {
"nvim-treesitter/nvim-treesitter-textobjects",
"RRethy/nvim-treesitter-textsubjects",
"nvim-treesitter/nvim-treesitter-refactor",
},
2022-10-09 19:20:47 +02:00
}
function M.config()
2022-10-09 22:40:29 +02:00
require("nvim-treesitter.configs").setup({
ensure_installed = {
"css",
"go",
"lua",
"vim",
"help",
"fish",
"gitignore",
},
sync_install = false,
auto_install = true,
highlight = { enable = true },
indent = { enable = false },
context_commentstring = { enable = true, enable_autocmd = false },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-n>",
node_incremental = "<C-n>",
scope_incremental = "<C-s>",
node_decremental = "<C-r>",
},
},
refactor = {
smart_rename = {
enable = true,
client = {
smart_rename = "<leader>cr",
},
},
navigation = {
enable = true,
keymaps = {
-- goto_definition = "gd",
-- list_definitions = "gnD",
-- list_definitions_toc = "gO",
-- goto_next_usage = "<a-*>",
-- goto_previous_usage = "<a-#>",
},
},
},
query_linter = {
enable = true,
use_virtual_text = true,
lint_events = { "BufWrite", "CursorHold" },
},
textsubjects = {
enable = true,
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
},
},
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = true, -- Whether the query persists across vim sessions
keybindings = {
toggle_query_editor = "o",
toggle_hl_groups = "i",
toggle_injected_languages = "t",
toggle_anonymous_nodes = "a",
toggle_language_display = "I",
focus_language = "f",
unfocus_language = "F",
update = "R",
goto_node = "<cr>",
show_help = "?",
},
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
lsp_interop = {
enable = true,
peek_definition_code = {
["gD"] = "@function.outer",
},
},
},
})
2022-10-09 19:20:47 +02:00
end
return M