Refactor the code
This commit is contained in:
parent
714d9c1825
commit
7a6dbbaa02
15
init.lua
15
init.lua
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue