Files
dotfiles-and-setup/src_files/.config/nvim/lua/plugins_lazy/treesitter.lua

58 lines
2.6 KiB
Lua

return {
{
"nvim-treesitter/nvim-treesitter",
branch = 'master',
lazy = false,
build = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"vimdoc", "bash", "lua", "c", "cpp", "go", "python", "ruby",
"html", "css", "javascript", "jsdoc", "sql", "json", "yaml",
"markdown", "markdown_inline",
-- "odin", "zig", "ocaml", "java", "typescript",
},
sync_install = false, -- install `ensure_installed` parsers synchronously
auto_install = true, -- install missing on BufEnter, requires tree-sitter CLI
ignore_install = {
"csv",
},
indent = { enable = true },
highlight = {
enable = true, -- `false` will disable the whole extension
disable = function(lang, buf)
for i, v in ipairs({ "html", "csv", }) do
if lang == v then
print("treesitter disabled for this language")
return true
end
end
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > (100 * 1024) then -- 100 KB
vim.notify(
"larger file, treesitter disabled for performance",
vim.log.levels.WARN,
{title = "Treesitter"}
)
return true
end
end,
-- true, false, or list of langs; may cause slowness or duplicate highlights
additional_vim_regex_highlighting = { "markdown" },
},
})
-- TODO: decide if needed/wanted
-- local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs()
-- treesitter_parser_config.templ = {
-- install_info = {
-- url = "https://github.com/vrischmann/tree-sitter-templ.git",
-- files = {"src/parser.c", "src/scanner.c"},
-- branch = "master",
-- },
-- }
-- vim.treesitter.language.register("templ", "templ")
end
},
}