From 97b22ac13c5778efb4dc3a1298785fc6a3cab47e Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Fri, 31 May 2024 20:19:54 +0545 Subject: [PATCH 1/2] feat(bigfile): add bigfile module --- lua/lazyvim/plugins/extras/editor/bigfile.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/editor/bigfile.lua diff --git a/lua/lazyvim/plugins/extras/editor/bigfile.lua b/lua/lazyvim/plugins/extras/editor/bigfile.lua new file mode 100644 index 00000000..4137c237 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/bigfile.lua @@ -0,0 +1,19 @@ +return { + "LunarVim/bigfile.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + pattern = function(bufnr, filesize_mib) + if filesize_mib >= 2 then + return true + end + -- you can't use `nvim_buf_line_count` because this runs on BufReadPre + local file_contents = vim.fn.readfile(vim.api.nvim_buf_get_name(bufnr)) + local file_length = #file_contents + if file_length > 5000 then + return true + end + + return false + end, + }, +} From ba0e1d916c8bf3d67ab74f30ce4dc6471a4ed273 Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Fri, 31 May 2024 22:06:52 +0545 Subject: [PATCH 2/2] Update bigfile.lua --- lua/lazyvim/plugins/extras/editor/bigfile.lua | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/lua/lazyvim/plugins/extras/editor/bigfile.lua b/lua/lazyvim/plugins/extras/editor/bigfile.lua index 4137c237..508d5a98 100644 --- a/lua/lazyvim/plugins/extras/editor/bigfile.lua +++ b/lua/lazyvim/plugins/extras/editor/bigfile.lua @@ -1,19 +1,7 @@ return { - "LunarVim/bigfile.nvim", - event = { "BufReadPre", "BufNewFile" }, - opts = { - pattern = function(bufnr, filesize_mib) - if filesize_mib >= 2 then - return true - end - -- you can't use `nvim_buf_line_count` because this runs on BufReadPre - local file_contents = vim.fn.readfile(vim.api.nvim_buf_get_name(bufnr)) - local file_length = #file_contents - if file_length > 5000 then - return true - end - - return false - end, - }, + "LunarVim/bigfile.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + filesize = 2, -- size of the file in MiB, the plugin round file sizes to the closest MiB + }, }