64 lines
1.9 KiB
Lua
64 lines
1.9 KiB
Lua
-- Create autogroups first
|
|
local MZuninoGroup = vim.api.nvim_create_augroup("mzunino", {})
|
|
local yank_group = vim.api.nvim_create_augroup("HighlightYank", {})
|
|
|
|
-- Set bigfile size threshold
|
|
vim.g.bigfile_size = 1024 * 1024 * 1.5 -- 1.5 MB
|
|
|
|
-- Netrw diagnostic disable
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "netrw",
|
|
callback = function()
|
|
vim.diagnostic.enable(false)
|
|
end,
|
|
})
|
|
|
|
-- Template files
|
|
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
|
pattern = "*.templ",
|
|
command = "set filetype=templ",
|
|
})
|
|
|
|
-- Highlight on yank
|
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
|
group = yank_group,
|
|
pattern = "*",
|
|
callback = function()
|
|
vim.highlight.on_yank({
|
|
higroup = "IncSearch",
|
|
timeout = 40,
|
|
})
|
|
end,
|
|
})
|
|
|
|
-- Remove trailing whitespace on save
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
group = MZuninoGroup,
|
|
pattern = "*",
|
|
command = [[%s/\s\+$//e]],
|
|
})
|
|
|
|
-- Bigfile detection
|
|
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("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
|
callback = function(ev)
|
|
local opts = { buffer = ev.buf, silent = true }
|
|
nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
|
|
nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
|
|
nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
|
|
nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
|
|
nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
|
|
nmap("<leader>lr", "<cmd>LspRestart<CR>", vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
|
|
end,
|
|
})
|