From 938a6718c6f0d5c6716a34bd3383758907820c52 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 25 Jun 2024 20:30:57 +0200 Subject: [PATCH] feat(autocmds): added proper bigfile support --- lua/lazyvim/config/autocmds.lua | 22 ++++++++++++++++++++++ lua/lazyvim/config/options.lua | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 81d0209a..cf013e1f 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -114,3 +114,25 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") end, }) + +vim.filetype.add({ + pattern = { + [".*"] = { + function(path, buf) + return vim.bo[buf].filetype ~= "bigfile" and path and vim.fn.getfsize(path) > vim.g.bigfile_size and "bigfile" + or nil + end, + }, + }, +}) + +vim.api.nvim_create_autocmd({ "FileType" }, { + group = augroup("bigfile"), + pattern = "bigfile", + callback = function(ev) + vim.b.minianimate_disable = true + vim.schedule(function() + vim.bo[ev.buf].syntax = vim.filetype.match({ buf = ev.buf }) or "" + end) + end, +}) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index d2f8e24a..f324be99 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -40,6 +40,12 @@ vim.g.lazyvim_statuscolumn = { -- Hide deprecation warnings vim.g.deprecation_warnings = false +-- Set filetype to `bigfile` for files larger than 1.5 MB +-- Only vim syntax will be enabled (with the correct filetype) +-- LSP, treesitter and other ft plugins will be disabled. +-- mini.animate will also be disabled. +vim.g.bigfile_size = 1024 * 1024 * 1.5 -- 1.5 MB + -- Show the current document symbols location from Trouble in lualine vim.g.trouble_lualine = true