From f6880b715e48068b85245ebe8bda5f0fadde6d03 Mon Sep 17 00:00:00 2001 From: bretello Date: Fri, 15 Sep 2023 00:13:32 +0200 Subject: [PATCH] vim: group autocommands in augroups --- vim/vimrc | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index fc09952..02da635 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -82,36 +82,49 @@ syntax match jsonComment "\(/\*\)\|\(\*/\)" hi def link jsonComment Comment -au BufRead dvc.yaml let b:ale_fix_on_save=0 -au BufRead *.dvc let b:ale_fix_on_save=0 -au BufRead *.dvc set filetype=yaml +augroup dvc + au BufRead dvc.yaml let b:ale_fix_on_save=0 + au BufRead *.dvc let b:ale_fix_on_save=0 + au BufRead *.dvc set filetype=yaml +augroup END -au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible -au BufRead,BufNewFile */.github/*/*.y{,a}ml +augroup ansible + au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible +augroup END + +augroup githubactions + au BufRead,BufNewFile */.github/*/*.y{,a}ml \ let b:ale_linters = {'yaml': ['actionlint'] } -au BufRead,BufNewFile rules.v[46],*.rules setlocal filetype=iptables +augroup END +augroup iptables + au BufRead,BufNewFile rules.v[46],*.rules setlocal filetype=iptables +augroup END -autocmd! bufwritepost ~/.vimrc source ~/.vimrc -autocmd! bufwritepost $DOTFILES/vim/vimrc source ~/.vimrc -autocmd! bufwritepost $DOTFILES/vim/shortcuts.vim source ~/.vimrc -autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugInstall -autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugUpdate +augroup vimconfig + autocmd! bufwritepost ~/.vimrc source ~/.vimrc + autocmd! bufwritepost $DOTFILES/vim/vimrc source ~/.vimrc + autocmd! bufwritepost $DOTFILES/vim/shortcuts.vim source ~/.vimrc + autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugInstall + autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugUpdate +augroup END if has('persistent_undo') let undo_dir=$HOME . "/.vim/undo" if !isdirectory(undo_dir) - call mkdir(undo_dir , "p", 0o700) + call mkdir(undo_dir , "p", 0700) endif let &undodir=undo_dir set undofile endif -" Return to last edit position when opening files (from amix's vimrc) -au BufReadPost * if ! exists('b:dotgitFolder') | if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif -" set a marker to avoid returning to the previous position in .git folders -" (avoids returning to previous position for COMMIT_EDITMSG etc ) -au BufReadPost */.git/* let b:dotgitFolder = 1 +augroup dotgit + " Return to last edit position when opening files (from amix's vimrc) + au BufReadPost * if ! exists('b:dotgitFolder') | if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + " set a marker to avoid returning to the previous position in .git folders + " (avoids returning to previous position for COMMIT_EDITMSG etc ) + au BufReadPost */.git/* let b:dotgitFolder = 1 +augroup END " Bash like keys for the command line cnoremap