mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Fix(auto_install): Install parser if Filetype already known
If setup function was called after `FileType` autocommand triggers the installation of parser was not done. This commit checks if filetype is already know before adding the autocommand.
This commit is contained in:
parent
2953b6ae78
commit
8672843527
1 changed files with 10 additions and 6 deletions
|
|
@ -555,15 +555,19 @@ local function install(options)
|
|||
end
|
||||
|
||||
function M.setup_auto_install()
|
||||
local function try_install_curr_lang()
|
||||
local lang = parsers.get_buf_lang()
|
||||
if parsers.get_parser_configs()[lang] and not is_installed(lang) and not is_ignored_parser(lang) then
|
||||
install() { lang }
|
||||
end
|
||||
end
|
||||
|
||||
try_install_curr_lang()
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "*" },
|
||||
group = vim.api.nvim_create_augroup("NvimTreesitter-auto_install", { clear = true }),
|
||||
callback = function()
|
||||
local lang = parsers.get_buf_lang()
|
||||
if parsers.get_parser_configs()[lang] and not is_installed(lang) and not is_ignored_parser(lang) then
|
||||
install() { lang }
|
||||
end
|
||||
end,
|
||||
callback = try_install_curr_lang,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue