return { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", cmd = { "TSInstall", "TSUpdate", "TSUpdateSync" }, dependencies = { "nvim-treesitter/nvim-treesitter-refactor", "nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter/playground", }, event = "VeryLazy", keys = function() local icon = require("util.icons").ui.Tree return { -- stylua: ignore start { "Tp", "TSPlaygroundToggle", desc = icon.." [T]reesitter [p]layground (toggle)" }, { "Th", "TSHighlightCapturesUnderCursor", desc = icon.." [T]reesitter [h]ighlights" }, { "Tn", "TSNodeUnderCursor", desc = icon.." [T]reesitter [n]ode under cursor" }, -- stylua: ignore end } end, config = function() require("nvim-treesitter.configs").setup { ensure_installed = { "bash", "c", "cmake", "cpp", "haskell", "html", "javascript", "latex", "lua", "make", "markdown", "markdown_inline", "python", "query", "toml", "vim", "vimdoc", "yaml", }, highlight = { enable = true, disable = { "vimdoc" }, }, incremental_selection = { enable = true, keymaps = { init_selection = "gnn", -- mapped in normal mode node_incremental = "", -- mapped in visual mode node_decremental = "", -- mapped in visual mode scope_incremental = nil, -- disabled, normally mapped in visual mode }, }, refactor = { highlight_definitions = { enable = true }, highlight_current_scope = { enable = false }, smart_rename = { enable = true, keymaps = { smart_rename = "grr" }, }, navigation = { enable = true, keymaps = { goto_definition = "gd", -- default: 'gnd' list_definitions = nil, -- disabled, default: 'gnD' list_definitions_toc = "gO", goto_next_usage = "", goto_previous_usage = "", }, }, }, textobjects = { select = { enable = true, keymaps = { ["ab"] = "@block.outer", ["ib"] = "@block.inner", ["ac"] = "@conditional.outer", ["ic"] = "@conditional.inner", ["af"] = "@function.outer", ["if"] = "@function.inner", ["al"] = "@loop.outer", ["il"] = "@loop.inner", ["aa"] = "@parameter.outer", ["ia"] = "@parameter.inner", }, }, }, playground = { enable = true }, } end, }