diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-09-27 12:13:11 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-10-26 12:42:10 +0100 |
| commit | c3b526fe51d6f4dd1dda099d69258909d0abb531 (patch) | |
| tree | ba5a24810910a298ec632f6d0fbe9cdde6cb3d73 | |
| parent | 04ff77442ac6fc808724df86641e8ee07d30379d (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.
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | autoload/nvim_treesitter.vim | 4 | ||||
| -rw-r--r-- | doc/nvim-treesitter.txt | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 9 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 4 |
5 files changed, 16 insertions, 5 deletions
@@ -106,7 +106,7 @@ so you'll need to activate them by putting this in your `init.vim` file: ```lua require'nvim-treesitter.configs'.setup { - ensure_installed = "all", -- one of "all", "language", or a list of languages + ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages highlight = { enable = true, -- false will disable the whole extension disable = { "c", "rust" }, -- list of language that will be disabled diff --git a/autoload/nvim_treesitter.vim b/autoload/nvim_treesitter.vim index a19a7470..2b02db2d 100644 --- a/autoload/nvim_treesitter.vim +++ b/autoload/nvim_treesitter.vim @@ -7,11 +7,11 @@ function! nvim_treesitter#foldexpr() abort endfunction function! nvim_treesitter#installable_parsers(arglead, cmdline, cursorpos) abort - return join(luaeval("require'nvim-treesitter.parsers'.available_parsers()") + ['all'], "\n") + return join(luaeval("require'nvim-treesitter.parsers'.available_parsers()") + ['all', 'maintained'], "\n") endfunction function! nvim_treesitter#installed_parsers(arglead, cmdline, cursorpos) abort - return join(luaeval("require'nvim-treesitter.info'.installed_parsers()") + ['all'], "\n") + return join(luaeval("require'nvim-treesitter.info'.installed_parsers()") + ['all', 'maintained'], "\n") endfunction function! nvim_treesitter#available_modules(arglead, cmdline, cursorpos) abort diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index c8b78964..7cdc38c9 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -36,7 +36,7 @@ To enable supported features, put this in your `init.vim` file: > lua <<EOF require'nvim-treesitter.configs'.setup { - ensure_installed = "all", -- one of "all", "language", or a list of languages + ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages highlight = { enable = true, -- false will disable the whole extension disable = { "c", "rust" }, -- list of language that will be disabled 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 |
