Fix treesitter config

This commit is contained in:
Thomas Avé 2024-11-22 23:50:37 +01:00
parent 8eb289f178
commit e434548c90
1 changed files with 21 additions and 24 deletions

View File

@ -5,9 +5,28 @@ return {
"nvim-treesitter/nvim-treesitter-textobjects",
},
build = ":TSUpdate",
config = function (_, opts)
require("nvim-treesitter").setup(opts)
config = function ()
require("nvim-treesitter.configs").setup({
ensure_installed = { "typst", "cpp", "c", "lua", "vim", "dockerfile", "python", "java", "cmake", "diff", "gitcommit", "html", "css", "javascript", "json", "rust", "sql", "yaml", "markdown", "markdown_inline", "nix", "bibtex" },
auto_install = true,
highlight = {
enable = true,
sync_install = true,
additional_vim_regex_highlighting = false,
disable = function(lang, buf) -- Disable if file size is too big
if lang == "ini" or lang == "markdown" then
return true
end
local max_filesize = 2000 * 1024 -- 2MB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
},
indent = {
enable = true
},
textobjects = {
select = {
enable = true,
@ -46,26 +65,4 @@ return {
},
})
end,
opts = {
ensure_installed_sync = { "typst", "cpp", "c", "lua", "vim", "dockerfile", "python", "java", "cmake", "diff", "gitcommit", "html", "css", "javascript", "json", "rust", "sql", "yaml", "markdown", "markdown_inline", "nix", "bibtex" },
auto_install = true,
highlight = {
enable = true,
sync_install = true,
additional_vim_regex_highlighting = false,
disable = function(lang, buf) -- Disable if file size is too big
if lang == "ini" or lang == "markdown" then
return true
end
local max_filesize = 2000 * 1024 -- 2MB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
},
indent = {
enable = true
},
},
}