mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
add log-autocmd
This commit is contained in:
parent
91b4d85592
commit
a6ded3a154
119
plugin/log-autocmds.vim
Normal file
119
plugin/log-autocmds.vim
Normal file
@ -0,0 +1,119 @@
|
||||
command! LogAutocmds call s:log_autocmds_toggle()
|
||||
|
||||
function! s:log_autocmds_toggle()
|
||||
augroup LogAutocmd
|
||||
autocmd!
|
||||
augroup END
|
||||
|
||||
let l:date = strftime('%F', localtime())
|
||||
let s:activate = get(s:, 'activate', 0) ? 0 : 1
|
||||
if !s:activate
|
||||
call s:log('Stopped autocmd log (' . l:date . ')')
|
||||
return
|
||||
endif
|
||||
|
||||
call s:log('Started autocmd log (' . l:date . ')')
|
||||
augroup LogAutocmd
|
||||
for l:au in s:aulist
|
||||
silent execute 'autocmd' l:au '* call s:log(''' . l:au . ''')'
|
||||
endfor
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! s:log(message)
|
||||
silent execute '!echo "'
|
||||
\ . strftime('%T', localtime()) . ' - ' . a:message . '"'
|
||||
\ '>> /tmp/vim_log_autocommands'
|
||||
endfunction
|
||||
|
||||
" These are deliberately left out due to side effects
|
||||
" - SourceCmd
|
||||
" - FileAppendCmd
|
||||
" - FileWriteCmd
|
||||
" - BufWriteCmd
|
||||
" - FileReadCmd
|
||||
" - BufReadCmd
|
||||
" - FuncUndefined
|
||||
|
||||
let s:aulist = [
|
||||
\ 'BufNewFile',
|
||||
\ 'BufReadPre',
|
||||
\ 'BufRead',
|
||||
\ 'BufReadPost',
|
||||
\ 'FileReadPre',
|
||||
\ 'FileReadPost',
|
||||
\ 'FilterReadPre',
|
||||
\ 'FilterReadPost',
|
||||
\ 'StdinReadPre',
|
||||
\ 'StdinReadPost',
|
||||
\ 'BufWrite',
|
||||
\ 'BufWritePre',
|
||||
\ 'BufWritePost',
|
||||
\ 'FileWritePre',
|
||||
\ 'FileWritePost',
|
||||
\ 'FileAppendPre',
|
||||
\ 'FileAppendPost',
|
||||
\ 'FilterWritePre',
|
||||
\ 'FilterWritePost',
|
||||
\ 'BufAdd',
|
||||
\ 'BufCreate',
|
||||
\ 'BufDelete',
|
||||
\ 'BufWipeout',
|
||||
\ 'BufFilePre',
|
||||
\ 'BufFilePost',
|
||||
\ 'BufEnter',
|
||||
\ 'BufLeave',
|
||||
\ 'BufWinEnter',
|
||||
\ 'BufWinLeave',
|
||||
\ 'BufUnload',
|
||||
\ 'BufHidden',
|
||||
\ 'BufNew',
|
||||
\ 'SwapExists',
|
||||
\ 'FileType',
|
||||
\ 'Syntax',
|
||||
\ 'EncodingChanged',
|
||||
\ 'TermChanged',
|
||||
\ 'VimEnter',
|
||||
\ 'GUIEnter',
|
||||
\ 'GUIFailed',
|
||||
\ 'TermResponse',
|
||||
\ 'QuitPre',
|
||||
\ 'VimLeavePre',
|
||||
\ 'VimLeave',
|
||||
\ 'FileChangedShell',
|
||||
\ 'FileChangedShellPost',
|
||||
\ 'FileChangedRO',
|
||||
\ 'ShellCmdPost',
|
||||
\ 'ShellFilterPost',
|
||||
\ 'CmdUndefined',
|
||||
\ 'SpellFileMissing',
|
||||
\ 'SourcePre',
|
||||
\ 'VimResized',
|
||||
\ 'FocusGained',
|
||||
\ 'FocusLost',
|
||||
\ 'CursorHold',
|
||||
\ 'CursorHoldI',
|
||||
\ 'CursorMoved',
|
||||
\ 'CursorMovedI',
|
||||
\ 'WinEnter',
|
||||
\ 'WinLeave',
|
||||
\ 'TabEnter',
|
||||
\ 'TabLeave',
|
||||
\ 'CmdwinEnter',
|
||||
\ 'CmdwinLeave',
|
||||
\ 'InsertEnter',
|
||||
\ 'InsertChange',
|
||||
\ 'InsertLeave',
|
||||
\ 'InsertCharPre',
|
||||
\ 'TextChanged',
|
||||
\ 'TextChangedI',
|
||||
\ 'ColorScheme',
|
||||
\ 'RemoteReply',
|
||||
\ 'QuickFixCmdPre',
|
||||
\ 'QuickFixCmdPost',
|
||||
\ 'SessionLoadPost',
|
||||
\ 'MenuPopup',
|
||||
\ 'CompleteDone',
|
||||
\ 'User',
|
||||
\ ]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user