From 45dcebb15f1a954eba2bcb3ae4c1a03f710a1f2a Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Fri, 8 May 2020 11:22:59 +0200 Subject: refacto/feat: better handling of parser updates features: - node_movement is moving between scopes. - add selection initialization from normal mode - add a decremental selection improvements: - attach to buffer to run tree parsing on change - run state update on CursorMoved - the buffer state is: ``` { cursor_pos = { row=row, col=col }, current_node = node_under_cursor, selection = { range = nil, -- activates when starting a selection nodes = {} -- filling up when starting an incremental selection }, parser = parser, -- parser for current buffer } ``` - refacto all the modules reliant on parsing the tree, update the current nodes, get the current nodes... fixes: - fix has_parser to look for .so libraries - fix should select the whole file when selection root in selection --- lua/nvim-treesitter/locals.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lua/nvim-treesitter/locals.lua') diff --git a/lua/nvim-treesitter/locals.lua b/lua/nvim-treesitter/locals.lua index b16408ac..313d7655 100644 --- a/lua/nvim-treesitter/locals.lua +++ b/lua/nvim-treesitter/locals.lua @@ -3,11 +3,12 @@ -- its the way nvim-treesitter uses to "understand" the code local api = vim.api local ts = vim.treesitter + local queries = require'nvim-treesitter.query' -local parsers = require'nvim-treesitter.parsers' +local utils = require'nvim-treesitter.utils' local M = { - locals={} + locals = {} } function M.collect_locals(bufnr) @@ -17,7 +18,7 @@ function M.collect_locals(bufnr) local query = queries.get_query(ft, 'locals') if not query then return end - local parser = parsers.get_parser(bufnr, ft) + local parser = utils.get_parser(bufnr, ft) if not parser then return end local root = parser:parse():root() -- cgit v1.2.3