Add tree-sitter based text objects
Mappings for: * functions * function arguments/parameters * comments
This commit is contained in:
parent
eae24ab24c
commit
0d04a9812c
@ -1,13 +1,19 @@
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
dependencies = {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
-- TODO: Fork this and add CMake support
|
||||
'RRethy/nvim-treesitter-endwise',
|
||||
},
|
||||
build = ':TSUpdate',
|
||||
config = function()
|
||||
require('nvim-treesitter').setup()
|
||||
local config = {
|
||||
require('nvim-treesitter.configs').setup({
|
||||
sync_install = false,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
|
||||
-- List of languages that must be available
|
||||
ensure_installed = {
|
||||
'asm',
|
||||
'bash',
|
||||
@ -27,6 +33,7 @@ return {
|
||||
'gitattributes',
|
||||
'gitignore',
|
||||
'glsl',
|
||||
'go',
|
||||
'gpg',
|
||||
'hlsl',
|
||||
'html',
|
||||
@ -34,6 +41,7 @@ return {
|
||||
'javascript',
|
||||
'jq',
|
||||
'json',
|
||||
'julia',
|
||||
'llvm',
|
||||
'lua',
|
||||
'make',
|
||||
@ -57,17 +65,29 @@ return {
|
||||
'xml',
|
||||
'yaml',
|
||||
},
|
||||
sync_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
-- After opening statements insert end statements
|
||||
endwise = { enable = true },
|
||||
|
||||
-- Text objects using Tree-sitter groups
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
-- include_surrounding_whitespace = true,
|
||||
keymaps = {
|
||||
-- Function text objects
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
-- Parameter/argument text objects
|
||||
['a,'] = '@parameter.outer',
|
||||
['i,'] = '@parameter.inner',
|
||||
-- Comment text objects
|
||||
['a/'] = '@comment.outer',
|
||||
['i/'] = '@comment.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
endwise = {
|
||||
enable = true,
|
||||
},
|
||||
}
|
||||
require('nvim-treesitter.configs').setup(config)
|
||||
})
|
||||
end
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user