1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2025-07-04 14:39:25 +00:00

[neovim] Refactor

This commit is contained in:
2025-02-21 16:24:32 +01:00
parent b8fcf02379
commit 8d7675acf4
8 changed files with 67 additions and 38 deletions

View File

@ -6,7 +6,7 @@ vim.api.nvim_create_autocmd("TextYankPost", {
})
-- resize splits if window got resized
vim.api.nvim_create_autocmd({ "VimResized" }, {
vim.api.nvim_create_autocmd("VimResized", {
callback = function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
@ -15,7 +15,7 @@ vim.api.nvim_create_autocmd({ "VimResized" }, {
})
-- Set expandtab=true in several file types
vim.api.nvim_create_autocmd({ "FileType" }, {
vim.api.nvim_create_autocmd("FileType", {
pattern = { "go", "makefile", "lua" },
callback = function()
vim.opt_local.expandtab = false
@ -23,19 +23,33 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
})
-- Use 'q' to quit from common plugins
vim.api.nvim_create_autocmd({ "FileType" }, {
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"PlenaryTestPopup",
"checkhealth",
"dbout",
"gitsigns-blame",
"grug-far",
"help",
"lspinfo",
"man",
"neotest-output",
"neotest-output-panel",
"neotest-summary",
"notify",
"qf",
"query",
"checkhealth",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
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,
})
@ -48,14 +62,10 @@ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
]])
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "hcl",
command = "setlocal shiftwidth=2 tabstop=2",
})
-- helm files indentation
-- Set hcl and helm indentation to 2
vim.api.nvim_create_autocmd("FileType", {
pattern = "helm",
pattern = { "hcl", "helm" },
command = "setlocal shiftwidth=2 tabstop=2",
})