From 2f6eca0dc513d474765290f1a5a4c02aed549be0 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 7 Nov 2018 10:34:07 +0100 Subject: Plein de trucs en vrac... J’ai honte.. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/l9.vim | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 plugin/l9.vim (limited to 'plugin/l9.vim') diff --git a/plugin/l9.vim b/plugin/l9.vim new file mode 100644 index 0000000..03613e4 --- /dev/null +++ b/plugin/l9.vim @@ -0,0 +1,108 @@ +"============================================================================= +" Copyright (C) 2009-2010 Takeshi NISHIDA +" +" GetLatestVimScripts: 3252 1 :AutoInstall: L9 +"============================================================================= +" LOAD GUARD {{{1 + +if !l9#guardScriptLoading(expand(':p'), 702, 0, []) + finish +endif + +" }}}1 +"============================================================================= +" OPTIONS: {{{1 + +call l9#defineVariableDefault('g:l9_balloonly', 'balloonly.exe') + +" }}}1 +"============================================================================= +" ASSERTION: {{{1 + +" This command has effect only if $L9_DEBUG is non-zero. +" Used as follows: +" L9Assert a:i > 0 +" This command can't interpret script-local variables directly. +" NG: L9Assert s:a == 1 +" OK: execute 'L9Assert ' . s:a . ' == 1' +" +if $L9_DEBUG + command -nargs=* L9Assert call eval(() ? 0 : s:handleFailedAssersion()) + + function s:handleFailedAssersion(expr) + echoerr '[L9Assert] Assersion failure: ' . a:expr + if input('[L9Assert] Continue? (Y/N) ', 'Y') !=? 'Y' + throw 'L9Assert ' . a:expr + endif + endfunction + +else + command -nargs=* L9Assert : +endif + +" }}}1 +"============================================================================= +" TIMER: {{{1 + +" These commands have effect only if $L9_TIMER is non-zero. +" Used as follows: +" L9Timer foo +" ... (1) +" L9Timer bar +" ... (2) +" L9TimerStop +" ... +" L9TimerDump <- shows each elapsed time of (1) and (2) +" +if $L9_TIMER + command -nargs=1 L9Timer call s:timerBegin() + command -nargs=0 L9TimerStop call s:timerStop() + command -nargs=0 L9TimerDump call s:timerDump() + + let s:timerData = [] + let s:timerTagMaxLen = 0 + + function s:timerBegin(tag) + L9TimerStop + let s:timerCurrent = {'tag': strftime('%c ') . a:tag . ' ', 'time': reltime()} + let s:timerTagMaxLen = max([len(s:timerCurrent.tag), s:timerTagMaxLen]) + endfunction + + function s:timerStop() + if !exists('s:timerCurrent') + return + endif + let s:timerCurrent.time = reltimestr(reltime(s:timerCurrent.time)) + call add(s:timerData, s:timerCurrent) + unlet s:timerCurrent + endfunction + + function s:timerDump() + L9TimerStop + let lines = map(s:timerData, 'v:val.tag . repeat(" ", s:timerTagMaxLen - len(v:val.tag)) . v:val.time') + call l9#tempbuffer#openReadOnly('[l9-timer]', '', lines, 0, 0, 0, {}) + let s:timerData = [] + let s:timerTagMaxLen = 0 + endfunction + +else + command -nargs=1 L9Timer : + command -nargs=0 L9TimerStop : + command -nargs=0 L9TimerDump : +endif + +" }}}1 +"============================================================================= +" GREP BUFFER: {{{1 + +" Grep for current buffer by l9#grepBuffers() +" Used as :L9GrepBuffer/pattern +command -nargs=? L9GrepBuffer call l9#grepBuffers(, [bufnr('%')]) + +" Grep for all buffers by l9#grepBuffers() +" Used as :L9GrepBufferAll/pattern +command -nargs=? L9GrepBufferAll call l9#grepBuffers(, range(1, bufnr('$'))) + +" }}}1 +"============================================================================= +" vim: set fdm=marker: -- cgit v1.2.3