From 35534e8c1ca28fbc68451b3d1444d3d8e7a1c53f Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Fri, 16 Oct 2020 09:06:39 +0200 Subject: [PATCH] nvim: ts text objects --- .config/nvim/init.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index b2e4868..91558b9 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -382,6 +382,26 @@ require'nvim-treesitter.configs'.setup { node_decremental = "grm", }, }, + textobjects = { + select = { + enable = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + + -- Or you can define your own textobjects like this + ["iF"] = { + python = "(function_definition) @function", + cpp = "(function_definition) @function", + c = "(function_definition) @function", + java = "(method_declaration) @function", + }, + }, + }, + }, } END