mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
fix: prepare injections mechanism
This commit is contained in:
parent
5783e7d248
commit
d169c0614c
2 changed files with 8 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ function M.collect_locals(bufnr)
|
|||
if not ft then return end
|
||||
|
||||
local query = queries.get_query(ft, 'locals')
|
||||
local parser = parsers.get_parser(bufnr)
|
||||
local parser = parsers.get_parser(bufnr, ft)
|
||||
|
||||
if not parser then return end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,17 @@ function M.has_parser(lang)
|
|||
return #api.nvim_get_runtime_file('parser/' .. lang .. '.*', false) > 0
|
||||
end
|
||||
|
||||
function M.get_parser(bufnr)
|
||||
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] = ts.get_parser(buf)
|
||||
M[buf] = {}
|
||||
end
|
||||
return M[buf]
|
||||
if not M[buf][lang] then
|
||||
M[buf][lang] = ts.get_parser(buf, lang)
|
||||
end
|
||||
return M[buf][lang]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue