77 lines
1.9 KiB
Lua
77 lines
1.9 KiB
Lua
-- https://github.com/nvim-treesitter/nvim-treesitter
|
|
|
|
local languages = {
|
|
"dap_repl",
|
|
"bash",
|
|
"zsh",
|
|
"python",
|
|
"c",
|
|
"cpp",
|
|
"lua",
|
|
"luadoc",
|
|
"vim",
|
|
"vimdoc",
|
|
"php",
|
|
"rust",
|
|
"comment",
|
|
"gitcommit",
|
|
"xml",
|
|
"sql",
|
|
"html",
|
|
"json",
|
|
"gotmpl",
|
|
"markdown",
|
|
"go",
|
|
"svelte",
|
|
{ "scss", extra_ft = { "css" } },
|
|
"tsx",
|
|
"typescript",
|
|
"yaml",
|
|
}
|
|
|
|
---@type LazyPluginSpec
|
|
return {
|
|
"nvim-treesitter/nvim-treesitter",
|
|
lazy = false,
|
|
build = function()
|
|
local ts = require("nvim-treesitter")
|
|
ts.install(languages):await(ts.update)
|
|
end,
|
|
dependencies = {
|
|
{
|
|
"LiadOz/nvim-dap-repl-highlights",
|
|
config = true,
|
|
},
|
|
},
|
|
config = function()
|
|
local ts = require("nvim-treesitter")
|
|
ts.install(languages):await(function()
|
|
local filetypes = {}
|
|
for i, value in ipairs(languages) do
|
|
local lang = value
|
|
if type(value) == "table" then
|
|
lang = value[1]
|
|
for _, ft in ipairs(value.extra_ft) do
|
|
vim.treesitter.language.register(lang, ft)
|
|
end
|
|
filetypes[i] = lang
|
|
end
|
|
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
|
|
if not vim.list_contains(filetypes, ft) then
|
|
table.insert(filetypes, ft)
|
|
end
|
|
end
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = filetypes,
|
|
callback = function()
|
|
vim.treesitter.start()
|
|
vim.wo.foldmethod = "expr"
|
|
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
|
end,
|
|
})
|
|
end)
|
|
end,
|
|
}
|