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

@ -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