mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-01 20:59:26 +00:00
[neovim] Disable heavy plugins on very large files
This commit is contained in:
@ -24,16 +24,6 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
end,
|
||||
})
|
||||
|
||||
-- Disable illuminate on very large files
|
||||
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
|
||||
callback = function()
|
||||
local line_count = vim.api.nvim_buf_line_count(0)
|
||||
if line_count >= 5000 then
|
||||
vim.cmd("IlluminatePauseBuf")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Ensure terraform files use hcl LSP
|
||||
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
|
||||
pattern = { "*.tf" },
|
||||
@ -43,3 +33,26 @@ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
|
||||
]])
|
||||
end,
|
||||
})
|
||||
|
||||
-- Disable some plugins on very large files
|
||||
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
||||
pattern = { "*" },
|
||||
callback = function(args)
|
||||
local highlighter = require("vim.treesitter.highlighter")
|
||||
local ts_was_active = highlighter.active[args.buf]
|
||||
local file_size = vim.fn.getfsize(args.file)
|
||||
if file_size > 1024 * 1024 then
|
||||
vim.cmd("TSBufDisable highlight")
|
||||
vim.cmd("syntax off")
|
||||
vim.cmd("syntax clear")
|
||||
vim.cmd("IlluminatePauseBuf")
|
||||
vim.cmd("NoMatchParen")
|
||||
vim.cmd("UfoDisable")
|
||||
vim.cmd("IBLDisable")
|
||||
vim.cmd("LspStop")
|
||||
if ts_was_active then
|
||||
vim.notify("File larger than 1MB; syntax highlighting and heavy CPU use plugins turned off.")
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
Reference in New Issue
Block a user