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
1 changed files with 11 additions and 1 deletions

View File

@ -7,11 +7,21 @@ return {
require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all",
auto_install = true,
highlight = {
enable = true,
language_tree = true,
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,
additional_vim_regex_highlighting = false,
},
incremental_selection = { enable = true },
textobjects = { enable = true },