Skip to content

Commit

Permalink
Nvim: disable treesitter on large files
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Dec 12, 2024
1 parent 3f2fa5a commit c5384e2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .config/nvim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)

local function disable_plugins_for_large_files()
local max_filesize = 1024 * 1024 -- 1 MB
local filepath = vim.fn.expand("%:p")
local filesize = vim.fn.getfsize(filepath)
if filesize > max_filesize then
-- Disable treesitter
vim.cmd("TSBufDisable")
end
end

-- Autocmd to check file size on BufRead
vim.api.nvim_create_autocmd("BufRead", {
callback = disable_plugins_for_large_files,
desc = "Disable heavy plugins for large files",
})

require("lazy").setup({
root = lazy_home,
spec = {
Expand Down

0 comments on commit c5384e2

Please sign in to comment.