1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2025-04-02 22:29:50 +00:00
dotfiles/.config/nvim/lua/core/autocommands.lua
Daniel Carrillo 7d01253a29
[neovim] replace neo-tree with snacks.nvim
Replace neo-tree.nvim with snacks.nvim for file explorer functionality and
remove several other plugins including:
- mini-animate
- mini-starter
- indent-blankline

The snacks.nvim plugin provides better file explorer, dashboard, indentation
guides, and other UI improvements in a more cohesive package.

Also removed the large file autocommand as snacks.nvim handles this with its
bigfile module.
2025-03-30 18:01:59 +02:00

71 lines
1.5 KiB
Lua

-- Highlight Yanked Text
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
(vim.hl or vim.highlight).on_yank()
end,
})
-- resize splits if window got resized
vim.api.nvim_create_autocmd("VimResized", {
callback = function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
vim.cmd("tabnext " .. current_tab)
end,
})
-- Set expandtab=true in several file types
vim.api.nvim_create_autocmd("FileType", {
pattern = { "go", "makefile", "lua" },
callback = function()
vim.opt_local.expandtab = false
end,
})
-- Use 'q' to quit from common plugins
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"PlenaryTestPopup",
"checkhealth",
"dbout",
"gitsigns-blame",
"grug-far",
"help",
"lspinfo",
"neotest-output",
"neotest-output-panel",
"neotest-summary",
"notify",
"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,
})
-- Ensure terraform files use hcl LSP
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
pattern = { "*.tf" },
callback = function()
vim.cmd([[
set filetype=hcl
]])
end,
})
-- Set hcl and helm indentation to 2
vim.api.nvim_create_autocmd("FileType", {
pattern = { "hcl", "helm" },
command = "setlocal shiftwidth=2 tabstop=2",
})