Users must now use the :TSInstallAll command to install all treesitter parsers defined in their config. So there's no automatic downloading of treesitter parsers like before tree-sitter-cli is a required dependency now --------- Co-authored-by: siduck <siduck@tutanota.com>
43 lines
1.3 KiB
Lua
43 lines
1.3 KiB
Lua
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
-- user event that loads after UIEnter + only if file buf is there
|
|
autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, {
|
|
group = vim.api.nvim_create_augroup("NvFilePost", { clear = true }),
|
|
callback = function(args)
|
|
local file = vim.api.nvim_buf_get_name(args.buf)
|
|
local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf })
|
|
|
|
if not vim.g.ui_entered and args.event == "UIEnter" then
|
|
vim.g.ui_entered = true
|
|
end
|
|
|
|
if file ~= "" and buftype ~= "nofile" and vim.g.ui_entered then
|
|
vim.api.nvim_exec_autocmds("User", { pattern = "FilePost", modeline = false })
|
|
vim.api.nvim_del_augroup_by_name "NvFilePost"
|
|
|
|
vim.schedule(function()
|
|
vim.api.nvim_exec_autocmds("FileType", {})
|
|
|
|
if vim.g.editorconfig then
|
|
require("editorconfig").config(args.buf)
|
|
end
|
|
end)
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "*",
|
|
callback = function()
|
|
pcall(vim.treesitter.start)
|
|
end,
|
|
})
|
|
|
|
local create_cmd = vim.api.nvim_create_user_command
|
|
|
|
create_cmd("TSInstallAll", function()
|
|
local spec = require("lazy.core.config").plugins["nvim-treesitter"]
|
|
local opts = type(spec.opts) == "table" and spec.opts or {}
|
|
require("nvim-treesitter").install(opts.ensure_installed)
|
|
end, {})
|