feat(autocmds): added proper bigfile support

This commit is contained in:
Folke Lemaitre 2024-06-25 20:30:57 +02:00
parent a33eabddd9
commit 938a6718c6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 28 additions and 0 deletions

View file

@ -114,3 +114,25 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end, 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,
})

View file

@ -40,6 +40,12 @@ vim.g.lazyvim_statuscolumn = {
-- Hide deprecation warnings -- Hide deprecation warnings
vim.g.deprecation_warnings = false 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 -- Show the current document symbols location from Trouble in lualine
vim.g.trouble_lualine = true vim.g.trouble_lualine = true