diff --git a/init.lua b/init.lua index ed50b69d7f3..db34d08f21e 100644 --- a/init.lua +++ b/init.lua @@ -874,8 +874,6 @@ require('lazy').setup({ branch = 'main', -- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro` config = function() - local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } - require('nvim-treesitter').install(parsers) vim.api.nvim_create_autocmd('FileType', { callback = function(args) local buf, filetype = args.buf, args.match @@ -899,6 +897,24 @@ require('lazy').setup({ }) end, }, + { -- Automatically install Treesitter parsers for languages you encounter. + + -- NOTE: This plugin is a convenience feature and is not strictly necessary for + -- regular use. If you prefer, you can remove it and install parsers manually + -- directly with treesitter using `require('nvim-treesitter').install()`. + 'lewis6991/ts-install.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + config = function() + local ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } + vim.list_extend(ensure_installed, { + -- You can add other parsers here that you want to be always installed + }) + require('ts-install').setup { + ensure_install = ensure_installed, + auto_install = true, + } + end, + }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and