treesitter.lua (2410B)
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 = { 37 [']m'] = '@function.outer', 38 [']]'] = '@class.outer', 39 }, 40 goto_next_end = { 41 [']M'] = '@function.outer', 42 [']['] = '@class.outer', 43 }, 44 goto_previous_start = { 45 ['[m'] = '@function.outer', 46 ['[['] = '@class.outer', 47 }, 48 goto_previous_end = { 49 ['[M'] = '@function.outer', 50 ['[]'] = '@class.outer', 51 }, 52 }, 53 swap = { 54 enable = true, 55 swap_next = { 56 ['<leader>a'] = '@parameter.inner', 57 }, 58 swap_previous = { 59 ['<leader>A'] = '@parameter.inner', 60 }, 61 }, 62 }, 63 } 64 end 65 66 return { 67 { 68 'nvim-treesitter/nvim-treesitter', 69 branch = 'master', 70 build = ":TSUpdate", 71 config = config, 72 lazy = false, 73 }, 74 75 -- Additional text objects via treesitter 76 'nvim-treesitter/nvim-treesitter-textobjects', 77 78 -- Show context 79 { 80 "nvim-treesitter/nvim-treesitter-context", 81 keys = { 82 { "<leader>^", function() require('treesitter-context').toggle() end, desc = "Context" }, 83 }, 84 }, 85 }