From 1def627edde459fdfc8b2c69c57d356451d2f6e4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 8 Dec 2023 15:09:59 +0100 Subject: [PATCH] nvim: Turn off treesitter highlights in big files Files above 1000 lines, 300 linelength or really big filesize. --- nvim/.config/nvim/lua/plugins/treesitter.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua index b25cb2e..6afa8ed 100644 --- a/nvim/.config/nvim/lua/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -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 },