mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -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
|
|
@ -2,10 +2,9 @@ local api = vim.api
|
|||
|
||||
local install = require'nvim-treesitter.install'
|
||||
local utils = require'nvim-treesitter.utils'
|
||||
local ts_utils = require'nvim-treesitter.ts_utils'
|
||||
local info = require'nvim-treesitter.info'
|
||||
local configs = require'nvim-treesitter.configs'
|
||||
local state = require'nvim-treesitter.state'
|
||||
local ts_utils = require'nvim-treesitter.ts_utils'
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
@ -21,20 +20,13 @@ function M.setup()
|
|||
api.nvim_command(string.format("autocmd NvimTreesitter FileType %s %s", ft, cmd))
|
||||
end
|
||||
end
|
||||
local cmd = string.format("lua require'nvim-treesitter.state'.attach_to_buffer(%s)", ft)
|
||||
api.nvim_command(string.format('autocmd NvimTreesitter FileType %s %s', ft, cmd))
|
||||
end
|
||||
|
||||
state.run_update()
|
||||
end
|
||||
|
||||
function M.statusline(indicator_size)
|
||||
local indicator_size = indicator_size or 100
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local buf_state = state.get_buf_state(bufnr)
|
||||
if not buf_state then return "" end
|
||||
|
||||
local current_node = buf_state.current_node
|
||||
local current_node = ts_utils.get_node_at_cursor()
|
||||
if not current_node then return "" end
|
||||
|
||||
local expr = current_node:parent()
|
||||
|
|
@ -56,13 +48,4 @@ function M.statusline(indicator_size)
|
|||
end
|
||||
end
|
||||
|
||||
function M.get_buf_state()
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
return state.exposed_state(bufnr)
|
||||
end
|
||||
|
||||
function M.get_node_api()
|
||||
return ts_utils
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue