treesitter.lua (2294B)
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 }, 32 }, 33 move = { 34 enable = true, 35 set_jumps = true, -- whether to set jumps in the jumplist 36 goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" }, 37 goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" }, 38 goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" }, 39 goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" }, 40 }, 41 swap = { 42 enable = true, 43 swap_next = { 44 ['<leader>a'] = '@parameter.inner', 45 }, 46 swap_previous = { 47 ['<leader>A'] = '@parameter.inner', 48 }, 49 }, 50 }, 51 } 52 end 53 54 return { 55 { 56 'nvim-treesitter/nvim-treesitter', 57 branch = 'master', 58 build = ":TSUpdate", 59 config = config, 60 lazy = false, 61 }, 62 63 -- Additional text objects via treesitter 64 'nvim-treesitter/nvim-treesitter-textobjects', 65 66 -- Show context 67 { 68 "nvim-treesitter/nvim-treesitter-context", 69 keys = { 70 { "<leader>^", function() require('treesitter-context').toggle() end, desc = "Context" }, 71 }, 72 }, 73 }