local ok, treesitter = pcall(require, 'nvim-treesitter.configs') if not ok then return end treesitter.setup { incremental_selection = { enable = true, keymaps = { -- mappings for incremental selection (visual mappings) init_selection = "gnn", -- maps in normal mode to init the node/scope selection node_incremental = "grn", -- increment to the upper named parent scope_incremental = "grc", -- increment to the upper scope (as defined in locals.scm) node_decremental = "grm" -- decrement to the previous node } }, textobjects = { -- syntax-aware textobjects enable = true, lsp_interop = { enable = true, peek_definition_code = { ["DF"] = "@function.outer", } }, keymaps = { ["iL"] = { -- you can define your own textobjects directly here go = "(function_definition) @function", }, -- or you use the queries from supported languages with textobjects.scm ["af"] = "@function.outer", ["if"] = "@function.inner", ["aC"] = "@class.outer", ["iC"] = "@class.inner", ["ac"] = "@conditional.outer", ["ic"] = "@conditional.inner", ["ae"] = "@block.outer", ["ie"] = "@block.inner", ["al"] = "@loop.outer", ["il"] = "@loop.inner", ["is"] = "@statement.inner", ["as"] = "@statement.outer", ["ad"] = "@comment.outer", ["am"] = "@call.outer", ["im"] = "@call.inner" }, move = { enable = true, set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { ["]]"] = "@function.outer", ["]c"] = { query = "@class.outer", desc = "Next class start" }, -- -- You can use regex matching and/or pass a list in a "query" key to group multiple queires. ["]o"] = "@loop.*", -- ["]o"] = { query = { "@loop.inner", "@loop.outer" } } -- -- You can pass a query group to use query from `queries//.scm file in your runtime path. -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, }, goto_next_end = { ["]["] = "@function.outer", ["]C"] = "@class.outer", }, goto_previous_start = { ["[["] = "@function.outer", ["[c"] = "@class.outer", }, goto_previous_end = { ["[]"] = "@function.outer", ["[C"] = "@class.outer", } } }, ensure_installed = { 'javascript', 'typescript', 'css', 'json', 'c', 'lua', 'go' }, sync_install = false, auto_install = true, highlight = { enable = true, additional_vim_regex_highlighting = false, }, }