fix: treesitter fix (branch)
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
return {
|
return {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
branch = "main",
|
||||||
event = { "BufReadPost", "BufNewFile" },
|
event = { "BufReadPost", "BufNewFile" },
|
||||||
config = function()
|
config = function()
|
||||||
local ts = require("nvim-treesitter")
|
local ts = require("nvim-treesitter")
|
||||||
|
|
||||||
ts.setup({
|
ts.setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"python",
|
"python",
|
||||||
@@ -25,28 +25,6 @@ return {
|
|||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
pcall(vim.treesitter.language.register, "html", "gotmpl")
|
pcall(vim.treesitter.language.register, "html", "gotmpl")
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
group = vim.api.nvim_create_augroup("TreesitterOnDemand", { clear = true }),
|
|
||||||
callback = function(args)
|
|
||||||
local ft = args.match
|
|
||||||
local lang = vim.treesitter.language.get_lang(ft) or ft
|
|
||||||
|
|
||||||
local installed = ts.get_installed and ts.get_installed() or {}
|
|
||||||
if not vim.list_contains(installed, lang) then
|
|
||||||
pcall(function()
|
|
||||||
local ok = ts.install(lang)
|
|
||||||
if ok and ok.wait then
|
|
||||||
ok:wait()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
pcall(vim.treesitter.start, args.buf, lang)
|
|
||||||
end,
|
|
||||||
desc = "enable nvim-treesitter and install parser if not installed",
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user