summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter/install.lua
diff options
context:
space:
mode:
authorJonas Strittmatter <40792180+smjonas@users.noreply.github.com>2022-07-08 09:36:54 +0200
committerGitHub <noreply@github.com>2022-07-08 07:36:54 +0000
commit365f0eb75f4b8de4655476388c99aaa97f149ded (patch)
treef10dcb86f85baa296573c9017f0754246f64dd45 /lua/nvim-treesitter/install.lua
parent8f13ef1563254400da1686f3d3abc62919b2a88d (diff)
feat: add option to auto-install missing parsers (#3130)
Diffstat (limited to 'lua/nvim-treesitter/install.lua')
-rw-r--r--lua/nvim-treesitter/install.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index e709849a..be980ca0 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -425,6 +425,18 @@ local function install(options)
end
end
+function M.setup_auto_install()
+ vim.api.nvim_create_autocmd("FileType", {
+ pattern = { "*" },
+ callback = function()
+ local lang = parsers.get_buf_lang()
+ if parsers.get_parser_configs()[lang] and not parsers.has_parser(lang) then
+ install { ask_reinstall = true } { lang }
+ end
+ end,
+ })
+end
+
function M.update(options)
options = options or {}
return function(...)