nvim: Turn off treesitter highlights in big files

Files above 1000 lines, 300 linelength or really big filesize.
This commit is contained in:
Marty Oehme 2023-12-08 15:09:59 +01:00
parent 7f112816b0
commit 1def627edd
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -7,11 +7,21 @@ return {
require("nvim-treesitter.configs").setup({ require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all", ensure_installed = "all",
auto_install = true,
highlight = { highlight = {
enable = true, enable = true,
language_tree = true,
disable = function(_, bufnr) disable = function(_, bufnr)
return vim.api.nvim_buf_line_count(bufnr) > 7000 if
vim.api.nvim_buf_line_count(bufnr) > 1000
or vim.fn.strwidth(vim.fn.getline(".")) > 300
or vim.fn.getfsize(vim.fn.expand("%")) > 1024*1024
then
return true
end
return false
end, end,
additional_vim_regex_highlighting = false,
}, },
incremental_selection = { enable = true }, incremental_selection = { enable = true },
textobjects = { enable = true }, textobjects = { enable = true },