From 78b40f895cb2bf789944f94abd47dd7f7ab3f8dc Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Thu, 23 Apr 2020 07:55:00 +0200 Subject: textobj: add incremental node selection --- autoload/nvim_treesitter.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 autoload/nvim_treesitter.vim (limited to 'autoload') diff --git a/autoload/nvim_treesitter.vim b/autoload/nvim_treesitter.vim new file mode 100644 index 00000000..3e5ce40e --- /dev/null +++ b/autoload/nvim_treesitter.vim @@ -0,0 +1,16 @@ +function! s:visual_node(node_range) + let [l:cursor_start, l:cursor_end] = a:node_range + if !empty(l:cursor_start) && !empty(l:cursor_end) + call cursor(l:cursor_start[0]+1, l:cursor_start[1]+1) + normal v + call cursor(l:cursor_end[0]+1, l:cursor_end[1]) + endif +endfunction + +function! nvim_treesitter#select_node_incr() + call s:visual_node(luaeval('require"nvim-treesitter.textobj".node_incremental()')) +endfunction + +function! nvim_treesitter#select_context_incr() + call s:visual_node(luaeval('require"nvim-treesitter.textobj".context_incremental()')) +endfunction -- cgit v1.2.3