Skip to content

Commit

Permalink
perf(nvim/treesitter): disable treesitter for large files
Browse files Browse the repository at this point in the history
  • Loading branch information
wongjiahau committed Oct 11, 2022
1 parent 14ef651 commit 825a987
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ require("nvim-treesitter.configs").setup({
ensure_installed = "all",
highlight = {
enable = true, -- false will disable the whole extension
disable = {}, -- list of language that will be disabled
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
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,
},
})

Expand Down

0 comments on commit 825a987

Please sign in to comment.