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