Skip to content

Commit

Permalink
Nvim: style tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Dec 12, 2024
1 parent 2dbd14d commit a1d1b44
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions .config/nvim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ 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
local filetype = vim.bo.filetype
if filetype ~= "" then
vim.cmd("TSBufDisable " .. filetype)
end

-- Disable nvim-cmp
local cmp = require("cmp")
if cmp then
cmp.setup.buffer({ enabled = false })
end

vim.api.nvim_echo({
{ "Plugins disabled for large file: " .. filepath, "WarningMsg" },
}, false, {})
if filesize <= max_filesize then
return
end

-- Disable treesitter
local filetype = vim.bo.filetype
if filetype ~= "" then
vim.cmd("TSBufDisable " .. filetype)
end

-- Disable nvim-cmp
local cmp = require("cmp")
if cmp then
cmp.setup.buffer({ enabled = false })
end

vim.api.nvim_echo({
{ "Plugins disabled for large file: " .. filepath, "WarningMsg" },
}, false, {})
end

-- Autocmd to check file size on BufRead
Expand Down

0 comments on commit a1d1b44

Please sign in to comment.