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 {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
-- TODO: Fork this and add CMake support
|
-- TODO: Fork this and add CMake support
|
||||||
'RRethy/nvim-treesitter-endwise',
|
'RRethy/nvim-treesitter-endwise',
|
||||||
},
|
},
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
require('nvim-treesitter').setup()
|
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 = {
|
ensure_installed = {
|
||||||
'asm',
|
'asm',
|
||||||
'bash',
|
'bash',
|
||||||
@ -27,6 +33,7 @@ return {
|
|||||||
'gitattributes',
|
'gitattributes',
|
||||||
'gitignore',
|
'gitignore',
|
||||||
'glsl',
|
'glsl',
|
||||||
|
'go',
|
||||||
'gpg',
|
'gpg',
|
||||||
'hlsl',
|
'hlsl',
|
||||||
'html',
|
'html',
|
||||||
@ -34,6 +41,7 @@ return {
|
|||||||
'javascript',
|
'javascript',
|
||||||
'jq',
|
'jq',
|
||||||
'json',
|
'json',
|
||||||
|
'julia',
|
||||||
'llvm',
|
'llvm',
|
||||||
'lua',
|
'lua',
|
||||||
'make',
|
'make',
|
||||||
@ -57,17 +65,29 @@ return {
|
|||||||
'xml',
|
'xml',
|
||||||
'yaml',
|
'yaml',
|
||||||
},
|
},
|
||||||
sync_install = false,
|
|
||||||
highlight = {
|
-- After opening statements insert end statements
|
||||||
enable = true,
|
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
|
end
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user