2014-02-04 23:32:29 -05:00
|
|
|
scriptencoding utf-8
|
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
|
|
|
|
2015-06-28 10:01:55 -04:00
|
|
|
function! s:_vital_loaded(V)
|
|
|
|
let s:V = a:V
|
|
|
|
let s:E = s:V.import("Over.Exception")
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! s:_vital_depends()
|
|
|
|
return [
|
|
|
|
\ "Over.Exception",
|
|
|
|
\ ]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2014-02-04 23:32:29 -05:00
|
|
|
let s:cache_command = {}
|
2014-08-27 21:22:57 -04:00
|
|
|
function! s:doautocmd_user(prefix, command)
|
|
|
|
let group = a:prefix . "-vital-over-commandline-doautocmd-dummy"
|
2015-06-28 10:01:55 -04:00
|
|
|
if !has_key(s:cache_command, a:prefix)
|
|
|
|
let s:cache_command[a:prefix] = {}
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !has_key(s:cache_command[a:prefix], a:command)
|
2014-08-27 21:22:57 -04:00
|
|
|
execute "autocmd " . group
|
2014-02-04 23:32:29 -05:00
|
|
|
\ . " User " . a:command." silent! execute ''"
|
|
|
|
|
|
|
|
if v:version > 703 || v:version == 703 && has("patch438")
|
2015-06-28 10:01:55 -04:00
|
|
|
let s:cache_command[a:prefix][a:command] = "doautocmd <nomodeline> User " . a:command
|
2014-02-04 23:32:29 -05:00
|
|
|
else
|
2015-06-28 10:01:55 -04:00
|
|
|
let s:cache_command[a:prefix][a:command] = "doautocmd User " . a:command
|
2014-02-04 23:32:29 -05:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-06-28 10:01:55 -04:00
|
|
|
execute s:cache_command[a:prefix][a:command]
|
2014-02-04 23:32:29 -05:00
|
|
|
endfunction
|
|
|
|
|
2015-06-28 10:01:55 -04:00
|
|
|
|
2014-02-04 23:32:29 -05:00
|
|
|
let s:hooks = [
|
|
|
|
\ "enter",
|
|
|
|
\ "leave",
|
|
|
|
\ "char",
|
|
|
|
\ "char_pre",
|
2014-06-06 12:35:19 -04:00
|
|
|
\ "draw",
|
|
|
|
\ "draw_pre",
|
2014-02-04 23:32:29 -05:00
|
|
|
\ "execute_pre",
|
|
|
|
\ "execute_failed",
|
|
|
|
\ "execute",
|
2014-06-06 12:35:19 -04:00
|
|
|
\ "exception",
|
2014-02-04 23:32:29 -05:00
|
|
|
\]
|
|
|
|
|
|
|
|
let s:hooks_camel = [
|
|
|
|
\ "Enter",
|
|
|
|
\ "Leave",
|
|
|
|
\ "Char",
|
|
|
|
\ "CharPre",
|
2014-06-06 12:35:19 -04:00
|
|
|
\ "Draw",
|
|
|
|
\ "DrawPre",
|
2014-02-04 23:32:29 -05:00
|
|
|
\ "ExecutePre",
|
|
|
|
\ "ExecuteFailed",
|
|
|
|
\ "Execute",
|
2014-06-06 12:35:19 -04:00
|
|
|
\ "Exception",
|
2014-02-04 23:32:29 -05:00
|
|
|
\]
|
|
|
|
|
|
|
|
|
|
|
|
let s:module = {
|
|
|
|
\ "name" : "Doautocmd",
|
|
|
|
\}
|
|
|
|
|
|
|
|
|
|
|
|
for s:i in range(len(s:hooks))
|
2014-08-27 21:22:57 -04:00
|
|
|
execute join([
|
2015-06-28 10:01:55 -04:00
|
|
|
\ "function! s:module.on_" . s:hooks[s:i] . "(cmdline, ...)",
|
|
|
|
\ " let s:cmdline = a:cmdline",
|
2014-08-27 21:22:57 -04:00
|
|
|
\ " call s:doautocmd_user(self.prefix, self.prefix . " . string(s:hooks_camel[s:i]) . ")",
|
2014-02-04 23:32:29 -05:00
|
|
|
\ "endfunction",
|
|
|
|
\ ], "\n")
|
|
|
|
endfor
|
|
|
|
|
|
|
|
|
2015-06-28 10:01:55 -04:00
|
|
|
function! s:get_cmdline()
|
|
|
|
if !exists("s:cmdline")
|
|
|
|
execute s:E.throw_cmd("Undefined cmdline object.", "Over.Commandline.Modules.Doautocmd")
|
|
|
|
endif
|
|
|
|
return s:cmdline
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2014-02-04 23:32:29 -05:00
|
|
|
function! s:make(prefix)
|
2015-06-28 10:01:55 -04:00
|
|
|
if has_key(s:cache_command, a:prefix)
|
|
|
|
unlet! s:cache_command[a:prefix]
|
|
|
|
endif
|
2014-08-27 21:22:57 -04:00
|
|
|
execute "augroup " a:prefix . "-vital-over-commandline-doautocmd-dummy"
|
|
|
|
autocmd!
|
|
|
|
augroup END
|
|
|
|
|
2014-02-04 23:32:29 -05:00
|
|
|
let module = deepcopy(s:module)
|
|
|
|
let module.prefix = a:prefix
|
|
|
|
return module
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|
2016-03-22 08:55:42 -04:00
|
|
|
" ___Revitalizer___
|
|
|
|
" NOTE: below code is generated by :Revitalize.
|
|
|
|
" Do not mofidify the code nor append new lines
|
|
|
|
if v:version > 703 || v:version == 703 && has('patch1170')
|
|
|
|
function! s:___revitalizer_function___(fstr) abort
|
|
|
|
return function(a:fstr)
|
|
|
|
endfunction
|
|
|
|
else
|
|
|
|
function! s:___revitalizer_SID() abort
|
|
|
|
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze____revitalizer_SID$')
|
|
|
|
endfunction
|
|
|
|
let s:___revitalizer_sid = '<SNR>' . s:___revitalizer_SID() . '_'
|
|
|
|
function! s:___revitalizer_function___(fstr) abort
|
|
|
|
return function(substitute(a:fstr, 's:', s:___revitalizer_sid, 'g'))
|
|
|
|
endfunction
|
|
|
|
endif
|
|
|
|
|
2016-03-22 10:04:08 -04:00
|
|
|
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'doautocmd_user': s:___revitalizer_function___('s:doautocmd_user'),'get_cmdline': s:___revitalizer_function___('s:get_cmdline'),'make': s:___revitalizer_function___('s:make')}
|
2016-03-22 08:55:42 -04:00
|
|
|
|
|
|
|
unlet! s:___revitalizer_sid
|
|
|
|
delfunction s:___revitalizer_function___
|
|
|
|
|
|
|
|
function! vital#_easymotion#Over#Commandline#Modules#Doautocmd#import() abort
|
|
|
|
return s:___revitalizer_functions___
|
|
|
|
endfunction
|
|
|
|
" ___Revitalizer___
|