nvim autocmds

- close special filetypes with q
- auto spellcheck and wrap
This commit is contained in:
Henrik Bakken
2025-04-02 10:55:11 +02:00
parent 8ab93fb356
commit 4b47ecacd8
+37
View File
@@ -191,6 +191,7 @@ map(
-- LSP
map("n", "<leader>ll", "<cmd>e ~/.local/state/nvim/lsp.log<cr>")
map("n", "<leader>lc", "<cmd>checkhealth<cr>")
local diagnostic_goto = function(count, severity)
severity = severity and vim.diagnostic.severity[severity] or nil
return function() vim.diagnostic.jump({ severity, float = true, count = count }) end
@@ -238,6 +239,42 @@ vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*",
command = "if &buftype == '' && !&modified && expand('%') != '' | exec 'checktime ' . expand('<abuf>') | endif",
})
-- Close some filetypes with <q>
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("close_with_q", { clear = true }),
pattern = {
"PlenaryTestPopup",
"checkhealth",
"floggraph",
"fugitive",
"gitsigns-blame",
"grug-far",
"help",
"lspinfo",
"notify",
"oil",
"qf",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.schedule(function()
vim.keymap.set("n", "q", function()
vim.cmd("close")
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
end, { buffer = event.buf, silent = true, desc = "Quit Buffer" })
end)
end,
})
-- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("wrap_spell", { clear = true }),
pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- ----------------------------------------
-- SPECS