Refactor the code

This commit is contained in:
orip 2025-12-12 13:03:32 +02:00
parent 714d9c1825
commit 7a6dbbaa02
1 changed files with 7 additions and 8 deletions

View File

@ -972,20 +972,19 @@ require('lazy').setup({
return
end
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
if not vim.tbl_contains(available_parsers, language) then
treesitter_try_attach(buf, language)
return
end
-- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed
local installed_parsers = require('nvim-treesitter').get_installed 'parsers'
if vim.tbl_contains(installed_parsers, language) then
-- enable the parser if it is installed
treesitter_try_attach(buf, language)
else
elseif vim.tbl_contains(available_parsers, language) then
-- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed
require('nvim-treesitter').install(language):await(function()
treesitter_try_attach(buf, language)
end)
else
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
treesitter_try_attach(buf, language)
end
end,
})