#vim bigfiles #
#til a sweet lil' hack to disable #neovim plugins and features that might make things sluggish... this has definitely not happened to me 100 times before.
local bigfile = vim.api.nvim_create_augroup('bigfile', { clear = true })
vim.g.bigfile_size = 1024 * 1024 * 1.5
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 = 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,
})
trigger actions on events with vim.api.nvim_create_autocommand #
-- vim.api.nvim_create_autocmd({event}, {opts})
vim.api.nvim_create_autocmd(
-- the event
"BufWritePost",
-- the effect
{
pattern = "*.js",
command = "silent! !prettier --write %",
}
)
organizing autocommands with vim.api.nvim_create_augroup #
local myGroup = vim.api.nvim_create_augroup("MyAutoGroup", { clear = true })
vim.api.nvim_create_autocmd(
"BufWritePost",
{
-- the group
group = myGroup,
pattern = "*.js",
command = "silent! !prettier --write %",
}
)