Files
dotfiles/.config/nvim/lua/config/autocmds.lua
Stefan Imhoff a41290c297 feat(nix): nix and back again
I tried Nix, but it had too many downsides so I removed it.

1. Didn't like that all files are immutable and simple config changes
need a complete rebuild.
2. Setting up a new Mac didn't work as smoothly as promised. Not worth
the effort.
3. It sucked a lot to always have to type in the password twice on each
darwin-rebuild
4. It solves problems I never had.
2024-08-07 17:49:02 +02:00

56 lines
1.5 KiB
Lua

-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
-- Reload tmux config on save
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*tmux.conf" },
command = "execute 'silent !tmux source <afile> --silent'",
})
-- Reload gitmux config on save
vim.api.nvim_create_autocmd({ "BufRead" }, {
pattern = { "gitmux.conf" },
callback = function()
vim.cmd([[set filetype=sh]])
end,
})
-- Restart yabai on config save
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { ".yabairc" },
command = "!yabai --restart-service",
})
-- Add specific settings for Markdown files
vim.api.nvim_create_autocmd({ "BufNewFile", "BufFilePre", "BufRead" }, {
pattern = { "*.mdx", "*.md" },
callback = function()
vim.cmd([[set wrap linebreak nolist]])
vim.cmd([[SoftWrapMode]])
end,
})
-- Evenly resize windows after resizing
vim.api.nvim_create_autocmd({ "VimResized" }, {
pattern = { "*" },
callback = function()
vim.cmd([[tabdo wincmd =]])
end,
})
-- Turn off paste mode when leaving insert mode
vim.api.nvim_create_autocmd("InsertLeave", {
pattern = { "*" },
command = "set nopaste",
})
-- Change conceallevel for JSON files
vim.api.nvim_create_autocmd("FileType", {
pattern = { "json", "jsonc" },
callback = function()
vim.wo.spell = false
vim.wo.conceallevel = 0
end,
})