refacto: remove buf_state

- remove buf_state and related code
- add get_node_at_cursor()
- better incremental selection (code is localized)
This commit is contained in:
kiyan42 2020-06-19 13:45:33 +02:00
parent 772aa4c169
commit 38af29a912
9 changed files with 100 additions and 233 deletions

View file

@ -1,6 +1,7 @@
local api = vim.api
local locals = require'nvim-treesitter.locals'
local parsers = require'nvim-treesitter.parsers'
local M = {}
@ -205,4 +206,10 @@ function M.previous_scope(node)
end
end
function M.get_node_at_cursor()
local cursor = api.nvim_win_get_cursor(0)
local root = parsers.get_parser().tree:root()
return root:named_descendant_for_range(cursor[1]-1,cursor[2],cursor[1]-1,cursor[2])
end
return M