diff options
| author | Matt Turner <mattst88@gmail.com> | 2026-11-11 19:29:03 -0500 |
|---|---|---|
| committer | Matt Turner <mattst88@gmail.com> | 2026-11-11 19:29:07 -0500 |
| commit | 3b0b650f5c342351e86d4ff2f494f244aab920e9 (patch) | |
| tree | efb80e50cba56dbcb003f89ebf1b726f41c32492 /nvim/.config | |
| parent | c7c7e89b003c8c030b0eddef237b15c102be2947 (diff) | |
bigfile.nvim calls vim.validate with a table, which is deprecated and
warns on every startup. It has not been updated since 2023, and two of
its features no longer did anything here: the treesitter one relies on
nvim-treesitter.configs, which the main branch dropped, and the
indent_blankline one uses the ibl v2 API.
Instead, give files over 10 MiB the "bigfile" filetype. No parser,
syntax file, or LSP config matches it, so treesitter, syntax, and LSP
stay off. A FileType autocmd turns off swap, undo, list, and indent
guides for those buffers, and turns off matchparen, which is global.
Diffstat (limited to 'nvim/.config')
| -rw-r--r-- | nvim/.config/nvim/init.lua | 3 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/config/bigfile.lua | 43 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/bigfile.lua | 20 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/treesitter.lua | 4 |
4 files changed, 46 insertions, 24 deletions
diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 1a6f8cf..dd72ea4 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -14,4 +14,7 @@ require("config.lsp") -- Random require("config.misc") +-- Turn off expensive features for large files +require("config.bigfile") + vim.cmd[[colorscheme adwaita]] diff --git a/nvim/.config/nvim/lua/config/bigfile.lua b/nvim/.config/nvim/lua/config/bigfile.lua new file mode 100644 index 0000000..359a1db --- /dev/null +++ b/nvim/.config/nvim/lua/config/bigfile.lua @@ -0,0 +1,43 @@ +-- Make nvim faster when working on large files. +-- +-- Files over the limit get the "bigfile" filetype. Nothing (treesitter, LSP, +-- syntax) is set up for that filetype, so those stay off without having to +-- disable each one. +local limit = 10 * 1024 * 1024 -- 10 MiB + +vim.filetype.add({ + pattern = { + [".*"] = { + function(path, buf) + if not path or not buf or path ~= vim.api.nvim_buf_get_name(buf) then + return + end + if vim.fn.getfsize(path) > limit then + return "bigfile" + end + end, + { priority = math.huge }, + }, + }, +}) + +vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("bigfile", { clear = true }), + pattern = "bigfile", + callback = function(args) + -- matchparen is global; this turns it off everywhere, until :DoMatchParen. + if vim.fn.exists(":NoMatchParen") == 2 then + vim.cmd.NoMatchParen() + end + + vim.opt_local.swapfile = false + vim.opt_local.foldmethod = "manual" + vim.opt_local.undolevels = -1 + vim.opt_local.undoreload = 0 + vim.opt_local.list = false + + pcall(function() + require("ibl").setup_buffer(args.buf, { enabled = false }) + end) + end, +}) diff --git a/nvim/.config/nvim/lua/plugins/bigfile.lua b/nvim/.config/nvim/lua/plugins/bigfile.lua deleted file mode 100644 index bb2e965..0000000 --- a/nvim/.config/nvim/lua/plugins/bigfile.lua +++ /dev/null @@ -1,20 +0,0 @@ --- Motivation: Make nvim faster when working on large files -return { - "LunarVim/bigfile.nvim", - config = function() - require("bigfile").setup({ - filesize = 10, -- Size in MiB - pattern = { "*" }, - features = { -- features to disable for big files - "indent_blankline", - "illuminate", - "lsp", - "treesitter", - "syntax", - "matchparen", - "vimopts", - "filetype", - } - }) - end -} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua index 7331d2b..f9d9434 100644 --- a/nvim/.config/nvim/lua/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -41,10 +41,6 @@ return { vim.api.nvim_create_autocmd("FileType", { group = vim.api.nvim_create_augroup("treesitter", { clear = true }), callback = function(args) - -- Set by bigfile.nvim for files over its size limit. - if vim.b[args.buf].bigfile_disable_treesitter then - return - end -- Returns false (or errors) if no parser is installed for -- this filetype. if not pcall(vim.treesitter.start, args.buf) then |
