.config/nvim/plugin/vimrc/autocmds.vim

Sun, 19 Feb 2023 03:46:56 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 19 Feb 2023 03:46:56 -0600
changeset 1023
5a252b101778
parent 1022
d509e282ae10
child 1025
9dfc1a5a52dc
permissions
-rw-r--r--

update lock

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

mercurial