FollieHiyuki-dotfiles/home/.config/nvim/lua/autocmd.lua
FollieHiyuki a2a7caa279
neovim: bunch of changes again
- Fix commit 8a8e0db586 : vim.opt is a table, so it should have been
  vim.o -> vim.opt:get()
- Add filetype.nvim (improved startup time)
- Drop vimtex. Potentially will switch to tex.nvim
- Re-compile packer only inside '/modules' directory (less eager)
2021-10-17 21:48:14 +07:00

42 lines
1.6 KiB
Lua

local definitions = {
-- ':h hex-editing'
-- binary = {
-- {'BufReadPre' , '*.bin,*.exe', 'let &bin=1'},
-- {'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'},
-- {'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'},
-- {'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'},
-- {'BufWritePre' , '*.bin,*.exe', 'endif'},
-- {'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'},
-- {'BufWritePost', '*.bin,*.exe', 'set nomod | endif'}
-- },
-- Auto-hide UI elements in specific buffers
-- buf = {
-- {'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'},
-- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]}
-- },
wins = {
-- Equalize window dimensions when resizing vim window
{'VimResized', '*', 'tabdo wincmd ='},
-- Force writing shada on leaving nvim
{'VimLeave', '*', [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread'
-- {'FocusGained', '* checktime'}
},
yank = {
{'TextYankPost', [[* silent! lua vim.highlight.on_yank({higroup='IncSearch', timeout=300})]]}
}
}
for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup ' .. group_name)
vim.api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
vim.api.nvim_command(command)
end
vim.api.nvim_command('augroup END')
end