Merge abhinav-dev

autocmd registration simplification
This commit is contained in:
Rane Brown 2019-08-28 03:50:30 -06:00
commit f6a99569bd
2 changed files with 30 additions and 28 deletions

View File

@ -3463,6 +3463,7 @@ Contributors and their Github usernames in roughly chronological order:
- Jonny Bylsma (@jbylsma) - Jonny Bylsma (@jbylsma)
- Shaedil (@Shaedil) - Shaedil (@Shaedil)
- Robin Lowe (@defau1t) - Robin Lowe (@defau1t)
- Abhinav Gupta (@abhinav)
============================================================================== ==============================================================================
@ -3478,7 +3479,6 @@ https://github.com/vimwiki-backup/vimwiki/issues.
2.5 (in progress)~ 2.5 (in progress)~
New:~ New:~
* PR #744: Fix typo in vimwiki_list_manipulation
* PR #711: Allow forcing VimwikiAll2HTML with ! * PR #711: Allow forcing VimwikiAll2HTML with !
* PR #702: Make remapping documentation more accessible to newer vim users * PR #702: Make remapping documentation more accessible to newer vim users
* PR #673: Add :VimwikiGoto key mapping. * PR #673: Add :VimwikiGoto key mapping.
@ -3544,6 +3544,7 @@ Removed:~
point. point.
Fixed:~ Fixed:~
* PR #744: Fix typo in vimwiki_list_manipulation
* Issue #715: s:clean_url is compatible with vim pre 7.4.1546 (sticky type * Issue #715: s:clean_url is compatible with vim pre 7.4.1546 (sticky type
checking) checking)
* Issue #729: Normalize links uses relative paths in diary pages for * Issue #729: Normalize links uses relative paths in diary pages for

View File

@ -308,33 +308,34 @@ endif
augroup vimwiki augroup vimwiki
autocmd! autocmd!
autocmd ColorScheme * call s:setup_cleared_syntax() autocmd ColorScheme * call s:setup_cleared_syntax()
for s:ext in s:known_extensions
exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()' " ['.md', '.mdown'] => *.md,*.mdown
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()' let pat = join(map(s:known_extensions, '"*" . v:val'), ',')
exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()' exe 'autocmd BufNewFile,BufRead '.pat.' call s:setup_new_wiki_buffer()'
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_win_enter()' exe 'autocmd BufEnter '.pat.' call s:setup_buffer_enter()'
if exists('##DiffUpdated') exe 'autocmd BufLeave '.pat.' call s:setup_buffer_leave()'
exe 'autocmd DiffUpdated *'.s:ext.' call s:setup_buffer_win_enter()' exe 'autocmd BufWinEnter '.pat.' call s:setup_buffer_win_enter()'
endif if exists('##DiffUpdated')
" automatically generate a level 1 header for new files exe 'autocmd DiffUpdated '.pat.' call s:setup_buffer_win_enter()'
exe 'autocmd BufNewFile *'.s:ext.' call s:create_h1(expand("%:p"))' endif
" Format tables when exit from insert mode. Do not use textwidth to " automatically generate a level 1 header for new files
" autowrap tables. exe 'autocmd BufNewFile '.pat.' call s:create_h1(expand("%:p"))'
if vimwiki#vars#get_global('table_auto_fmt') " Format tables when exit from insert mode. Do not use textwidth to
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."), 2)' " autowrap tables.
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))' if vimwiki#vars#get_global('table_auto_fmt')
endif exe 'autocmd InsertLeave '.pat.' call vimwiki#tbl#format(line("."), 2)'
if vimwiki#vars#get_global('folding') =~? ':quick$' exe 'autocmd InsertEnter '.pat.' call vimwiki#tbl#reset_tw(line("."))'
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text endif
" Don't screw up folds when inserting text that might affect them, until if vimwiki#vars#get_global('folding') =~? ':quick$'
" leaving insert mode. Foldmethod is local to the window. Protect against " from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
" screwing up folding when switching between windows. " Don't screw up folds when inserting text that might affect them, until
exe 'autocmd InsertEnter *'.s:ext.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'. " leaving insert mode. Foldmethod is local to the window. Protect against
\ ' | setlocal foldmethod=manual | endif' " screwing up folding when switching between windows.
exe 'autocmd InsertLeave,WinLeave *'.s:ext.' if exists("w:last_fdm") |'. exe 'autocmd InsertEnter '.pat.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'.
\ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif' \ ' | setlocal foldmethod=manual | endif'
endif exe 'autocmd InsertLeave,WinLeave '.pat.' if exists("w:last_fdm") |'.
endfor \ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
endif
augroup END augroup END