Sun, 19 Feb 2023 11:30:19 -0600
vim-polyglot has been a nuisance too often
1022 | 1 | augroup vimrc |
2 | autocmd! | |
3 | ||
1025 | 4 | autocmd TermOpen * startinsert |
5 | ||
1022 | 6 | autocmd WinLeave * if !pumvisible() | stopinsert | endif |
7 | ||
8 | " complement to autowriteall | |
9 | autocmd FocusLost * silent! wa | |
10 | ||
11 | " Make paths when writing, as necessary | |
12 | autocmd BufWritePre * :call vimrc#MkNonExDir(expand('<afile>'), +expand('<abuf>')) | |
13 | ||
14 | if ! &diff | |
15 | " set and load a session based on servername | |
16 | autocmd VimEnter * nested call vimrc#AutoSessionCheck() | |
17 | ||
18 | " Jump to last known pos | |
19 | autocmd BufReadPost * | |
20 | \ if &filetype !~# 'mail\|^git\|^hg' && line("'\"") >= 1 && line("'\"") <= line("$") | | |
21 | \ exe "normal! g`\"" | | |
22 | \ endif | |
23 | ||
24 | " Simple highlight conflict markers | |
25 | autocmd BufReadPost * | |
26 | \ match Error "^\([<>|]\)\{7} \@=\|^=\{7}$" | |
27 | endif | |
28 | ||
29 | " Simplify noisy ltag output | |
30 | autocmd BufReadPost quickfix | |
31 | \ if w:quickfix_title =~# '^:ltag' | | |
32 | \ setl modifiable | | |
33 | \ silent exe ':%s/\^\\V\s*\|\\\$|.*//g' | | |
34 | \ setl nomodifiable | | |
35 | \ endif | |
36 | ||
37 | " easy close quickfix | |
38 | autocmd BufReadPost quickfix nmap <buffer> q <C-w>c | |
39 | ||
40 | " Neomutt changed their tmpfile pattern, ugh | |
41 | autocmd BufNewFile,BufRead neomutt-*-\w\+ setf mail | |
42 | augroup END | |
43 | ||
44 | " https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/ | |
45 | " hacked to work with vimwiki | |
46 | augroup encrypted | |
47 | autocmd! | |
48 | autocmd BufReadPre,FileReadPre *.gpg,*.gpg.* setl noswapfile noundofile nobackup viminfo= | |
49 | autocmd BufReadPost *.gpg,*.gpg.* call vimrc#SafeFilterFile('gpg2 -d') | |
50 | autocmd BufWritePre *.gpg,*.gpg.* call vimrc#SafeFilterFile('gpg2 -se -a --default-recipient-self') | |
51 | autocmd BufWritePost *.gpg,*.gpg.* :sil undo | |
52 | augroup END | |
53 |