File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -917,7 +917,18 @@ require('lazy').setup({
917917 local language = vim .treesitter .language .get_lang (filetype )
918918 if not language then return end
919919
920- treesitter_try_attach (buf , language )
920+ local installed_parsers = require (' nvim-treesitter' ).get_installed ' parsers'
921+
922+ if vim .tbl_contains (installed_parsers , language ) then
923+ -- enable the parser if it is installed
924+ treesitter_try_attach (buf , language )
925+ elseif vim .tbl_contains (available_parsers , language ) then
926+ -- if a parser is available in `nvim-treesitter` auto install it, and enable it after the installation is done
927+ require (' nvim-treesitter' ).install (language ):await (function () treesitter_try_attach (buf , language ) end )
928+ else
929+ -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
930+ treesitter_try_attach (buf , language )
931+ end
921932 end ,
922933 })
923934 end ,
You can’t perform that action at this time.
0 commit comments