treesitter.lua (2398B)
1 -- Highlight, edit, and navigate code 2 local config = function() 3 require('nvim-treesitter.configs').setup { 4 -- Add languages to be installed here that you want installed for treesitter 5 ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'vim', 'vimdoc', 'bash', 'ledger', 'ruby', 6 'python', 'java', 'sql', 'markdown_inline', 'html' }, 7 8 highlight = { enable = true }, 9 indent = { enable = true, disable = { 'python' } }, 10 incremental_selection = { 11 enable = true, 12 keymaps = { 13 init_selection = '<c-space>', 14 node_incremental = '<c-space>', 15 scope_incremental = '<c-s>', 16 node_decremental = '<c-+>', 17 }, 18 }, 19 textobjects = { 20 select = { 21 enable = true, 22 lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim 23 keymaps = { 24 -- You can use the capture groups defined in textobjects.scm 25 ['aa'] = '@parameter.outer', 26 ['ia'] = '@parameter.inner', 27 ['af'] = '@function.outer', 28 ['if'] = '@function.inner', 29 ['ac'] = '@class.outer', 30 ['ic'] = '@class.inner', 31 ["as"] = { query = "@local.scope", query_group = "locals", desc = "Select language scope" }, 32 33 }, 34 }, 35 move = { 36 enable = true, 37 set_jumps = true, -- whether to set jumps in the jumplist 38 goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" }, 39 goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" }, 40 goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" }, 41 goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" }, 42 }, 43 swap = { 44 enable = true, 45 swap_next = { 46 ['<leader>a'] = '@parameter.inner', 47 }, 48 swap_previous = { 49 ['<leader>A'] = '@parameter.inner', 50 }, 51 }, 52 }, 53 } 54 end 55 56 return { 57 { 58 'nvim-treesitter/nvim-treesitter', 59 branch = 'master', 60 build = ":TSUpdate", 61 config = config, 62 lazy = false, 63 }, 64 65 -- Additional text objects via treesitter 66 'nvim-treesitter/nvim-treesitter-textobjects', 67 68 -- Show context 69 { 70 "nvim-treesitter/nvim-treesitter-context", 71 keys = { 72 { "<leader>^", function() require('treesitter-context').toggle() end, desc = "Context" }, 73 }, 74 }, 75 }