File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -903,7 +903,18 @@ require('lazy').setup({
903903 local language = vim .treesitter .language .get_lang (filetype )
904904 if not language then return end
905905
906- treesitter_try_attach (buf , language )
906+ local installed_parsers = require (' nvim-treesitter' ).get_installed ' parsers'
907+
908+ if vim .tbl_contains (installed_parsers , language ) then
909+ -- enable the parser if it is installed
910+ treesitter_try_attach (buf , language )
911+ elseif vim .tbl_contains (available_parsers , language ) then
912+ -- if a parser is available in `nvim-treesitter` auto install it, and enable it after the installation is done
913+ require (' nvim-treesitter' ).install (language ):await (function () treesitter_try_attach (buf , language ) end )
914+ else
915+ -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
916+ treesitter_try_attach (buf , language )
917+ end
907918 end ,
908919 })
909920 end ,
You can’t perform that action at this time.
0 commit comments