summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2020-09-27 12:13:11 +0200
committerStephan Seitz <stephan.lauf@yahoo.de>2020-10-26 12:42:10 +0100
commitc3b526fe51d6f4dd1dda099d69258909d0abb531 (patch)
treeba5a24810910a298ec632f6d0fbe9cdde6cb3d73 /lua/nvim-treesitter
parent04ff77442ac6fc808724df86641e8ee07d30379d (diff)
feat(install): add "maintained" option to only install maintained parsers
Unmaintained parsers only give users little benefit but take sometimes a a long time to install (e.g. Markdown, Julia, Haskell parser). We could recommend to only install maintained parsers by default.
Diffstat (limited to 'lua/nvim-treesitter')
-rw-r--r--lua/nvim-treesitter/install.lua9
-rw-r--r--lua/nvim-treesitter/parsers.lua4
2 files changed, 12 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index 38abfc9c..f7fb1d47 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -188,6 +188,9 @@ local function install(with_sync, ask_reinstall)
if ... == 'all' then
languages = parsers.available_parsers()
ask = false
+ elseif ... == 'maintained' then
+ languages = parsers.maintained_parsers()
+ ask = false
else
languages = vim.tbl_flatten({...})
ask = ask_reinstall
@@ -221,9 +224,13 @@ function M.uninstall(lang)
path_sep = '\\'
end
- if lang == 'all' then
+ if vim.tbl_contains({'all', 'maintained'}, lang) then
reset_progress_counter()
local installed = info.installed_parsers()
+ if lang == "maintained" then
+ local maintained = parsers.maintained_parsers()
+ installed = vim.tbl_filter(function(l) return vim.tbl_contains(maintained, l) end, installed)
+ end
for _, lang in pairs(installed) do
M.uninstall(lang)
end
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 864907d6..293186c5 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -357,6 +357,10 @@ function M.available_parsers()
return vim.tbl_keys(M.list)
end
+function M.maintained_parsers()
+ return vim.tbl_filter(function(lang) return M.list[lang].maintainers end, M.available_parsers())
+end
+
function M.get_parser_configs()
return M.list
end