mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-04 04:20:09 -04:00
feat(setup)!: remove ensure_install field
Instead, call `require('nvim-treesitter').install( { ... } )` manually.
This gives users full control over how they want to install parsers
(sync, from grammar, limited concurrency) and obviates the need for
calling `setup` for most users.
This commit is contained in:
parent
73adbe597e
commit
522e0c6991
7 changed files with 37 additions and 46 deletions
|
|
@ -3,13 +3,11 @@ local M = {}
|
|||
M.tiers = { 'stable', 'unstable', 'unmaintained', 'unsupported' }
|
||||
|
||||
---@class TSConfig
|
||||
---@field ensure_install string[]
|
||||
---@field ignore_install string[]
|
||||
---@field install_dir string
|
||||
|
||||
---@type TSConfig
|
||||
local config = {
|
||||
ensure_install = {},
|
||||
ignore_install = {},
|
||||
install_dir = vim.fs.joinpath(vim.fn.stdpath('data'), 'site'),
|
||||
}
|
||||
|
|
@ -20,21 +18,10 @@ function M.setup(user_data)
|
|||
if user_data then
|
||||
if user_data.install_dir then
|
||||
user_data.install_dir = vim.fs.normalize(user_data.install_dir)
|
||||
--TODO(clason): leave to user!
|
||||
vim.opt.runtimepath:append(user_data.install_dir)
|
||||
end
|
||||
config = vim.tbl_deep_extend('force', config, user_data)
|
||||
end
|
||||
|
||||
if #config.ensure_install > 0 then
|
||||
local to_install = M.norm_languages(
|
||||
config.ensure_install,
|
||||
{ ignored = true, installed = true, unsupported = true }
|
||||
)
|
||||
if #to_install > 0 then
|
||||
require('nvim-treesitter.install').install(to_install, { force = true })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns the install path for parsers, parser info, and queries.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,18 @@ function M.setup(...)
|
|||
require('nvim-treesitter.config').setup(...)
|
||||
end
|
||||
|
||||
function M.install(...)
|
||||
require('nvim-treesitter.install').install(...)
|
||||
end
|
||||
|
||||
function M.uninstall(...)
|
||||
require('nvim-treesitter.install').uninstall(...)
|
||||
end
|
||||
|
||||
function M.update(...)
|
||||
require('nvim-treesitter.install').update(...)
|
||||
end
|
||||
|
||||
function M.indentexpr()
|
||||
return require('nvim-treesitter.indent').get_indent(vim.v.lnum)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue