mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-03 12:06:55 -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
|
|
@ -45,23 +45,4 @@ function M.get_cache_dir()
|
|||
return nil, 'Invalid cache rights, $XDG_CACHE_HOME or /tmp should be read/write'
|
||||
end
|
||||
|
||||
function M.has_parser(lang)
|
||||
local lang = lang or api.nvim_buf_get_option(0, 'filetype')
|
||||
return #api.nvim_get_runtime_file('parser/' .. lang .. '.so', false) > 0
|
||||
end
|
||||
|
||||
function M.get_parser(bufnr, lang)
|
||||
if M.has_parser() then
|
||||
local buf = bufnr or api.nvim_get_current_buf()
|
||||
local lang = lang or api.nvim_buf_get_option(buf, 'ft')
|
||||
if not M[buf] then
|
||||
M[buf] = {}
|
||||
end
|
||||
if not M[buf][lang] then
|
||||
M[buf][lang] = ts.get_parser(buf, lang)
|
||||
end
|
||||
return M[buf][lang]
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue