mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-05 04:50:03 -04:00
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:
parent
772aa4c169
commit
38af29a912
9 changed files with 100 additions and 233 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue