From ae023f2876d282713cb16602add5e66c9fc051c4 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Thu, 15 Oct 2015 22:38:56 +0200 Subject: [PATCH] NEw vim setup --- vim/.vim/after/plugin/snipMate.vim | 46 + vim/.vim/autoload/buf_utils.vim | 24 + vim/.vim/autoload/cached_file_contents.vim | 104 + vim/.vim/autoload/env_reload.vim | 12 + vim/.vim/autoload/funcref.vim | 95 + vim/.vim/autoload/glob.vim | 27 + vim/.vim/autoload/snipMate.vim | 622 +++++ vim/.vim/autoload/snipMate_python_demo.vim | 47 + vim/.vim/autoload/snipmate/jumping.vim | 205 ++ vim/.vim/autoload/snipmate/legacy.vim | 130 + vim/.vim/autoload/snipmate/parse.vim | 219 ++ vim/.vim/autoload/snipmate/util.vim | 22 + vim/.vim/autoload/tiny_cmd.vim | 19 + .../autoload/tinykeymap/map/para_move.vim | 12 + vim/.vim/autoload/tlib.vim | 8 + vim/.vim/autoload/tlib/Filter_cnf.vim | 151 ++ vim/.vim/autoload/tlib/Filter_cnfd.vim | 53 + vim/.vim/autoload/tlib/Filter_fuzzy.vim | 83 + vim/.vim/autoload/tlib/Filter_glob.vim | 68 + vim/.vim/autoload/tlib/Object.vim | 154 ++ vim/.vim/autoload/tlib/Test.vim | 19 + vim/.vim/autoload/tlib/TestChild.vim | 19 + vim/.vim/autoload/tlib/World.vim | 1376 ++++++++++ vim/.vim/autoload/tlib/agent.vim | 614 +++++ vim/.vim/autoload/tlib/arg.vim | 103 + vim/.vim/autoload/tlib/autocmdgroup.vim | 14 + vim/.vim/autoload/tlib/balloon.vim | 54 + vim/.vim/autoload/tlib/bitwise.vim | 141 ++ vim/.vim/autoload/tlib/buffer.vim | 400 +++ vim/.vim/autoload/tlib/cache.vim | 335 +++ vim/.vim/autoload/tlib/char.vim | 59 + vim/.vim/autoload/tlib/cmd.vim | 111 + vim/.vim/autoload/tlib/comments.vim | 26 + vim/.vim/autoload/tlib/date.vim | 120 + vim/.vim/autoload/tlib/dir.vim | 93 + vim/.vim/autoload/tlib/eval.vim | 47 + vim/.vim/autoload/tlib/file.vim | 253 ++ vim/.vim/autoload/tlib/fixes.vim | 14 + vim/.vim/autoload/tlib/grep.vim | 38 + vim/.vim/autoload/tlib/hash.vim | 145 ++ vim/.vim/autoload/tlib/hook.vim | 25 + vim/.vim/autoload/tlib/input.vim | 1312 ++++++++++ vim/.vim/autoload/tlib/list.vim | 182 ++ vim/.vim/autoload/tlib/map.vim | 23 + vim/.vim/autoload/tlib/normal.vim | 34 + vim/.vim/autoload/tlib/notify.vim | 105 + vim/.vim/autoload/tlib/number.vim | 30 + vim/.vim/autoload/tlib/paragraph.vim | 97 + vim/.vim/autoload/tlib/persistent.vim | 47 + vim/.vim/autoload/tlib/progressbar.vim | 72 + vim/.vim/autoload/tlib/rx.vim | 55 + vim/.vim/autoload/tlib/scratch.vim | 136 + vim/.vim/autoload/tlib/signs.vim | 103 + vim/.vim/autoload/tlib/string.vim | 150 ++ vim/.vim/autoload/tlib/syntax.vim | 38 + vim/.vim/autoload/tlib/sys.vim | 198 ++ vim/.vim/autoload/tlib/tab.vim | 49 + vim/.vim/autoload/tlib/tag.vim | 132 + vim/.vim/autoload/tlib/textobjects.vim | 45 + vim/.vim/autoload/tlib/time.vim | 52 + vim/.vim/autoload/tlib/type.vim | 29 + vim/.vim/autoload/tlib/url.vim | 52 + vim/.vim/autoload/tlib/var.vim | 83 + vim/.vim/autoload/tlib/vcs.vim | 160 ++ vim/.vim/autoload/tlib/vim.vim | 152 ++ vim/.vim/autoload/tlib/win.vim | 128 + vim/.vim/autoload/tovl/scratch_buffer.vim | 103 + vim/.vim/autoload/tovl/ui/filter_list.vim | 473 ++++ vim/.vim/doc/SnipMate.txt | 634 +++++ vim/.vim/doc/cached_file_contents.txt | 7 + vim/.vim/doc/funcref.txt | 35 + vim/.vim/doc/supertab.txt | 473 ++++ vim/.vim/doc/tags | 406 +++ vim/.vim/doc/tiny_cmd.txt | 18 + vim/.vim/doc/tlib.txt | 2247 +++++++++++++++++ vim/.vim/etc/tpl_tlib.txt | 30 + vim/.vim/ftplugin/html_snip_helper.vim | 10 + vim/.vim/ftplugin/snippets.vim | 20 + vim/.vim/indent/snippets.vim | 32 + vim/.vim/plugin/02tlib.vim | 118 + vim/.vim/plugin/snipMate.vim | 135 + vim/.vim/plugin/supertab.vim | 1144 +++++++++ vim/.vim/plugin/templates.vim | 62 + .../samples/tlib/input/tlib_input_list.vim | 50 + vim/.vim/scripts/create_crc_table.rb | 67 + vim/.vim/snippets/_.snippets | 7 + vim/.vim/snippets/c.snippets | 113 + vim/.vim/snippets/cpp.snippets | 32 + vim/.vim/snippets/css.snippets | 14 + vim/.vim/snippets/cuda.snippets | 133 + vim/.vim/snippets/html.snippets | 192 ++ vim/.vim/snippets/java.snippets | 80 + vim/.vim/snippets/javascript.snippets | 77 + vim/.vim/snippets/perl.snippets | 93 + vim/.vim/snippets/php.snippets | 219 ++ vim/.vim/snippets/python.snippets | 91 + vim/.vim/snippets/ruby.snippets | 422 ++++ vim/.vim/snippets/sh.snippets | 34 + vim/.vim/snippets/snippet.snippets | 8 + vim/.vim/snippets/tex.snippets | 115 + vim/.vim/snippets/vim.snippets | 34 + vim/.vim/snippets/zsh.snippets | 60 + vim/.vim/spec/tlib/arg.vim | 66 + vim/.vim/spec/tlib/date.vim | 40 + vim/.vim/spec/tlib/file.vim | 59 + vim/.vim/spec/tlib/hash.vim | 58 + vim/.vim/spec/tlib/input.vim | 127 + vim/.vim/spec/tlib/list.vim | 67 + vim/.vim/spec/tlib/rx.vim | 27 + vim/.vim/spec/tlib/string.vim | 29 + vim/.vim/spec/tlib/url.vim | 23 + vim/.vim/spec/tlib/var.vim | 37 + vim/.vim/syntax/snippet.vim | 11 + vim/.vim/syntax/snippets.vim | 23 + vim/.vim/t/jumping.vim | 175 ++ vim/.vim/t/parser.vim | 116 + vim/.vim/t/tests.sh | 20 + vim/.vim/templates/c | 7 + vim/.vim/templates/cuda | 16 + vim/.vim/templates/html | 16 + vim/.vim/templates/perl | 6 + vim/.vim/templates/python | 7 + vim/.vim/templates/sh | 4 + vim/.vim/templates/xhtml | 18 + vim/.vim/templates/xslt | 27 + vim/.vim/test/tlib.vim | 219 ++ vim/.vimrc | 10 +- 127 files changed, 18564 insertions(+), 3 deletions(-) create mode 100644 vim/.vim/after/plugin/snipMate.vim create mode 100644 vim/.vim/autoload/buf_utils.vim create mode 100644 vim/.vim/autoload/cached_file_contents.vim create mode 100644 vim/.vim/autoload/env_reload.vim create mode 100644 vim/.vim/autoload/funcref.vim create mode 100644 vim/.vim/autoload/glob.vim create mode 100644 vim/.vim/autoload/snipMate.vim create mode 100644 vim/.vim/autoload/snipMate_python_demo.vim create mode 100644 vim/.vim/autoload/snipmate/jumping.vim create mode 100644 vim/.vim/autoload/snipmate/legacy.vim create mode 100644 vim/.vim/autoload/snipmate/parse.vim create mode 100644 vim/.vim/autoload/snipmate/util.vim create mode 100644 vim/.vim/autoload/tiny_cmd.vim create mode 100644 vim/.vim/autoload/tinykeymap/map/para_move.vim create mode 100755 vim/.vim/autoload/tlib.vim create mode 100755 vim/.vim/autoload/tlib/Filter_cnf.vim create mode 100755 vim/.vim/autoload/tlib/Filter_cnfd.vim create mode 100755 vim/.vim/autoload/tlib/Filter_fuzzy.vim create mode 100644 vim/.vim/autoload/tlib/Filter_glob.vim create mode 100755 vim/.vim/autoload/tlib/Object.vim create mode 100755 vim/.vim/autoload/tlib/Test.vim create mode 100755 vim/.vim/autoload/tlib/TestChild.vim create mode 100755 vim/.vim/autoload/tlib/World.vim create mode 100644 vim/.vim/autoload/tlib/agent.vim create mode 100755 vim/.vim/autoload/tlib/arg.vim create mode 100755 vim/.vim/autoload/tlib/autocmdgroup.vim create mode 100644 vim/.vim/autoload/tlib/balloon.vim create mode 100644 vim/.vim/autoload/tlib/bitwise.vim create mode 100644 vim/.vim/autoload/tlib/buffer.vim create mode 100755 vim/.vim/autoload/tlib/cache.vim create mode 100755 vim/.vim/autoload/tlib/char.vim create mode 100755 vim/.vim/autoload/tlib/cmd.vim create mode 100755 vim/.vim/autoload/tlib/comments.vim create mode 100755 vim/.vim/autoload/tlib/date.vim create mode 100755 vim/.vim/autoload/tlib/dir.vim create mode 100755 vim/.vim/autoload/tlib/eval.vim create mode 100644 vim/.vim/autoload/tlib/file.vim create mode 100644 vim/.vim/autoload/tlib/fixes.vim create mode 100644 vim/.vim/autoload/tlib/grep.vim create mode 100644 vim/.vim/autoload/tlib/hash.vim create mode 100755 vim/.vim/autoload/tlib/hook.vim create mode 100644 vim/.vim/autoload/tlib/input.vim create mode 100755 vim/.vim/autoload/tlib/list.vim create mode 100755 vim/.vim/autoload/tlib/map.vim create mode 100755 vim/.vim/autoload/tlib/normal.vim create mode 100755 vim/.vim/autoload/tlib/notify.vim create mode 100644 vim/.vim/autoload/tlib/number.vim create mode 100755 vim/.vim/autoload/tlib/paragraph.vim create mode 100644 vim/.vim/autoload/tlib/persistent.vim create mode 100755 vim/.vim/autoload/tlib/progressbar.vim create mode 100755 vim/.vim/autoload/tlib/rx.vim create mode 100755 vim/.vim/autoload/tlib/scratch.vim create mode 100755 vim/.vim/autoload/tlib/signs.vim create mode 100755 vim/.vim/autoload/tlib/string.vim create mode 100755 vim/.vim/autoload/tlib/syntax.vim create mode 100644 vim/.vim/autoload/tlib/sys.vim create mode 100755 vim/.vim/autoload/tlib/tab.vim create mode 100755 vim/.vim/autoload/tlib/tag.vim create mode 100755 vim/.vim/autoload/tlib/textobjects.vim create mode 100755 vim/.vim/autoload/tlib/time.vim create mode 100755 vim/.vim/autoload/tlib/type.vim create mode 100755 vim/.vim/autoload/tlib/url.vim create mode 100755 vim/.vim/autoload/tlib/var.vim create mode 100644 vim/.vim/autoload/tlib/vcs.vim create mode 100644 vim/.vim/autoload/tlib/vim.vim create mode 100755 vim/.vim/autoload/tlib/win.vim create mode 100644 vim/.vim/autoload/tovl/scratch_buffer.vim create mode 100644 vim/.vim/autoload/tovl/ui/filter_list.vim create mode 100644 vim/.vim/doc/SnipMate.txt create mode 100644 vim/.vim/doc/cached_file_contents.txt create mode 100644 vim/.vim/doc/funcref.txt create mode 100644 vim/.vim/doc/supertab.txt create mode 100644 vim/.vim/doc/tags create mode 100644 vim/.vim/doc/tiny_cmd.txt create mode 100755 vim/.vim/doc/tlib.txt create mode 100644 vim/.vim/etc/tpl_tlib.txt create mode 100644 vim/.vim/ftplugin/html_snip_helper.vim create mode 100644 vim/.vim/ftplugin/snippets.vim create mode 100644 vim/.vim/indent/snippets.vim create mode 100755 vim/.vim/plugin/02tlib.vim create mode 100644 vim/.vim/plugin/snipMate.vim create mode 100644 vim/.vim/plugin/supertab.vim create mode 100644 vim/.vim/plugin/templates.vim create mode 100644 vim/.vim/samples/tlib/input/tlib_input_list.vim create mode 100644 vim/.vim/scripts/create_crc_table.rb create mode 100644 vim/.vim/snippets/_.snippets create mode 100644 vim/.vim/snippets/c.snippets create mode 100644 vim/.vim/snippets/cpp.snippets create mode 100644 vim/.vim/snippets/css.snippets create mode 100644 vim/.vim/snippets/cuda.snippets create mode 100644 vim/.vim/snippets/html.snippets create mode 100644 vim/.vim/snippets/java.snippets create mode 100644 vim/.vim/snippets/javascript.snippets create mode 100644 vim/.vim/snippets/perl.snippets create mode 100644 vim/.vim/snippets/php.snippets create mode 100644 vim/.vim/snippets/python.snippets create mode 100644 vim/.vim/snippets/ruby.snippets create mode 100644 vim/.vim/snippets/sh.snippets create mode 100644 vim/.vim/snippets/snippet.snippets create mode 100644 vim/.vim/snippets/tex.snippets create mode 100644 vim/.vim/snippets/vim.snippets create mode 100644 vim/.vim/snippets/zsh.snippets create mode 100755 vim/.vim/spec/tlib/arg.vim create mode 100644 vim/.vim/spec/tlib/date.vim create mode 100755 vim/.vim/spec/tlib/file.vim create mode 100644 vim/.vim/spec/tlib/hash.vim create mode 100755 vim/.vim/spec/tlib/input.vim create mode 100755 vim/.vim/spec/tlib/list.vim create mode 100755 vim/.vim/spec/tlib/rx.vim create mode 100755 vim/.vim/spec/tlib/string.vim create mode 100755 vim/.vim/spec/tlib/url.vim create mode 100755 vim/.vim/spec/tlib/var.vim create mode 100644 vim/.vim/syntax/snippet.vim create mode 100644 vim/.vim/syntax/snippets.vim create mode 100644 vim/.vim/t/jumping.vim create mode 100644 vim/.vim/t/parser.vim create mode 100755 vim/.vim/t/tests.sh create mode 100644 vim/.vim/templates/c create mode 100644 vim/.vim/templates/cuda create mode 100644 vim/.vim/templates/html create mode 100644 vim/.vim/templates/perl create mode 100644 vim/.vim/templates/python create mode 100644 vim/.vim/templates/sh create mode 100644 vim/.vim/templates/xhtml create mode 100644 vim/.vim/templates/xslt create mode 100755 vim/.vim/test/tlib.vim diff --git a/vim/.vim/after/plugin/snipMate.vim b/vim/.vim/after/plugin/snipMate.vim new file mode 100644 index 0000000..3d6bac7 --- /dev/null +++ b/vim/.vim/after/plugin/snipMate.vim @@ -0,0 +1,46 @@ +" snipMate maps +" These maps are created here in order to make sure we can reliably create maps +" after SuperTab. + +let s:save_cpo = &cpo +set cpo&vim + +function! s:map_if_not_mapped(lhs, rhs, mode) abort + let l:unique = s:overwrite ? '' : ' ' + if !hasmapto(a:rhs, a:mode) + silent! exe a:mode . 'map' . l:unique a:lhs a:rhs + endif +endfunction + +if !exists('g:snips_no_mappings') || !g:snips_no_mappings + if exists('g:snips_trigger_key') + echom 'g:snips_trigger_key is deprecated. See :h snipMate-mappings' + exec 'imap ' g:snips_trigger_key 'snipMateTrigger' + exec 'smap ' g:snips_trigger_key 'snipMateSNext' + exec 'xmap ' g:snips_trigger_key 'snipMateVisual' + else + " Remove SuperTab map if it exists + let s:overwrite = maparg('', 'i') ==? 'SuperTabForward' + call s:map_if_not_mapped('', 'snipMateNextOrTrigger', 'i') + call s:map_if_not_mapped('', 'snipMateNextOrTrigger', 's') + let s:overwrite = 0 + call s:map_if_not_mapped('', 'snipMateVisual', 'x') + endif + + if exists('g:snips_trigger_key_backwards') + echom 'g:snips_trigger_key_backwards is deprecated. See :h snipMate-mappings' + exec 'imap ' g:snips_trigger_key_backwards 'snipMateIBack' + exec 'smap ' g:snips_trigger_key_backwards 'snipMateSBack' + else + let s:overwrite = maparg('', 'i') ==? 'SuperTabBackward' + call s:map_if_not_mapped('', 'snipMateBack', 'i') + call s:map_if_not_mapped('', 'snipMateBack', 's') + let s:overwrite = 0 + endif + + call s:map_if_not_mapped('', 'snipMateShow', 'i') +endif + +let &cpo = s:save_cpo + +" vim:noet: diff --git a/vim/.vim/autoload/buf_utils.vim b/vim/.vim/autoload/buf_utils.vim new file mode 100644 index 0000000..d14d404 --- /dev/null +++ b/vim/.vim/autoload/buf_utils.vim @@ -0,0 +1,24 @@ +" buf_identifier is either a buf_nr or a filename +" If any window shows the buffer move to the buffer +" If not show it in current window (by c-w s c^ you can always +" reshow the last buffer +" +" Example: buf_utils#GotoBuf("/tmp/tfile.txt", {'create': 1}) +" returns: The command which was used to switch to the buffer +fun! buf_utils#GotoBuf(buf_identifier, opts) + let buf_nr = bufnr(a:buf_identifier) + if buf_nr == -1 && ( get(a:opts, 'create', 0) || has_key(a:opts, 'create_cmd')) + exec get(a:opts,'create_cmd','e').' '.fnameescape(a:buf_identifier) + return "e" + else + let win_nr = bufwinnr(buf_nr) + if win_nr == -1 + exec 'b '.buf_nr + return "b" + else + exec win_nr.'wincmd w' + return "w" + endif + wincmd w" + endif +endf diff --git a/vim/.vim/autoload/cached_file_contents.vim b/vim/.vim/autoload/cached_file_contents.vim new file mode 100644 index 0000000..3fc3ce4 --- /dev/null +++ b/vim/.vim/autoload/cached_file_contents.vim @@ -0,0 +1,104 @@ +" cached_file_contents.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.3.0 + +"exec vam#DefineAndBind('s:c','g:cache_dir_options','{}') +if !exists('g:cache_dir_options') | let g:cache_dir_options = {} | endif | let s:c = g:cache_dir_options + +let s:c['cache_dir'] = get(s:c, 'cache_dir', expand('$HOME').'/.vim-cache') +let s:c['scanned_files'] = get(s:c, 'scanned_files', {}) +let s:scanned_files = s:c['scanned_files'] + + +let s:define_cache_file = "let this_dir = s:c['cache_dir'].'/cached-file-contents' | let cache_file = expand(this_dir.'/'.substitute(string([func_as_string, a:file]),'[[\\]{}:/\\,''\"# ]\\+','_','g'))" + +" read a file, run function to extract contents and cache the result returned +" by that function in memory. Optionally the result can be cached on disk as +" because VimL can be slow! +" +" file : the file to be read +" func: { 'func': function which will be called by funcref#Call +" , 'version' : if this version changes cache will be invalidate automatically +" , 'ftime_check': optional, default 1. if set to 0 cache isn't updated when file changes and file is in cache +" } +" +" default: what to return if file doesn't exist +" think twice about adding lines. This function is called many times. +function! cached_file_contents#CachedFileContents(file, func, ...) abort + let ignore_ftime = a:0 > 0 ? a:1 : 0 + " using string for default so that is evaluated when needed only + let use_file_cache = get(a:func, 'use_file_cache', 0) + + " simple kind of normalization. necessary when using file caching + " this seems to be slower: + " let file = fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + " / = assume its an absolute path + " let file = a:file[0] == '/' ? a:file : expand(a:file, ':p') + let file = a:file[0] == '/' ? a:file : fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + let func_as_string = string(a:func['func']) + + if (!has_key(s:scanned_files, func_as_string)) + let s:scanned_files[func_as_string] = {} + endif + let dict = s:scanned_files[func_as_string] + if use_file_cache && !has_key(dict, a:file) + exec s:define_cache_file + if filereadable(cache_file) + let dict[file] = eval(readfile(cache_file,'b')[0]) + endif + endif + if has_key(dict, a:file) + let d = dict[a:file] + if use_file_cache + \ && (ignore_ftime || getftime(a:file) <= d['ftime']) + \ && d['version'] == a:func['version'] + return dict[a:file]['scan_result'] + endif + endif + let scan_result = funcref#Call(a:func['func'], [a:file] ) + let dict[a:file] = {"ftime": getftime(a:file), 'version': a:func['version'], "scan_result": scan_result } + if use_file_cache + if !exists('cache_file') | exec s:define_cache_file | endif + if !isdirectory(this_dir) | call mkdir(this_dir,'p',0700) | endif + call writefile([string(dict[a:file])], cache_file) + endif + return scan_result +endfunction + +fun! cached_file_contents#ClearScanCache() + let s:c['scanned_files'] = {} + + " Don't run rm -fr. Ask user to run it. It cache_dir may have been set to + " $HOME ! (should nevere be the case but who knows + echoe "run manually in your shell: rm -fr ".shellescape(s:c['cache_dir'])."/*" +endf + +fun! cached_file_contents#Test() + + " usually you use a global option so that the function can be reused + let my_interpreting_func = {'func' : funcref#Function('return len(readfile(ARGS[0]))'), 'version': 2, 'use_file_cache':1} + let my_interpreting_func2 = {'func' : funcref#Function('return ARGS[0]') , 'version': 2, 'use_file_cache':1} + + let tmp = tempname() + call writefile(['some text','2nd line'], tmp) + + let r = [ cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + \ , cached_file_contents#CachedFileContents(tmp, my_interpreting_func2) ] + if r != [2, tmp] + throw "test failed 1, got ".string(r) + endif + unlet r + + sleep 3 + + " now let's change contents + call writefile(['some text','2nd line','3rd line'], tmp) + + let r = cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + if 3 != r + throw "test failed 2, got ".string(r) + endif + + echo "test passed" +endf diff --git a/vim/.vim/autoload/env_reload.vim b/vim/.vim/autoload/env_reload.vim new file mode 100644 index 0000000..d8af33a --- /dev/null +++ b/vim/.vim/autoload/env_reload.vim @@ -0,0 +1,12 @@ +" in sh/bash you can type export to get a list of environment variables +" This function assigns those env vars to Vim. +" Does not delete env vars yet +" Example: env_reload#ReloadEnv(system("sh -c 'export'") +fun! env_reload#ReloadEnv(bash_export_command_output) + for i in split(a:bash_export_command_output,"\n") + let m = matchlist(i, 'export \([^=]\+\)="\(.*\)"') + if empty(m) | continue | endif + " don't care about quoted values right now. + exec 'let $'.m[1].'='.string(m[2]) + endfor +endf diff --git a/vim/.vim/autoload/funcref.vim b/vim/.vim/autoload/funcref.vim new file mode 100644 index 0000000..20eec54 --- /dev/null +++ b/vim/.vim/autoload/funcref.vim @@ -0,0 +1,95 @@ +" funcref.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.1.0 + +" documentation see doc/funcref.txt + +" usage: +" funcref#Function("filename#Function") +" optionally pass arguments: +" funcref#Function("filename#Function",{'args': [2]}) +" optionally define self: +" funcref#Function("filename#Function",{'self': object}) +function! funcref#Function(name,...) + let d = a:0 > 0 ? a:1 : {} + let d['faked_function_reference'] = a:name + return d +endfunction + +" args : same as used for call(f,[args], self) +" f must be either +" - a string which can be evaled (use "return 'value'" to return a value) +" - a Vim function reference created by function('..') +" - a faked function reference created by funcref#Function(..) +" +" the last "self" argument can be overriden by the function reference +" You can pass arguments in a closure like style +function! funcref#Call(...) + let args = copy(a:000) + + " add parameters: + if (len(args) < 2) + call add(args, []) + endif + + + let isDict = type(args[0]) == type({}) + + " prepend parameters which were passed by faked function reference: + if isDict && has_key(args[0], 'args') + let args[1] = args[0]['args']+args[1] + endif + + " always pass self. this way you can call functions from dictionaries not + " refering to self + if (len(args) < 3) + call add(args, {}) + endif + + " the funcref overrides self: + if isDict && has_key(args[0], 'self') + let args[2] = args[0]['self'] + endif + + if type(a:1) == 2 + " funcref: function must have been laoded + return call(function('call'), args) + elseif isDict && has_key(args[0], 'faked_function_reference') + let Fun = args[0]['faked_function_reference'] + if type(Fun) == type('') + \ && (Fun[:len('return ')-1] == 'return ' + \ || Fun[:len('call ')-1] == 'call ' + \ || Fun[:len('if ')-1] == 'if ' + \ || Fun[:len('let ')-1] == 'let ' + \ || Fun[:len('echo ')-1] == 'echo ' + \ || Fun[:len('exec ')-1] == 'exec ' + \ || Fun[:len('debug ')-1] == 'debug ') + " it doesn't make sense to list all vim commands here + " So if you want to execute another action consider using + " funcref#Function('exec '.string('aw')) or such + + " function is a String, call exec + let ARGS = args[1] + let SELF = args[2] + exec Fun + else + " pseudo function, let's load it.. + if type(Fun) == 1 + if !exists('*'.Fun) + " lazily load function + let file = substitute(substitute(Fun,'#[^#]*$','',''),'#','/','g') + exec 'runtime /autoload/'.file.'.vim' + endif + let Fun2 = function(Fun) + else + let Fun2 = Fun + endif + let args[0] = Fun + return call(function('call'), args) + endif + else + " no function, return the value + return args[0] + endif +endfunction diff --git a/vim/.vim/autoload/glob.vim b/vim/.vim/autoload/glob.vim new file mode 100644 index 0000000..9a0f79a --- /dev/null +++ b/vim/.vim/autoload/glob.vim @@ -0,0 +1,27 @@ +exec vam#DefineAndBind('s:c','g:glob_like', '{}') + +" ignore vcs stuff, Don't think you want those.. +let s:c['regex_ignore_directory'] = '\<\%([_.]darcs\|\.git\|.svn\|.hg\|.cvs\|.bzr\)\>' +let s:c['glob_cache'] = get(s:c, 'glob_cache', {}) +let s:glob_cache = s:c['glob_cache'] + +fun! glob#Glob(pattern, ...) + let pattern = a:pattern + if pattern[0] == '~' + let pattern = $HOME.pattern[1:] + endif + let opts = a:0 > 0 ? a:1 : {} + " never cache current directory. You're very likely to edit files in it. + + let c = getcwd() + let cachable = get(opts, 'cachable', 0) && pattern[:len(c)-1] != c + if cachable && has_key(s:glob_cache, pattern) + return s:glob_cache[pattern] + endif + + " FIXME: don't recurse into \.git directory (thus reimplement glob in vimL!) + let r = filter(split(glob(pattern),"\n"),'v:val !~ '.string(s:c['regex_ignore_directory'])) + if cachable | let s:glob_cache[pattern] = r | endif + return r +endf + diff --git a/vim/.vim/autoload/snipMate.vim b/vim/.vim/autoload/snipMate.vim new file mode 100644 index 0000000..4b5ebc1 --- /dev/null +++ b/vim/.vim/autoload/snipMate.vim @@ -0,0 +1,622 @@ +" config which can be overridden (shared lines) +if !exists('g:snipMate') + let g:snipMate = {} +endif + +try + call tlib#input#List('mi', '', []) +catch /.*/ + echoe "you're missing tlib. See install instructions at ".expand(':h:h').'/README.md' +endtry + +fun! Filename(...) abort + let filename = expand('%:t:r') + if filename == '' | return a:0 == 2 ? a:2 : '' | endif + return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g') +endf + +let s:cache = {} + +function! snipMate#expandSnip(snip, version, col) abort + let lnum = line('.') + let col = a:col + let line = getline(lnum) + let indent = match(line, '\S\|$') + 1 + let b:snip_state = snipmate#jumping#state() + + if a:version == 1 + let [snippet, b:snip_state.stops] = snipmate#parse#snippet(a:snip) + " Build stop/mirror info + let b:snip_state.stop_count = s:build_stops(snippet, b:snip_state.stops, lnum, col, indent) + let snipLines = snipMate#sniplist_str(snippet, b:snip_state.stops) + else + let snippet = snipmate#legacy#process_snippet(a:snip) + let [b:snip_state.stops, b:snip_state.stop_count] = snipmate#legacy#build_stops(snippet, lnum, col - indent, indent) + let snipLines = split(substitute(snippet, printf('%s\d\+\|%s{\d\+.\{-}}', + \ g:snipmate#legacy#sigil, g:snipmate#legacy#sigil), '', 'g'), "\n", 1) + endif + + " Abort if the snippet is empty + if empty(snippet) + return '' + endif + + " Expand snippet onto current position + let afterCursor = strpart(line, col - 1) + " Keep text after the cursor + if afterCursor != "\t" && afterCursor != ' ' + let line = strpart(line, 0, col - 1) + let snipLines[-1] .= afterCursor + else + let afterCursor = '' + " For some reason the cursor needs to move one right after this + if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore' + let col += 1 + endif + endif + + " Insert snippet with proper indentation + call setline(lnum, line . snipLines[0]) + call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val")) + + " Open any folds snippet expands into + if &foldenable + silent! exec lnum . ',' . (lnum + len(snipLines) - 1) . 'foldopen' + endif + + aug snipmate_changes + au CursorMoved,CursorMovedI if exists('b:snip_state') | + \ call b:snip_state.update_changes() | + \ else | + \ silent! au! snipmate_changes * | + \ endif + aug END + + let b:snip_state.stop_no = 0 + return b:snip_state.set_stop(0) +endfunction + +function! snipMate#placeholder_str(num, stops) abort + return snipMate#sniplist_str(a:stops[a:num].placeholder, a:stops)[0] +endfunction + +function! snipMate#sniplist_str(snippet, stops) abort + let lines = [''] + let pos = 0 + let add_to = 1 + let seen_stops = [] + + while pos < len(a:snippet) + let item = a:snippet[pos] + + if type(item) == type('') + if add_to + let lines[-1] .= item + else + call add(lines, item) + endif + let add_to = 0 + elseif type(item) == type([]) + let lines[-1] .= snipMate#placeholder_str(item[0], a:stops) + let add_to = 1 + endif + + let pos += 1 + unlet item " avoid E706 + endwhile + + return lines +endfunction + +function! s:build_stops(snippet, stops, lnum, col, indent) abort + let stops = a:stops + let line = a:lnum + let col = a:col + + for [id, dict] in items(stops) + for i in dict.instances + if len(i) > 1 && type(i[1]) != type({}) + if !has_key(dict, 'placeholder') + let dict.placeholder = i[1:] + else + unlet i[1:] + endif + endif + endfor + if !has_key(dict, 'placeholder') + let dict.placeholder = [] + let j = 0 + while len(dict.instances[j]) > 1 + let j += 1 + endwhile + call add(dict.instances[j], '') + endif + unlet dict.instances + endfor + + let [line, col] = s:build_loc_info(a:snippet, stops, line, col, a:indent) + + " add zero tabstop if it doesn't exist and then link it to the highest stop + " number + let stops[0] = get(stops, 0, + \ { 'placeholder' : [], 'line' : line, 'col' : col }) + let stop_count = max(keys(stops)) + 2 + let stops[stop_count - 1] = stops[0] + + return stop_count +endfunction + +function! s:build_loc_info(snippet, stops, line, col, indent) abort + let stops = a:stops + let line = a:line + let col = a:col + let pos = 0 + let in_text = 0 + + while pos < len(a:snippet) + let item = a:snippet[pos] + + if type(item) == type('') + if in_text + let line += 1 + let col = a:indent + endif + let col += len(item) + let in_text = 1 + elseif type(item) == type([]) + let id = item[0] + if len(item) > 1 && type(item[1]) != type({}) + let stops[id].line = line + let stops[id].col = col + let [line, col] = s:build_loc_info(item[1:], stops, line, col, a:indent) + else + call s:add_mirror(stops, id, line, col, item) + let col += len(snipMate#placeholder_str(id, stops)) + endif + let in_text = 0 + endif + + let pos += 1 + unlet item " avoid E706 + endwhile + + return [line, col] +endfunction + +function! s:add_mirror(stops, id, line, col, item) abort + let stops = a:stops + let item = a:item + let stops[a:id].mirrors = get(stops[a:id], 'mirrors', []) + let mirror = get(a:item, 1, {}) + let mirror.line = a:line + let mirror.col = a:col + call add(stops[a:id].mirrors, mirror) + if len(item) == 1 + call add(item, mirror) + endif +endfunction + +" reads a .snippets file +" returns list of +" ['triggername', 'name', 'contents'] +" if triggername is not set 'default' is assumed +" TODO: better error checking +fun! snipMate#ReadSnippetsFile(file) abort + let result = [] + let new_scopes = [] + if !filereadable(a:file) | return [result, new_scopes] | endif + let inSnip = 0 + let line_no = 0 + let snipversion = get(g:snipMate, 'snippet_version', 0) + for line in readfile(a:file) + ["\n"] + let line_no += 1 + + if inSnip && (line[0] == "\t" || line == '') + let content .= strpart(line, 1)."\n" + continue + elseif inSnip + call add(result, [trigger, name, + \ content[:-2], bang, snipversion]) + let inSnip = 0 + endif + + if line[:6] == 'snippet' + let inSnip = 1 + let bang = (line[7] == '!') + let trigger = strpart(line, 8 + bang) + let name = '' + let space = stridx(trigger, ' ') + 1 + if space " Process multi snip + let name = strpart(trigger, space) + let trigger = strpart(trigger, 0, space - 1) + endif + let content = '' + if trigger =~ '^\s*$' " discard snippets with empty triggers + echom 'Invalid snippet in' a:file 'near line' line_no + let inSnip = 0 + endif + elseif line[:6] == 'extends' + call extend(new_scopes, map(split(strpart(line, 8)), + \ "substitute(v:val, ',*$', '', '')")) + elseif line[:6] == 'version' + let snipversion = +strpart(line, 8) + endif + endfor + return [result, new_scopes] +endf + +function! s:GetScopes() abort + let ret = exists('b:snipMate.scope_aliases') ? copy(b:snipMate.scope_aliases) : {} + let global = get(g:snipMate, 'scope_aliases', {}) + for alias in keys(global) + if has_key(ret, alias) + let ret[alias] = join(split(ret[alias], ',') + \ + split(global[alias], ','), ',') + else + let ret[alias] = global[alias] + endif + endfor + return ret +endfunction + +" adds scope aliases to list. +" returns new list +" the aliases of aliases are added recursively +fun! s:AddScopeAliases(list) abort + let did = {} + let scope_aliases = s:GetScopes() + let new = a:list + let new2 = [] + while !empty(new) + for i in new + if !has_key(did, i) + let did[i] = 1 + call extend(new2, split(get(scope_aliases,i,''),',')) + endif + endfor + let new = new2 + let new2 = [] + endwhile + return keys(did) +endf + +au SourceCmd *.snippet,*.snippets call s:source_snippet() + +function! s:info_from_filename(file) abort + let parts = split(fnamemodify(a:file, ':r'), '/') + let snipidx = len(parts) - index(reverse(copy(parts)), 'snippets') - 1 + let rtp_prefix = join(parts[(snipidx - + \ (parts[snipidx - 1] == 'after' ? 3 : 2)):snipidx - 1], '/') + let trigger = get(parts, snipidx + 2, '') + let desc = get(parts, snipidx + 3, get(g:snipMate, 'override', 0) ? + \ '' : fnamemodify(a:file, ':t')) + return [rtp_prefix, trigger, desc] +endfunction + +function! s:source_snippet() abort + let file = expand(':p') + let [rtp_prefix, trigger, desc] = s:info_from_filename(file) + let new_snips = [] + if fnamemodify(file, ':e') == 'snippet' + call add(new_snips, [trigger, desc, join(readfile(file), "\n"), 0, + \ get(g:snipMate, 'snippet_version', 0)]) + else + let [snippets, extends] = s:CachedSnips(file) + let new_snips = deepcopy(snippets) + call extend(s:lookup_state.extends, extends) + endif + for snip in new_snips + if get(g:snipMate, 'override', 0) + let snip[1] = join([s:lookup_state.scope, snip[1]]) + else + let snip[1] = join([s:lookup_state.scope, rtp_prefix, + \ empty(snip[1]) ? desc : snip[1]]) + endif + endfor + call extend(s:lookup_state.snips, new_snips) +endfunction + +function! s:CachedSnips(file) abort + let mtime = getftime(a:file) + if has_key(s:cache, a:file) && s:cache[a:file].mtime >= mtime + return s:cache[a:file].contents + endif + let s:cache[a:file] = {} + let s:cache[a:file].mtime = mtime + let s:cache[a:file].contents = snipMate#ReadSnippetsFile(a:file) + return s:cache[a:file].contents +endfunction + +function! s:snippet_filenames(scope, trigger) abort + let mid = ['', '_*', '/*'] + let mid += map(copy(mid), "'/' . a:trigger . '*' . v:val") + call map(mid, "'snippets/' . a:scope . v:val . '.snippet'") + return map(mid[:2], 'v:val . "s"') + mid[3:] +endfunction + +function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort + let d = a:dict + if !has_key(d, a:trigger) || a:bang + let d[a:trigger] = {} + endif + let d[a:trigger][a:path] = [a:snippet, a:snipversion] +endfunction + +if v:version < 704 || has('win32') + function! s:Glob(path, expr) + let res = [] + for p in split(a:path, ',') + let h = split(fnamemodify(a:expr, ':h'), '/')[0] + if isdirectory(p . '/' . h) + call extend(res, split(glob(p . '/' . a:expr), "\n")) + endif + endfor + return filter(res, 'filereadable(v:val)') + endfunction +else + function! s:Glob(path, expr) + return split(globpath(a:path, a:expr), "\n") + endfunction +endif + +" default triggers based on paths +function! snipMate#DefaultPool(scopes, trigger, result) abort + let scopes = s:AddScopeAliases(a:scopes) + let scopes_done = [] + let s:lookup_state = {} + let s:lookup_state.snips = [] + + while !empty(scopes) + let scope = remove(scopes, 0) + let s:lookup_state.scope = scope + let s:lookup_state.extends = [] + + for expr in s:snippet_filenames(scope, escape(a:trigger, "*[]?{}`'$|#%")) + for path in g:snipMate.snippet_dirs + for file in s:Glob(path, expr) + source `=file` + endfor + endfor + endfor + + call add(scopes_done, scope) + call extend(scopes, s:lookup_state.extends) + call filter(scopes, 'index(scopes_done, v:val) == -1') + endwhile + + for [trigger, desc, contents, bang, snipversion] in s:lookup_state.snips + if trigger =~ '\V\^' . escape(a:trigger, '\') + call snipMate#SetByPath(a:result, trigger, desc, contents, bang, snipversion) + endif + endfor +endfunction + +" return a dict of snippets found in runtimepath matching trigger +" scopes: list of scopes. usually this is the filetype. eg ['c','cpp'] +" trigger may contain glob patterns. Thus use '*' to get all triggers +" +fun! snipMate#GetSnippets(scopes, trigger) abort + let result = {} + + for F in values(g:snipMateSources) + call funcref#Call(F, [a:scopes, a:trigger, result]) + endfor + return result +endf + +function! snipMate#OpenSnippetFiles() abort + let files = [] + let scopes_done = [] + let exists = [] + let notexists = [] + for scope in s:AddScopeAliases(snipMate#ScopesByFile()) + let files += s:snippet_filenames(scope, '') + endfor + call filter(files, "v:val !~# '\\*'") + for path in g:snipMate.snippet_dirs + let fullpaths = map(copy(files), 'printf("%s/%s", path, v:val)') + let exists += filter(copy(fullpaths), 'filereadable(v:val)') + let notexists += map(filter(copy(fullpaths), + \ 'v:val =~# "\.snippets" && !filereadable(v:val)'), + \ '"does not exist: " . v:val') + endfor + let all = exists + notexists + let select = tlib#input#List('mi', 'select files to be opened in splits', all) + for idx in select + exec 'sp' all[idx - 1] + endfor +endfunction + +fun! snipMate#ScopesByFile() abort + " duplicates are removed in AddScopeAliases + return filter(funcref#Call(g:snipMate.get_scopes), "v:val != ''") +endf + +" used by both: completion and insert snippet +fun! snipMate#GetSnippetsForWordBelowCursor(word, exact) abort + " Split non-word characters into their own piece + " so 'foo.bar..baz' becomes ['foo', '.', 'bar', '.', '.', 'baz'] + " First split just after a \W and then split each resultant string just + " before a \W + let parts = filter(tlib#list#Flatten( + \ map(split(a:word, '\W\zs'), 'split(v:val, "\\ze\\W")')), + \ '!empty(v:val)') + " Only look at the last few possibilities. Too many can be slow. + if len(parts) > 5 + let parts = parts[-5:] + endif + let lookups = [a:word] + let lookup = '' + for w in reverse(parts) + let lookup = w . lookup + if index(lookups, lookup) == -1 + call add(lookups, lookup) + endif + endfor + + " Remove empty lookup entries, but only if there are other nonempty lookups + if len(lookups) > 1 + call filter(lookups, 'v:val != ""') + endif + + let matching_snippets = [] + let snippet = '' + " prefer longest word + for word in lookups + let g:snipMate.word = word + for [k,snippetD] in items(funcref#Call(g:snipMate['get_snippets'], [snipMate#ScopesByFile(), word])) + " hack: require exact match + if a:exact && k !=# word + continue + endif + call add(matching_snippets, [k, snippetD]) + if a:exact + break + endif + endfor + endfor + return matching_snippets +endf + +" snippets: dict containing snippets by name +" usually this is just {'default' : snippet_contents } +fun! s:ChooseSnippet(snippets) abort + let snippet = [] + let keys = keys(a:snippets) + let i = 1 + for snip in keys + let snippet += [i.'. '.snip] + let i += 1 + endfor + if len(snippet) == 1 + " there's only a single snippet, choose it + let idx = 0 + else + let idx = tlib#input#List('si','select snippet by name',snippet) -1 + if idx == -1 + return '' + endif + endif + " if a:snippets[..] is a String Call returns it + " If it's a function or a function string the result is returned + return funcref#Call(a:snippets[keys(a:snippets)[idx]]) +endf + +fun! snipMate#WordBelowCursor() abort + return matchstr(getline('.'), '\S\+\%' . col('.') . 'c') +endf + +fun! snipMate#GetSnippetsForWordBelowCursorForComplete(word) abort + let snippets = map(snipMate#GetSnippetsForWordBelowCursor(a:word, 0), 'v:val[0]') + return filter(snippets, 'v:val =~# "\\V\\^' . escape(a:word, '"\') . '"') +endf + +fun! snipMate#CanBeTriggered() abort + let word = snipMate#WordBelowCursor() + let matches = snipMate#GetSnippetsForWordBelowCursorForComplete(word) + return len(matches) > 0 +endf + +fun! snipMate#ShowAvailableSnips() abort + let col = col('.') + let word = snipMate#WordBelowCursor() + let matches = snipMate#GetSnippetsForWordBelowCursorForComplete(word) + + " Pretty hacky, but really can't have the tab swallowed! + if len(matches) == 0 + call feedkeys(g:snipMate['no_match_completion_feedkeys_chars'], 'n') + return "" + endif + + call complete(col - len(word), sort(matches)) + return '' +endf + +" Pass an argument to force snippet expansion instead of triggering or jumping +function! snipMate#TriggerSnippet(...) abort + if exists('g:SuperTabMappingForward') + if g:SuperTabMappingForward == "" + let SuperTabPlug = maparg('SuperTabForward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + elseif g:SuperTabMappingBackward == "" + let SuperTabPlug = maparg('SuperTabBackward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + endif + endif + + if pumvisible() " Update snippet if completion is used, or deal with supertab + if exists('SuperTabKey') + call feedkeys(SuperTabKey) | return '' + endif + call feedkeys("\a", 'n') " Close completion menu + call feedkeys("\") | return '' + endif + + if exists('b:snip_state') && a:0 == 0 " Jump only if no arguments + let jump = b:snip_state.jump_stop(0) + if type(jump) == 1 " returned a string + return jump + endif + endif + + let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') + let list = snipMate#GetSnippetsForWordBelowCursor(word, 1) + if empty(list) + let snippet = '' + else + let [trigger, snippetD] = list[0] + let snippet = s:ChooseSnippet(snippetD) + " Before expanding snippet, create new undo point |i_CTRL-G| + let &undolevels = &undolevels + let col = col('.') - len(trigger) + sil exe 's/\V'.escape(trigger, '/\.').'\%#//' + return snipMate#expandSnip(snippet[0], snippet[1], col) + endif + + " should allow other plugins to register hooks instead (duplicate code) + if exists('SuperTabKey') + call feedkeys(SuperTabKey) + return '' + endif + return word == '' + \ ? "\" + \ : "\=snipMate#ShowAvailableSnips()\" +endfunction + +fun! snipMate#BackwardsSnippet() abort + if exists('b:snip_state') | return b:snip_state.jump_stop(1) | endif + + if exists('g:SuperTabMappingForward') + if g:SuperTabMappingForward == "" + let SuperTabPlug = maparg('SuperTabForward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + elseif g:SuperTabMappingBackward == "" + let SuperTabPlug = maparg('SuperTabBackward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + endif + endif + " should allow other plugins to register hooks instead (duplicate code) + if exists('SuperTabKey') + call feedkeys(SuperTabKey) + return '' + endif + return "\" +endf + +" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/.vim/autoload/snipMate_python_demo.vim b/vim/.vim/autoload/snipMate_python_demo.vim new file mode 100644 index 0000000..de495d2 --- /dev/null +++ b/vim/.vim/autoload/snipMate_python_demo.vim @@ -0,0 +1,47 @@ +" This file demonstrates +" - how to register your own snippet sources (call snipMate_python_demo#Activate() in ftplugin/python.vim) +" - implents a source which creates snippets based on python function +" definitions found in the current file +" +" Example: +" +" def abc(a,b,c=None) +" will create a snippet on the fly which looks like this: +" abc(${1:a}, ${2:b}, ${3:c=None}) + +fun! snipMate_python_demo#Activate() abort + if !exists('g:snipMateSources') + let g:snipMateSources = {} + endif + + let g:snipMateSources['python'] = funcref#Function('snipMate_python_demo#FunctionsFromCurrentFileAndTags') +endf + +fun! s:Add(dict, line, source, trigger) abort + let matched = matchlist(a:line,'def\s\+\([^( \t]\+\)[ \t]*(\([^)]*\)') + if len(matched) > 2 + let name = matched[1] + " TODO: is this a glob? + if name !~ a:trigger | return | endif + let a:dict[name] = get(a:dict, name, {}) + let sd = a:dict[name] + let args = [] + let nr=1 + for arg in split(matched[2], '\s*,\s*') + call add(args, '${'.nr.':'.arg.'}') + let nr+=1 + endfor + let sd[a:source] = name.'('.join(args,', ').')' + endif +endf +fun! snipMate_python_demo#FunctionsFromCurrentFileAndTags(scopes, trigger, result) abort + " getting all might be too much + if a:trigger == '*' | return | endif + if index(a:scopes, 'python') < 0 | return | endif + for t in taglist('^'.a:trigger) + call s:Add(a:result, t.cmd, 'tags-' . t.filename, a:trigger) + endfor + for l in getline(0, line('$')) + call s:Add(a:result, l, 'current-file', a:trigger) + endfor +endf diff --git a/vim/.vim/autoload/snipmate/jumping.vim b/vim/.vim/autoload/snipmate/jumping.vim new file mode 100644 index 0000000..25db961 --- /dev/null +++ b/vim/.vim/autoload/snipmate/jumping.vim @@ -0,0 +1,205 @@ +function! s:sfile() abort + return expand('') +endfunction + +let s:state_proto = {} + +function! snipmate#jumping#state() abort + return copy(s:state_proto) +endfunction + +function! s:listize_mirror(mirrors) abort + return map(copy(a:mirrors), '[v:val.line, v:val.col]') +endfunction + +" Removes snippet state info +function! s:state_remove() dict abort + " Remove all autocmds in group snipmate_changes in the current buffer + unlet! b:snip_state + silent! au! snipmate_changes * +endfunction + +function! s:state_find_next_stop(backwards) dict abort + let self.stop_no += a:backwards? -1 : 1 + while !has_key(self.stops, self.stop_no) + if self.stop_no == self.stop_count + let self.stop_no = 0 + endif + if self.stop_no <= 0 && a:backwards + let self.stop_no = self.stop_count - 1 + endif + let self.stop_no += a:backwards? -1 : 1 + endwhile +endfunction + +" Update state information to correspond to the given tab stop +function! s:state_set_stop(backwards) dict abort + call self.find_next_stop(a:backwards) + let self.cur_stop = self.stops[self.stop_no] + let self.stop_len = (type(self.cur_stop.placeholder) == type(0)) + \ ? self.cur_stop.placeholder + \ : len(snipMate#placeholder_str(self.stop_no, self.stops)) + let self.start_col = self.cur_stop.col + let self.end_col = self.start_col + self.stop_len + let self.mirrors = get(self.cur_stop, 'mirrors', []) + let self.old_mirrors = deepcopy(self.mirrors) + call cursor(self.cur_stop.line, self.cur_stop.col) + let self.prev_len = col('$') + let self.changed = 0 + let ret = self.select_word() + if (self.stop_no == 0 || self.stop_no == self.stop_count - 1) && !a:backwards + call self.remove() + endif + return ret +endfunction + +" Jump to the next/previous tab stop +function! s:state_jump_stop(backwards) dict abort + " Update changes just in case + " This seems to be only needed because insert completion does not trigger + " the CursorMovedI event + call self.update_changes() + + " Store placeholder/location changes + let self.cur_stop.col = self.start_col + if self.changed + call self.remove_nested() + unlet! self.cur_stop.placeholder " avoid type error for old parsing version + let self.cur_stop.placeholder = [strpart(getline('.'), + \ self.start_col - 1, self.end_col - self.start_col)] + endif + + return self.set_stop(a:backwards) +endfunction + +function! s:state_remove_nested(...) dict abort + let id = a:0 ? a:1 : self.stop_no + if type(self.stops[id].placeholder) == type([]) + for i in self.stops[id].placeholder + if type(i) == type([]) + if type(i[1]) != type({}) + call self.remove_nested(i[0]) + call remove(self.stops, i[0]) + else + call filter(self.stops[i[0]].mirrors, 'v:val isnot i[1]') + endif + endif + unlet i " Avoid E706 + endfor + endif +endfunction + +" Select the placeholder for the current tab stop +function! s:state_select_word() dict abort + let len = self.stop_len + if !len | return '' | endif + let l = col('.') != 1 ? 'l' : '' + if &sel == 'exclusive' + return "\".l.'v'.len."l\" + endif + return len == 1 ? "\".l.'gh' : "\".l.'v'.(len - 1)."l\" +endfunction + +" Update the snippet as text is typed. The self.update_mirrors() function does +" the actual work. +" If the cursor moves outside of a placeholder, call self.remove() +function! s:state_update_changes() dict abort + let change_len = col('$') - self.prev_len + let self.changed = self.changed || change_len != 0 + let self.end_col += change_len + let col = col('.') + + if line('.') != self.cur_stop.line || col < self.start_col || col > self.end_col + return self.remove() + endif + + call self.update(self.cur_stop, change_len) + if !empty(self.mirrors) + call self.update_mirrors(change_len) + endif + + let self.prev_len = col('$') +endfunction + +" Actually update the mirrors for any changed text +function! s:state_update_mirrors(change) dict abort + let newWordLen = self.end_col - self.start_col + let newWord = strpart(getline('.'), self.start_col - 1, newWordLen) + let changeLen = a:change + let curLine = line('.') + let curCol = col('.') + let oldStartSnip = self.start_col + let i = 0 + + for mirror in self.mirrors + for stop in values(filter(copy(self.stops), 'v:key != 0')) + if type(stop.placeholder) == type(0) + if mirror.line == stop.line && mirror.col > stop.col + \ && mirror.col < stop.col + stop.placeholder + let stop.placeholder += changeLen + endif + endif + endfor + + call self.update(mirror, changeLen) + " Split the line into three parts: the mirror, what's before it, and + " what's after it. Then combine them using the new mirror string. + " Subtract one to go from column index to byte index + let theline = getline(mirror.line) + let update = strpart(theline, 0, mirror.col - 1) + let update .= substitute(newWord, get(mirror, 'pat', ''), get(mirror, 'sub', ''), get(mirror, 'flags', '')) + let update .= strpart(theline, mirror.col + self.end_col - self.start_col - a:change - 1) + call setline(mirror.line, update) + endfor + + " Reposition the cursor in case a var updates on the same line but before + " the current tabstop + if oldStartSnip != self.start_col || mode() == 'i' + call cursor(0, curCol + self.start_col - oldStartSnip) + endif +endfunction + +function! s:state_find_update_objects(item) dict abort + let item = a:item + let item.update_objects = [] + + " Filter the zeroth stop because it's duplicated as the last + for stop in values(filter(copy(self.stops), 'v:key != 0')) + if stop.line == item.line && stop.col > item.col + call add(item.update_objects, stop) + endif + + for mirror in get(stop, 'mirrors', []) + if mirror.line == item.line && mirror.col > item.col + call add(item.update_objects, mirror) + endif + endfor + endfor + + return item.update_objects +endfunction + +function! s:state_update(item, change_len) dict abort + let item = a:item + if exists('item.update_objects') + let to_update = item.update_objects + else + let to_update = self.find_update_objects(a:item) + let item.update_objects = to_update + endif + + for obj in to_update + let obj.col += a:change_len + if obj is self.cur_stop + let self.start_col += a:change_len + let self.end_col += a:change_len + endif + endfor +endfunction + +call extend(s:state_proto, snipmate#util#add_methods(s:sfile(), 'state', + \ [ 'remove', 'set_stop', 'jump_stop', 'remove_nested', + \ 'select_word', 'update_changes', 'update_mirrors', + \ 'find_next_stop', 'find_update_objects', 'update' ]), 'error') + +" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/.vim/autoload/snipmate/legacy.vim b/vim/.vim/autoload/snipmate/legacy.vim new file mode 100644 index 0000000..deee2ec --- /dev/null +++ b/vim/.vim/autoload/snipmate/legacy.vim @@ -0,0 +1,130 @@ +let s:sigil = nr2char(31) +let snipmate#legacy#sigil = s:sigil + +" Prepare snippet to be processed by s:BuildTabStops +function! snipmate#legacy#process_snippet(snip) abort + let snippet = a:snip + let esc_bslash = '\%(\\\@ 0) ? &sts : &sw), 'g') + endif + return snippet +endfunction + +" Builds a list of a list of each tab stop in the snippet containing: +" 1.) The tab stop's line number. +" 2.) The tab stop's column number +" (by getting the length of the string between the last "\n" and the +" tab stop). +" 3.) The length of the text after the colon for the current tab stop +" (e.g. "${1:foo}" would return 3). +" 4.) If the "${#:}" construct is given, another list containing all +" the matches of "$#", to be replaced with the placeholder. This list is +" composed the same way as the parent; the first item is the line number, +" and the second is the column. +function! snipmate#legacy#build_stops(snip, lnum, col, indent) abort + let stops = {} + let i = 0 + let withoutVars = substitute(a:snip, s:sigil . '\d\+', '', 'g') + while a:snip =~ s:sigil . '{' . i + let beforeTabStop = matchstr(withoutVars, '^.*\ze'.s:sigil .'{'.i.'\D') + let withoutOthers = substitute(withoutVars, ''.s:sigil .'{\('.i.'\D\)\@!\d\+.\{-}}', '', 'g') + + let stops[i] = {} + let stops[i].line = a:lnum + s:count(beforeTabStop, "\n") + let stops[i].col = a:indent + len(matchstr(withoutOthers, '[^\n]\{-}\ze'.s:sigil .'{'.i.'\D')) + let stops[i].placeholder = 0 + let stops[i].mirrors = [] + if stops[i].line == a:lnum + let stops[i].col += a:col + endif + + " Get all $# matches in another list, if ${#:name} is given + if withoutVars =~ printf('%s{%d:', s:sigil, i) + let stops[i].placeholder = len(matchstr(withoutVars, ''.s:sigil .'{'.i.':\zs.\{-}\ze}')) + let withoutOthers = substitute(a:snip, ''.s:sigil .'{\d\+.\{-}}\|'.s:sigil .''.i.'\@!\d\+', '', 'g') + + while match(withoutOthers, ''.s:sigil .''.i.'\(\D\|$\)') != -1 + let stops[i].mirrors = get(stops[i], 'mirrors', []) + let beforeMark = matchstr(withoutOthers, + \ printf('^.\{-}\ze%s%s%d\(\D\|$\)', + \ repeat('.', stops[i].placeholder), s:sigil, i)) + let line = a:lnum + s:count(beforeMark, "\n") + let col = a:indent + (line > a:lnum + \ ? len(matchstr(beforeMark, '.*\n\zs.*')) + \ : a:col + len(beforeMark)) + call add(stops[i].mirrors, { 'line' : line, 'col' : col }) + let withoutOthers = substitute(withoutOthers, ''.s:sigil .''.i.'\ze\(\D\|$\)', '', '') + endw + endif + let i += 1 + endw + let stops[i] = stops[0] + return [stops, i + 1] +endfunction + +" Counts occurences of haystack in needle +function! s:count(haystack, needle) abort + let counter = 0 + let index = stridx(a:haystack, a:needle) + while index != -1 + let index = stridx(a:haystack, a:needle, index+1) + let counter += 1 + endw + return counter +endfunction diff --git a/vim/.vim/autoload/snipmate/parse.vim b/vim/.vim/autoload/snipmate/parse.vim new file mode 100644 index 0000000..2dd60a3 --- /dev/null +++ b/vim/.vim/autoload/snipmate/parse.vim @@ -0,0 +1,219 @@ +" Snippet definition parsing code + +function! s:sfile() abort + return expand('') +endfunction + +let s:parser_proto = {} + +function! s:new_parser(text) abort + let ret = copy(s:parser_proto) + let ret.input = a:text + let ret.len = strlen(ret.input) + let ret.pos = -1 + let ret.indent = 0 + let ret.value = [] + let ret.vars = {} + call ret.advance() + return ret +endfunction + +function! s:parser_advance(...) dict abort + let self.pos += a:0 ? a:1 : 1 + let self.next = self.input[self.pos] +endfunction + +function! s:parser_same(tok) dict abort + if self.next == a:tok + call self.advance() + return 1 + else + return 0 + endif +endfunction + +function! s:parser_id() dict abort + if self.input[(self.pos):(self.pos+5)] == 'VISUAL' + call self.advance(6) + return 'VISUAL' + elseif self.next =~ '\d' + let end = matchend(self.input, '\d\+', self.pos) + let res = strpart(self.input, self.pos, end - self.pos) + call self.advance(end - self.pos) + return +res " force conversion to Number + endif + return -1 +endfunction + +function! s:parser_add_var(var) dict abort + let id = a:var[0] + if !has_key(self.vars, id) + let self.vars[id] = { 'instances' : [] } + endif + call add(self.vars[id].instances, a:var) +endfunction + +function! s:parser_var() dict abort + let ret = [] + if self.same('{') + let id = self.id() + if id >= 0 + call add(ret, id) + call extend(ret, self.varend()) + endif + else + let id = self.id() + if id >= 0 + call add(ret, id) + endif + endif + return ret +endfunction + +function! s:parser_varend() dict abort + let ret = [] + if self.same(':') + call extend(ret, self.placeholder()) + elseif self.same('/') + call add(ret, self.subst()) + endif + call self.same('}') + return ret +endfunction + +function! s:parser_placeholder() dict abort + return self.parse('}') +endfunction + +function! s:parser_subst() dict abort + let ret = {} + let ret.pat = join(self.text('/', 1)) + if self.same('/') + let ret.sub = join(self.text('/}')) + endif + if self.same('/') + let ret.flags = join(self.text('}', 1)) + endif + return ret +endfunction + +function! s:parser_expr() dict abort + let str = join(self.text('`', 1)) + call self.same('`') + return snipmate#util#eval(str) +endfunction + +function! s:parser_text(...) dict abort + let res = [] + let val = '' + if a:0 == 2 && a:2 + let till = '\V' . escape(a:1, '\') + else + let till = '[`$' . (a:0 ? a:1 : '') . ']' + endif + + while self.pos < self.len + if self.same('\') + if self.next != "\n" + let val .= self.next + endif + call self.advance() + elseif self.next =~# till + break + elseif self.next == "\n" + call add(res, val) + let val = '' + let self.indent = 0 + call self.advance() + elseif self.next == "\t" + let self.indent += 1 + let val .= s:indent(1) + call self.advance() + else + let val .= self.next + call self.advance() + endif + endwhile + + call add(res, val) + return res +endfunction + +function! s:parser_parse(...) dict abort + let ret = a:0 ? [] : self.value + while self.pos < self.len + if self.same('$') + let var = self.var() + if !empty(var) + if var[0] is# 'VISUAL' + let add_to = s:visual_placeholder(var, self.indent) + if !empty(ret) && type(ret[-1]) == type('') + let ret[-1] .= add_to[0] + else + call add(ret, add_to[0]) + endif + call extend(ret, add_to[1:-1]) + elseif var[0] >= 0 + call add(ret, var) + call self.add_var(var) + endif + endif + elseif self.same('`') + let add_to = self.expr() + if !empty(ret) && type(ret[-1]) == type('') + let ret[-1] .= add_to + else + call add(ret, add_to) + endif + else + let text = a:0 ? self.text(a:1) : self.text() + if exists('add_to') + let ret[-1] .= text[0] + call remove(text, 0) + unlet add_to + endif + call extend(ret, text) + endif + if a:0 && self.next == a:1 + break + endif + endwhile + return ret +endfunction + +call extend(s:parser_proto, snipmate#util#add_methods(s:sfile(), 'parser', + \ [ 'advance', 'same', 'id', 'add_var', 'var', 'varend', + \ 'placeholder', 'subst', 'expr', 'text', 'parse' ]), 'error') + +function! s:indent(count) abort + if &expandtab + let shift = repeat(' ', (&sts > 0) ? &sts : &sw) + else + let shift = "\t" + endif + return repeat(shift, a:count) +endfunction + +function! s:visual_placeholder(var, indent) abort + let arg = get(a:var, 1, {}) + if type(arg) == type({}) + let pat = get(arg, 'pat', '') + let sub = get(arg, 'sub', '') + let flags = get(arg, 'flags', '') + let content = split(substitute(get(b:, 'snipmate_visual', ''), pat, sub, flags), "\n", 1) + else + let content = split(get(b:, 'snipmate_visual', arg), "\n", 1) + endif + + let indent = s:indent(a:indent) + call map(content, '(v:key != 0) ? indent . v:val : v:val') + + return content +endfunction + +function! snipmate#parse#snippet(text) abort + let parser = s:new_parser(a:text) + call parser.parse() + unlet! b:snipmate_visual + return [parser.value, parser.vars] +endfunction diff --git a/vim/.vim/autoload/snipmate/util.vim b/vim/.vim/autoload/snipmate/util.vim new file mode 100644 index 0000000..cb7ddc8 --- /dev/null +++ b/vim/.vim/autoload/snipmate/util.vim @@ -0,0 +1,22 @@ +" The next function was based on s:function and s:add_methods in fugitive +" +function! snipmate#util#add_methods(sfile, namespace, methods) abort + let dict = {} + for name in a:methods + let dict[name] = function(join([matchstr(a:sfile, '\d\+'), + \ a:namespace, name], '_')) + endfor + return dict +endfunction + +function! snipmate#util#eval(arg) + try + let ret = eval(a:arg) + catch + echohl ErrorMsg + echom 'SnipMate:Expression: ' . v:exception + echohl None + let ret = '' + endtry + return type(ret) == type('') ? ret : string(ret) +endfunction diff --git a/vim/.vim/autoload/tiny_cmd.vim b/vim/.vim/autoload/tiny_cmd.vim new file mode 100644 index 0000000..052bbe0 --- /dev/null +++ b/vim/.vim/autoload/tiny_cmd.vim @@ -0,0 +1,19 @@ +" vim suffers: + +exec vam#DefineAndBind('s:c','g:vim_tiny_cmd', '{}') + +fun! tiny_cmd#Put(a) + let new = get(s:c,'next',0) +1 + let s:c['next'] = new + let s:c[new] = a:a + return new +endf + +fun! tiny_cmd#Get(nr) + return s:c[a:nr] +endf + +" Get and remove item +fun! tiny_cmd#Pop(nr) + let r = s:c[a:nr] | unlet s:c[a:nr] | return r +endf diff --git a/vim/.vim/autoload/tinykeymap/map/para_move.vim b/vim/.vim/autoload/tinykeymap/map/para_move.vim new file mode 100644 index 0000000..908f5f7 --- /dev/null +++ b/vim/.vim/autoload/tinykeymap/map/para_move.vim @@ -0,0 +1,12 @@ +" para_move.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-08-28. +" @Last Change: 2012-08-29. +" @Revision: 3 + +" Move paragraphs +call tinykeymap#EnterMap("para_move", "gp", {'name': 'move paragraph'}) +call tinykeymap#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '')") +call tinykeymap#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '')") + diff --git a/vim/.vim/autoload/tlib.vim b/vim/.vim/autoload/tlib.vim new file mode 100755 index 0000000..5d805ac --- /dev/null +++ b/vim/.vim/autoload/tlib.vim @@ -0,0 +1,8 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 13 + +" :nodefault: +TLet g:tlib#debug = 0 + diff --git a/vim/.vim/autoload/tlib/Filter_cnf.vim b/vim/.vim/autoload/tlib/Filter_cnf.vim new file mode 100755 index 0000000..0bcb6c0 --- /dev/null +++ b/vim/.vim/autoload/tlib/Filter_cnf.vim @@ -0,0 +1,151 @@ +" Filter_cnf.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-11-18. +" @Revision: 0.0.114 + +let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + +" The search pattern for |tlib#input#List()| is in conjunctive normal +" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... +" The pattern is a '/\V' very no-'/magic' regexp pattern. +" +" Pressing joins two patterns with AND. +" Pressing | joins two patterns with OR. +" I.e. In order to get "lala AND (foo OR bar)", you type +" "lala foo|bar". +" +" This is also the base class for other filters. +function! tlib#Filter_cnf#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call a:world.PushHelp( + \ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not), + \ 'AND, OR, NOT') +endf + + +" :nodoc: +function! s:prototype.AssessName(world, name) dict "{{{3 + let xa = 0 + let prefix = self.FilterRxPrefix() + for flt in a:world.filter_pos + " let flt = prefix . a:world.GetRx(fltl) + " if flt =~# '\u' && a:name =~# flt + " let xa += 5 + " endif + + if a:name =~ '\^'. flt + let xa += 4 + elseif a:name =~ '\<'. flt + let xa += 3 + " elseif a:name =~ '[[:punct:][:space:][:digit:]]'. flt + " let xa += 2 + elseif a:name =~ '\A'. flt .'\|'. flt .'\A' + let xa += 1 + endif + endfor + " TLogVAR a:name, xa + return xa +endf + + +" :nodoc: +function! s:prototype.Match(world, text) dict "{{{3 + " TLogVAR a:text + " let sc = &smartcase + " let ic = &ignorecase + " if &ignorecase + " set smartcase + " endif + " try + if !empty(a:world.filter_neg) + for rx in a:world.filter_neg + " TLogVAR rx + if a:text =~ rx + return 0 + endif + endfor + endif + if !empty(a:world.filter_pos) + for rx in a:world.filter_pos + " TLogVAR rx + if a:text !~ rx + return 0 + endif + endfor + endif + " finally + " let &smartcase = sc + " let &ignorecase = ic + " endtry + return 1 +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + let filter1 = deepcopy(a:filter) + call map(filter1, '"(". join(reverse(self.Pretty(v:val)), " OR ") .")"') + return join(reverse(filter1), ' AND ') +endf + + +function! s:prototype.Pretty(filter) dict "{{{3 + " call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''=>'', ''g'')') + call map(a:filter, 'self.CleanFilter(v:val)') + return a:filter +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = reverse(split(a:pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let filter = a:world.filter[0][0] + " TLogVAR filter + let str = matchstr(filter, '\(\\\(\.\\{-}\|[.?*+$^]\)\|\)$') + if empty(str) + let filter = filter[0 : -2] + else + let filter = strpart(filter, 0, len(filter) - len(str)) + endif + " TLogVAR str, filter + let a:world.filter[0][0] = filter +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict "{{{3 + return '\V' +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return a:filter +endf + diff --git a/vim/.vim/autoload/tlib/Filter_cnfd.vim b/vim/.vim/autoload/tlib/Filter_cnfd.vim new file mode 100755 index 0000000..27f00fe --- /dev/null +++ b/vim/.vim/autoload/tlib/Filter_cnfd.vim @@ -0,0 +1,53 @@ +" Filter_cnfd.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-01-23. +" @Revision: 0.0.57 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. +" As a consequence, patterns cannot match dots. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_cnfd#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('.', 'Any characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, '\.', '\\.\\{-}', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= a:char == 46 ? '\.\{-}' : nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\.\\{-}', '.', 'g') +endf + diff --git a/vim/.vim/autoload/tlib/Filter_fuzzy.vim b/vim/.vim/autoload/tlib/Filter_fuzzy.vim new file mode 100755 index 0000000..349bfd5 --- /dev/null +++ b/vim/.vim/autoload/tlib/Filter_fuzzy.vim @@ -0,0 +1,83 @@ +" Filter_fuzzy.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2013-09-25. +" @Revision: 0.0.47 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" Support for "fuzzy" pattern matching in |tlib#input#List()|. +" Patterns are interpreted as if characters were connected with '.\{-}'. +" +" In "fuzzy" mode, the pretty printing of filenames is disabled. +function! tlib#Filter_fuzzy#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 + " TLogVAR a:world.display_format + " :nodoc: + function! a:world.Set_display_format(value) dict + if a:value == 'filename' + let self.display_format = '' + else + let self.display_format = a:value + endif + endf +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('Patterns are interpreted as if characters were connected with .\{-}') +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + " TLogVAR a:filter + let filter1 = deepcopy(a:filter) + call map(filter1, '"{". join(reverse(v:val), " OR ") ."}"') + return join(reverse(filter1), ' AND ') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(map(split(v:val, ''\zs''), ''tlib#rx#Escape(v:val, "V")''), ''\.\{-}'')') + a:world.filter[0][1 : -1] + endif +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let ch = tlib#rx#Escape(nr2char(a:char), 'V') + if empty(a:world.filter[0][0]) + let a:world.filter[0][0] .= ch + else + let a:world.filter[0][0] .= '\.\{-}'. ch + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let a:world.filter[0][0] = substitute(a:world.filter[0][0], '\(\\\.\\{-}\)\?.$', '', '') +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\\.\\{-}', '', 'g') +endf + diff --git a/vim/.vim/autoload/tlib/Filter_glob.vim b/vim/.vim/autoload/tlib/Filter_glob.vim new file mode 100644 index 0000000..904b226 --- /dev/null +++ b/vim/.vim/autoload/tlib/Filter_glob.vim @@ -0,0 +1,68 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-11-18. +" @Revision: 0.0.82 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_glob'], 'name': 'glob'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" A character that should be expanded to '\.\{-}'. +TLet g:tlib#Filter_glob#seq = '*' + + +" A character that should be expanded to '\.\?'. +TLet g:tlib#Filter_glob#char = '?' + + +" The same as |tlib#Filter_cnf#New()| but a a customizable character +" |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and +" |g:tlib#Filter_glob#char| is expanded to '\.'. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_glob#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp(g:tlib#Filter_glob#seq, 'Any characters') + call a:world.PushHelp(g:tlib#Filter_glob#char, 'Single characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#seq, 'V'), '\\.\\{-}', 'g') + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#char, 'V'), '\\.', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + " TLogVAR a:char, nr2char(a:char) + if a:char == char2nr(g:tlib#Filter_glob#seq) + let char = '\.\{-}' + elseif a:char == char2nr(g:tlib#Filter_glob#char) + let char = '\.' + else + let char = nr2char(a:char) + endif + let a:world.filter[0][0] .= char +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + let filter = substitute(a:filter, '\\\.\\{-}', g:tlib#Filter_glob#seq, 'g') + let filter = substitute(filter, '\\\.', g:tlib#Filter_glob#char, 'g') + return filter +endf + diff --git a/vim/.vim/autoload/tlib/Object.vim b/vim/.vim/autoload/tlib/Object.vim new file mode 100755 index 0000000..21f38b2 --- /dev/null +++ b/vim/.vim/autoload/tlib/Object.vim @@ -0,0 +1,154 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 127 + +" :filedoc: +" Provides a prototype plus some OO-like methods. + +let s:id_counter = 0 +let s:prototype = {'_class': ['object'], '_super': [], '_id': 0} "{{{2 + +" :def: function! tlib#Object#New(?fields={}) +" This function creates a prototype that provides some kind of +" inheritance mechanism and a way to call parent/super methods. +" +" The usage demonstrated in the following example works best when every +" class/prototype is defined in a file of its own. +" +" The reason for why there is a dedicated constructor function is that +" this layout facilitates the use of templates and that methods are +" hidden from the user. Other solutions are possible. +" +" EXAMPLES: > +" let s:prototype = tlib#Object#New({ +" \ '_class': ['FooBar'], +" \ 'foo': 1, +" \ 'bar': 2, +" \ }) +" " Constructor +" function! FooBar(...) +" let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) +" return object +" endf +" function! s:prototype.babble() { +" echo "I think, therefore I am ". (self.foo * self.bar) ." months old." +" } +" +" < This could now be used like this: > +" let myfoo = FooBar({'foo': 3}) +" call myfoo.babble() +" => I think, therefore I am 6 months old. +" echo myfoo.IsA('FooBar') +" => 1 +" echo myfoo.IsA('object') +" => 1 +" echo myfoo.IsA('Foo') +" => 0 +" echo myfoo.RespondTo('babble') +" => 1 +" echo myfoo.RespondTo('speak') +" => 0 +function! tlib#Object#New(...) "{{{3 + return s:prototype.New(a:0 >= 1 ? a:1 : {}) +endf + + +function! s:prototype.New(...) dict "{{{3 + let object = deepcopy(self) + let s:id_counter += 1 + let object._id = s:id_counter + if a:0 >= 1 && !empty(a:1) + " call object.Extend(deepcopy(a:1)) + call object.Extend(a:1) + endif + return object +endf + + +function! s:prototype.Inherit(object) dict "{{{3 + let class = copy(self._class) + " TLogVAR class + let objid = self._id + for c in get(a:object, '_class', []) + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:object, 'keep') + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, a:object) + return self +endf + + +function! s:prototype.Extend(dictionary) dict "{{{3 + let super = copy(self) + let class = copy(self._class) + " TLogVAR class + let objid = self._id + let thisclass = get(a:dictionary, '_class', []) + for c in type(thisclass) == 3 ? thisclass : [thisclass] + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:dictionary) + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, super) + return self +endf + + +function! s:prototype.IsA(class) dict "{{{3 + return index(self._class, a:class) != -1 +endf + + +function! s:prototype.IsRelated(object) dict "{{{3 + return len(filter(a:object._class, 'self.IsA(v:val)')) > 1 +endf + + +function! s:prototype.RespondTo(name) dict "{{{3 + " return has_key(self, a:name) && type(self[a:name]) == 2 + return has_key(self, a:name) +endf + + +function! s:prototype.Super(method, arglist) dict "{{{3 + for o in self._super + " TLogVAR o + if o.RespondTo(a:method) + " let self._tmp_method = o[a:method] + " TLogVAR self._tmp_method + " return call(self._tmp_method, a:arglist, self) + return call(o[a:method], a:arglist, self) + endif + endfor + echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self) +endf + + +function! tlib#Object#Methods(object, ...) "{{{3 + TVarArg ['pattern', '\d\+'] + let o = items(a:object) + call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"') + let acc = {} + for e in o + let id = matchstr(string(e[1]), pattern) + if !empty(id) + let acc[id] = e[0] + endif + endfor + return acc +endf + diff --git a/vim/.vim/autoload/tlib/Test.vim b/vim/.vim/autoload/tlib/Test.vim new file mode 100755 index 0000000..4a4281e --- /dev/null +++ b/vim/.vim/autoload/tlib/Test.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + +" :enddoc: + + +let s:prototype = tlib#Object#New({'_class': ['Test']}) "{{{2 +function! tlib#Test#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'Test.vim' +endf + diff --git a/vim/.vim/autoload/tlib/TestChild.vim b/vim/.vim/autoload/tlib/TestChild.vim new file mode 100755 index 0000000..16979a7 --- /dev/null +++ b/vim/.vim/autoload/tlib/TestChild.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 15 + +" :enddoc: + + +let s:prototype = tlib#Test#New({'_class': ['TestChild']}) "{{{2 +function! tlib#TestChild#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'TestChild.vim' +endf + diff --git a/vim/.vim/autoload/tlib/World.vim b/vim/.vim/autoload/tlib/World.vim new file mode 100755 index 0000000..c184947 --- /dev/null +++ b/vim/.vim/autoload/tlib/World.vim @@ -0,0 +1,1376 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1405 + +" :filedoc: +" A prototype used by |tlib#input#List|. +" Inherits from |tlib#Object#New|. + + +" Size of the input list window (in percent) from the main size (of &lines). +" See |tlib#input#List()|. +TLet g:tlib_inputlist_pct = 50 + +" Size of filename columns when listing filenames. +" See |tlib#input#List()|. +TLet g:tlib_inputlist_width_filename = '&co / 3' +" TLet g:tlib_inputlist_width_filename = 25 + +" If true, |tlib#input#List()| will show some indicators about the +" status of a filename (e.g. buflisted(), bufloaded() etc.). +" This is disabled by default because vim checks also for the file on +" disk when doing this. +TLet g:tlib_inputlist_filename_indicators = 0 + +" If not null, display only a short info about the filter. +TLet g:tlib_inputlist_shortmessage = 0 + + + +" Known keys & values: +" scratch_split ... See |tlib#scratch#UseScratch()| +let s:prototype = tlib#Object#New({ + \ '_class': 'World', + \ 'name': 'world', + \ 'allow_suspend': 1, + \ 'base': [], + \ 'bufnr': -1, + \ 'buffer_local': 1, + \ 'cache_var': '', + \ 'display_format': '', + \ 'fileencoding': &fileencoding, + \ 'fmt_display': {}, + \ 'fmt_filter': {}, + \ 'fmt_options': {}, + \ 'filetype': '', + \ 'filter': [['']], + \ 'filter_format': '', + \ 'filter_options': '', + \ 'follow_cursor': '', + \ 'has_menu': 0, + \ 'help_extra': [], + \ 'index_table': [], + \ 'initial_filter': [['']], + \ 'initial_index': 1, + \ 'initial_display': 1, + \ 'initialized': 0, + \ 'key_handlers': [], + \ 'list': [], + \ 'matcher': {}, + \ 'next_agent': '', + \ 'next_eval': '', + \ 'next_state': '', + \ 'numeric_chars': g:tlib#input#numeric_chars, + \ 'offset': 1, + \ 'offset_horizontal': 0, + \ 'on_leave': [], + \ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'), + \ 'post_handlers': [], + \ 'query': '', + \ 'resize': 0, + \ 'resize_vertical': 0, + \ 'restore_from_cache': [], + \ 'filtered_items': [], + \ 'resume_state': '', + \ 'retrieve_eval': '', + \ 'return_agent': '', + \ 'rv': '', + \ 'scratch': '__InputList__', + \ 'scratch_filetype': 'tlibInputList', + \ 'scratch_hidden': g:tlib#scratch#hidden, + \ 'scratch_vertical': 0, + \ 'scratch_split': 1, + \ 'sel_idx': [], + \ 'show_empty': 0, + \ 'state': 'display', + \ 'state_handlers': [], + \ 'sticky': 0, + \ 'temp_lines': [], + \ 'temp_prompt': [], + \ 'timeout': 0, + \ 'timeout_resolution': 2, + \ 'tabpagenr': -1, + \ 'type': '', + \ 'win_wnr': -1, + \ 'win_height': -1, + \ 'win_width': -1, + \ 'win_pct': 25, + \ }) + " \ 'handlers': [], + " \ 'filter_options': '\c', + +function! tlib#World#New(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf')) + return object +endf + + +" :nodoc: +function! s:prototype.Set_display_format(value) dict "{{{3 + if a:value == 'filename' + call self.Set_highlight_filename() + let self.display_format = 'world.FormatFilename(%s)' + else + let self.display_format = a:value + endif +endf + + +" :nodoc: +function! s:prototype.DisplayFormat(list) dict "{{{3 + let display_format = self.display_format + if !empty(display_format) + if has_key(self, 'InitFormatName') + call self.InitFormatName() + endif + let cache = self.fmt_display + " TLogVAR display_format, fmt_entries + return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') + else + return a:list + endif +endf + + +" :nodoc: +function! s:prototype.Set_highlight_filename() dict "{{{3 + let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' +endf + + +if g:tlib#input#format_filename == 'r' + + " :nodoc: + function! s:prototype.Highlight_filename() dict "{{{3 + syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/ + hi def link TLibDir Directory + syntax match TLibFilename /[^\/]\+$/ + hi def link TLibFilename Normal + endf + + " :nodoc: + function! s:prototype.FormatFilename(file) dict "{{{3 + if !has_key(self.fmt_options, 'maxlen') + let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) + let maxfi = max(map(copy(self.base), 'strwidth(v:val)')) + let self.fmt_options.maxlen = min([maxco, maxfi]) + " TLogVAR maxco, maxfi, self.fmt_options.maxlen + endif + let max = self.fmt_options.maxlen + if len(a:file) > max + let filename = '...' . strpart(a:file, len(a:file) - max + 3) + else + let filename = printf('% '. max .'s', a:file) + endif + return filename + endf + +else + + " :nodoc: + function! s:prototype.Highlight_filename() dict "{{{3 + " let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename) + " TLogVAR self.base + let self.width_filename = min([ + \ get(self, 'width_filename', &co), + \ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width), + \ max(map(copy(self.base), 'strwidth(matchstr(v:val, "[^\\/]*$"))')) + \ ]) + " TLogVAR self.width_filename + exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' + " exec 'syntax match TLibDir /\(|\|\[.\{-}\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + " exec 'syntax match TLibMarker /\(|\|\[.\{-}\]\) \S.*$/ contains=TLibDir' + exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir' + hi def link TLibMarker Special + hi def link TLibDir Directory + hi def link TLibFilename NonText + " :nodoc: + function! self.Highlighter(rx) dict + let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/' + exec 'match' self.matcher.highlight rx + endf + endf + + + " :nodoc: + function! s:prototype.UseFilenameIndicators() dict "{{{3 + return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') + endf + + + " :nodoc: + function! s:prototype.InitFormatName() dict "{{{3 + if self.UseFilenameIndicators() + let self._buffers = {} + for bufnr in range(1, bufnr('$')) + let filename = fnamemodify(bufname(bufnr), ':p') + " TLogVAR filename + let bufdef = { + \ 'bufnr': bufnr, + \ } + " '&buflisted' + for opt in ['&modified', '&bufhidden'] + let bufdef[opt] = getbufvar(bufnr, opt) + endfor + let self._buffers[filename] = bufdef + endfor + endif + endf + + + " :nodoc: + function! s:prototype.FormatFilename(file) dict "{{{3 + " TLogVAR a:file + let width = self.width_filename + let split = match(a:file, '[/\\]\zs[^/\\]\+$') + if split == -1 + let fname = a:file + let dname = a:file + else + let fname = strpart(a:file, split) + " let dname = strpart(a:file, 0, split - 1) + let dname = a:file + endif + if strwidth(fname) > width + let fname = strpart(fname, 0, width - 3) .'...' + endif + let dnmax = &co - max([width, strwidth(fname)]) - 8 - self.index_width - &fdc + let use_indicators = self.UseFilenameIndicators() + " TLogVAR use_indicators + let marker = [] + if use_indicators + call insert(marker, '[') + if g:tlib_inputlist_filename_indicators + let bufdef = get(self._buffers, a:file, {}) + " let bnr = bufnr(a:file) + let bnr = get(bufdef, 'bufnr', -1) + " TLogVAR a:file, bnr, self.bufnr + if bnr != -1 + if bnr == self.bufnr + call add(marker, '%') + else + call add(marker, bnr) + endif + if get(bufdef, '&modified', 0) + call add(marker, '+') + endif + if get(bufdef, '&bufhidden', '') == 'hide' + call add(marker, 'h') + endif + " if !get(bufdef, '&buflisted', 1) + " call add(marker, 'u') + " endif + " echom "DBG" a:file string(get(self,'filename_indicators')) + endif + endif + if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file) + if len(marker) > 1 + call add(marker, '|') + endif + call add(marker, self.filename_indicators[a:file]) + endif + if len(marker) <= 1 + call add(marker, ' ') + endif + call add(marker, ']') + else + call add(marker, '|') + endif + let markers = join(marker, '') + if !empty(markers) + let dnmax -= len(markers) + endif + if strwidth(dname) > dnmax + let dname = '...'. strpart(dname, len(dname) - dnmax) + endif + return printf("%-*s %s %s", + \ self.width_filename + len(fname) - strwidth(fname), + \ fname, markers, dname) + endf + +endif + + +" :nodoc: +function! s:prototype.GetSelectedItems(current) dict "{{{3 + " TLogVAR a:current + if stridx(self.type, 'i') != -1 + let rv = copy(self.sel_idx) + else + let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') + endif + if !empty(a:current) + " TLogVAR a:current, rv, type(a:current) + if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current) + call s:InsertSelectedItems(rv, a:current) + elseif tlib#type#IsList(a:current) + for item in a:current + call s:InsertSelectedItems(rv, item) + endfor + elseif tlib#type#IsDictionary(a:current) + for [inum, item] in items(a:current) + call s:InsertSelectedItems(rv, item) + endfor + endif + endif + " TAssert empty(rv) || rv[0] == a:current + if stridx(self.type, 'i') != -1 + if !empty(self.index_table) + " TLogVAR rv, self.index_table + call map(rv, 'self.index_table[v:val - 1]') + " TLogVAR rv + endif + endif + return rv +endf + + +function! s:InsertSelectedItems(rv, current) "{{{3 + let ci = index(a:rv, a:current) + if ci != -1 + call remove(a:rv, ci) + endif + call insert(a:rv, a:current) +endf + + +" :nodoc: +function! s:prototype.SelectItemsByNames(mode, items) dict "{{{3 + for item in a:items + let bi = index(self.base, item) + 1 + " TLogVAR item, bi + if bi > 0 + let si = index(self.sel_idx, bi) + " TLogVAR self.sel_idx + " TLogVAR si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode == 'toggle' + call remove(self.sel_idx, si) + endif + endif + endfor + return 1 +endf + + +" :nodoc: +function! s:prototype.SelectItem(mode, index) dict "{{{3 + let bi = self.GetBaseIdx(a:index) + " if self.RespondTo('MaySelectItem') + " if !self.MaySelectItem(bi) + " return 0 + " endif + " endif + " TLogVAR bi + let si = index(self.sel_idx, bi) + " TLogVAR self.sel_idx + " TLogVAR si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode == 'toggle' + call remove(self.sel_idx, si) + endif + return 1 +endf + + +" :nodoc: +function! s:prototype.FormatArgs(format_string, arg) dict "{{{3 + let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) + return [a:format_string] + repeat([string(a:arg)], nargs) +endf + + +" :nodoc: +function! s:prototype.GetRx(filter) dict "{{{3 + return '\('. join(filter(copy(a:filter), 'v:val[0] != "!"'), '\|') .'\)' +endf + + +" :nodoc: +function! s:prototype.GetRx0(...) dict "{{{3 + exec tlib#arg#Let(['negative']) + let rx0 = [] + for filter in self.filter + " TLogVAR filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " TLogVAR rx + if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not) + call add(rx0, rx) + endif + endfor + let rx0s = join(rx0, '\|') + if empty(rx0s) + return '' + else + return self.FilterRxPrefix() .'\('. rx0s .'\)' + endif +endf + + +" :nodoc: +function! s:prototype.FormatName(cache, format, value) dict "{{{3 + " TLogVAR a:format, a:value + " TLogDBG has_key(self.fmt_display, a:value) + if has_key(a:cache, a:value) + " TLogDBG "cached" + return a:cache[a:value] + else + let world = self + let ftpl = self.FormatArgs(a:format, a:value) + let fn = call(function("printf"), ftpl) + let fmt = eval(fn) + " TLogVAR ftpl, fn, fmt + let a:cache[a:value] = fmt + return fmt + endif +endf + + +" :nodoc: +function! s:prototype.GetItem(idx) dict "{{{3 + return self.list[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.GetListIdx(baseidx) dict "{{{3 + " if empty(self.index_table) + let baseidx = a:baseidx + " else + " let baseidx = 0 + self.index_table[a:baseidx - 1] + " " TLogVAR a:baseidx, baseidx, self.index_table + " endif + let rv = index(self.table, baseidx) + " TLogVAR rv, self.table + return rv +endf + + +" :nodoc: +" The first index is 1. +function! s:prototype.GetBaseIdx(idx) dict "{{{3 + " TLogVAR a:idx, self.table, self.index_table + if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) + return self.table[a:idx - 1] + else + return 0 + endif +endf + + +" :nodoc: +function! s:prototype.GetBaseIdx0(idx) dict "{{{3 + let idx0 = self.GetBaseIdx(a:idx) - 1 + if idx0 < 0 + call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg') + endif + return idx0 +endf + + +" :nodoc: +function! s:prototype.GetBaseItem(idx) dict "{{{3 + return self.base[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.SetBaseItem(idx, item) dict "{{{3 + let self.base[a:idx - 1] = a:item +endf + + +" :nodoc: +function! s:prototype.GetLineIdx(lnum) dict "{{{3 + let line = getline(a:lnum) + let prefidx = substitute(matchstr(line, '^\d\+\ze[*:]'), '^0\+', '', '') + return prefidx +endf + + +" :nodoc: +function! s:prototype.SetPrefIdx() dict "{{{3 + " let pref = sort(range(1, self.llen), 'self.SortPrefs') + " let self.prefidx = get(pref, 0, self.initial_index) + let pref_idx = -1 + let pref_weight = -1 + " TLogVAR self.filter_pos, self.filter_neg + " let t0 = localtime() " DBG + for idx in range(1, self.llen) + let item = self.GetItem(idx) + let weight = self.matcher.AssessName(self, item) + " TLogVAR item, weight + if weight > pref_weight + let pref_idx = idx + let pref_weight = weight + endif + endfor + " TLogVAR localtime() - t0 + " TLogVAR pref_idx + " TLogDBG self.GetItem(pref_idx) + if pref_idx == -1 + let self.prefidx = self.initial_index + else + let self.prefidx = pref_idx + endif +endf + + +" " :nodoc: +" function! s:prototype.GetCurrentItem() dict "{{{3 +" let idx = self.prefidx +" " TLogVAR idx +" if stridx(self.type, 'i') != -1 +" return idx +" elseif !empty(self.list) +" if len(self.list) >= idx +" let idx1 = idx - 1 +" let rv = self.list[idx - 1] +" " TLogVAR idx, idx1, rv, self.list +" return rv +" endif +" else +" return '' +" endif +" endf + + +" :nodoc: +function! s:prototype.CurrentItem() dict "{{{3 + if stridx(self.type, 'i') != -1 + return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) + else + if self.llen == 1 + " TLogVAR self.llen + return self.list[0] + elseif self.prefidx > 0 + " TLogVAR self.prefidx + " return self.GetCurrentItem() + if len(self.list) >= self.prefidx + let rv = self.list[self.prefidx - 1] + " TLogVAR idx, rv, self.list + return rv + endif + else + return '' + endif + endif +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict "{{{3 + return self.matcher.FilterRxPrefix() +endf + + +" :nodoc: +function! s:prototype.SetFilter() dict "{{{3 + " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') + let mrx = self.FilterRxPrefix() . self.filter_options + let self.filter_pos = [] + let self.filter_neg = [] + " TLogVAR mrx, self.filter + for filter in self.filter + " TLogVAR filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " TLogVAR rx + if !empty(rx) + if rx =~ '\u' + let mrx1 = mrx .'\C' + else + let mrx1 = mrx + endif + " TLogVAR rx + if rx[0] == g:tlib#input#not + if len(rx) > 1 + call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') + endif + else + call add(self.filter_pos, mrx1 .'\('. rx .'\)') + endif + endif + endfor + " TLogVAR self.filter_pos, self.filter_neg +endf + + +" :nodoc: +function! s:prototype.IsValidFilter() dict "{{{3 + let last = self.FilterRxPrefix() .'\('. self.filter[0][0] .'\)' + " TLogVAR last + try + let a = match("", last) + return 1 + catch + return 0 + endtry +endf + + +" :nodoc: +function! s:prototype.SetMatchMode(match_mode) dict "{{{3 + " TLogVAR a:match_mode + if !empty(a:match_mode) + unlet self.matcher + try + let self.matcher = tlib#Filter_{a:match_mode}#New() + call self.matcher.Init(self) + catch /^Vim\%((\a\+)\)\=:E117/ + throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode + endtry + endif +endf + + +" function! s:prototype.Match(text) dict "{{{3 +" return self.matcher.Match(self, text) +" endf + + +" :nodoc: +function! s:prototype.MatchBaseIdx(idx) dict "{{{3 + let text = self.GetBaseItem(a:idx) + if !empty(self.filter_format) + let text = self.FormatName(self.fmt_filter, self.filter_format, text) + endif + " TLogVAR text + " return self.Match(text) + return self.matcher.Match(self, text) +endf + + +" :nodoc: +function! s:prototype.BuildTableList() dict "{{{3 + " let time0 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time0 + call self.SetFilter() + " TLogVAR self.filter_neg, self.filter_pos + let self.table = range(1, len(self.base)) + " TLogVAR self.filtered_items + let copy_base = 1 + if !empty(self.filtered_items) + let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1') + let copy_base = 0 + endif + if !empty(self.filter_pos) || !empty(self.filter_neg) + let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)') + let copy_base = 0 + endif + if copy_base + let self.list = copy(self.base) + else + let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)') + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFilter() dict "{{{3 + " TLogVAR self.filter + if self.filter[0] == [''] && len(self.filter) > 1 + call remove(self.filter, 0) + elseif empty(self.filter[0][0]) && len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + else + call self.matcher.ReduceFrontFilter(self) + endif +endf + + +" :nodoc: +" filter is either a string or a list of list of strings. +function! s:prototype.SetInitialFilter(filter) dict "{{{3 + " let self.initial_filter = [[''], [a:filter]] + if type(a:filter) == 3 + let self.initial_filter = deepcopy(a:filter) + else + let self.initial_filter = [[a:filter]] + endif +endf + + +" :nodoc: +function! s:prototype.PopFilter() dict "{{{3 + " TLogVAR self.filter + if len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + elseif len(self.filter) > 1 + call remove(self.filter, 0) + else + let self.filter[0] = [''] + endif +endf + + +" :nodoc: +function! s:prototype.FilterIsEmpty() dict "{{{3 + " TLogVAR self.filter + return self.filter == copy(self.initial_filter) +endf + + +" :nodoc: +function! s:prototype.DisplayFilter() dict "{{{3 + let filter1 = copy(self.filter) + call filter(filter1, 'v:val != [""]') + " TLogVAR self.matcher['_class'] + let rv = self.matcher.DisplayFilter(filter1) + let rv = self.CleanFilter(rv) + return rv +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(pattern) dict "{{{3 + call self.matcher.SetFrontFilter(self, a:pattern) +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(char) dict "{{{3 + call self.matcher.PushFrontFilter(self, a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return self.matcher.CleanFilter(a:filter) +endf + + +" :nodoc: +function! s:prototype.UseScratch() dict "{{{3 + " if type(self.scratch) != 0 && get(self, 'buffer_local', 1) + " if self.scratch != fnamemodify(self.scratch, ':p') + " let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch]) + " " TLogVAR self.scratch + " endif + " " let self.scratch_hidden = 'wipe' + " endif + keepjumps keepalt let rv = tlib#scratch#UseScratch(self) + " if expand('%:t') == self.scratch + let b:tlib_world = self + " endif + return rv +endf + + +" :nodoc: +function! s:prototype.CloseScratch(...) dict "{{{3 + TVarArg ['reset_scratch', 0] + " TVarArg ['reset_scratch', 1] + " TLogVAR reset_scratch + if self.sticky + return 0 + else + let rv = tlib#scratch#CloseScratch(self, reset_scratch) + " TLogVAR rv + if rv + call self.SwitchWindow('win') + endif + return rv + endif +endf + + +" :nodoc: +function! s:prototype.Initialize() dict "{{{3 + let self.initialized = 1 + call self.SetOrigin(1) + call self.Reset(1) + if !empty(self.cache_var) && exists(self.cache_var) + for prop in self.restore_from_cache + exec 'let self[prop] = get('. self.cache_var .', prop, self[prop])' + endfor + exec 'unlet '. self.cache_var + endif +endf + + +" :nodoc: +function! s:prototype.Leave() dict "{{{3 + if !empty(self.cache_var) + exec 'let '. self.cache_var .' = self' + endif + for handler in self.on_leave + call call(handler, [self]) + endfor +endf + + +" :nodoc: +function! s:prototype.UseInputListScratch() dict "{{{3 + let scratch = self.UseScratch() + if !exists('b:tlib_list_init') + call tlib#autocmdgroup#Init() + autocmd TLib VimResized call feedkeys("\", 't') + " autocmd TLib WinLeave let b:tlib_world_event = 'WinLeave' | call feedkeys("\", 't') + let b:tlib_list_init = 1 + endif + if !exists('w:tlib_list_init') + " TLogVAR scratch + if has_key(self, 'index_next_syntax') + exec 'syntax match InputlListIndex /^\d\+:\s/ nextgroup='. self.index_next_syntax + else + syntax match InputlListIndex /^\d\+:\s/ + endif + syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex + syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex + hi def link InputlListIndex Constant + hi def link InputlListCursor Search + hi def link InputlListSelected IncSearch + setlocal nowrap + " hi def link InputlListIndex Special + " let b:tlibDisplayListMarks = {} + let b:tlibDisplayListMarks = [] + let b:tlibDisplayListWorld = self + call tlib#hook#Run('tlib_UseInputListScratch', self) + let w:tlib_list_init = 1 + endif + return scratch +endf + + +" s:prototype.Reset(?initial=0) +" :nodoc: +function! s:prototype.Reset(...) dict "{{{3 + TVarArg ['initial', 0] + " TLogVAR initial + let self.state = 'display' + let self.offset = 1 + let self.filter = deepcopy(self.initial_filter) + let self.idx = '' + let self.prefidx = 0 + let self.initial_display = 1 + let self.fmt_display = {} + let self.fmt_filter = {} + call self.UseInputListScratch() + call self.ResetSelected() + call self.Retrieve(!initial) + return self +endf + + +" :nodoc: +function! s:prototype.ResetSelected() dict "{{{3 + let self.sel_idx = [] +endf + + +" :nodoc: +function! s:prototype.Retrieve(anyway) dict "{{{3 + " TLogVAR a:anyway, self.base + " TLogDBG (a:anyway || empty(self.base)) + if (a:anyway || empty(self.base)) + let ra = self.retrieve_eval + " TLogVAR ra + if !empty(ra) + let back = self.SwitchWindow('win') + let world = self + let self.base = eval(ra) + " TLogVAR self.base + exec back + return 1 + endif + endif + return 0 +endf + + +function! s:FormatHelp(help) "{{{3 + " TLogVAR a:help + let max = [0, 0] + for item in a:help + " TLogVAR item + if type(item) == 3 + let itemlen = map(copy(item), 'strwidth(v:val)') + " TLogVAR itemlen + let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]') + endif + unlet item + endfor + " TLogVAR max + let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2)) + if cols < 1 + let cols = 1 + endif + let fmt = printf('%%%ds: %%-%ds', max[0], max[1]) + " TLogVAR cols, fmt + let help = [] + let idx = -1 + let maxidx = len(a:help) + while idx < maxidx + let push_item = 0 + let accum = [] + for i in range(cols) + let idx += 1 + if idx >= maxidx + break + endif + let item = a:help[idx] + if type(item) == 3 + call add(accum, item) + else + let push_item = 1 + break + endif + unlet item + endfor + if !empty(accum) + call add(help, s:FormatHelpItem(accum, fmt)) + endif + if push_item + call add(help, a:help[idx]) + endif + endwh + " TLogVAR help + return help +endf + + +function! s:FormatHelpItem(item, fmt) "{{{3 + let args = [join(repeat([a:fmt], len(a:item)), ' ')] + for item in a:item + " TLogVAR item + let args += item + endfor + " TLogVAR args + return call('printf', args) +endf + + +" :nodoc: +function! s:prototype.InitHelp() dict "{{{3 + return [] +endf + + +" :nodoc: +function! s:prototype.PushHelp(...) dict "{{{3 + " TLogVAR a:000 + if a:0 == 1 + if type(a:1) == 3 + let self.temp_lines += a:1 + else + call add(self.temp_lines, a:1) + endif + elseif a:0 == 2 + call add(self.temp_lines, a:000) + else + throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000) + endif + " TLogVAR helpstring +endf + + +" :nodoc: +function! s:prototype.DisplayHelp() dict "{{{3 + let self.temp_lines = self.InitHelp() + call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') + call self.PushHelp('Enter, ', 'Pick the current item') + call self.PushHelp('Mouse', 'L: Pick item, R: Show menu') + call self.PushHelp('', 'Select an item') + call self.PushHelp(', ', 'Reduce filter') + call self.PushHelp(', ', 'Enter command') + + if self.key_mode == 'default' + call self.PushHelp('', 'Reset the display') + call self.PushHelp('Up/Down', 'Next/previous item') + call self.PushHelp('', 'Edit top filter string') + call self.PushHelp('Page Up/Down', 'Scroll') + call self.PushHelp('', 'Enter * Wildcard') + if self.allow_suspend + call self.PushHelp('', 'Suspend/Resume') + call self.PushHelp('', 'Switch to origin') + endif + if stridx(self.type, 'm') != -1 + call self.PushHelp('', '(Un)Select items') + call self.PushHelp('#', '(Un)Select the current item') + call self.PushHelp('', '(Un)Select all items') + call self.PushHelp('', '(Un)Restrict view to selection') + " \ ' ... Show only selected', + endif + endif + + " TLogVAR len(self.temp_lines) + call self.matcher.Help(self) + + " TLogVAR self.key_mode + for handler in values(self.key_map[self.key_mode]) + " TLogVAR handler + let key = get(handler, 'key_name', '') + " TLogVAR key + if !empty(key) + let desc = get(handler, 'help', '') + if empty(desc) + let desc = get(handler, 'agent', '') + endif + call self.PushHelp(key, desc) + endif + endfor + + if !has_key(self.key_map[self.key_mode], 'unknown_key') + call self.PushHelp('Letter', 'Filter the list') + endif + + if self.key_mode == 'default' && !empty(self.help_extra) + call self.PushHelp(self.help_extra) + endif + + " TLogVAR len(self.temp_lines) + call self.PushHelp([ + \ '', + \ 'Matches at word boundaries are prioritized.', + \ ]) + let self.temp_lines = s:FormatHelp(self.temp_lines) + call self.PrintLines() +endf + + +function! s:prototype.PrintLines() dict "{{{3 + let self.temp_prompt = ['Press any key to continue.', 'Question'] + call tlib#buffer#DeleteRange('1', '$') + call append(0, self.temp_lines) + call tlib#buffer#DeleteRange('$', '$') + 1 + call self.Resize(len(self.temp_lines), 0) + let self.temp_lines = [] +endf + + +" :nodoc: +function! s:prototype.Resize(hsize, vsize) dict "{{{3 + " TLogVAR self.scratch_vertical, a:hsize, a:vsize + let world_resize = '' + let winpos = '' + let scratch_split = get(self, 'scratch_split', 1) + " TLogVAR scratch_split + if scratch_split > 0 + if self.scratch_vertical + if a:vsize + let world_resize = 'vert resize '. a:vsize + let winpos = tlib#fixes#Winpos() + " let w:winresize = {'v': a:vsize} + setlocal winfixwidth + endif + else + if a:hsize + let world_resize = 'resize '. a:hsize + " let w:winresize = {'h': a:hsize} + setlocal winfixheight + endif + endif + endif + if !empty(world_resize) + " TLogVAR world_resize, winpos + exec world_resize + if !empty(winpos) + exec winpos + endif + " redraw! + endif +endf + + +" :nodoc: +function! s:prototype.GetResize(size) dict "{{{3 + let resize0 = get(self, 'resize', 0) + let resize = empty(resize0) ? 0 : eval(resize0) + " TLogVAR resize0, resize + let resize = resize == 0 ? a:size : min([a:size, resize]) + " let min = self.scratch_vertical ? &cols : &lines + let min1 = (self.scratch_vertical ? self.win_width : self.win_height) * g:tlib_inputlist_pct + let min2 = (self.scratch_vertical ? &columns : &lines) * self.win_pct + let min = max([min1, min2]) + let resize = min([resize, (min / 100)]) + " TLogVAR resize, a:size, min, min1, min2 + return resize +endf + + +" function! s:prototype.DisplayList(?query=self.Query(), ?list=[]) +" :nodoc: +function! s:prototype.DisplayList(...) dict "{{{3 + " TLogVAR self.state + let query = a:0 >= 1 ? a:1 : self.Query() + let list = a:0 >= 2 ? a:2 : [] + " TLogVAR query, len(list) + " TLogDBG 'len(list) = '. len(list) + call self.UseScratch() + " TLogVAR self.scratch + " TAssert IsNotEmpty(self.scratch) + if self.state == 'scroll' + call self.ScrollToOffset() + elseif self.state == 'help' + call self.DisplayHelp() + call self.SetStatusline(query) + elseif self.state == 'printlines' + call self.PrintLines() + call self.SetStatusline(query) + else + " TLogVAR query + " let ll = len(list) + let ll = self.llen + " let x = len(ll) + 1 + let x = self.index_width + 1 + " TLogVAR ll + if self.state =~ '\' + call self.Resize(self.GetResize(ll), eval(get(self, 'resize_vertical', 0))) + call tlib#normal#WithRegister('gg"tdG', 't') + let lines = copy(list) + let lines = map(lines, 'substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g")') + let w = winwidth(0) - &fdc + " let w = winwidth(0) - &fdc - 1 + let lines = map(lines, 'printf("%-'. w .'.'. w .'s", v:val)') + " TLogVAR lines + call append(0, lines) + call tlib#normal#WithRegister('G"tddgg', 't') + endif + " TLogVAR self.prefidx + let base_pref = self.GetBaseIdx(self.prefidx) + " TLogVAR base_pref + if self.state =~ '\' + call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') + " TLogVAR b:tlibDisplayListMarks + call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') + " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + " call add(b:tlibDisplayListMarks, self.prefidx) + " call self.DisplayListMark(x, self.GetBaseIdx(self.prefidx), '*') + endif + let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + call add(b:tlibDisplayListMarks, base_pref) + call self.DisplayListMark(x, base_pref, '*') + call self.SetOffset() + call self.SetStatusline(query) + " TLogVAR self.offset + call self.ScrollToOffset() + let rx0 = self.GetRx0() + " TLogVAR rx0 + if !empty(self.matcher.highlight) + if empty(rx0) + match none + elseif self.IsValidFilter() + if has_key(self, 'Highlighter') + call self.Highlighter(rx0) + else + exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/' + endif + endif + endif + endif + redraw +endf + + +" :nodoc: +function! s:prototype.SetStatusline(query) dict "{{{3 + " TLogVAR a:query + if !empty(self.temp_prompt) + let echo = get(self.temp_prompt, 0, '') + let hl = get(self.temp_prompt, 1, 'Normal') + let self.temp_prompt = [] + else + let hl = 'Normal' + let query = a:query + let options = [self.matcher.name] + if self.sticky + call add(options, '#') + endif + if self.key_mode != 'default' + call add(options, 'map:'. self.key_mode) + endif + if !empty(self.filtered_items) + if g:tlib_inputlist_shortmessage + call add(options, 'R') + else + call add(options, 'restricted') + endif + endif + if !empty(options) + let sopts = printf('[%s]', join(options, ', ')) + " let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts + let echo = query . ' ' . sopts + " let query .= '%%='. sopts .' ' + endif + " TLogVAR &l:statusline, query + " let &l:statusline = query + endif + echo + if hl != 'Normal' + exec 'echohl' hl + echo echo + echohl None + else + echo echo + endif +endf + + +" :nodoc: +function! s:prototype.Query() dict "{{{3 + let flt = self.DisplayFilter() + if g:tlib_inputlist_shortmessage + let query = 'Filter: '. flt + else + let query = self.query .' (filter: '. flt .'; press for help)' + endif + return query +endf + + +" :nodoc: +function! s:prototype.ScrollToOffset() dict "{{{3 + " TLogVAR self.scratch_vertical, self.llen, winheight(0) + exec 'norm! '. self.offset .'zt' +endf + + +" :nodoc: +function! s:prototype.SetOffset() dict "{{{3 + " TLogVAR self.prefidx, self.offset + " TLogDBG winheight(0) + " TLogDBG self.prefidx > self.offset + winheight(0) - 1 + let listtop = len(self.list) - winheight(0) + 1 + if listtop < 1 + let listtop = 1 + endif + if self.prefidx > listtop + let self.offset = listtop + elseif self.prefidx > self.offset + winheight(0) - 1 + let listoff = self.prefidx - winheight(0) + 1 + let self.offset = min([listtop, listoff]) + " TLogVAR self.prefidx + " TLogDBG len(self.list) + " TLogDBG winheight(0) + " TLogVAR listtop, listoff, self.offset + elseif self.prefidx < self.offset + let self.offset = self.prefidx + endif + " TLogVAR self.offset +endf + + +" :nodoc: +function! s:prototype.ClearAllMarks() dict "{{{3 + let x = self.index_width + 1 + call map(range(1, line('$')), 'self.DisplayListMark(x, v:val, ":")') +endf + + +" :nodoc: +function! s:prototype.MarkCurrent(y) dict "{{{3 + let x = self.index_width + 1 + call self.DisplayListMark(x, a:y, '*') +endf + + +" :nodoc: +function! s:prototype.DisplayListMark(x, y, mark) dict "{{{3 + " TLogVAR a:y, a:mark + if a:x > 0 && a:y >= 0 + " TLogDBG a:x .'x'. a:y .' '. a:mark + let sy = self.GetListIdx(a:y) + 1 + " TLogVAR sy + if sy >= 1 + call setpos('.', [0, sy, a:x, 0]) + exec 'norm! r'. a:mark + " exec 'norm! '. a:y .'gg'. a:x .'|r'. a:mark + endif + endif + return a:y +endf + + +" :nodoc: +function! s:prototype.SwitchWindow(where) dict "{{{3 + " TLogDBG string(tlib#win#List()) + if self.tabpagenr != tabpagenr() + call tlib#tab#Set(self.tabpagenr) + endif + let wnr = get(self, a:where.'_wnr') + " TLogVAR self, wnr + return tlib#win#Set(wnr) +endf + + +" :nodoc: +function! s:prototype.FollowCursor() dict "{{{3 + if !empty(self.follow_cursor) + let back = self.SwitchWindow('win') + " TLogVAR back + " TLogDBG winnr() + try + call call(self.follow_cursor, [self, [self.CurrentItem()]]) + finally + exec back + endtry + endif +endf + + +" :nodoc: +function! s:prototype.SetOrigin(...) dict "{{{3 + TVarArg ['winview', 0] + " TLogVAR self.win_wnr, self.bufnr + " TLogDBG bufname('%') + " TLogDBG winnr() + " TLogDBG winnr('$') + let self.win_wnr = winnr() + let self.win_height = winheight(self.win_wnr) + let self.win_width = winwidth(self.win_wnr) + " TLogVAR self.win_wnr, self.win_height, self.win_width + let self.bufnr = bufnr('%') + let self.tabpagenr = tabpagenr() + let self.cursor = getpos('.') + if winview + let self.winview = tlib#win#GetLayout() + endif + " TLogVAR self.win_wnr, self.bufnr, self.winview + return self +endf + + +" :nodoc: +function! s:prototype.RestoreOrigin(...) dict "{{{3 + TVarArg ['winview', 0] + if winview + " TLogVAR winview + call tlib#win#SetLayout(self.winview) + endif + " TLogVAR self.win_wnr, self.bufnr, self.cursor, &splitbelow + " TLogDBG "RestoreOrigin0 ". string(tlib#win#List()) + " If &splitbelow or &splitright is false, we cannot rely on + " self.win_wnr to be our source buffer since, e.g, opening a buffer + " in a split window changes the whole layout. + " Possible solutions: + " - Restrict buffer switching to cases when the number of windows + " hasn't changed. + " - Guess the right window, which we try to do here. + if &splitbelow == 0 || &splitright == 0 + let wn = bufwinnr(self.bufnr) + " TLogVAR wn + if wn == -1 + let wn = 1 + end + else + let wn = self.win_wnr + endif + if wn != winnr() + exec wn .'wincmd w' + endif + exec 'buffer! '. self.bufnr + call setpos('.', self.cursor) + " TLogDBG "RestoreOrigin1 ". string(tlib#win#List()) +endf + + +function! s:prototype.Suspend() dict "{{{3 + call tlib#agent#Suspend(self, self.rv) +endf + diff --git a/vim/.vim/autoload/tlib/agent.vim b/vim/.vim/autoload/tlib/agent.vim new file mode 100644 index 0000000..87731a9 --- /dev/null +++ b/vim/.vim/autoload/tlib/agent.vim @@ -0,0 +1,614 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 252 + + +" :filedoc: +" Various agents for use as key handlers in tlib#input#List() + +" Number of items to move when pressing in the input list window. +TLet g:tlib_scroll_lines = 10 + + +" General {{{1 + +function! tlib#agent#Exit(world, selected) "{{{3 + if a:world.key_mode == 'default' + call a:world.CloseScratch() + let a:world.state = 'exit empty escape' + let a:world.list = [] + " let a:world.base = [] + call a:world.ResetSelected() + else + let a:world.key_mode = 'default' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#CopyItems(world, selected) "{{{3 + let @* = join(a:selected, "\n") + let a:world.state = 'redisplay' + return a:world +endf + + + +" InputList related {{{1 + +function! tlib#agent#PageUp(world, selected) "{{{3 + let a:world.offset -= (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#PageDown(world, selected) "{{{3 + let a:world.offset += (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#Home(world, selected) "{{{3 + let a:world.prefidx = 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#End(world, selected) "{{{3 + let a:world.prefidx = len(a:world.list) + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Up(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + let a:world.idx = '' + if a:world.prefidx > lines + let a:world.prefidx -= lines + else + let a:world.prefidx = len(a:world.list) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Down(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + let a:world.idx = '' + if a:world.prefidx <= (len(a:world.list) - lines) + let a:world.prefidx += lines + else + let a:world.prefidx = 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#UpN(world, selected) "{{{3 + return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#DownN(world, selected) "{{{3 + return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#ShiftLeft(world, selected) "{{{3 + let a:world.offset_horizontal -= (winwidth(0) / 2) + if a:world.offset_horizontal < 0 + let a:world.offset_horizontal = 0 + endif + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#ShiftRight(world, selected) "{{{3 + let a:world.offset_horizontal += (winwidth(0) / 2) + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#Reset(world, selected) "{{{3 + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#ToggleRestrictView(world, selected) "{{{3 + if empty(a:world.filtered_items) + return tlib#agent#RestrictView(a:world, a:selected) + else + return tlib#agent#UnrestrictView(a:world, a:selected) + endif +endf + + +function! tlib#agent#RestrictView(world, selected) "{{{3 + " TLogVAR a:selected + let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1') + " TLogVAR 1, filtered_items + let filtered_items = filter(filtered_items, 'v:val > 0') + " TLogVAR 2, filtered_items + if !empty(filtered_items) + let a:world.filtered_items = filtered_items + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#UnrestrictView(world, selected) "{{{3 + let a:world.filtered_items = [] + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Input(world, selected) "{{{3 + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + let flt1 = input('Filter: ', flt0) + echo + if flt1 != flt0 + if empty(flt1) + call getchar(0) + else + call a:world.SetFrontFilter(flt1) + endif + endif + let a:world.state = 'display' + return a:world +endf + + +" Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the +" original position in the parent window. +function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 + let world = a:world + let winnr = world.win_wnr + " TLogVAR winnr + if winnr != -1 + let world = tlib#agent#Suspend(world, a:selected) + if world.state =~ '\' + call world.SwitchWindow('win') + " let pos = world.cursor + " " TLogVAR pos + " if !empty(pos) + " call setpos('.', pos) + " endif + return world + endif + endif + let world.state = 'redisplay' + return world +endf + + +" Suspend lets you temporarily leave the input loop of +" |tlib#input#List|. You can resume editing the list by pressing , +" . , or in the suspended window. +" and will immediatly select the item under the cursor. +" < will select the item but the window will remain opened. +function! tlib#agent#Suspend(world, selected) "{{{3 + if a:world.allow_suspend + " TAssert IsNotEmpty(a:world.scratch) + " TLogDBG bufnr('%') + let br = tlib#buffer#Set(a:world.scratch) + " TLogVAR br, a:world.bufnr, a:world.scratch + if bufnr('%') != a:world.scratch + echohl WarningMsg + echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%') + echohl NONE + endif + " TLogVAR bufnr('%'), bufname('%'), a:world.scratch + call tlib#autocmdgroup#Init() + exec 'autocmd TLib BufEnter call tlib#input#Resume("world", 0, '. a:world.scratch .')' + let b:tlib_world = a:world + exec br + let a:world.state = 'exit suspend' + else + echom 'Suspend disabled' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#Help(world, selected) "{{{3 + let a:world.state = 'help' + return a:world +endf + + +function! tlib#agent#OR(world, selected) "{{{3 + if !empty(a:world.filter[0]) + call insert(a:world.filter[0], '') + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#AND(world, selected) "{{{3 + if !empty(a:world.filter[0]) + call insert(a:world.filter, ['']) + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#ReduceFilter(world, selected) "{{{3 + call a:world.ReduceFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#PopFilter(world, selected) "{{{3 + call a:world.PopFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Debug(world, selected) "{{{3 + " echo string(world.state) + echo string(a:world.filter) + echo string(a:world.idx) + echo string(a:world.prefidx) + echo string(a:world.sel_idx) + call getchar() + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Select(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + " let a:world.state = 'display keepcursor' + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectUp(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx > 1 + let a:world.prefidx -= 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectDown(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx < len(a:world.list) + let a:world.prefidx += 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectAll(world, selected) "{{{3 + let listrange = range(1, len(a:world.list)) + let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) + \ ? 'toggle' : 'set' + for i in listrange + call a:world.SelectItem(mode, i) + endfor + let a:world.state = 'display keepcursor' + return a:world +endf + + +function! tlib#agent#ToggleStickyList(world, selected) "{{{3 + let a:world.sticky = !a:world.sticky + let a:world.state = 'display keepcursor' + return a:world +endf + + + +" EditList related {{{1 + +function! tlib#agent#EditItem(world, selected) "{{{3 + let lidx = a:world.prefidx + " TLogVAR lidx + " TLogVAR a:world.table + let bidx = a:world.GetBaseIdx(lidx) + " TLogVAR bidx + let item = a:world.GetBaseItem(bidx) + let item = input(lidx .'@'. bidx .': ', item) + if item != '' + call a:world.SetBaseItem(bidx, item) + endif + let a:world.state = 'display' + return a:world +endf + + +" Insert a new item below the current one. +function! tlib#agent#NewItem(world, selected) "{{{3 + let basepi = a:world.GetBaseIdx(a:world.prefidx) + let item = input('New item: ') + call insert(a:world.base, item, basepi) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#DeleteItems(world, selected) "{{{3 + let remove = copy(a:world.sel_idx) + let basepi = a:world.GetBaseIdx(a:world.prefidx) + if index(remove, basepi) == -1 + call add(remove, basepi) + endif + " call map(remove, 'a:world.GetBaseIdx(v:val)') + for idx in reverse(sort(remove)) + call remove(a:world.base, idx - 1) + endfor + let a:world.state = 'display' + call a:world.ResetSelected() + " let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#Cut(world, selected) "{{{3 + let world = tlib#agent#Copy(a:world, a:selected) + return tlib#agent#DeleteItems(world, a:selected) +endf + + +function! tlib#agent#Copy(world, selected) "{{{3 + let a:world.clipboard = [] + let bidxs = copy(a:world.sel_idx) + call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) + for bidx in sort(bidxs) + call add(a:world.clipboard, a:world.GetBaseItem(bidx)) + endfor + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Paste(world, selected) "{{{3 + if has_key(a:world, 'clipboard') + for e in reverse(copy(a:world.clipboard)) + call insert(a:world.base, e, a:world.prefidx) + endfor + endif + let a:world.state = 'display' + call a:world.ResetSelected() + return a:world +endf + + +function! tlib#agent#EditReturnValue(world, rv) "{{{3 + return [a:world.state !~ '\', a:world.base] +endf + + + +" Files related {{{1 + +function! tlib#agent#ViewFile(world, selected) "{{{3 + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + " TLogVAR back + for filename in a:selected + call tlib#file#Edit(filename) + endfor + " if !&hidden && &l:modified + " let cmd0 = 'split' + " let cmd1 = 'sbuffer' + " else + " let cmd0 = 'edit' + " let cmd1 = 'buffer' + " endif + " call tlib#file#With(cmd0, cmd1, a:selected, a:world) + " TLogVAR &filetype + exec back + let a:world.state = 'display' + endif + return a:world +endf + + +function! tlib#agent#EditFile(world, selected) "{{{3 + return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) +endf + + +function! tlib#agent#EditFileInSplit(world, selected) "{{{3 + call a:world.CloseScratch() + " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) + " call tlib#file#With('split', 'sbuffer', a:selected[1:-1], a:world) + call tlib#file#With('split', 'sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 + call a:world.CloseScratch() + " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) + " call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world) + let winpos = tlib#fixes#Winpos() + call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world) + if !empty(winpos) + exec winpos + endif + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInTab(world, selected) "{{{3 + " TLogVAR a:selected + call a:world.CloseScratch() + call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 + let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ShowInfo(world, selected) + let lines = [] + for f in a:selected + if filereadable(f) + let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] + call add(lines, fnamemodify(f, ':p')) + call add(lines, ' '. join(desc, '; ')) + endif + endfor + let a:world.temp_lines = lines + let a:world.state = 'printlines' + return a:world +endf + + + +" Buffer related {{{1 + +function! tlib#agent#PreviewLine(world, selected) "{{{3 + let l = a:selected[0] + let ww = winnr() + exec a:world.win_wnr .'wincmd w' + call tlib#buffer#ViewLine(l, 1) + exec ww .'wincmd w' + let a:world.state = 'redisplay' + return a:world +endf + + +" If not called from the scratch, we assume/guess that we don't have to +" suspend the input-evaluation loop. +function! tlib#agent#GotoLine(world, selected) "{{{3 + if !empty(a:selected) + + " let l = a:selected[0] + " " TLogVAR l + " let back = a:world.SwitchWindow('win') + " " TLogVAR back + " " if a:world.win_wnr != winnr() + " " let world = tlib#agent#Suspend(a:world, a:selected) + " " exec a:world.win_wnr .'wincmd w' + " " endif + " call tlib#buffer#ViewLine(l) + " exec back + " let a:world.state = 'display' + + let l = a:selected[0] + if a:world.win_wnr != winnr() + let world = tlib#agent#Suspend(a:world, a:selected) + exec a:world.win_wnr .'wincmd w' + endif + call tlib#buffer#ViewLine(l, 1) + + endif + return a:world +endf + + +function! tlib#agent#DoAtLine(world, selected) "{{{3 + if !empty(a:selected) + let cmd = input('Command: ', '', 'command') + if !empty(cmd) + call a:world.SwitchWindow('win') + " let pos = getpos('.') + let view = winsaveview() + for l in a:selected + call tlib#buffer#ViewLine(l, '') + exec cmd + endfor + " call setpos('.', pos) + call winrestview(view) + endif + endif + call a:world.ResetSelected() + let a:world.state = 'exit' + return a:world +endf + + +function! tlib#agent#Wildcard(world, selected) "{{{3 + if !empty(a:world.filter[0]) + let rx_type = a:world.matcher.FilterRxPrefix() + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + if rx_type == '\V' + let flt0 .= '\.\{-}' + else + let flt0 .= '.\{-}' + endif + call a:world.SetFrontFilter(flt0) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Null(world, selected) "{{{3 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ExecAgentByName(world, selected) "{{{3 + let s:agent_names_world = a:world + let agent_names = {'Help': 'tlib#agent#Help'} + for def in values(a:world.key_map[a:world.key_mode]) + if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent) + let agent_names[def.help] = def.agent + endif + endfor + let s:agent_names = sort(keys(agent_names)) + let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames') + " TLogVAR command + if !has_key(agent_names, command) + " TLogVAR command + silent! let matches = filter(keys(agent_names), 'v:val =~ command') + " TLogVAR matches + if len(matches) == 1 + let command = matches[0] + endif + endif + if has_key(agent_names, command) + let agent = agent_names[command] + return call(agent, [a:world, a:selected]) + else + if !empty(command) + echohl WarningMsg + echom "Unknown command:" command + echohl NONE + sleep 1 + endif + let a:world.state = 'display' + return a:world + endif +endf + + +function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) + return filter(copy(s:agent_names), 'stridx(v:val, a:ArgLead) != -1') +endf + diff --git a/vim/.vim/autoload/tlib/arg.vim b/vim/.vim/autoload/tlib/arg.vim new file mode 100755 index 0000000..96d5dc5 --- /dev/null +++ b/vim/.vim/autoload/tlib/arg.vim @@ -0,0 +1,103 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2014-07-01. +" @Revision: 63 + + +" :def: function! tlib#arg#Get(n, var, ?default="", ?test='') +" Set a positional argument from a variable argument list. +" See tlib#string#RemoveBackslashes() for an example. +function! tlib#arg#Get(n, var, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let atest = a:0 >= 2 ? a:2 : '' + " TLogVAR default, atest + if !empty(atest) + let atest = ' && (a:'. a:n .' '. atest .')' + endif + let test = printf('a:0 >= %d', a:n) . atest + return printf('let %s = %s ? a:%d : %s', a:var, test, a:n, string(default)) +endf + + +" :def: function! tlib#arg#Let(list, ?default='') +" Set a positional arguments from a variable argument list. +" See tlib#input#List() for an example. +function! tlib#arg#Let(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let list = map(copy(a:list), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(range(1, len(list)), 'call("tlib#arg#Get", [v:val] + list[v:val - 1])') + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#Key(dict, list, ?default='') +" See |:TKeyArg|. +function! tlib#arg#Key(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let dict = a:list[0] + let list = map(copy(a:list[1:-1]), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(list, '"let ". v:val[0] ." = ". string(get(dict, v:val[0], v:val[1]))') + " TLogVAR dict, list, args + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':') +function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1 + TVarArg ['keys', {}], ['evaluate', 0], ['sep', ':'] + let keyargs = {} + let args = split(a:string, '\\\@ +" exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +function! tlib#arg#Ex(arg, ...) "{{{3 + if exists('*fnameescape') && a:0 == 0 + return fnameescape(a:arg) + else + " let chars = '%# \' + let chars = '%#! ' + if a:0 >= 1 + let chars .= a:1 + endif + return escape(a:arg, chars) + endif +endf + + diff --git a/vim/.vim/autoload/tlib/autocmdgroup.vim b/vim/.vim/autoload/tlib/autocmdgroup.vim new file mode 100755 index 0000000..8439524 --- /dev/null +++ b/vim/.vim/autoload/tlib/autocmdgroup.vim @@ -0,0 +1,14 @@ +" autocmdgroup.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 7 + +augroup TLib + autocmd! +augroup END + + +function! tlib#autocmdgroup#Init() "{{{3 +endf + diff --git a/vim/.vim/autoload/tlib/balloon.vim b/vim/.vim/autoload/tlib/balloon.vim new file mode 100644 index 0000000..cc70d03 --- /dev/null +++ b/vim/.vim/autoload/tlib/balloon.vim @@ -0,0 +1,54 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-08-30. +" @Last Change: 2010-09-05. +" @Revision: 27 + + +function! tlib#balloon#Register(expr) "{{{3 + if !has('balloon_eval') + return + endif + if !exists('b:tlib_balloons') + let b:tlib_balloons = [] + endif + if !&ballooneval + setlocal ballooneval + endif + if &balloonexpr != 'tlib#balloon#Expr()' + if !empty(&balloonexpr) + call add(b:tlib_balloons, &balloonexpr) + endif + setlocal ballooneval balloonexpr=tlib#balloon#Expr() + endif + if index(b:tlib_balloons, a:expr) == -1 + call add(b:tlib_balloons, a:expr) + endif +endf + + +function! tlib#balloon#Remove(expr) "{{{3 + if !exists('b:tlib_balloons') + call filter(b:tlib_balloons, 'v:val != a:expr') + endif +endf + + +function! tlib#balloon#Expr() "{{{3 + " TLogVAR exists('b:tlib_balloons') + if !exists('b:tlib_balloons') + return '' + endif + let text = map(copy(b:tlib_balloons), 'eval(v:val)') + " TLogVAR b:tlib_balloons, text + call filter(text, '!empty(v:val)') + if has('balloon_multiline') + return join(text, "\n----------------------------------\n") + else + return get(text, 0, '') + endif +endf + + diff --git a/vim/.vim/autoload/tlib/bitwise.vim b/vim/.vim/autoload/tlib/bitwise.vim new file mode 100644 index 0000000..54a4258 --- /dev/null +++ b/vim/.vim/autoload/tlib/bitwise.vim @@ -0,0 +1,141 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 124 + + +function! tlib#bitwise#Num2Bits(num) "{{{3 + if type(a:num) <= 1 || type(a:num) == 5 + let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list')) + elseif type(a:num) == 3 + let bits = copy(a:num) + else + throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num) + endif + return bits +endf + + +function! tlib#bitwise#Bits2Num(bits, ...) "{{{3 + let base = a:0 >= 1 ? a:1 : 10 + " TLogVAR a:bits + let num = 0.0 + for i in range(len(a:bits)) + if get(a:bits, i, 0) + let num += pow(2, i) + endif + endfor + " TLogVAR num + if base == 10 + if type(base) == 5 + return num + else + return float2nr(num) + endif + else + return tlib#number#ConvertBase(num, base) + endif +endf + + +function! tlib#bitwise#AND(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) && get(bits2, v:val)') +endf + + +function! tlib#bitwise#OR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) || get(bits2, v:val)') +endf + + +function! tlib#bitwise#XOR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)') +endf + + +function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3 + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits = map(range, a:expr) + if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#ShiftRight(bits, n) "{{{3 + let bits = a:bits[a:n : -1] + if empty(bits) + let bits = [0] + endif + return bits +endf + + +function! tlib#bitwise#ShiftLeft(bits, n) "{{{3 + let bits = repeat([0], a:n) + a:bits + return bits +endf + + +function! tlib#bitwise#Add(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + " TLogVAR bits1, bits2, range + let carry = 0 + let bits = [] + for i in range + let sum = get(bits1, i) + get(bits2, i) + carry + if sum == 3 + let bit = 1 + let carry = 1 + elseif sum == 2 + let bit = 0 + let carry = 1 + elseif sum == 1 + let bit = 1 + let carry = 0 + elseif sum == 0 + let bit = 0 + let carry = 0 + endif + call add(bits, bit) + " TLogVAR i, bits, bit + endfor + if carry == 1 + call add(bits, carry) + endif + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#Sub(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits2 = map(range, '!get(bits2, v:val)') + let bits2 = tlib#bitwise#Add(bits2, [1], 'bits') + let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits') + let bits = bits3[0 : -2] + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + diff --git a/vim/.vim/autoload/tlib/buffer.vim b/vim/.vim/autoload/tlib/buffer.vim new file mode 100644 index 0000000..007f46d --- /dev/null +++ b/vim/.vim/autoload/tlib/buffer.vim @@ -0,0 +1,400 @@ +" buffer.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2015-05-20. +" @Revision: 0.1.352 + + +" Where to display the line when using |tlib#buffer#ViewLine|. +" For possible values for position see |scroll-cursor|. +TLet g:tlib_viewline_position = 'zz' + + +let s:bmru = [] + + +function! tlib#buffer#EnableMRU() "{{{3 + call tlib#autocmdgroup#Init() + autocmd TLib BufEnter * call s:BMRU_Push(bufnr('%')) +endf + + +function! tlib#buffer#DisableMRU() "{{{3 + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter +endf + + +function! s:BMRU_Push(bnr) "{{{3 + let i = index(s:bmru, a:bnr) + if i >= 0 + call remove(s:bmru, i) + endif + call insert(s:bmru, a:bnr) +endf + + +function! s:CompareBuffernameByBasename(a, b) "{{{3 + let rx = '"\zs.\{-}\ze" \+\S\+ \+\d\+$' + let an = matchstr(a:a, rx) + let an = fnamemodify(an, ':t') + let bn = matchstr(a:b, rx) + let bn = fnamemodify(bn, ':t') + let rv = an == bn ? 0 : an > bn ? 1 : -1 + return rv +endf + + +function! s:CompareBufferNrByMRU(a, b) "{{{3 + let an = matchstr(a:a, '\s*\zs\d\+\ze') + let bn = matchstr(a:b, '\s*\zs\d\+\ze') + let ai = index(s:bmru, 0 + an) + if ai == -1 + return 1 + else + let bi = index(s:bmru, 0 + bn) + if bi == -1 + return -1 + else + return ai == bi ? 0 : ai > bi ? 1 : -1 + endif + endif +endf + + +" Set the buffer to buffer and return a command as string that can be +" evaluated by |:execute| in order to restore the original view. +function! tlib#buffer#Set(buffer) "{{{3 + let lazyredraw = &lazyredraw + set lazyredraw + try + let cb = bufnr('%') + let sn = bufnr(a:buffer) + if sn != cb + let ws = bufwinnr(sn) + if ws != -1 + let wb = bufwinnr('%') + exec ws.'wincmd w' + return wb.'wincmd w' + else + silent exec 'sbuffer! '. sn + return 'wincmd c' + endif + else + return '' + endif + finally + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#Eval(buffer, code) +" Evaluate CODE in BUFFER. +" +" EXAMPLES: > +" call tlib#buffer#Eval('foo.txt', 'echo b:bar') +function! tlib#buffer#Eval(buffer, code) "{{{3 + " let cb = bufnr('%') + " let wb = bufwinnr('%') + " " TLogVAR cb + " let sn = bufnr(a:buffer) + " let sb = sn != cb + let lazyredraw = &lazyredraw + set lazyredraw + let restore = tlib#buffer#Set(a:buffer) + try + exec a:code + " if sb + " let ws = bufwinnr(sn) + " if ws != -1 + " try + " exec ws.'wincmd w' + " exec a:code + " finally + " exec wb.'wincmd w' + " endtry + " else + " try + " silent exec 'sbuffer! '. sn + " exec a:code + " finally + " wincmd c + " endtry + " endif + " else + " exec a:code + " endif + finally + exec restore + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') +" Possible values for the "order" argument: +" bufnr :: Default behaviour +" mru :: Sort buffers according to most recent use +" basename :: Sort by the file's basename (last component) +" +" NOTE: MRU order works on second invocation only. If you want to always +" use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. +function! tlib#buffer#GetList(...) + TVarArg ['show_hidden', 0], ['show_number', 0], ['order', ''] + " TLogVAR show_hidden, show_number, order + let ls_bang = show_hidden ? '!' : '' + redir => bfs + exec 'silent ls'. ls_bang + redir END + let buffer_list = split(bfs, '\n') + if order == 'mru' + if empty(s:bmru) + call tlib#buffer#EnableMRU() + echom 'tlib: Installed Buffer MRU logger; disable with: call tlib#buffer#DisableMRU()' + else + call sort(buffer_list, function('s:CompareBufferNrByMRU')) + endif + elseif order == 'basename' + call sort(buffer_list, function('s:CompareBuffernameByBasename')) + endif + let buffer_nr = map(copy(buffer_list), 'str2nr(matchstr(v:val, ''\s*\zs\d\+\ze''))') + " TLogVAR buffer_list, buffer_nr + if show_number + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+.\{-}\ze\s\+\S\+ \d\+\s*$'')') + else + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+\zs.\{-}\ze\s\+\S\+ \d\+\s*$'')') + endif + " TLogVAR buffer_list + " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')') + " TLogVAR buffer_list + call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))') + " TLogVAR buffer_list + return [buffer_nr, buffer_list] +endf + + +" :def: function! tlib#buffer#ViewLine(line, ?position='z') +" line is either a number or a string that begins with a number. +" For possible values for position see |scroll-cursor|. +" See also |g:tlib_viewline_position|. +function! tlib#buffer#ViewLine(line, ...) "{{{3 + if a:line + TVarArg 'pos' + let ln = matchstr(a:line, '^\d\+') + let lt = matchstr(a:line, '^\d\+: \zs.*') + " TLogVAR pos, ln, lt + exec ln + if empty(pos) + let pos = tlib#var#Get('tlib_viewline_position', 'wbg') + endif + " TLogVAR pos + if !empty(pos) + exec 'norm! '. pos + endif + call tlib#buffer#HighlightLine(ln) + " let @/ = '\%'. ln .'l.*' + endif +endf + + +function! s:UndoHighlightLine() "{{{3 + 3match none + autocmd! TLib CursorMoved,CursorMovedI + autocmd! TLib CursorHold,CursorHoldI + autocmd! TLib InsertEnter,InsertChange,InsertLeave + autocmd! TLib BufLeave,BufWinLeave,WinLeave,BufHidden +endf + + +function! tlib#buffer#HighlightLine(...) "{{{3 + TVarArg ['line', line('.')] + " exec '3match MatchParen /^\%'. a:line .'l.*/' + exec '3match Search /^\%'. line .'l.*/' + call tlib#autocmdgroup#Init() + exec 'autocmd TLib CursorMoved,CursorMovedI if line(".") != '. line .' | call s:UndoHighlightLine() | endif' + autocmd TLib CursorHold,CursorHoldI call s:UndoHighlightLine() + autocmd TLib InsertEnter call s:UndoHighlightLine() + " autocmd TLib BufLeave,BufWinLeave,WinLeave,BufHidden call s:UndoHighlightLine() +endf + + +" Delete the lines in the current buffer. Wrapper for |:delete|. +function! tlib#buffer#DeleteRange(line1, line2) "{{{3 + let r = @t + try + exec a:line1.','.a:line2.'delete t' + finally + let @t = r + endtry +endf + + +" Replace a range of lines. +function! tlib#buffer#ReplaceRange(line1, line2, lines) + call tlib#buffer#DeleteRange(a:line1, a:line2) + call append(a:line1 - 1, a:lines) +endf + + +" Initialize some scratch area at the bottom of the current buffer. +function! tlib#buffer#ScratchStart() "{{{3 + norm! Go + let b:tlib_inbuffer_scratch = line('$') + return b:tlib_inbuffer_scratch +endf + + +" Remove the in-buffer scratch area. +function! tlib#buffer#ScratchEnd() "{{{3 + if !exists('b:tlib_inbuffer_scratch') + echoerr 'tlib: In-buffer scratch not initalized' + endif + call tlib#buffer#DeleteRange(b:tlib_inbuffer_scratch, line('$')) + unlet b:tlib_inbuffer_scratch +endf + + +" Run exec on all buffers via bufdo and return to the original buffer. +function! tlib#buffer#BufDo(exec) "{{{3 + let bn = bufnr('%') + exec 'bufdo '. a:exec + exec 'buffer! '. bn +endf + + +" :def: function! tlib#buffer#InsertText(text, keyargs) +" Keyargs: +" 'shift': 0|N +" 'col': col('.')|N +" 'lineno': line('.')|N +" 'indent': 0|1 +" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) +" Insert text (a string) in the buffer. +function! tlib#buffer#InsertText(text, ...) "{{{3 + TVarArg ['keyargs', {}] + " TLogVAR a:text, keyargs + TKeyArg keyargs, ['shift', 0], ['col', col('.')], ['lineno', line('.')], ['pos', 'e'], + \ ['indent', 0] + " TLogVAR shift, col, lineno, pos, indent + let grow = 0 + let post_del_last_line = line('$') == 1 + let line = getline(lineno) + if col + shift > 0 + let pre = line[0 : (col - 1 + shift)] + let post = line[(col + shift): -1] + else + let pre = '' + let post = line + endif + " TLogVAR lineno, line, pre, post + let text0 = pre . a:text . post + let text = split(text0, '\n', 1) + " TLogVAR text + let icol = len(pre) + " exec 'norm! '. lineno .'G' + call cursor(lineno, col) + if indent && col > 1 + if &fo =~# '[or]' + " FIXME: Is the simple version sufficient? + " VERSION 1 + " " This doesn't work because it's not guaranteed that the + " " cursor is set. + " let cline = getline('.') + " norm! a + " "norm! o + " " TAssertExec redraw | sleep 3 + " let idt = strpart(getline('.'), 0, col('.') + shift) + " " TLogVAR idt + " let idtl = len(idt) + " -1,.delete + " " TAssertExec redraw | sleep 3 + " call append(lineno - 1, cline) + " call cursor(lineno, col) + " " TAssertExec redraw | sleep 3 + " if idtl == 0 && icol != 0 + " let idt = matchstr(pre, '^\s\+') + " let idtl = len(idt) + " endif + " VERSION 2 + let idt = matchstr(pre, '^\s\+') + let idtl = len(idt) + else + let [m_0, idt, iline; rest] = matchlist(pre, '^\(\s*\)\(.*\)$') + let idtl = len(idt) + endif + if idtl < icol + let idt .= repeat(' ', icol - idtl) + endif + " TLogVAR idt + let idtl1 = len(idt) + for i in range(1, len(text) - 1) + let text[i] = idt . text[i] + let grow += idtl1 + endfor + endif + " TLogVAR text + " exec 'norm! '. lineno .'Gdd' + call tlib#normal#WithRegister('"tdd', 't') + call append(lineno - 1, text) + if post_del_last_line + call tlib#buffer#KeepCursorPosition('$delete') + endif + let tlen = len(text) + let posshift = matchstr(pos, '\d\+') + " TLogVAR pos + if pos =~ '^e' + exec lineno + tlen - 1 + exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' + elseif pos =~ '^s' + " TLogVAR lineno, pre, posshift + exec lineno + exec 'norm! '. len(pre) .'|' + if !empty(posshift) + exec 'norm! '. posshift .'h' + endif + endif + " TLogDBG getline(lineno) + " TLogDBG string(getline(1, '$')) + return grow +endf + + +function! tlib#buffer#InsertText0(text, ...) "{{{3 + TVarArg ['keyargs', {}] + let mode = get(keyargs, 'mode', 'i') + " TLogVAR mode + if !has_key(keyargs, 'shift') + let col = col('.') + " if mode =~ 'i' + " let col += 1 + " endif + let keyargs.shift = col >= col('$') ? 0 : -1 + " let keyargs.shift = col('.') >= col('$') ? 0 : -1 + " TLogVAR col + " TLogDBG col('.') .'-'. col('$') .': '. string(getline('.')) + endif + " TLogVAR keyargs.shift + return tlib#buffer#InsertText(a:text, keyargs) +endf + + +function! tlib#buffer#CurrentByte() "{{{3 + return line2byte(line('.')) + col('.') +endf + + +" Evaluate cmd while maintaining the cursor position and jump registers. +function! tlib#buffer#KeepCursorPosition(cmd) "{{{3 + " let pos = getpos('.') + let view = winsaveview() + try + keepjumps exec a:cmd + finally + " call setpos('.', pos) + call winrestview(view) + endtry +endf + diff --git a/vim/.vim/autoload/tlib/cache.vim b/vim/.vim/autoload/tlib/cache.vim new file mode 100755 index 0000000..2d59c3e --- /dev/null +++ b/vim/.vim/autoload/tlib/cache.vim @@ -0,0 +1,335 @@ +" cache.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2013-09-25. +" @Revision: 0.1.243 + + +" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. +" You might want to delete old files from this directory from time to +" time with a command like: > +" find ~/vimfiles/cache/ -atime +31 -type f -print -delete +TLet g:tlib_cache = '' + +" |tlib#cache#Purge()|: Remove cache files older than N days. +TLet g:tlib#cache#purge_days = 31 + +" Purge the cache every N days. Disable automatic purging by setting +" this value to a negative value. +TLet g:tlib#cache#purge_every_days = 31 + +" The encoding used for the purge-cache script. +" Default: 'enc' +TLet g:tlib#cache#script_encoding = &enc + +" Whether to run the directory removal script: +" 0 ... No +" 1 ... Query user +" 2 ... Yes +TLet g:tlib#cache#run_script = 1 + +" Verbosity level: +" 0 ... Be quiet +" 1 ... Display informative message +" 2 ... Display detailed messages +TLet g:tlib#cache#verbosity = 1 + +" A list of regexps that are matched against partial filenames of the +" cached files. If a regexp matches, the file won't be removed by +" |tlib#cache#Purge()|. +TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] + +" If the cache filename is longer than N characters, use +" |pathshorten()|. +TLet g:tlib#cache#max_filename = 200 + + +" :display: tlib#cache#Dir(?mode = 'bg') +" The default cache directory. +function! tlib#cache#Dir(...) "{{{3 + TVarArg ['mode', 'bg'] + let dir = tlib#var#Get('tlib_cache', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) + endif + return dir +endf + + +" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') +function! tlib#cache#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir() + let dir = dir0 + if a:0 >= 1 && !empty(a:1) + let file = a:1 + else + if empty(expand('%:t')) + return '' + endif + let file = expand('%:p') + let file = tlib#file#Relative(file, tlib#file#Join([dir, '..'])) + endif + " TLogVAR file, dir + let mkdir = a:0 >= 2 ? a:2 : 0 + let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g') + let dirs = [dir, a:type] + let dirf = fnamemodify(file, ':h') + if dirf != '.' + call add(dirs, dirf) + endif + let dir = tlib#file#Join(dirs) + " TLogVAR dir + let dir = tlib#dir#PlainName(dir) + " TLogVAR dir + let file = fnamemodify(file, ':t') + " TLogVAR file, dir, mkdir + let cache_file = tlib#file#Join([dir, file]) + if len(cache_file) > g:tlib#cache#max_filename + if v:version >= 704 + let shortfilename = pathshorten(file) .'_'. sha256(file) + else + let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file) + endif + let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) + else + if mkdir && !isdirectory(dir) + try + call mkdir(dir, 'p') + catch /^Vim\%((\a\+)\)\=:E739:/ + if filereadable(dir) && !isdirectory(dir) + echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir + " call delete(dir) + " call mkdir(dir, 'p') + endif + endtry + endif + endif + " TLogVAR cache_file + return cache_file +endf + + +let s:timestamps = {} + + +function! s:SetTimestamp(cfile, type) "{{{3 + if !has_key(s:timestamps, a:cfile) + let s:timestamps[a:cfile] = {} + endif + let s:timestamps[a:cfile].atime = getftime(a:cfile) + let s:timestamps[a:cfile][a:type] = s:timestamps[a:cfile].atime +endf + + +function! tlib#cache#Save(cfile, dictionary) "{{{3 + " TLogVAR a:cfile, a:dictionary + if !empty(a:cfile) + " TLogVAR a:dictionary + call writefile([string(a:dictionary)], a:cfile, 'b') + call s:SetTimestamp(a:cfile, 'write') + endif +endf + + +function! tlib#cache#MTime(cfile) "{{{3 + let mtime = {'mtime': getftime(a:cfile)} + let mtime = extend(mtime, get(s:timestamps, a:cfile, {})) + return mtime +endf + + +function! tlib#cache#Get(cfile, ...) "{{{3 + call tlib#cache#MaybePurge() + if !empty(a:cfile) && filereadable(a:cfile) + let val = readfile(a:cfile, 'b') + call s:SetTimestamp(a:cfile, 'read') + return eval(join(val, "\n")) + else + let default = a:0 >= 1 ? a:1 : {} + return default + endif +endf + + +" Get a cached value from cfile. If it is outdated (compared to ftime) +" or does not exist, create it calling a generator function. +function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 + if !filereadable(a:cfile) || (a:ftime != 0 && getftime(a:cfile) < a:ftime) + let args = a:0 >= 1 ? a:1 : [] + " TLogVAR a:generator, args + let val = call(a:generator, args) + " TLogVAR val + let cval = {'val': val} + " TLogVAR cval + call tlib#cache#Save(a:cfile, cval) + return val + else + let val = tlib#cache#Get(a:cfile) + return val.val + endif +endf + + +" Call |tlib#cache#Purge()| if the last purge was done before +" |g:tlib#cache#purge_every_days|. +function! tlib#cache#MaybePurge() "{{{3 + if g:tlib#cache#purge_every_days < 0 + return + endif + let dir = tlib#cache#Dir('g') + let last_purge = tlib#file#Join([dir, '.last_purge']) + let last_purge_exists = filereadable(last_purge) + if last_purge_exists + let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift + let should_purge = getftime(last_purge) < threshold + else + let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**']))) + endif + if should_purge + if last_purge_exists + let yn = 'y' + else + let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?" + let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no') + endif + if yn =~ '^y\%[es]$' + call tlib#cache#Purge() + else + let g:tlib#cache#purge_every_days = -1 + if !last_purge_exists + call s:PurgeTimestamp(dir) + endif + echohl WarningMsg + echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir + echohl NONE + endif + elseif !last_purge_exists + call s:PurgeTimestamp(dir) + endif +endf + + +" Delete old files. +function! tlib#cache#Purge() "{{{3 + let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift + let dir = tlib#cache#Dir('g') + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir + echohl NONE + endif + let files = tlib#cache#ListFilesInCache() + let deldir = [] + let newer = [] + let msg = [] + let more = &more + set nomore + try + for file in files + if isdirectory(file) + if empty(filter(copy(newer), 'strpart(v:val, 0, len(file)) ==# file')) + call add(deldir, file) + endif + else + if getftime(file) < threshold + if delete(file) + call add(msg, "TLib: Could not delete cache file: ". file) + elseif g:tlib#cache#verbosity >= 2 + call add(msg, "TLib: Delete cache file: ". file) + endif + else + call add(newer, file) + endif + endif + endfor + finally + let &more = more + endtry + if !empty(msg) && g:tlib#cache#verbosity >= 1 + echo join(msg, "\n") + endif + if !empty(deldir) + if &shell =~ 'sh\(\.exe\)\?$' + let scriptfile = 'deldir.sh' + let rmdir = 'rm -rf %s' + else + let scriptfile = 'deldir.bat' + let rmdir = 'rmdir /S /Q %s' + endif + let enc = g:tlib#cache#script_encoding + if has('multi_byte') && enc != &enc + call map(deldir, 'iconv(v:val, &enc, enc)') + endif + let scriptfile = tlib#file#Join([dir, scriptfile]) + if filereadable(scriptfile) + let script = readfile(scriptfile) + else + let script = [] + endif + let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') + let script = tlib#list#Uniq(script) + call writefile(script, scriptfile) + call inputsave() + if g:tlib#cache#run_script == 0 + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + if g:tlib#cache#verbosity >= 2 + echom "TLib: Purged cache. Need to run script to delete directories" + endif + echom "TLib: Please review and execute: ". scriptfile + echohl NONE + endif + else + try + let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') + if yn =~ '^y\%[es]$' + exec 'cd '. fnameescape(dir) + exec '! ' &shell shellescape(scriptfile, 1) + exec 'cd -' + call delete(scriptfile) + elseif yn =~ '^e\%[dit]$' + exec 'edit '. fnameescape(scriptfile) + endif + finally + call inputrestore() + endtry + endif + endif + call s:PurgeTimestamp(dir) +endf + + +function! s:PurgeTimestamp(dir) "{{{3 + let last_purge = tlib#file#Join([a:dir, '.last_purge']) + " TLogVAR last_purge + call writefile([" "], last_purge) +endf + +function! tlib#cache#ListFilesInCache(...) "{{{3 + let dir = a:0 >= 1 ? a:1 : tlib#cache#Dir('g') + if v:version > 702 || (v:version == 702 && has('patch51')) + let filess = glob(tlib#file#Join([dir, '**']), 1) + else + let filess = glob(tlib#file#Join([dir, '**'])) + endif + let files = reverse(split(filess, '\n')) + let pos0 = len(tlib#dir#CanonicName(dir)) + call filter(files, 's:ShouldPurge(strpart(v:val, pos0))') + return files +endf + + +function! s:ShouldPurge(partial_filename) "{{{3 + " TLogVAR a:partial_filename + for rx in g:tlib#cache#dont_purge + if a:partial_filename =~ rx + " TLogVAR a:partial_filename, rx + return 0 + endif + endfor + return 1 +endf + diff --git a/vim/.vim/autoload/tlib/char.vim b/vim/.vim/autoload/tlib/char.vim new file mode 100755 index 0000000..d3d2cb6 --- /dev/null +++ b/vim/.vim/autoload/tlib/char.vim @@ -0,0 +1,59 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 38 + + +" :def: function! tlib#char#Get(?timeout=0) +" Get a character. +" +" EXAMPLES: > +" echo tlib#char#Get() +" echo tlib#char#Get(5) +function! tlib#char#Get(...) "{{{3 + TVarArg ['timeout', 0], ['resolution', 0], ['getmod', 0] + let char = -1 + let mode = 0 + if timeout == 0 || !has('reltime') + let char = getchar() + else + let char = tlib#char#GetWithTimeout(timeout, resolution) + endif + if getmod + if char != -1 + let mode = getcharmod() + endif + return [char, mode] + else + return char + endif +endf + + +function! tlib#char#IsAvailable() "{{{3 + let ch = getchar(1) + return type(ch) == 0 && ch != 0 +endf + + +function! tlib#char#GetWithTimeout(timeout, ...) "{{{3 + TVarArg ['resolution', 2] + " TLogVAR a:timeout, resolution + let start = tlib#time#MSecs() + while 1 + let c = getchar(0) + if type(c) != 0 || c != 0 + return c + else + let now = tlib#time#MSecs() + let diff = tlib#time#DiffMSecs(now, start, resolution) + " TLogVAR diff + if diff > a:timeout + return -1 + endif + endif + endwh + return -1 +endf + + diff --git a/vim/.vim/autoload/tlib/cmd.vim b/vim/.vim/autoload/tlib/cmd.vim new file mode 100755 index 0000000..1fc270d --- /dev/null +++ b/vim/.vim/autoload/tlib/cmd.vim @@ -0,0 +1,111 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 55 + + +let g:tlib#cmd#last_output = [] + + +function! tlib#cmd#OutputAsList(command) "{{{3 + " TLogVAR a:command + if exists('s:redir_lines') + redir END + let cache = s:redir_lines + endif + let s:redir_lines = '' + redir =>> s:redir_lines + silent! exec a:command + redir END + let g:tlib#cmd#last_output = split(s:redir_lines, '\n') + unlet s:redir_lines + if exists('cache') + let s:redir_lines = cache + redir =>> s:redir_lines + endif + return g:tlib#cmd#last_output +endf + + +" See |:TBrowseOutput|. +function! tlib#cmd#BrowseOutput(command) "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#DefaultBrowseOutput", a:command) +endf + +" :def: function! tlib#cmd#BrowseOutputWithCallback(callback, command) +" Execute COMMAND and present its output in a |tlib#input#List()|; +" when a line is selected, execute the function named as the CALLBACK +" and pass in that line as an argument. +" +" The CALLBACK function gives you an opportunity to massage the COMMAND output +" and possibly act on it in a meaningful way. For example, if COMMAND listed +" all URIs found in the current buffer, CALLBACK could validate and then open +" the selected URI in the system's default browser. +" +" This function is meant to be a tool to help compose the implementations of +" powerful commands that use |tlib#input#List()| as a common interface. See +" |TBrowseScriptnames| as an example. +" +" EXAMPLES: > +" call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3 + let list = tlib#cmd#OutputAsList(a:command) + let cmds = tlib#input#List('m', 'Output of: '. a:command, list) + if !empty(cmds) + for cmd in cmds + let Callback = function(a:callback) + call call(Callback, [cmd]) + endfor + endif +endf + +function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3 + call feedkeys(':'. a:cmd) +endf + +function! tlib#cmd#ParseScriptname(line) "{{{3 + " let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') + let parsedValue = matchstr(a:line, '^\s*\d\+:\s*\zs.*$') + exe 'drop '. fnameescape(parsedValue) +endf + +" :def: function! tlib#cmd#UseVertical(?rx='') +" Look at the history whether the command was called with vertical. If +" an rx is provided check first if the last entry in the history matches +" this rx. +function! tlib#cmd#UseVertical(...) "{{{3 + TVarArg ['rx'] + let h0 = histget(':') + let rx0 = '\C\\s\+' + if !empty(rx) + let rx0 .= '.\{-}'.rx + endif + " TLogVAR h0, rx0 + return h0 =~ rx0 +endf + + +" Print the time in seconds or milliseconds (if your version of VIM +" has |+reltime|) a command takes. +function! tlib#cmd#Time(cmd) "{{{3 + if has('reltime') + let start = tlib#time#Now() + exec a:cmd + let end = tlib#time#Now() + let diff = string(tlib#time#Diff(end, start)) .'ms' + else + let start = localtime() + exec a:cmd + let diff = (localtime() - start) .'s' + endif + echom 'Time: '. diff .': '. a:cmd +endf + + +function! tlib#cmd#Capture(cmd) "{{{3 + redir => s + silent exec a:cmd + redir END + return s +endf + diff --git a/vim/.vim/autoload/tlib/comments.vim b/vim/.vim/autoload/tlib/comments.vim new file mode 100755 index 0000000..879cde1 --- /dev/null +++ b/vim/.vim/autoload/tlib/comments.vim @@ -0,0 +1,26 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 25 + + +" function! tlib#comments#Comments(?rx='') +function! tlib#comments#Comments(...) + TVarArg ['rx', ''] + let comments = {} + let co = &comments + while !empty(co) + " TLogVAR co + let [m_0, m_key, m_val, m_val1, co0, co; rest] = matchlist(co, '^\([^:]*\):\(\(\\.\|[^,]*\)\+\)\(,\(.*\)$\|$\)') + " TLogVAR m_key, m_val, co + if empty(m_key) + let m_key = ':' + endif + if empty(rx) || m_key =~ rx + let comments[m_key] = m_val + endif + endwh + return comments +endf + + diff --git a/vim/.vim/autoload/tlib/date.vim b/vim/.vim/autoload/tlib/date.vim new file mode 100755 index 0000000..482d72c --- /dev/null +++ b/vim/.vim/autoload/tlib/date.vim @@ -0,0 +1,120 @@ +" date.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-03-25. +" @Last Change: 2010-09-17. +" @Revision: 0.0.34 + + +if !exists('g:tlib#date#ShortDatePrefix') | let g:tlib#date#ShortDatePrefix = '20' | endif "{{{2 +if !exists('g:tlib#date#TimeZoneShift') | let g:tlib#date#TimeZoneShift = 0 | endif "{{{2 + +let g:tlib#date#dayshift = 60 * 60 * 24 + + +" :display: tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) +function! tlib#date#DiffInDays(date, ...) + let allow_zero = a:0 >= 2 ? a:2 : 0 + let s0 = tlib#date#SecondsSince1970(a:date, 0, allow_zero) + let s1 = a:0 >= 1 ? tlib#date#SecondsSince1970(a:1, 0, allow_zero) : localtime() + let dd = (s0 - s1) / g:tlib#date#dayshift + " TLogVAR dd + return dd +endf + + +" :display: tlib#date#Parse(date, ?allow_zero=0) "{{{3 +function! tlib#date#Parse(date, ...) "{{{3 + let min = a:0 >= 1 && a:1 ? 0 : 1 + " TLogVAR a:date, min + let m = matchlist(a:date, '^\(\d\{2}\|\d\{4}\)-\(\d\{1,2}\)-\(\d\{1,2}\)$') + if !empty(m) + let year = m[1] + let month = m[2] + let days = m[3] + else + let m = matchlist(a:date, '^\(\d\+\)/\(\d\{1,2}\)/\(\d\{1,2}\)$') + if !empty(m) + let year = m[1] + let month = m[3] + let days = m[2] + else + let m = matchlist(a:date, '^\(\d\{1,2}\)\.\s*\(\d\{1,2}\)\.\s*\(\d\d\{2}\|\d\{4}\)$') + if !empty(m) + let year = m[3] + let month = m[2] + let days = m[1] + endif + endif + endif + if empty(m) || year == '' || month == '' || days == '' || + \ month < min || month > 12 || days < min || days > 31 + echoerr 'TLib: Invalid date: '. a:date + return [] + endif + if strlen(year) == 2 + let year = g:tlib#date#ShortDatePrefix . year + endif + return [0 + year, 0 + month, 0 + days] +endf + + +" tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) +function! tlib#date#SecondsSince1970(date, ...) "{{{3 + let allow_zero = a:0 >= 2 ? a:2 : 0 + " TLogVAR a:date, allow_zero + let date = tlib#date#Parse(a:date, allow_zero) + if empty(date) + return 0 + endif + let [year, month, days] = date + if a:0 >= 1 && a:1 > 0 + let days = days + a:1 + end + let days_passed = days + let i = 1970 + while i < year + let days_passed = days_passed + 365 + if i % 4 == 0 || i == 2000 + let days_passed = days_passed + 1 + endif + let i = i + 1 + endwh + let i = 1 + while i < month + if i == 1 + let days_passed = days_passed + 31 + elseif i == 2 + let days_passed = days_passed + 28 + if year % 4 == 0 || year == 2000 + let days_passed = days_passed + 1 + endif + elseif i == 3 + let days_passed = days_passed + 31 + elseif i == 4 + let days_passed = days_passed + 30 + elseif i == 5 + let days_passed = days_passed + 31 + elseif i == 6 + let days_passed = days_passed + 30 + elseif i == 7 + let days_passed = days_passed + 31 + elseif i == 8 + let days_passed = days_passed + 31 + elseif i == 9 + let days_passed = days_passed + 30 + elseif i == 10 + let days_passed = days_passed + 31 + elseif i == 11 + let days_passed = days_passed + 30 + endif + let i = i + 1 + endwh + let seconds = (days_passed - 1) * 24 * 60 * 60 + let seconds = seconds + (strftime('%H') + g:tlib#date#TimeZoneShift) * 60 * 60 + let seconds = seconds + strftime('%M') * 60 + let seconds = seconds + strftime('%S') + return seconds +endf + diff --git a/vim/.vim/autoload/tlib/dir.vim b/vim/.vim/autoload/tlib/dir.vim new file mode 100755 index 0000000..256589b --- /dev/null +++ b/vim/.vim/autoload/tlib/dir.vim @@ -0,0 +1,93 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 39 + +" TLet g:tlib#dir#sep = '/' +TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/' + + +let s:dir_stack = [] + +" EXAMPLES: > +" tlib#dir#CanonicName('foo/bar') +" => 'foo/bar/' +function! tlib#dir#CanonicName(dirname) "{{{3 + let dirname = tlib#file#Canonic(a:dirname) + if dirname !~ '[/\\]$' + return dirname . g:tlib#dir#sep + endif + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#NativeName('foo/bar/') +" On Windows: +" => 'foo\bar\' +" On Linux: +" => 'foo/bar/' +function! tlib#dir#NativeName(dirname) "{{{3 + let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep) + let dirname = substitute(a:dirname, '[\/]', sep, 'g') + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#PlainName('foo/bar/') +" => 'foo/bar' +function! tlib#dir#PlainName(dirname) "{{{3 + let dirname = a:dirname + while index(['/', '\'], dirname[-1 : -1]) != -1 + let dirname = dirname[0 : -2] + endwh + return dirname + " return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '') +endf + + +" Create a directory if it doesn't already exist. +function! tlib#dir#Ensure(dir) "{{{3 + if !isdirectory(a:dir) + let dir = tlib#dir#PlainName(a:dir) + return mkdir(dir, 'p') + endif + return 1 +endf + + +" Return the first directory in &rtp. +function! tlib#dir#MyRuntime() "{{{3 + return get(split(&rtp, ','), 0) +endf + + +" :def: function! tlib#dir#CD(dir, ?locally=0) => CWD +function! tlib#dir#CD(dir, ...) "{{{3 + TVarArg ['locally', 0] + let cmd = locally ? 'lcd ' : 'cd ' + " let cwd = getcwd() + let cmd .= tlib#arg#Ex(a:dir) + " TLogVAR a:dir, locally, cmd + exec cmd + " return cwd + return getcwd() +endf + + +" :def: function! tlib#dir#Push(dir, ?locally=0) => CWD +function! tlib#dir#Push(dir, ...) "{{{3 + TVarArg ['locally', 0] + call add(s:dir_stack, [getcwd(), locally]) + return tlib#dir#CD(a:dir, locally) +endf + + +" :def: function! tlib#dir#Pop() => CWD +function! tlib#dir#Pop() "{{{3 + let [dir, locally] = remove(s:dir_stack, -1) + return tlib#dir#CD(dir, locally) +endf + + diff --git a/vim/.vim/autoload/tlib/eval.vim b/vim/.vim/autoload/tlib/eval.vim new file mode 100755 index 0000000..bfabcd4 --- /dev/null +++ b/vim/.vim/autoload/tlib/eval.vim @@ -0,0 +1,47 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 35 + + +function! tlib#eval#FormatValue(value, ...) "{{{3 + TVarArg ['indent', 0] + " TLogVAR a:value, indent + let indent1 = indent + 1 + let indenti = repeat(' ', &sw) + let type = type(a:value) + let acc = [] + if type == 0 || type == 1 || type == 2 + " TLogDBG 'Use string() for type='. type + call add(acc, string(a:value)) + elseif type == 3 "List + " TLogDBG 'List' + call add(acc, '[') + for e in a:value + call add(acc, printf('%s%s,', indenti, tlib#eval#FormatValue(e, indent1))) + unlet e + endfor + call add(acc, ']') + elseif type == 4 "Dictionary + " TLogDBG 'Dictionary' + call add(acc, '{') + let indent1 = indent + 1 + for [k, v] in items(a:value) + call add(acc, printf("%s%s: %s,", indenti, string(k), tlib#eval#FormatValue(v, indent1))) + unlet k v + endfor + call add(acc, '}') + else + " TLogDBG 'Unknown type: '. string(a:value) + call add(acc, string(a:value)) + endif + if indent > 0 + let is = repeat(' ', indent * &sw) + for i in range(1,len(acc) - 1) + let acc[i] = is . acc[i] + endfor + endif + return join(acc, "\n") +endf + + diff --git a/vim/.vim/autoload/tlib/file.vim b/vim/.vim/autoload/tlib/file.vim new file mode 100644 index 0000000..c16253d --- /dev/null +++ b/vim/.vim/autoload/tlib/file.vim @@ -0,0 +1,253 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 163 + + +if !exists('g:tlib#file#drop') + " If true, use |:drop| to edit loaded buffers (only available with GUI). + let g:tlib#file#drop = has('gui') "{{{2 +endif + + +if !exists('g:tlib#file#use_tabs') + let g:tlib#file#use_tabs = 0 "{{{2 +endif + + +if !exists('g:tlib#file#edit_cmds') + let g:tlib#file#edit_cmds = g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {} "{{{2 +endif + + +if !exists('g:tlib#file#absolute_filename_rx') + let g:tlib#file#absolute_filename_rx = '^\~\?[\/]' "{{{2 +endif + +""" File related {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + + +" EXAMPLES: > +" tlib#file#Split('foo/bar/filename.txt') +" => ['foo', 'bar', 'filename.txt'] +function! tlib#file#Split(filename) "{{{3 + let prefix = matchstr(a:filename, '^\(\w\+:\)\?/\+') + " TLogVAR prefix + if !empty(prefix) + let filename = a:filename[len(prefix) : -1] + else + let filename = a:filename + endif + let rv = split(filename, '[\/]') + " let rv = split(filename, '[\/]', 1) + if !empty(prefix) + call insert(rv, prefix[0:-2]) + endif + return rv +endf + + +" :display: tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) +" EXAMPLES: > +" tlib#file#Join(['foo', 'bar', 'filename.txt']) +" => 'foo/bar/filename.txt' +function! tlib#file#Join(filename_parts, ...) "{{{3 + TVarArg ['strip_slashes', 1], 'maybe_absolute' + " TLogVAR a:filename_parts, strip_slashes + if maybe_absolute + let filename_parts = [] + for part in a:filename_parts + if part =~ g:tlib#file#absolute_filename_rx + let filename_parts = [] + endif + call add(filename_parts, part) + endfor + else + let filename_parts = a:filename_parts + endif + if strip_slashes + " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$' + let rx = '[/\\]\+$' + let parts = map(copy(filename_parts), 'substitute(v:val, rx, "", "")') + " TLogVAR parts + return join(parts, g:tlib#dir#sep) + else + return join(filename_parts, g:tlib#dir#sep) + endif +endf + + +" EXAMPLES: > +" tlib#file#Relative('foo/bar/filename.txt', 'foo') +" => 'bar/filename.txt' +function! tlib#file#Relative(filename, basedir) "{{{3 + " TLogVAR a:filename, a:basedir + " TLogDBG getcwd() + " TLogDBG expand('%:p') + let b0 = tlib#file#Absolute(a:basedir) + let b = tlib#file#Split(b0) + " TLogVAR b + let f0 = tlib#file#Absolute(a:filename) + let fn = fnamemodify(f0, ':t') + let fd = fnamemodify(f0, ':h') + let f = tlib#file#Split(fd) + " TLogVAR f0, fn, fd, f + if f[0] != b[0] + let rv = f0 + else + while !empty(f) && !empty(b) + if f[0] != b[0] + break + endif + call remove(f, 0) + call remove(b, 0) + endwh + " TLogVAR f, b + let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) + endif + " TLogVAR rv + return rv +endf + + +function! tlib#file#Absolute(filename, ...) "{{{3 + if filereadable(a:filename) + let filename = fnamemodify(a:filename, ':p') + elseif a:filename =~ '^\(/\|[^\/]\+:\)' + let filename = a:filename + else + let cwd = a:0 >= 1 ? a:1 : getcwd() + let filename = tlib#file#Join([cwd, a:filename]) + endif + let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g') + let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g') + return filename +endf + + +function! tlib#file#Canonic(filename, ...) "{{{3 + TVarArg ['mode', ''] + if a:filename =~ '^\\\\' + let mode = 'windows' + elseif a:filename =~ '^\(file\|ftp\|http\)s\?:' + let mode = 'url' + elseif (empty(mode) && g:tlib#sys#windows) + let mode = 'windows' + endif + let filename = a:filename + if mode == 'windows' + let filename = substitute(filename, '/', '\\', 'g') + else + let filename = substitute(filename, '\\', '/', 'g') + endif + return filename +endf + + +function! s:SetScrollBind(world) "{{{3 + let sb = get(a:world, 'scrollbind', &scrollbind) + if sb != &scrollbind + let &scrollbind = sb + endif +endf + + +" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) +function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3 + " TLogVAR a:fcmd, a:bcmd, a:files + exec tlib#arg#Let([['world', {}]]) + call tlib#autocmdgroup#Init() + augroup TLibFileRead + autocmd! + augroup END + for f in a:files + let bn = bufnr('^'.f.'$') + " TLogVAR f, bn + let bufloaded = bufloaded(bn) + let ok = 0 + let s:bufread = "" + if bn != -1 && buflisted(bn) + if !empty(a:bcmd) + " TLogDBG a:bcmd .' '. bn + exec a:bcmd .' '. bn + let ok = 1 + call s:SetScrollBind(world) + endif + else + if filereadable(f) + if !empty(a:fcmd) + " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) + exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' + try + exec a:fcmd .' '. tlib#arg#Ex(f) + finally + exec 'autocmd! TLibFileRead BufRead' + endtry + let ok = 1 + call s:SetScrollBind(world) + endif + else + echohl error + echom 'File not readable: '. f + echohl NONE + endif + endif + " TLogVAR ok, bufloaded, &filetype + if empty(s:bufread) && ok && !bufloaded && empty(&filetype) + doautocmd BufRead + endif + endfor + augroup! TLibFileRead + unlet! s:bufread + " TLogDBG "done" +endf + + +" Return 0 if the file isn't readable/doesn't exist. +" Otherwise return 1. +function! tlib#file#Edit(fileid) "{{{3 + if type(a:fileid) == 0 + let bn = a:fileid + let filename = fnamemodify(bufname(bn), ':p') + else + let filename = fnamemodify(a:fileid, ':p') + let bn = bufnr(filename) + endif + if filename == expand('%:p') + return 1 + else + " TLogVAR a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename) + if bn != -1 && buflisted(bn) + if g:tlib#file#drop + " echom "DBG" get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + else + " echom "DBG" get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + exec get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + endif + return 1 + elseif filereadable(filename) + try + " let file = tlib#arg#Ex(filename) + " " TLogVAR file + " echom "DBG" get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + catch /E325/ + " swap file exists, let the user handle it + catch + echohl error + echom v:exception + echohl NONE + endtry + return 1 + else + echom "TLIB: File not readable: " . filename + if filename != a:fileid + echom "TLIB: original filename: " . a:fileid + endif + endif + endif + return 0 +endf + diff --git a/vim/.vim/autoload/tlib/fixes.vim b/vim/.vim/autoload/tlib/fixes.vim new file mode 100644 index 0000000..e9247dd --- /dev/null +++ b/vim/.vim/autoload/tlib/fixes.vim @@ -0,0 +1,14 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-02-22. +" @Revision: 3 + + +function! tlib#fixes#Winpos() "{{{3 + if has('gui_win32') + return 'winpos '. getwinposx() .' '. getwinposy() + else + return '' + endif +endf + diff --git a/vim/.vim/autoload/tlib/grep.vim b/vim/.vim/autoload/tlib/grep.vim new file mode 100644 index 0000000..894b1ee --- /dev/null +++ b/vim/.vim/autoload/tlib/grep.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-10-16. +" @Revision: 31 + + +function! tlib#grep#Do(cmd, rx, files) "{{{3 + " TLogVAR a:cmd, a:rx, a:files + let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ') + let rx = '/'. escape(a:rx, '/') .'/j' + " TLogVAR rx, files + silent exec a:cmd rx files +endf + + +function! tlib#grep#LocList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files) +endf + + +function! tlib#grep#QuickFixList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files) +endf + + +function! tlib#grep#List(rx, files) "{{{3 + call setqflist([]) + call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files) + let qfl = getqflist() + " TLogVAR qfl + " try + silent! colder + " catch + " call setqflist([], 'r') + " endtry + return qfl +endf + diff --git a/vim/.vim/autoload/tlib/hash.vim b/vim/.vim/autoload/tlib/hash.vim new file mode 100644 index 0000000..29c9ef6 --- /dev/null +++ b/vim/.vim/autoload/tlib/hash.vim @@ -0,0 +1,145 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 276 + + +if !exists('g:tlib#hash#use_crc32') + let g:tlib#hash#use_crc32 = '' "{{{2 +endif + + +if !exists('g:tlib#hash#use_adler32') + let g:tlib#hash#use_adler32 = '' "{{{2 +endif + + +function! tlib#hash#CRC32B(chars) "{{{3 + if !empty(g:tlib#hash#use_crc32) + let use = g:tlib#hash#use_crc32 + elseif has('ruby') + let use = 'ruby' + else + let use = 'vim' + endif + if exists('*tlib#hash#CRC32B_'. use) + return tlib#hash#CRC32B_{use}(a:chars) + else + throw "Unknown version of tlib#hash#CRC32B: ". use + endif +endf + + +function! tlib#hash#CRC32B_ruby(chars) "{{{3 + if has('ruby') + let rv = '' + if !exists('s:loaded_ruby_zlib') + ruby require 'zlib' + let s:loaded_ruby_zlib = 1 + endif + ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars"))) + return rv + else + throw "tlib#hash#CRC32B_ruby not supported in this version of vim" + endif +endf + + +function! tlib#hash#CRC32B_vim(chars) "{{{3 + if !exists('s:crc_table') + let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1) + let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0) + endif + let xFFFF_FFFF = repeat([1], 32) + let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits') + for char in split(a:chars, '\zs') + let octet = char2nr(char) + let r1 = tlib#bitwise#ShiftRight(crc, 8) + let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits') + let i1 = tlib#bitwise#XOR(i0, octet, 'bits') + let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits')) + let r2 = s:crc_table[i2] + let crc = tlib#bitwise#XOR(r1, r2, 'bits') + endfor + let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits') + let rv = tlib#bitwise#Bits2Num(crc, 16) + if len(rv) < 8 + let rv = repeat('0', 8 - len(rv)) . rv + endif + return rv +endf + + +" :nodoc: +function! tlib#hash#CreateCrcTable() "{{{3 + let sum = 0.0 + for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32] + let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0) + let sum += exp + endfor + let divisor = tlib#bitwise#Num2Bits(sum) + let crc_table = [] + for octet in range(256) + let remainder = tlib#bitwise#Num2Bits(octet) + for i in range(8) + if get(remainder, i) != 0 + let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits") + endif + endfor + let remainder = tlib#bitwise#ShiftRight(remainder, 8) + call add(crc_table, remainder) + endfor + return crc_table +endf + + +function! tlib#hash#Adler32(chars) "{{{3 + if !empty(g:tlib#hash#use_adler32) + let use = g:tlib#hash#use_adler32 + elseif exists('*or') + let use = 'vim' + else + let use = 'tlib' + endif + if exists('*tlib#hash#Adler32_'. use) + return tlib#hash#Adler32_{use}(a:chars) + else + throw "Unknown version of tlib#hash#Adler32_: ". use + endif +endf + + +function! tlib#hash#Adler32_vim(chars) "{{{3 + if exists('*or') + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = b * float2nr(pow(2, 16)) + let checksum = or(bb, a) + " TLogVAR checksum, a, b, bb + return printf("%08X", checksum) + else + throw "TLIB: Vim version doesn't support bitwise or()" + endif +endf + + +function! tlib#hash#Adler32_tlib(chars) "{{{3 + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16) + let checksum = tlib#bitwise#OR(bb, a, "bits") + return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16)) +endf + + diff --git a/vim/.vim/autoload/tlib/hook.vim b/vim/.vim/autoload/tlib/hook.vim new file mode 100755 index 0000000..07d0504 --- /dev/null +++ b/vim/.vim/autoload/tlib/hook.vim @@ -0,0 +1,25 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + + +" :def: function! tlib#hook#Run(hook, ?dict={}) +" Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. +function! tlib#hook#Run(hook, ...) "{{{3 + TVarArg ['dict', {}] + if has_key(dict, a:hook) + let hook = dict[a:hook] + else + let hook = tlib#var#Get(a:hook, 'wbg') + endif + if empty(hook) + return 0 + else + let world = dict + exec hook + return 1 + endif +endf + + diff --git a/vim/.vim/autoload/tlib/input.vim b/vim/.vim/autoload/tlib/input.vim new file mode 100644 index 0000000..0ca18cd --- /dev/null +++ b/vim/.vim/autoload/tlib/input.vim @@ -0,0 +1,1312 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1340 + + +" :filedoc: +" Input-related, select from a list etc. + +" If a list is bigger than this value, don't try to be smart when +" selecting an item. Be slightly faster instead. +" See |tlib#input#List()|. +TLet g:tlib#input#sortprefs_threshold = 200 + + +" If a list contains more items, |tlib#input#List()| does not perform an +" incremental "live search" but uses |input()| to query the user for a +" filter. This is useful on slower machines or with very long lists. +TLet g:tlib#input#livesearch_threshold = 1000 + + +" Determine how |tlib#input#List()| and related functions work. +" Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: +" glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, +" |g:tlib#Filter_glob#char|) are interpreted as glob-like +" |wildcards| (this is the default method) +" - Examples: +" - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_glob#New()|. +" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is +" expanded to "\.\{-}" +" - A period character (".") acts as a wildcard as if ".\{-}" (see +" |/\{-|) were entered. +" - Examples: +" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_cnfd#New()|. +" cnf .... Match substrings +" - A blank creates an AND conjunction, i.e. the next pattern has to +" match too. +" - A pipe character ("|") creates an OR conjunction, either this or +" the next next pattern has to match. +" - Patterns are very 'nomagic' |regexp| with a |\V| prefix. +" - A pattern starting with "-" makes the filter exclude items +" matching that pattern. +" - Examples: +" - "foo bar" matches items that contain the strings "foo" AND +" "bar". +" - "foo|bar boo|far" matches items that contain either ("foo" OR +" "bar") AND ("boo" OR "far"). +" - See also |tlib#Filter_cnf#New()|. +" seq .... Match sequences of characters +" - |tlib#Filter_seq#New()| +" fuzzy .. Match fuzzy character sequences +" - |tlib#Filter_fuzzy#New()| +TLet g:tlib#input#filter_mode = 'glob' + + +" The highlight group to use for showing matches in the input list +" window. +" See |tlib#input#List()|. +TLet g:tlib#input#higroup = 'IncSearch' + +" When 1, automatically select the last remaining item only if the list +" had only one item to begin with. +" When 2, automatically select a last remaining item after applying +" any filters. +" See |tlib#input#List()|. +TLet g:tlib_pick_last_item = 1 + + +" :doc: +" Keys for |tlib#input#List|~ + +TLet g:tlib#input#and = ' ' +TLet g:tlib#input#or = '|' +TLet g:tlib#input#not = '-' + +" When editing a list with |tlib#input#List|, typing these numeric chars +" (as returned by getchar()) will select an item based on its index, not +" based on its name. I.e. in the default setting, typing a "4" will +" select the fourth item, not the item called "4". +" In order to make keys 0-9 filter the items in the list and make +" select an item by its index, remove the keys 48 to 57 from +" this dictionary. +" Format: [KEY] = BASE ... the number is calculated as KEY - BASE. +" :nodefault: +TLet g:tlib#input#numeric_chars = { + \ 176: 176, + \ 177: 176, + \ 178: 176, + \ 179: 176, + \ 180: 176, + \ 181: 176, + \ 182: 176, + \ 183: 176, + \ 184: 176, + \ 185: 176, + \} + " \ 48: 48, + " \ 49: 48, + " \ 50: 48, + " \ 51: 48, + " \ 52: 48, + " \ 53: 48, + " \ 54: 48, + " \ 55: 48, + " \ 56: 48, + " \ 57: 48, + + +" :nodefault: +" The default key bindings for single-item-select list views. +" +" This variable is best customized via the variable +" g:tlib_extend_keyagents_InputList_s. If you want to use , +" to move the cursor up and down, add these two lines to your |vimrc| +" file: +" +" let g:tlib_extend_keyagents_InputList_s = { +" \ 10: 'tlib#agent#Down', +" \ 11: 'tlib#agent#Up' +" \ } +TLet g:tlib#input#keyagents_InputList_s = { + \ "\": 'tlib#agent#PageUp', + \ "\": 'tlib#agent#PageDown', + \ "\": 'tlib#agent#Home', + \ "\": 'tlib#agent#End', + \ "\": 'tlib#agent#Up', + \ "\": 'tlib#agent#Down', + \ "\": 'tlib#agent#UpN', + \ "\": 'tlib#agent#DownN', + \ "\": 'tlib#agent#ShiftLeft', + \ "\": 'tlib#agent#ShiftRight', + \ 18: 'tlib#agent#Reset', + \ 242: 'tlib#agent#Reset', + \ 17: 'tlib#agent#Input', + \ 241: 'tlib#agent#Input', + \ 27: 'tlib#agent#Exit', + \ 26: 'tlib#agent#Suspend', + \ 250: 'tlib#agent#Suspend', + \ 15: 'tlib#agent#SuspendToParentWindow', + \ "\": 'tlib#agent#Help', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#Wildcard', + \ 191: 'tlib#agent#Debug', + \ char2nr(g:tlib#input#or): 'tlib#agent#OR', + \ char2nr(g:tlib#input#and): 'tlib#agent#AND', + \ } + " \ 63: 'tlib#agent#Help', + +if exists('g:tlib_extend_keyagents_InputList_s') + let g:tlib#input#keyagents_InputList_s = extend(g:tlib#input#keyagents_InputList_s, g:tlib_extend_keyagents_InputList_s) +endif + + +" :nodefault: +TLet g:tlib#input#keyagents_InputList_m = { + \ 35: 'tlib#agent#Select', + \ "\": 'tlib#agent#SelectUp', + \ "\": 'tlib#agent#SelectDown', + \ 1: 'tlib#agent#SelectAll', + \ 225: 'tlib#agent#SelectAll', + \ "\": 'tlib#agent#ToggleRestrictView', + \ } +" "\": 'tlib#agent#Select' + +if exists('g:tlib_extend_keyagents_InputList_m') + let g:tlib#input#keyagents_InputList_m = extend(g:tlib#input#keyagents_InputList_m, g:tlib_extend_keyagents_InputList_m) +endif + + + +" :nodefault: +TLet g:tlib#input#handlers_EditList = [ + \ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '', 'help': 'Edit item'}, + \ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '', 'help': 'Delete item(s)'}, + \ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '', 'help': 'New item'}, + \ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '', 'help': 'Cut item(s)'}, + \ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '', 'help': 'Copy item(s)'}, + \ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '', 'help': 'Paste item(s)'}, + \ {'pick_last_item': 0}, + \ {'return_agent': 'tlib#agent#EditReturnValue'}, + \ {'help_extra': [ + \ 'Submit changes by pressing ENTER or or ', + \ 'Cancel editing by pressing c' + \ ]}, + \ ] + + +" A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to +" customize keyboard shortcuts in the list view. +TLet g:tlib#input#user_shortcuts = {} + + +" If true, define a popup menu for |tlib#input#List()| and related +" functions. +TLet g:tlib#input#use_popup = has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32')) + + +" How to format filenames: +" l ... Show basenames on the left side, separated from the +" directory names +" r ... Show basenames on the right side +TLet g:tlib#input#format_filename = 'l' + + +" If g:tlib#input#format_filename == 'r', how much space should be kept +" free on the right side. +TLet g:tlib#input#filename_padding_r = '&co / 10' + + +" If g:tlib#input#format_filename == 'l', an expression that +" |eval()|uates to the maximum display width of filenames. +TLet g:tlib#input#filename_max_width = '&co / 2' + + +" Functions related to tlib#input#List(type, ...) "{{{2 + +" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) +" Select a single or multiple items from a list. Return either the list +" of selected elements or its indexes. +" +" By default, typing numbers will select an item by its index. See +" |g:tlib#input#numeric_chars| to find out how to change this. +" +" The item is automatically selected if the numbers typed equals the +" number of digits of the list length. I.e. if a list contains 20 items, +" typing 1 will first highlight item 1 but it won't select/use it +" because 1 is an ambiguous input in this context. If you press enter, +" the first item will be selected. If you press another digit (e.g. 0), +" item 10 will be selected. Another way to select item 1 would be to +" type 01. If the list contains only 9 items, typing 1 would select the +" first item right away. +" +" type can be: +" s ... Return one selected element +" si ... Return the index of the selected element +" m ... Return a list of selected elements +" mi ... Return a list of indexes +" +" Several pattern matching styles are supported. See +" |g:tlib#input#filter_mode|. +" +" EXAMPLES: > +" echo tlib#input#List('s', 'Select one item', [100,200,300]) +" echo tlib#input#List('si', 'Select one item', [100,200,300]) +" echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) +" echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) +" +" See ../samples/tlib/input/tlib_input_list.vim (move the cursor over +" the filename and press gf) for a more elaborated example. +function! tlib#input#List(type, ...) "{{{3 + exec tlib#arg#Let([ + \ ['query', ''], + \ ['list', []], + \ ['handlers', []], + \ ['rv', ''], + \ ['timeout', 0], + \ ]) + " let handlers = a:0 >= 1 ? a:1 : [] + " let rv = a:0 >= 2 ? a:2 : '' + " let timeout = a:0 >= 3 ? a:3 : 0 + " let backchar = ["\", "\"] + + if a:type =~ '^resume' + let world = b:tlib_{matchstr(a:type, ' \zs.\+')} + else + let world = tlib#World#New({ + \ 'type': a:type, + \ 'base': list, + \ 'query': query, + \ 'timeout': timeout, + \ 'rv': rv, + \ 'handlers': handlers, + \ }) + let scratch_name = tlib#list#Find(handlers, 'has_key(v:val, "scratch_name")', '', 'v:val.scratch_name') + if !empty(scratch_name) + let world.scratch = scratch_name + endif + let world.scratch_vertical = tlib#list#Find(handlers, 'has_key(v:val, "scratch_vertical")', 0, 'v:val.scratch_vertical') + call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format')) + let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index') + let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table') + let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")') + let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")') + let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format') + let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent') + let world.help_extra = tlib#list#Find(handlers, 'has_key(v:val, "help_extra")', '', 'v:val.help_extra') + let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize') + let world.show_empty = tlib#list#Find(handlers, 'has_key(v:val, "show_empty")', 0, 'v:val.show_empty') + let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")', + \ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item') + let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")', + \ g:tlib#input#numeric_chars, 'v:val.numeric_chars') + let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")') + let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter') + if !empty(filter) + " let world.initial_filter = [[''], [filter]] + " let world.initial_filter = [[filter]] + " TLogVAR world.initial_filter + call world.SetInitialFilter(filter) + endif + endif + return tlib#input#ListW(world) +endf + + +" A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from +" dict. +function! tlib#input#ListD(dict) "{{{3 + return tlib#input#ListW(tlib#World#New(a:dict)) +endf + + +" :def: function! tlib#input#ListW(world, ?command='') +" The second argument (command) is meant for internal use only. +" The same as |tlib#input#List| but the arguments are packed into world +" (an instance of tlib#World as returned by |tlib#World#New|). +function! tlib#input#ListW(world, ...) "{{{3 + TVarArg 'cmd' + " let time0 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time0 + let world = a:world + if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1 + let rv = get(world.base, 0, world.rv) + if stridx(world.type, 'm') != -1 + return [rv] + else + return rv + endif + endif + call s:Init(world, cmd) + " TLogVAR world.state, world.sticky, world.initial_index + " let statusline = &l:statusline + " let laststatus = &laststatus + let showmode = &showmode + set noshowmode + let lastsearch = @/ + let scrolloff = &l:scrolloff + let &l:scrolloff = 0 + let @/ = '' + let dlist = [] + let post_keys = '' + " let &laststatus = 2 + + try + while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) + let post_keys = '' + " TLogDBG 'while' + " TLogVAR world.state + " let time01 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time01, time01 - time0 + try + call s:RunStateHandlers(world) + + " if exists('b:tlib_world_event') + " let event = b:tlib_world_event + " unlet! b:tlib_world_event + " if event == 'WinLeave' + " " let world.resume_state = world.state + " let world = tlib#agent#Suspend(world, world.rv) + " break + " endif + " endif + + " let time02 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time02, time02 - time0 + if world.state =~ '\' + " TLogDBG 'reset' + " call world.Reset(world.state =~ '\') + call world.Reset() + continue + endif + + call s:SetOffset(world) + + " let time02 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time02, time02 - time0 + " TLogDBG 1 + " TLogVAR world.state + if world.state == 'scroll' + let world.prefidx = world.offset + let world.state = 'redisplay' + endif + + if world.state =~ '\' + let world.sticky = 1 + endif + + " TLogVAR world.filter + " TLogVAR world.sticky + if world.state =~ '\' + " TLogVAR world.rv + throw 'picked' + elseif world.state =~ '\' + let world.rv = world.CurrentItem() + " TLogVAR world.rv + throw 'picked' + elseif world.state =~ 'display' + if world.state =~ '^display' + " let time03 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time03, time03 - time0 + if world.IsValidFilter() + + " let time1 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time1, time1 - time0 + call world.BuildTableList() + " let time2 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time2, time2 - time0 + " TLogDBG 2 + " TLogDBG len(world.table) + " TLogVAR world.table + " let world.list = map(copy(world.table), 'world.GetBaseItem(v:val)') + " TLogDBG 3 + let world.llen = len(world.list) + " TLogVAR world.index_table + if empty(world.index_table) + let dindex = range(1, world.llen) + let world.index_width = len(world.llen) + else + let dindex = world.index_table + let world.index_width = len(max(dindex)) + endif + " let time3 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time3, time3 - time0 + if world.llen == 0 && !world.show_empty + call world.ReduceFilter() + let world.offset = 1 + " TLogDBG 'ReduceFilter' + continue + else + if world.llen == 1 + let world.last_item = world.list[0] + if world.pick_last_item >= 2 + " echom 'Pick last item: '. world.list[0] + let world.prefidx = '1' + " TLogDBG 'pick last item' + throw 'pick' + endif + else + let world.last_item = '' + endif + endif + " let time4 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time4, time4 - time0 + " TLogDBG 4 + " TLogVAR world.idx, world.llen, world.state + " TLogDBG world.FilterIsEmpty() + if world.state == 'display' + if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty() + call world.SetPrefIdx() + else + let world.prefidx = world.idx == '' ? world.initial_index : world.idx + endif + if world.prefidx > world.llen + let world.prefidx = world.llen + elseif world.prefidx < 1 + let world.prefidx = 1 + endif + endif + " let time5 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time5, time5 - time0 + " TLogVAR world.initial_index, world.prefidx + " TLogDBG 5 + " TLogDBG len(world.list) + " TLogVAR world.list + let dlist = world.DisplayFormat(world.list) + " TLogVAR world.prefidx + " TLogDBG 6 + " let time6 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time6, time6 - time0 + if world.offset_horizontal > 0 + call map(dlist, 'v:val[world.offset_horizontal:-1]') + endif + " let time7 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time7, time7 - time0 + " TLogVAR dindex + let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]') + " TLogVAR dlist + " let time8 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time8, time8 - time0 + + else + + let dlist = ['Malformed filter'] + + endif + else + if world.prefidx == 0 + let world.prefidx = 1 + endif + endif + " TLogVAR world.idx, world.prefidx + + " TLogDBG 7 + " TLogVAR world.prefidx, world.offset + " TLogDBG (world.prefidx > world.offset + winheight(0) - 1) + " if world.prefidx > world.offset + winheight(0) - 1 + " let listtop = world.llen - winheight(0) + 1 + " let listoff = world.prefidx - winheight(0) + 1 + " let world.offset = min([listtop, listoff]) + " TLogVAR world.prefidx + " TLogDBG len(list) + " TLogDBG winheight(0) + " TLogVAR listtop, listoff, world.offset + " elseif world.prefidx < world.offset + " let world.offset = world.prefidx + " endif + " TLogDBG 8 + if world.initial_display || !tlib#char#IsAvailable() + " TLogDBG len(dlist) + call world.DisplayList(world.Query(), dlist) + call world.FollowCursor() + let world.initial_display = 0 + " TLogDBG 9 + endif + if world.state =~ '\' + let world.state = 'suspend' + else + let world.state = '' + endif + else + " if world.state == 'scroll' + " let world.prefidx = world.offset + " endif + call world.DisplayList() + if world.state == 'help' || world.state == 'printlines' + let world.state = 'display' + else + let world.state = '' + call world.FollowCursor() + endif + endif + " TAssert IsNotEmpty(world.scratch) + let world.list_wnr = winnr() + + " TLogVAR world.state, world.next_state + if !empty(world.next_state) + let world.state = world.next_state + let world.next_state = '' + endif + + if world.state =~ '\' + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + continue + endif + + if world.state =~ '\' + let query = matchstr(world.state, '\" + if v:mouse_win == world.list_wnr + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + " let world.offset = world.prefidx + if empty(world.prefidx) + " call feedkeys(c, 't') + let c = s:GetModdedChar(world) + let world.state = 'help' + continue + endif + throw 'pick' + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + elseif c == "\" + if v:mouse_win == world.list_wnr + call s:BuildMenu(world) + let world.state = 'redisplay' + if s:PopupmenuExists() == 1 + " if v:mouse_lnum != line('.') + " endif + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]' + call world.DisplayList() + if line('w$') - v:mouse_lnum < 6 + popup ]TLibInputListPopupMenu + else + popup! ]TLibInputListPopupMenu + endif + endif + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + " TLogVAR world.prefidx, world.state + elseif has_key(world.key_map[world.key_mode], 'unknown_key') + let agent = world.key_map[world.key_mode].unknown_key.agent + let world = call(agent, [world, c]) + call s:CheckAgentReturnValue(agent, world) + elseif c >= 32 + let world.state = 'display' + let numbase = get(world.numeric_chars, c, -99999) + " TLogVAR numbase, world.numeric_chars, c + if numbase != -99999 + let world.idx .= (c - numbase) + if len(world.idx) == world.index_width + let world.prefidx = world.idx + " TLogVAR world.prefidx + throw 'pick' + endif + else + let world.idx = '' + " TLogVAR world.filter + if world.llen > g:tlib#input#livesearch_threshold + let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) + if empty(pattern) + let world.state = 'exit empty' + else + call world.SetFrontFilter(pattern) + echo + endif + elseif c == 124 + call insert(world.filter[0], []) + else + call world.PushFrontFilter(c) + endif + " continue + if c == 45 && world.filter[0][0] == '-' + let world.state = 'redisplay' + end + endif + else + let world.state = 'redisplay' + " let world.state = 'continue' + endif + + catch /^picked$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = 'exit' + + catch /^pick$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = '' + " TLogDBG 'Pick item #'. world.prefidx + + finally + " TLogDBG 'finally 1', world.state + if world.state =~ '\' + " if !world.allow_suspend + " echom "Cannot be suspended" + " let world.state = 'redisplay' + " endif + elseif !empty(world.list) && !empty(world.base) + " TLogVAR world.list + if empty(world.state) + let world.rv = world.CurrentItem() + " TLogVAR world.state, world.rv + endif + " TLogVAR "postprocess" + for handler in world.post_handlers + let state = get(handler, 'postprocess', '') + " TLogVAR handler + " TLogVAR state + " TLogVAR world.state + if state == world.state + let agent = handler.agent + let [world, world.rv] = call(agent, [world, world.rv]) + " TLogVAR world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + endif + endfor + endif + " TLogDBG 'state0='. world.state + endtry + " TLogDBG 'state1='. world.state + endwh + + " TLogVAR world.state + " TLogDBG string(tlib#win#List()) + " TLogDBG 'exit while loop' + " TLogVAR world.list + " TLogVAR world.sel_idx + " TLogVAR world.idx + " TLogVAR world.prefidx + " TLogVAR world.rv + " TLogVAR world.type, world.state, world.return_agent, world.index_table, world.rv + if world.state =~ '\<\(empty\|escape\)\>' + let world.sticky = 0 + endif + if world.state =~ '\' + " TLogDBG 'return suspended' + " TLogVAR world.prefidx + " exec world.prefidx + return + elseif world.state =~ '\' + " TLog "empty" + " TLogDBG 'return empty' + " TLogVAR world.type + if stridx(world.type, 'm') != -1 + return [] + elseif stridx(world.type, 'i') != -1 + return 0 + else + return '' + endif + elseif !empty(world.return_agent) + " TLogDBG 'return agent' + " TLogVAR world.return_agent + call world.CloseScratch() + " TLogDBG "return_agent ". string(tlib#win#List()) + " TAssert IsNotEmpty(world.scratch) + return call(world.return_agent, [world, world.GetSelectedItems(world.rv)]) + elseif stridx(world.type, 'w') != -1 + " TLog "return_world" + " TLogDBG 'return world' + return world + elseif stridx(world.type, 'm') != -1 + " TLog "return_multi" + " TLogDBG 'return multi' + return world.GetSelectedItems(world.rv) + elseif stridx(world.type, 'i') != -1 + " TLog "return_index" + " TLogDBG 'return index' + if empty(world.index_table) + return world.rv + else + return world.index_table[world.rv - 1] + endif + else + " TLog "return_else" + " TLogDBG 'return normal' + return world.rv + endif + + finally + call world.Leave() + + " TLogVAR statusline + " let &l:statusline = statusline + " let &laststatus = laststatus + if &showmode != showmode + let &showmode = showmode + endif + silent! let @/ = lastsearch + let &l:scrolloff = scrolloff + if s:PopupmenuExists() == 1 + silent! aunmenu ]TLibInputListPopupMenu + endif + + " TLogDBG 'finally 2' + " TLogDBG string(world.Methods()) + " TLogVAR world.state + " TLogDBG string(tlib#win#List()) + if world.state !~ '\' + " redraw + " TLogVAR world.sticky, bufnr("%") + if world.sticky + " TLogDBG "sticky" + " TLogVAR world.bufnr + " TLogDBG bufwinnr(world.bufnr) + if world.scratch_split > 0 + if bufwinnr(world.bufnr) == -1 + " TLogDBG "UseScratch" + call world.UseScratch() + endif + let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv)) + endif + else + " TLogDBG "non sticky" + " TLogVAR world.state, world.win_wnr, world.bufnr + if world.CloseScratch() + " TLogVAR world.winview + call tlib#win#SetLayout(world.winview) + endif + endif + endif + " for i in range(0,5) + " call getchar(0) + " endfor + echo + redraw! + if !empty(post_keys) + " TLogVAR post_keys + call feedkeys(post_keys) + endif + endtry +endf + + +function! s:GetModdedChar(world) "{{{3 + let [char, mode] = tlib#char#Get(a:world.timeout, a:world.timeout_resolution, 1) + if char !~ '\D' && char > 0 && mode != 0 + return printf("<%s-%s>", mode, char) + else + return char + endif +endf + + +function! s:Init(world, cmd) "{{{3 + " TLogVAR a:cmd + let a:world.initial_display = 1 + if a:cmd =~ '\' + let a:world.sticky = 1 + endif + if a:cmd =~ '^resume' + call a:world.UseInputListScratch() + let a:world.initial_index = line('.') + if a:cmd =~ '\' + let a:world.state = 'pick' + let a:world.prefidx = a:world.initial_index + else + call a:world.Retrieve(1) + endif + " if !empty(a:world.resume_state) + " let a:world.state = a:world.resume_state + " endif + elseif !a:world.initialized + " TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr + let a:world.filetype = &filetype + let a:world.fileencoding = &fileencoding + call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb')) + call a:world.Initialize() + if !has_key(a:world, 'key_mode') + let a:world.key_mode = 'default' + endif + " TLogVAR has_key(a:world,'key_map') + if has_key(a:world, 'key_map') + " TLogVAR has_key(a:world.key_map,a:world.key_mode) + if has_key(a:world.key_map, a:world.key_mode) + let a:world.key_map[a:world.key_mode] = extend( + \ a:world.key_map[a:world.key_mode], + \ copy(g:tlib#input#keyagents_InputList_s), + \ 'keep') + else + let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s) + endif + else + let a:world.key_map = { + \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s) + \ } + endif + " TLogVAR a:world.type + if stridx(a:world.type, 'm') != -1 + call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force') + endif + for key_mode in keys(a:world.key_map) + let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') + endfor + if type(a:world.key_handlers) == 3 + call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers) + elseif type(a:world.key_handlers) == 4 + for [world_key_mode, world_key_handlers] in items(a:world.key_handlers) + call s:ExtendKeyMap(a:world, world_key_mode, world_key_handlers) + endfor + else + throw "tlib#input#ListW: key_handlers must be either a list or a dictionary" + endif + if !empty(a:cmd) + let a:world.state .= ' '. a:cmd + endif + endif + " TLogVAR a:world.state, a:world.sticky +endf + + +function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3 + for handler in a:key_handlers + let k = get(handler, 'key', '') + if !empty(k) + let a:world.key_map[a:key_mode][k] = handler + endif + endfor +endf + + +function s:PopupmenuExists() + if !g:tlib#input#use_popup + \ || exists(':popup') != 2 + \ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2')) + " \ || !has('gui_win32') + let rv = -1 + else + try + let rv = 1 + silent amenu ]TLibInputListPopupMenu + catch + let rv = 0 + endtry + endif + " TLogVAR rv + return rv +endf + + +function! s:BuildMenu(world) "{{{3 + if g:tlib#input#use_popup && s:PopupmenuExists() == 0 + call s:BuildItem('Pick\ selected\ item', {'key_name': '', 'eval': 'let world.state = "pick"'}) + call s:BuildItem('Cancel', {'key_name': '', 'agent': 'tlib#agent#Exit'}) + call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'}) + call s:BuildItem('Select\ all', {'key_name': '', 'agent': 'tlib#agent#SelectAll'}) + call s:BuildItem('Reset\ list', {'key_name': '', 'agent': 'tlib#agent#Reset'}) + call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'}) + for [key_mode, key_handlers] in items(a:world.key_map) + let keys = sort(keys(key_handlers)) + let mitems = {} + for key in keys + let handler = key_handlers[key] + let k = get(handler, 'key', '') + if !empty(k) && has_key(handler, 'help') && !empty(handler.help) + if empty(key_mode) || key_mode == 'default' + let mname = '' + else + let mname = escape(key_mode, ' .\') .'.' + endif + if has_key(handler, 'submenu') + let submenu = escape(handler.submenu, ' .\') + else + let submenu = '~' + endif + for mfield in ['menu', 'help', 'key_name', 'agent'] + if has_key(handler, mfield) + let mname .= escape(handler[mfield], ' .\') + break + endif + endfor + if !has_key(mitems, submenu) + let mitems[submenu] = {} + endif + let mitems[submenu][mname] = handler + endif + endfor + for msubname in sort(keys(mitems)) + let msubitems = mitems[msubname] + if msubname == '~' + let msubmname = '' + else + let msubmname = msubname .'.' + endif + for mname in sort(keys(msubitems)) + let msname = msubmname . mname + let handler = msubitems[mname] + call s:BuildItem(msname, handler) + " if has_key(handler, 'agent') + " call s:BuildItem(msname, {'agent': handler.agent}) + " else + " call s:BuildItem(msname, {'key': handler.key_name}) + " endif + endfor + endfor + endfor + endif +endf + + +function! s:BuildItem(menu, def) "{{{3 + if has('gui_win32') + let key_mode = 'c' + elseif has('gui_gtk') || has('gui_gtk2') + let key_mode = 'raw' + endif + for k in ['agent', 'eval', 'key_name', 'key'] + if has('gui_win32') + elseif has('gui_gtk') || has('gui_gtk') + if k == 'agent' || k == 'eval' + continue + endif + endif + try + if has_key(a:def, k) + let v = a:def[k] + if k == 'key' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + else + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v + endif + elseif k == 'key_name' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + else + let key = v + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key + endif + elseif k == 'agent' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + elseif k == 'eval' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + endif + return + endif + catch + endtry + endfor +endf + + +function! s:RunStateHandlers(world) "{{{3 + " Provide the variable "world" in the environment of an "exec" + " handler (ea). + let world = a:world + for handler in a:world.state_handlers + let eh = get(handler, 'state', '') + if !empty(eh) && a:world.state =~ eh + let ea = get(handler, 'exec', '') + if !empty(ea) + exec ea + else + let agent = get(handler, 'agent', '') + let a:world = call(agent, [a:world, a:world.GetSelectedItems(a:world.CurrentItem())]) + call s:CheckAgentReturnValue(agent, a:world) + endif + endif + endfor +endf + + +function! s:CheckAgentReturnValue(name, value) "{{{3 + if type(a:value) != 4 && !has_key(a:value, 'state') + echoerr 'Malformed agent: '. a:name + endif + return a:value +endf + + +function! s:SetOffset(world) "{{{3 + let llenw = len(a:world.base) - winheight(0) + 1 + if a:world.offset > llenw + let a:world.offset = llenw + endif + if a:world.offset < 1 + let a:world.offset = 1 + endif +endf + + +" Functions related to tlib#input#EditList(type, ...) "{{{2 + +" :def: function! tlib#input#EditList(query, list, ?timeout=0) +" Edit a list. +" +" EXAMPLES: > +" echo tlib#input#EditList('Edit:', [100,200,300]) +function! tlib#input#EditList(query, list, ...) "{{{3 + let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList + let default = a:0 >= 2 ? a:2 : [] + let timeout = a:0 >= 3 ? a:3 : 0 + " TLogVAR handlers + let rv = tlib#input#List('me', a:query, copy(a:list), handlers, default, timeout) + " TLogVAR rv + if empty(rv) + return a:list + else + let [success, list] = rv + return success ? list : a:list + endif +endf + + +function! tlib#input#Resume(name, pick, bufnr) "{{{3 + " TLogVAR a:name, a:pick + echo + if bufnr('%') != a:bufnr + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%') + echohl NONE + endif + let br = tlib#buffer#Set(a:bufnr) + endif + if !exists('b:tlib_'. a:name) + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%') + echohl NONE + redir => varss + silent let b: + redir END + let vars = split(varss, '\n') + call filter(vars, 'v:val =~ "^b:tlib_"') + echom "DEBUG tlib#input#Resume" string(vars) + endif + else + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter + if b:tlib_{a:name}.state =~ '\' + let b:tlib_{a:name}.state = 'redisplay' + else + let b:tlib_{a:name}.state .= ' redisplay' + endif + " call tlib#input#List('resume '. a:name) + let cmd = 'resume '. a:name + if a:pick >= 1 + let cmd .= ' pick' + if a:pick >= 2 + let cmd .= ' sticky' + end + endif + call tlib#input#ListW(b:tlib_{a:name}, cmd) + endif +endf + + +" :def: function! tlib#input#CommandSelect(command, ?keyargs={}) +" Take a command, view the output, and let the user select an item from +" its output. +" +" EXAMPLE: > +" command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') +" command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +function! tlib#input#CommandSelect(command, ...) "{{{3 + TVarArg ['args', {}] + if has_key(args, 'retrieve') + let list = call(args.retrieve) + elseif has_key(args, 'list') + let list = args.list + else + let list = tlib#cmd#OutputAsList(a:command) + endif + if has_key(args, 'filter') + call map(list, args.filter) + endif + let type = has_key(args, 'type') ? args.type : 's' + let handlers = has_key(args, 'handlers') ? args.handlers : [] + let rv = tlib#input#List(type, 'Select', list, handlers) + if !empty(rv) + if has_key(args, 'process') + let rv = call(args.process, [rv]) + endif + endif + return rv +endf + + +" :def: function! tlib#input#Edit(name, value, callback, ?cb_args=[]) +" +" Edit a value (asynchronously) in a scratch buffer. Use name for +" identification. Call callback when done (or on cancel). +" In the scratch buffer: +" Press or to enter the new value, c to cancel +" editing. +" EXAMPLES: > +" fun! FooContinue(success, text) +" if a:success +" let b:var = a:text +" endif +" endf +" call tlib#input#Edit('foo', b:var, 'FooContinue') +function! tlib#input#Edit(name, value, callback, ...) "{{{3 + " TLogVAR a:value + TVarArg ['args', []] + let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_wnr': winnr()} + let scr = tlib#scratch#UseScratch(sargs) + + " :nodoc: + map c :call EditCallback(0) + " :nodoc: + imap c call EditCallback(0) + " :nodoc: + map :call EditCallback(1) + " :nodoc: + imap call EditCallback(1) + " :nodoc: + map :call EditCallback(1) + " :nodoc: + imap call EditCallback(1) + + call tlib#normal#WithRegister('gg"tdG', 't') + call append(1, split(a:value, "\", 1)) + " let hrm = 'DON''T DELETE THIS HEADER' + " let hr3 = repeat('"', (tlib#win#Width(0) - len(hrm)) / 2) + let s:horizontal_line = repeat('`', tlib#win#Width(0)) + " hr3.hrm.hr3 + let hd = ['Keys: , ... save/accept; c ... cancel', s:horizontal_line] + call append(1, hd) + call tlib#normal#WithRegister('gg"tdd', 't') + syntax match TlibEditComment /^\%1l.*/ + syntax match TlibEditComment /^```.*/ + hi link TlibEditComment Comment + exec len(hd) + 1 + if type(a:callback) == 4 + let b:tlib_scratch_edit_callback = get(a:callback, 'submit', '') + call call(get(a:callback, 'init', ''), []) + else + let b:tlib_scratch_edit_callback = a:callback + endif + let b:tlib_scratch_edit_args = args + let b:tlib_scratch_edit_scratch = sargs + " exec 'autocmd BufDelete,BufHidden,BufUnload call s:EditCallback('. string(a:name) .')' + " echohl MoreMsg + " echom 'Press to enter, c to cancel editing.' + " echohl NONE +endf + + +function! s:EditCallback(...) "{{{3 + TVarArg ['ok', -1] + " , ['bufnr', -1] + " autocmd! BufDelete,BufHidden,BufUnload + if ok == -1 + let ok = confirm('Use value') + endif + let start = getline(2) == s:horizontal_line ? 3 : 1 + let text = ok ? join(getline(start, '$'), "\n") : '' + let cb = b:tlib_scratch_edit_callback + let args = b:tlib_scratch_edit_args + let sargs = b:tlib_scratch_edit_scratch + " TLogVAR cb, args, sargs + call tlib#scratch#CloseScratch(b:tlib_scratch_edit_scratch) + call tlib#win#Set(sargs.win_wnr) + call call(cb, args + [ok, text]) +endf + + +function! tlib#input#Dialog(text, options, default) "{{{3 + if has('dialog_con') || has('dialog_gui') + let opts = join(map(a:options, '"&". v:val'), "\n") + let val = confirm(a:text, opts) + if val + let yn = a:options[val - 1] + else + let yn = a:default + endif + else + let oi = index(a:options, a:default) + if oi == -1 + let opts = printf("(%s|%s)", join(a:options, '/'), a:default) + else + let options = copy(a:options) + let options[oi] = toupper(options[oi]) + let opts = printf("(%s)", join(a:options, '/')) + endif + let yn = inputdialog(a:text .' '. opts) + endif + return yn +endf + diff --git a/vim/.vim/autoload/tlib/list.vim b/vim/.vim/autoload/tlib/list.vim new file mode 100755 index 0000000..e8db414 --- /dev/null +++ b/vim/.vim/autoload/tlib/list.vim @@ -0,0 +1,182 @@ +" list.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2015-10-13. +" @Revision: 59 + + +""" List related functions {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + +" :def: function! tlib#list#Inject(list, initial_value, funcref) +" EXAMPLES: > +" echo tlib#list#Inject([1,2,3], 0, function('Add') +" => 6 +function! tlib#list#Inject(list, value, Function) "{{{3 + if empty(a:list) + return a:value + else + let item = a:list[0] + let rest = a:list[1:-1] + let value = call(a:Function, [a:value, item]) + return tlib#list#Inject(rest, value, a:Function) + endif +endf + + +" EXAMPLES: > +" tlib#list#Compact([0,1,2,3,[], {}, ""]) +" => [1,2,3] +function! tlib#list#Compact(list) "{{{3 + return filter(copy(a:list), '!empty(v:val)') +endf + + +" EXAMPLES: > +" tlib#list#Flatten([0,[1,2,[3,""]]]) +" => [0,1,2,3,""] +function! tlib#list#Flatten(list) "{{{3 + let acc = [] + for e in a:list + if type(e) == 3 + let acc += tlib#list#Flatten(e) + else + call add(acc, e) + endif + unlet e + endfor + return acc +endf + + +" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") +" Basically the same as filter() +" +" EXAMPLES: > +" tlib#list#FindAll([1,2,3], 'v:val >= 2') +" => [2, 3] +function! tlib#list#FindAll(list, filter, ...) "{{{3 + let rv = filter(copy(a:list), a:filter) + if a:0 >= 1 && a:1 != '' + let rv = map(rv, a:1) + endif + return rv +endf + + +" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") +" +" EXAMPLES: > +" tlib#list#Find([1,2,3], 'v:val >= 2') +" => 2 +function! tlib#list#Find(list, filter, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let expr = a:0 >= 2 ? a:2 : '' + return get(tlib#list#FindAll(a:list, a:filter, expr), 0, default) +endf + + +" EXAMPLES: > +" tlib#list#Any([1,2,3], 'v:val >= 2') +" => 1 +function! tlib#list#Any(list, expr) "{{{3 + return !empty(tlib#list#FindAll(a:list, a:expr)) +endf + + +" EXAMPLES: > +" tlib#list#All([1,2,3], 'v:val >= 2') +" => 0 +function! tlib#list#All(list, expr) "{{{3 + return len(tlib#list#FindAll(a:list, a:expr)) == len(a:list) +endf + + +" EXAMPLES: > +" tlib#list#Remove([1,2,1,2], 2) +" => [1,1,2] +function! tlib#list#Remove(list, element) "{{{3 + let idx = index(a:list, a:element) + if idx != -1 + call remove(a:list, idx) + endif + return a:list +endf + + +" EXAMPLES: > +" tlib#list#RemoveAll([1,2,1,2], 2) +" => [1,1] +function! tlib#list#RemoveAll(list, element) "{{{3 + call filter(a:list, 'v:val != a:element') + return a:list +endf + + +" :def: function! tlib#list#Zip(lists, ?default='') +" EXAMPLES: > +" tlib#list#Zip([[1,2,3], [4,5,6]]) +" => [[1,4], [2,5], [3,6]] +function! tlib#list#Zip(lists, ...) "{{{3 + TVarArg 'default' + let lists = copy(a:lists) + let max = 0 + for l in lists + let ll = len(l) + if ll > max + let max = ll + endif + endfor + " TLogVAR default, max + return map(range(0, max - 1), 's:GetNthElement(v:val, lists, default)') +endf + +function! s:GetNthElement(n, lists, default) "{{{3 + " TLogVAR a:n, a:lists, a:default + return map(copy(a:lists), 'get(v:val, a:n, a:default)') +endf + + +function! tlib#list#Uniq(list, ...) "{{{3 + TVarArg ['get_value', ''], ['remove_empty', 0] + if remove_empty + call filter(a:list, 'type(v:val) == 0 || !empty(v:val)') + endif + " CREDITS: Based on syntastic#util#unique(list) by scrooloose + let seen = {} + let uniques = [] + if empty(get_value) + for e in a:list + if !has_key(seen, e) + let seen[e] = 1 + call add(uniques, e) + endif + unlet e + endfor + else + for e in a:list + let v = eval(printf(get_value, string(e))) + if !has_key(seen, v) + let seen[v] = 1 + call add(uniques, e) + endif + unlet e + endfor + endif + return uniques +endf + + +function! tlib#list#ToDictionary(list, default, ...) "{{{3 + TVarArg ['generator', ''] + let dict = {} + for item in a:list + if !empty(item) + let dict[item] = empty(generator) ? a:default : call(generator, [item, a:default]) + endif + endfor + return dict +endf + diff --git a/vim/.vim/autoload/tlib/map.vim b/vim/.vim/autoload/tlib/map.vim new file mode 100755 index 0000000..c1af13f --- /dev/null +++ b/vim/.vim/autoload/tlib/map.vim @@ -0,0 +1,23 @@ +" map.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-08-23. +" @Last Change: 2009-08-23. +" @Revision: 0.0.4 + +let s:save_cpo = &cpo +set cpo&vim + + +" If |pumvisible()| is true, return "\". Otherwise return a:key. +" For use in maps like: > +" imap tlib#map#PumAccept("\") +function! tlib#map#PumAccept(key) "{{{3 + return pumvisible() ? "\" : a:key +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/autoload/tlib/normal.vim b/vim/.vim/autoload/tlib/normal.vim new file mode 100755 index 0000000..faaa444 --- /dev/null +++ b/vim/.vim/autoload/tlib/normal.vim @@ -0,0 +1,34 @@ +" normal.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-10-06. +" @Last Change: 2010-09-22. +" @Revision: 28 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') +" Execute a normal command while maintaining all registers. +function! tlib#normal#WithRegister(cmd, ...) "{{{3 + TVarArg ['register', 't'], ['norm_cmd', 'norm!'] + let registers = {} + for reg in split('123456789'. register, '\zs') + exec 'let registers[reg] = @'. reg + endfor + exec 'let reg = @'. register + try + exec norm_cmd .' '. a:cmd + exec 'return @'. register + finally + for [reg, value] in items(registers) + exec 'let @'. reg .' = value' + endfor + endtry +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/autoload/tlib/notify.vim b/vim/.vim/autoload/tlib/notify.vim new file mode 100755 index 0000000..2f45bdb --- /dev/null +++ b/vim/.vim/autoload/tlib/notify.vim @@ -0,0 +1,105 @@ +" notify.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-09-19. +" @Last Change: 2015-04-07. +" @Revision: 0.3.19 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#notify#Echo(text, ?style='') +" Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' +" in order to prevent |press-enter| messages. +function! tlib#notify#Echo(text, ...) + TVarArg 'style' + let ruler = &ruler + let showcmd = &showcmd + let text = substitute(a:text, '\n', '|', 'g') + try + set noruler + set noshowcmd + if !empty(style) + exec 'echohl' style + endif + echo strpart(text, 0, &columns - 1) + finally + if !empty(style) + echohl None + endif + let &ruler = ruler + let &showcmd = showcmd + endtry +endf + + +" Contributed by Erik Falor: +" If the line containing the message is too long, echoing it will cause +" a 'Hit ENTER' prompt to appear. This function cleans up the line so +" that does not happen. +" The echoed line is too long if it is wider than the width of the +" window, minus cmdline space taken up by the ruler and showcmd +" features. +function! tlib#notify#TrimMessage(message) "{{{3 + let filler = '...' + + " If length of message with tabs converted into spaces + length of + " line number + 2 (for the ': ' that follows the line number) is + " greater than the width of the screen, truncate in the middle + let to_fill = &columns + " TLogVAR to_fill + + " Account for space used by elements in the command-line to avoid + " 'Hit ENTER' prompts. + " If showcmd is on, it will take up 12 columns. + " If the ruler is enabled, but not displayed in the statusline, it + " will in its default form take 17 columns. If the user defines a + " custom &rulerformat, they will need to specify how wide it is. + if has('cmdline_info') + if &showcmd + let to_fill -= 12 + else + let to_fill -= 1 + endif + " TLogVAR &showcmd, to_fill + + " TLogVAR &laststatus, &ruler, &rulerformat + if &ruler + if &laststatus == 0 || winnr('$') == 1 + if has('statusline') + if &rulerformat == '' + " default ruler is 17 chars wide + let to_fill -= 17 + elseif exists('g:MP_rulerwidth') + let to_fill -= g:MP_rulerwidth + else + " tml: fallback: guess length + let to_fill -= strlen(&rulerformat) + endif + else + endif + endif + else + endif + else + let to_fill -= 1 + endif + + " TLogVAR to_fill + " TLogDBG strlen(a:message) + if strlen(a:message) > to_fill + let front = to_fill / 2 - 1 + let back = front + if to_fill % 2 == 0 | let back -= 1 | endif + return strpart(a:message, 0, front) . filler . + \strpart(a:message, strlen(a:message) - back) + else + return a:message + endif +endfunction + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/autoload/tlib/number.vim b/vim/.vim/autoload/tlib/number.vim new file mode 100644 index 0000000..94fde02 --- /dev/null +++ b/vim/.vim/autoload/tlib/number.vim @@ -0,0 +1,30 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 14 + + +function! tlib#number#ConvertBase(num, base, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'string' + " TLogVAR a:num, a:base, rtype + let rv = [] + let num = 0.0 + a:num + while floor(num) > 0.0 + let div = floor(num / a:base) + let num1 = float2nr(num - a:base * div) + if a:base <= 10 + call insert(rv, num1) + elseif a:base == 16 + let char = "0123456789ABCDEF"[num1] + call insert(rv, char) + endif + let num = num / a:base + endwh + " TLogVAR rv + if rtype == 'list' + return rv + else + return join(rv, '') + endif +endf + + diff --git a/vim/.vim/autoload/tlib/paragraph.vim b/vim/.vim/autoload/tlib/paragraph.vim new file mode 100755 index 0000000..dd0d112 --- /dev/null +++ b/vim/.vim/autoload/tlib/paragraph.vim @@ -0,0 +1,97 @@ +" paragraph.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-10-26. +" @Last Change: 2011-04-03. +" @Revision: 62 + +let s:save_cpo = &cpo +set cpo&vim + + +" Return an object describing a |paragraph|. +function! tlib#paragraph#GetMetric() "{{{3 + let sp = {'text_start': line("'{") + 1} + if line("'}") == line("$") + let sp.last = 1 + let sp.text_end = line("'}") + if line("'{") == 1 + let sp.ws_start = 0 + let sp.ws_end = 0 + let sp.top = sp.text_start + let sp.bottom = sp.text_end + else + let sp.ws_start = prevnonblank(line("'{")) + 1 + let sp.ws_end = line("'{") + let sp.top = sp.ws_start + let sp.bottom = sp.text_end + endif + else + let sp.last = 0 + let sp.text_end = line("'}") - 1 + let sp.ws_start = line("'}") + for i in range(line("'}"), line('$')) + if getline(i) =~ '\w' + let sp.ws_end = i - 1 + break + elseif i == line("$") + let sp.ws_end = i + endif + endfor + let sp.top = sp.text_start + let sp.bottom = sp.ws_end + endif + return sp +endf + + +" This function can be used with the tinymode plugin to move around +" paragraphs. +" +" Example configuration: > +" +" call tinymode#EnterMap("para_move", "gp") +" call tinymode#ModeMsg("para_move", "Move paragraph: j/k") +" call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") +" call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") +" call tinymode#ModeArg("para_move", "owncount", 1) +function! tlib#paragraph#Move(direction, count) + " TLogVAR a:direction, a:count + let mycount = empty(a:count) ? 1 : a:count + for i in range(1, mycount) + let para = tlib#paragraph#GetMetric() + " TLogVAR para + let text = getline(para.text_start, para.text_end) + let ws = getline(para.ws_start, para.ws_end) + " TLogVAR text, ws + exec para.top .','. para.bottom .'delete' + if a:direction == "Down" + let other = tlib#paragraph#GetMetric() + let target = other.bottom + 1 + if other.last + let lines = ws + text + let pos = target + len(ws) + else + let lines = text + ws + let pos = target + endif + elseif a:direction == "Up" + if !para.last + norm! { + endif + let other = tlib#paragraph#GetMetric() + let target = other.text_start + let lines = text + ws + let pos = target + endif + " TLogVAR other, target + " TLogVAR lines + call append(target - 1, lines) + exec pos + endfor +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/autoload/tlib/persistent.vim b/vim/.vim/autoload/tlib/persistent.vim new file mode 100644 index 0000000..de3d487 --- /dev/null +++ b/vim/.vim/autoload/tlib/persistent.vim @@ -0,0 +1,47 @@ +" persistent.vim -- Persistent data +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-05-11. +" @Last Change: 2012-05-11. +" @Revision: 12 + +" The directory for persistent data files. If empty, use +" |tlib#dir#MyRuntime|.'/share'. +TLet g:tlib_persistent = '' + + +" :display: tlib#persistent#Dir(?mode = 'bg') +" Return the full directory name for persistent data files. +function! tlib#persistent#Dir() "{{{3 + TVarArg ['mode', 'bg'] + let dir = tlib#var#Get('tlib_persistent', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'share']) + endif + return dir +endf + +" :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0) +function! tlib#persistent#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let file = a:0 >= 1 ? a:1 : '' + let mkdir = a:0 >= 2 ? a:2 : 0 + return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir()) +endf + +function! tlib#persistent#Get(...) "{{{3 + return call('tlib#cache#Get', a:000) +endf + +function! tlib#persistent#MTime(cfile) "{{{3 + return tlib#cache#MTime(a:cfile) +endf + +function! tlib#persistent#Value(...) "{{{3 + return call('tlib#cache#Value', a:000) +endf + +function! tlib#persistent#Save(cfile, dictionary) "{{{3 + call tlib#cache#Save(a:cfile, a:dictionary) +endf + diff --git a/vim/.vim/autoload/tlib/progressbar.vim b/vim/.vim/autoload/tlib/progressbar.vim new file mode 100755 index 0000000..5353ffe --- /dev/null +++ b/vim/.vim/autoload/tlib/progressbar.vim @@ -0,0 +1,72 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 70 + +let s:statusline = [] +let s:laststatus = [] +let s:max = [] +let s:format = [] +let s:width = [] +let s:value = [] +let s:timestamp = -1 + +" EXAMPLE: > +" call tlib#progressbar#Init(20) +" try +" for i in range(20) +" call tlib#progressbar#Display(i) +" call DoSomethingThatTakesSomeTime(i) +" endfor +" finally +" call tlib#progressbar#Restore() +" endtry +function! tlib#progressbar#Init(max, ...) "{{{3 + TVarArg ['format', '%s'], ['width', 10] + call insert(s:statusline, &statusline) + call insert(s:laststatus, &laststatus) + call insert(s:max, a:max) + call insert(s:format, format) + call insert(s:width, width) + call insert(s:value, -1) + let &laststatus = 2 + let s:timestamp = localtime() +endf + + +function! tlib#progressbar#Display(value, ...) "{{{3 + TVarArg 'extra' + let ts = localtime() + if ts == s:timestamp + return + else + let s:timestamp = ts + endif + let val = a:value * s:width[0] / s:max[0] + if val != s:value[0] + let s:value[0] = val + let pbl = repeat('#', val) + let pbr = repeat('.', s:width[0] - val) + let txt = printf(s:format[0], '['.pbl.pbr.']') . extra + let &l:statusline = txt + " TLogDBG txt + redrawstatus + " redraw + " call tlib#notify#Echo(txt) + endif +endf + + +function! tlib#progressbar#Restore() "{{{3 + let &l:statusline = remove(s:statusline, 0) + let &laststatus = remove(s:laststatus, 0) + redrawstatus + " redraw + " echo + call remove(s:max, 0) + call remove(s:format, 0) + call remove(s:width, 0) + call remove(s:value, 0) +endf + + diff --git a/vim/.vim/autoload/tlib/rx.vim b/vim/.vim/autoload/tlib/rx.vim new file mode 100755 index 0000000..b4c0bd9 --- /dev/null +++ b/vim/.vim/autoload/tlib/rx.vim @@ -0,0 +1,55 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 29 + + +" :def: function! tlib#rx#Escape(text, ?magic='m') +" magic can be one of: m, M, v, V +" See :help 'magic' +function! tlib#rx#Escape(text, ...) "{{{3 + TVarArg 'magic' + if empty(magic) + let magic = 'm' + endif + if magic =~# '^\\\?m$' + return escape(a:text, '^$.*\[]~') + elseif magic =~# '^\\\?M$' + return escape(a:text, '^$\') + elseif magic =~# '^\\\?V$' + return escape(a:text, '\') + elseif magic =~# '^\\\?v$' + return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g') + else + echoerr 'tlib: Unsupported magic type' + return a:text + endif +endf + +" :def: function! tlib#rx#EscapeReplace(text, ?magic='m') +" Escape return |sub-replace-special|. +function! tlib#rx#EscapeReplace(text, ...) "{{{3 + TVarArg ['magic', 'm'] + if magic ==# 'm' || magic ==# 'v' + return escape(a:text, '\&~') + elseif magic ==# 'M' || magic ==# 'V' + return escape(a:text, '\') + else + echoerr 'magic must be one of: m, v, M, V' + endif +endf + + +function! tlib#rx#Suffixes(...) "{{{3 + TVarArg ['magic', 'm'] + let sfx = split(&suffixes, ',') + call map(sfx, 'tlib#rx#Escape(v:val, magic)') + if magic ==# 'v' + return '('. join(sfx, '|') .')$' + elseif magic ==# 'V' + return '\('. join(sfx, '\|') .'\)\$' + else + return '\('. join(sfx, '\|') .'\)$' + endif +endf + diff --git a/vim/.vim/autoload/tlib/scratch.vim b/vim/.vim/autoload/tlib/scratch.vim new file mode 100755 index 0000000..c9df64d --- /dev/null +++ b/vim/.vim/autoload/tlib/scratch.vim @@ -0,0 +1,136 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 255 + + +" Scratch window position. By default the list window is opened on the +" bottom. Set this variable to 'topleft' or '' to change this behaviour. +" See |tlib#input#List()|. +TLet g:tlib_scratch_pos = 'botright' + +" If you want the scratch buffer to be fully removed, you might want to +" set this variable to 'wipe'. +" See also https://github.com/tomtom/tlib_vim/pull/16 +TLet g:tlib#scratch#hidden = 'hide' + + +" :def: function! tlib#scratch#UseScratch(?keyargs={}) +" Display a scratch buffer (a buffer with no file). See :TScratch for an +" example. +" Return the scratch buffer's number. +" Values for keyargs: +" scratch_split ... 1: split, 0: window, -1: tab +function! tlib#scratch#UseScratch(...) "{{{3 + exec tlib#arg#Let([['keyargs', {}]]) + " TLogDBG string(keys(keyargs)) + let id = get(keyargs, 'scratch', '__Scratch__') + " TLogVAR id, bufwinnr(id) + " TLogVAR bufnr(id), bufname(id) + " TLogVAR 1, winnr(), bufnr('%'), bufname("%") + if bufwinnr(id) != -1 + " echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + " TLogVAR "reuse", bufnr("%"), bufname("%") + else + let winpos = '' + let bn = bufnr(id) + let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos) + " TLogVAR keyargs.scratch_vertical + if get(keyargs, 'scratch_vertical') + let wpos .= ' vertical' + let winpos = tlib#fixes#Winpos() + endif + " TLogVAR wpos + let scratch_split = get(keyargs, 'scratch_split', 1) + if bn != -1 + " TLogVAR bn + let wn = bufwinnr(bn) + if wn != -1 + " TLogVAR wn + exec 'noautocmd keepalt keepj' (wn .'wincmd w') + else + if scratch_split == 1 + let cmd = wpos.' sbuffer!' + elseif scratch_split == -1 + let cmd = wpos.' tab sbuffer!' + else + let cmd = 'buffer!' + endif + " TLogVAR cmd, bn + silent exec 'noautocmd keepalt keepj' cmd bn + endif + else + " TLogVAR id + if scratch_split == 1 + let cmd = wpos.' split' + elseif scratch_split == -1 + let cmd = wpos.' tab split' + else + let cmd = 'edit' + endif + " TLogVAR cmd, id + silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ') + " silent exec 'split '. id + endif + let ft = get(keyargs, 'scratch_filetype', '') + " TLogVAR ft, winpos + if !empty(winpos) + exec winpos + endif + setlocal buftype=nofile + let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden) + setlocal noswapfile + setlocal nobuflisted + setlocal foldmethod=manual + setlocal foldcolumn=0 + setlocal nospell + setlocal modifiable + setlocal noreadonly + " TLogVAR &ft, ft + if !empty(ft) + let &l:ft = ft + endif + endif + let keyargs.scratch = bufnr('%') + let keyargs.scratch_tabpagenr = tabpagenr() + let keyargs.scratch_winnr = winnr() + " TLogVAR 2, winnr(), bufnr('%'), bufname("%"), keyargs.scratch + return keyargs.scratch +endf + + +" Close a scratch buffer as defined in keyargs (usually a World). +" Return 1 if the scratch buffer is closed (or if it already was +" closed). +function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3 + TVarArg ['reset_scratch', 1] + let scratch = get(a:keyargs, 'scratch', '') + " TLogVAR scratch, reset_scratch + " TLogDBG string(tlib#win#List()) + if !empty(scratch) && winnr('$') > 1 + let wn = bufwinnr(scratch) + " TLogVAR wn + try + if wn != -1 + " TLogDBG winnr() + let wb = tlib#win#Set(wn) + let winpos = tlib#fixes#Winpos() + wincmd c + if get(a:keyargs, 'scratch_vertical') && !empty(winpos) + exec winpos + endif + " exec wb + " redraw + " TLogVAR winnr() + endif + return 1 + finally + if reset_scratch + let a:keyargs.scratch = '' + endif + endtry + endif + return 0 +endf + diff --git a/vim/.vim/autoload/tlib/signs.vim b/vim/.vim/autoload/tlib/signs.vim new file mode 100755 index 0000000..1664680 --- /dev/null +++ b/vim/.vim/autoload/tlib/signs.vim @@ -0,0 +1,103 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-03-12. +" @Last Change: 2011-03-10. +" @Revision: 0.0.45 + +let s:save_cpo = &cpo +set cpo&vim + + +let s:base = 2327 +let s:register = {} + + +" Clear all signs with name SIGN. +function! tlib#signs#ClearAll(sign) "{{{3 + " TLog a:sign + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" Clear all signs with name SIGN in buffer BUFNR. +function! tlib#signs#ClearBuffer(sign, bufnr) "{{{3 + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == a:bufnr') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" function! tlib#signs#Clear(sign, list) "{{{3 +" " TLogVAR a:sign +" let done = [] +" for item in a:list +" let bn = get(item, 'bufnr', -1) +" if index(done, bn) == -1 +" let idxs = keys(s:register) +" call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == bn') +" for idx in idxs +" exec 'sign unplace '. idx .' buffer='. s:register[idx].bn +" call remove(s:register, idx) +" endfor +" call add(done, bn) +" endif +" endfor +" endf + + +" Add signs for all locations in LIST. LIST must adhere with the +" quickfix list format (see |getqflist()|; only the fields lnum and +" bufnr are required). +" +" list:: a quickfix or location list +" sign:: a sign defined with |:sign-define| +function! tlib#signs#Mark(sign, list) "{{{3 + " TLogVAR a:sign + for item in a:list + let idx = s:SignId(item) + if idx >= 0 + let lnum = get(item, 'lnum', 0) + if lnum > 0 + let bn = get(item, 'bufnr') + exec ':sign place '. idx .' line='. lnum .' name='. a:sign .' buffer='. bn + let s:register[idx] = {'sign': a:sign, 'bn': bn} + endif + endif + endfor +endf + + +function! s:SignId(item) "{{{3 + " TLogVAR a:item + " let bn = bufnr('%') + let bn = get(a:item, 'bufnr', -1) + if bn == -1 + return -1 + else + let idx = s:base + bn * 500 + while has_key(s:register, idx) + let idx += 1 + endwh + return idx + endif +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/autoload/tlib/string.vim b/vim/.vim/autoload/tlib/string.vim new file mode 100755 index 0000000..62218a4 --- /dev/null +++ b/vim/.vim/autoload/tlib/string.vim @@ -0,0 +1,150 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 116 + + +" :def: function! tlib#string#RemoveBackslashes(text, ?chars=' ') +" Remove backslashes from text (but only in front of the characters in +" chars). +function! tlib#string#RemoveBackslashes(text, ...) "{{{3 + exec tlib#arg#Get(1, 'chars', ' ') + " TLogVAR chars + let rv = substitute(a:text, '\\\(['. chars .']\)', '\1', 'g') + return rv +endf + + +" :display: tlib#string#Chomp(string, ?max=0) +function! tlib#string#Chomp(string, ...) "{{{3 + let quant = a:0 >= 1 ? '\{,'. a:1 .'}' : '\+' + return substitute(a:string, '[[:cntrl:][:space:]]'. quant .'$', '', '') +endf + + +function! tlib#string#Format(template, dict) "{{{3 + let parts = split(a:template, '\ze%\({.\{-}}\|.\)') + let out = [] + for part in parts + let ml = matchlist(part, '^%\({\(.\{-}\)}\|\(.\)\)\(.*\)$') + if empty(ml) + let rest = part + else + let var = empty(ml[2]) ? ml[3] : ml[2] + let rest = ml[4] + if has_key(a:dict, var) + call add(out, a:dict[var]) + elseif var == '%%' + call add(out, '%') + else + call add(out, ml[1]) + endif + endif + call add(out, rest) + endfor + return join(out, '') +endf + + +" This function deviates from |printf()| in certain ways. +" Additional items: +" %{rx} ... insert escaped regexp +" %{fuzzyrx} ... insert typo-tolerant regexp +function! tlib#string#Printf1(format, string) "{{{3 + let s = split(a:format, '%.\zs') + " TLogVAR s + return join(map(s, 's:PrintFormat(v:val, a:string)'), '') +endf + +function! s:PrintFormat(format, string) "{{{3 + let cut = match(a:format, '%\({.\{-}}\|.\)$') + if cut == -1 + return a:format + else + let head = cut > 0 ? a:format[0 : cut - 1] : '' + let tail = a:format[cut : -1] + " TLogVAR head, tail + if tail == '%{fuzzyrx}' + let frx = [] + for i in range(len(a:string)) + if i > 0 + let pb = i - 1 + else + let pb = 0 + endif + let slice = tlib#rx#Escape(a:string[pb : i + 1]) + call add(frx, '['. slice .']') + call add(frx, '.\?') + endfor + let tail = join(frx, '') + elseif tail == '%{rx}' + let tail = tlib#rx#Escape(a:string) + elseif tail == '%%' + let tail = '%' + elseif tail == '%s' + let tail = a:string + endif + " TLogVAR tail + return head . tail + endif +endf +" function! tlib#string#Printf1(format, string) "{{{3 +" let n = len(split(a:format, '%\@ 0 +" let pb = i - 1 +" else +" let pb = 0 +" endif +" let slice = tlib#rx#Escape(a:string[pb : i + 1]) +" call add(frx, '['. slice .']') +" call add(frx, '.\?') +" endfor +" let f = s:RewriteFormatString(f, '%{fuzzyrx}', join(frx, '')) +" endif +" if f =~ '%\@= 1 ? a:1 : !g:tlib#sys#windows + if !executable && !ignore_cyg + let executable = tlib#sys#IsCygwinBin(a:cmd) + " TLogVAR 2, executable + endif + let s:executables[a:cmd] = executable + endif + " echom "DBG s:executables[a:cmd]" s:executables[a:cmd] + return s:executables[a:cmd] +endf + + +if !exists('g:tlib#sys#check_cygpath') + " If true, check whether we have to convert a path via cyppath -- + " see |tlib#sys#MaybeUseCygpath| + let g:tlib#sys#check_cygpath = g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1) "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_path_rx') + " If a full windows filename (with slashes instead of backslashes) + " matches this |regexp|, it is assumed to be a cygwin executable. + let g:tlib#sys#cygwin_path_rx = '/cygwin/' "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_expr') + " For cygwin binaries, convert command calls using this vim + " expression. + let g:tlib#sys#cygwin_expr = '"bash -c ''". escape(%s, "''\\") ."''"' "{{{2 +endif + + +function! tlib#sys#GetCmd(cmd) "{{{3 + if !empty(g:tlib#sys#cygwin_expr) && tlib#sys#IsCygwinBin(matchstr(a:cmd, '^\S\+')) + let cmd = eval(printf(g:tlib#sys#cygwin_expr, string(a:cmd))) + " TLogVAR cmd + return cmd + else + return a:cmd + endif +endf + + +" If cmd seems to be a cygwin executable, use cygpath to convert +" filenames. This assumes that cygwin's which command returns full +" filenames for non-cygwin executables. +function! tlib#sys#MaybeUseCygpath(cmd) "{{{3 + " echom "DBG" a:cmd + if g:tlib#sys#check_cygpath && tlib#sys#IsCygwinBin(a:cmd) + return 'cygpath -u "%s"' + endif + return '' +endf + + +function! tlib#sys#ConvertPath(converter, filename) "{{{3 + return tlib#string#Chomp(system(printf(a:converter, shellescape(a:filename)))) +endf + + +let s:native_filenames = {} + +function! tlib#sys#FileArgs(cmd, files) "{{{3 + let cygpath = tlib#sys#MaybeUseCygpath(a:cmd) + " TLogVAR cygpath + if empty(cygpath) + return a:files + else + let files = map(copy(a:files), 'has_key(s:native_filenames, v:val) ? s:native_filenames[v:val] : tlib#sys#CygPath(v:val)') + return files + endif +endf + + +" Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it +" is a special file that should not be opened in vim. +function! tlib#sys#IsSpecial(filename) abort "{{{3 + return a:filename =~ g:tlib#sys#system_rx +endf + + +" Open filename with the default OS application (see +" |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. +" Returns 1 if successful or 0 otherwise. +function! tlib#sys#Open(filename) abort "{{{3 + if !empty(g:tlib#sys#system_browser) && tlib#sys#IsSpecial(a:filename) + try + let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) + exec cmd + return 1 + catch + echohl ErrorMsg + echom v:exception + echohl NONE + endtry + endif + return 0 +endf + diff --git a/vim/.vim/autoload/tlib/tab.vim b/vim/.vim/autoload/tlib/tab.vim new file mode 100755 index 0000000..fa6bb8d --- /dev/null +++ b/vim/.vim/autoload/tlib/tab.vim @@ -0,0 +1,49 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +" Return a dictionary of bufnumbers => [[tabpage, winnr] ...] +function! tlib#tab#BufMap() "{{{3 + let acc = {} + for t in range(tabpagenr('$')) + let bb = tabpagebuflist(t + 1) + for b in range(len(bb)) + let bn = bb[b] + let bd = [t + 1, b + 1] + if has_key(acc, bn) + call add(acc[bn], bd) + else + let acc[bn] = [bd] + endif + endfor + endfor + return acc +endf + + +" Find a buffer's window at some tab page. +function! tlib#tab#TabWinNr(buffer) "{{{3 + let bn = bufnr(a:buffer) + let bt = tlib#tab#BufMap() + let tn = tabpagenr() + let wn = winnr() + let bc = get(bt, bn) + if !empty(bc) + for [t, w] in bc + if t == tn + return [t, w] + endif + endfor + return bc[0] + endif +endf + + +function! tlib#tab#Set(tabnr) "{{{3 + if a:tabnr > 0 + exec a:tabnr .'tabnext' + endif +endf + diff --git a/vim/.vim/autoload/tlib/tag.vim b/vim/.vim/autoload/tlib/tag.vim new file mode 100755 index 0000000..e4239d3 --- /dev/null +++ b/vim/.vim/autoload/tlib/tag.vim @@ -0,0 +1,132 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 59 + + +" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. +TLet g:tlib_tags_extra = '' + +" Filter the tag description through |substitute()| for these filetypes. +" This applies only if the tag cmd field (see |taglist()|) is used. +" :nodefault: +TLet g:tlib_tag_substitute = { + \ 'java': [['\s*{\s*$', '', '']], + \ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']], + \ 'vim': [ + \ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''], + \ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''], + \ ['"\?\s*{{{\d.*$', '', ''], + \ ], + \ } + + +" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0) +" Get all tags matching rx. Basically, this function simply calls +" |taglist()|, but when extra_tags is true, the list of the tag files +" (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. +" +" Example use: +" If you want to include tags for, eg, JDK, normal tags use can become +" slow. You could proceed as follows: +" 1. Create a tags file for the JDK sources. When creating the tags +" file, make sure to include inheritance information and the like +" (command-line options like --fields=+iaSm --extra=+q should be ok). +" In this example, we want tags only for public methods (there are +" most likely better ways to do this): > +" ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src +" head -n 6 tags > tags0 +" grep access:public tags >> tags0 +" < 2. Make 'tags' include project specific tags files. In +" ~/vimfiles/after/ftplugin/java.vim insert: > +" let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +" < 3. When this function is invoked as > +" echo tlib#tag#Retrieve('print') +" < it will return only project-local tags. If it is invoked as > +" echo tlib#tag#Retrieve('print', 1) +" < tags from the JDK will be included. +function! tlib#tag#Retrieve(rx, ...) "{{{3 + TVarArg ['extra_tags', 0] + " TLogVAR a:rx, extra_tags + if extra_tags + let tags_orig = &l:tags + if empty(tags_orig) + setlocal tags< + endif + try + let more_tags = tlib#var#Get('tlib_tags_extra', 'bg') + if !empty(more_tags) + let &l:tags .= ','. more_tags + endif + let taglist = taglist(a:rx) + finally + let &l:tags = tags_orig + endtry + else + let taglist = taglist(a:rx) + endif + return taglist +endf + + +" Retrieve tags that meet the constraints (a dictionnary of fields and +" regexp, with the exception of the kind field which is a list of chars). +" For the use of the optional use_extra argument see +" |tlib#tag#Retrieve()|. +" :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) +function! tlib#tag#Collect(constraints, ...) "{{{3 + TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1] + " TLogVAR a:constraints, use_extra + let rx = get(a:constraints, 'name', '') + if empty(rx) || rx == '*' + let rx = '.' + else + let rxl = ['\C'] + if match_front + call add(rxl, '^') + endif + " call add(rxl, tlib#rx#Escape(rx)) + call add(rxl, rx) + if match_end + call add(rxl, '$') + endif + let rx = join(rxl, '') + endif + " TLogVAR rx, use_extra + let tags = tlib#tag#Retrieve(rx, use_extra) + " TLogDBG len(tags) + for [field, rx] in items(a:constraints) + if !empty(rx) && rx != '*' + " TLogVAR field, rx + if field == 'kind' + call filter(tags, 'v:val.kind =~ "['. rx .']"') + elseif field != 'name' + call filter(tags, '!empty(get(v:val, field)) && get(v:val, field) =~ rx') + endif + endif + endfor + " TLogVAR tags + return tags +endf + + +function! tlib#tag#Format(tag) "{{{3 + if has_key(a:tag, 'signature') + let name = a:tag.name . a:tag.signature + elseif a:tag.cmd[0] == '/' + let name = a:tag.cmd + let name = substitute(name, '^/\^\?\s*', '', '') + let name = substitute(name, '\s*\$\?/$', '', '') + let name = substitute(name, '\s\{2,}', ' ', 'g') + let tsub = tlib#var#Get('tlib_tag_substitute', 'bg') + if has_key(tsub, &filetype) + for [rx, rplc, sub] in tsub[&filetype] + let name = substitute(name, rx, rplc, sub) + endfor + endif + else + let name = a:tag.name + endif + return name +endf + diff --git a/vim/.vim/autoload/tlib/textobjects.vim b/vim/.vim/autoload/tlib/textobjects.vim new file mode 100755 index 0000000..fb4170e --- /dev/null +++ b/vim/.vim/autoload/tlib/textobjects.vim @@ -0,0 +1,45 @@ +" textobjects.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-01-09. +" @Last Change: 2010-01-10. +" @Revision: 0.0.29 + +let s:save_cpo = &cpo +set cpo&vim + + +" :tag: standard-paragraph +" Select a "Standard Paragraph", i.e. a text block followed by blank +" lines. Other than |ap|, the last paragraph in a document is handled +" just the same. +" +" The |text-object| can be accessed as "sp". Example: > +" +" vsp ... select the current standard paragraph +" +" Return 1, if the paragraph is the last one in the document. +function! tlib#textobjects#StandardParagraph() "{{{3 + if line("'}") == line('$') + norm! vip + return 1 + else + norm! vap + return 0 + endif +endf + + +function! tlib#textobjects#Init() "{{{3 + if !exists('s:tlib_done_textobjects') + " sp ... Standard paragraph (for use as |text-objects|). + vnoremap sp :call tlib#textobjects#StandardParagraph() + onoremap sp :normal Vsp + let s:tlib_done_textobjects = 1 + endif +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/autoload/tlib/time.vim b/vim/.vim/autoload/tlib/time.vim new file mode 100755 index 0000000..a7450e8 --- /dev/null +++ b/vim/.vim/autoload/tlib/time.vim @@ -0,0 +1,52 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 30 + + +function! tlib#time#MSecs() "{{{3 + let rts = reltimestr(reltime()) + return substitute(rts, '\.', '', '') +endf + + +function! tlib#time#Now() "{{{3 + let rts = reltimestr(reltime()) + let rtl = split(rts, '\.') + return rtl +endf + + +function! tlib#time#Diff(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + let [as, am] = a:a + let [bs, bm] = a:b + let rv = 0 + (as - bs) + if resolution > 0 + let rv .= repeat('0', resolution) + let am = am[0 : resolution - 1] + let bm = bm[0 : resolution - 1] + let rv += (am - bm) + endif + return rv +endf + + +function! tlib#time#DiffMSecs(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + if a:a == a:b + return 0 + endif + let a = printf('%30s', a:a[0 : -(7 - resolution)]) + let b = printf('%30s', a:b[0 : -(7 - resolution)]) + for i in range(0, 29) + if a[i] != b[i] + let a = a[i : -1] + let b = b[i : -1] + return a - b + endif + endfor + return 0 +endf + + diff --git a/vim/.vim/autoload/tlib/type.vim b/vim/.vim/autoload/tlib/type.vim new file mode 100755 index 0000000..0e1d3b9 --- /dev/null +++ b/vim/.vim/autoload/tlib/type.vim @@ -0,0 +1,29 @@ +" type.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-09-30. +" @Last Change: 2010-09-27. +" @Revision: 0.0.4 + +function! tlib#type#IsNumber(expr) + return type(a:expr) == 0 +endf + +function! tlib#type#IsString(expr) + return type(a:expr) == 1 +endf + +function! tlib#type#IsFuncref(expr) + return type(a:expr) == 2 +endf + +function! tlib#type#IsList(expr) + return type(a:expr) == 3 +endf + +function! tlib#type#IsDictionary(expr) + return type(a:expr) == 4 +endf + + diff --git a/vim/.vim/autoload/tlib/url.vim b/vim/.vim/autoload/tlib/url.vim new file mode 100755 index 0000000..b948d48 --- /dev/null +++ b/vim/.vim/autoload/tlib/url.vim @@ -0,0 +1,52 @@ +" url.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2011-03-10. +" @Revision: 0.0.28 + + +" TODO: These functions could use printf() now. + +" Decode an encoded URL. +function! tlib#url#Decode(url) "{{{3 + return substitute(a:url, '\(+\|%\(%\|\x\x\)\)', '\=tlib#url#DecodeChar(submatch(1))', 'g') +endf + + +" Decode a single character. +function! tlib#url#DecodeChar(char) "{{{3 + if a:char == '%%' + return '%' + elseif a:char == '+' + return ' ' + else + return nr2char("0x".a:char[1 : -1]) + endif +endf + + +" Encode a single character. +function! tlib#url#EncodeChar(char) "{{{3 + if a:char == '%' + return '%%' + elseif a:char == ' ' + return '+' + else + return printf("%%%X", char2nr(a:char)) + endif +endf + + +" Encode an URL. +function! tlib#url#Encode(url, ...) "{{{3 + TVarArg ['extrachars', ''] + let rx = '\([^a-zA-Z0-9_.'. extrachars .'-]\)' + " TLogVAR a:url, rx + let rv = substitute(a:url, rx, '\=tlib#url#EncodeChar(submatch(1))', 'g') + " TLogVAR rv + return rv +endf + + diff --git a/vim/.vim/autoload/tlib/var.vim b/vim/.vim/autoload/tlib/var.vim new file mode 100755 index 0000000..dcd9264 --- /dev/null +++ b/vim/.vim/autoload/tlib/var.vim @@ -0,0 +1,83 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 30 + + +" Define a variable called NAME if yet undefined. +" You can also use the :TLLet command. +" +" EXAMPLES: > +" exec tlib#var#Let('g:foo', 1) +" TLet g:foo = 1 +function! tlib#var#Let(name, val) "{{{3 + return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, string(a:val)) + " return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, a:val) +endf + + +" :def: function! tlib#var#EGet(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo eval(tlib#var#EGet('foo', 'vg')) => 1 +" echo eval(tlib#var#EGet('foo', 'bg')) => 2 +" echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +function! tlib#var#EGet(var, namespace, ...) "{{{3 + let pre = [] + let post = [] + for namespace in split(a:namespace, '\zs') + let var = namespace .':'. a:var + call add(pre, printf('exists("%s") ? %s : (', var, var)) + call add(post, ')') + endfor + let default = a:0 >= 1 ? a:1 : '' + return join(pre) . string(default) . join(post) +endf + + +" :def: function! tlib#var#Get(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo tlib#var#Get('foo', 'bg') => 1 +" echo tlib#var#Get('foo', 'bg') => 2 +" echo tlib#var#Get('foo', 'wbg') => 3 +function! tlib#var#Get(var, namespace, ...) "{{{3 + let var_ = substitute(a:var, '#', '_', 'g') + for namespace in split(a:namespace, '\zs') + let vname = namespace == 'g' ? a:var : var_ + let var = namespace .':'. vname + if exists(var) + return {var} + endif + endfor + return a:0 >= 1 ? a:1 : '' +endf + + +" :def: function! tlib#var#List(rx, ?prefix='') +" Get a list of variables matching rx. +" EXAMPLE: +" echo tlib#var#List('tlib_', 'g:') +function! tlib#var#List(rx, ...) "{{{3 + TVarArg ['prefix', 'g:'] + if v:version >= 704 + exec 'let varlist = keys('. prefix .')' + else + redir => vars + silent! exec 'let '. prefix + redir END + let varlist = split(vars, '\n') + call map(varlist, 'matchstr(v:val, ''^\S\+'')') + endif + call filter(varlist, 'v:val =~ a:rx') + return varlist +endf + diff --git a/vim/.vim/autoload/tlib/vcs.vim b/vim/.vim/autoload/tlib/vcs.vim new file mode 100644 index 0000000..c7e21ba --- /dev/null +++ b/vim/.vim/autoload/tlib/vcs.vim @@ -0,0 +1,160 @@ +" vcs.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-03-08. +" @Last Change: 2014-09-30. +" @Revision: 133 + + +" A dictionarie of supported VCS (currently: git, hg, svn, bzr). +" :display: g:tlib#vcs#def {...} +TLet g:tlib#vcs#def = { + \ 'git': { + \ 'dir': '.git', + \ 'ls': 'git ls-files --full-name %s', + \ 'diff': 'git diff --no-ext-diff -U0 %s' + \ }, + \ 'hg': { + \ 'dir': '.hg', + \ 'diff': 'hg diff -U0 %s', + \ 'ls': 'hg manifest' + \ }, + \ 'svn': { + \ 'dir': '.svn', + \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s', + \ }, + \ 'bzr': { + \ 'dir': '.bzr', + \ 'diff': 'bzr diff --diff-options=-U0 %s', + \ } + \ } + + +" A dictionary of custom executables for VCS commands. If the value is +" empty, support for that VCS will be removed. If no key is present, it +" is assumed that the VCS "type" is the name of the executable. +" :display: g:tlib#vcs#executables {...} +TLet g:tlib#vcs#executables = {} + + +" If non-empty, use it as a format string to check whether a VCS is +" installed on your computer. +TLet g:tlib#vcs#check = has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s' + + +if !empty(g:tlib#vcs#check) + for [s:cmd, s:def] in items(g:tlib#vcs#def) + if !has_key(g:tlib#vcs#executables, s:cmd) + let s:cmd1 = printf(g:tlib#vcs#check, s:cmd) + let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : '' + endif + endfor + unlet! s:cmd s:def s:cmd1 +endif + + +function! tlib#vcs#Executable(type) "{{{3 + return get(g:tlib#vcs#executables, a:type, '') +endf + + +function! tlib#vcs#FindVCS(filename) "{{{3 + let type = '' + let dir = '' + let dirname = fnamemodify(a:filename, isdirectory(a:filename) ? ':p' : ':p:h') + let path = escape(dirname, ';') .';' + " TLogVAR a:filename, dirname, path + let depth = -1 + for vcs in keys(g:tlib#vcs#def) + let subdir = g:tlib#vcs#def[vcs].dir + let vcsdir = finddir(subdir, path) + " TLogVAR vcs, subdir, vcsdir + if !empty(vcsdir) + let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) + if vcsdir_depth > depth + let depth = vcsdir_depth + let type = vcs + let dir = vcsdir + " TLogVAR type, depth + endif + endif + endfor + " TLogVAR type, dir + if empty(type) + return ['', ''] + else + return [type, dir] + endif +endf + + +function! s:GetCmd(vcstype, cmd) + let vcsdef = get(g:tlib#vcs#def, a:vcstype, {}) + if has_key(vcsdef, a:cmd) + let cmd = vcsdef[a:cmd] + let bin = get(g:tlib#vcs#executables, a:vcstype, '') + if empty(bin) + let cmd = '' + elseif bin != a:vcstype + " let bin = escape(shellescape(bin), '\') + let bin = escape(bin, '\') + let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '') + endif + return cmd + else + return '' + endif +endf + + +" :display: tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) +" Return the files under VCS. +function! tlib#vcs#Ls(...) "{{{3 + if a:0 >= 2 + let vcs = a:2 + else + let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%')) + endif + " TLogVAR vcs + if !empty(vcs) + let [vcstype, vcsdir] = vcs + if has_key(g:tlib#vcs#def, vcstype) + let ls = s:GetCmd(vcstype, 'ls') + " TLogVAR ls + if !empty(ls) + let rootdir = fnamemodify(vcsdir, ':p:h:h') + " TLogVAR vcsdir, rootdir + if ls =~ '%s' + let cmd = printf(ls, shellescape(rootdir)) + else + let cmd = ls + endif + " TLogVAR cmd + let filess = system(cmd) + " TLogVAR filess + let files = split(filess, '\n') + call map(files, 'join([rootdir, v:val], "/")') + return files + endif + endif + endif + return [] +endf + + +" :display: tlib#vcs#Diff(filename, ?vcs=[type, dir]) +" Return the diff for "filename" +function! tlib#vcs#Diff(filename, ...) "{{{3 + let vcs = a:0 >= 1 ? a:1 : tlib#vcs#FindVCS(a:filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let diff = s:GetCmd(vcstype, 'diff') + if !empty(diff) + let cmd = printf(diff, shellescape(fnamemodify(a:filename, ':p'))) + let patch = system(cmd) + return patch + endif + endif + return [] +endf + diff --git a/vim/.vim/autoload/tlib/vim.vim b/vim/.vim/autoload/tlib/vim.vim new file mode 100644 index 0000000..7154aeb --- /dev/null +++ b/vim/.vim/autoload/tlib/vim.vim @@ -0,0 +1,152 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-07-19. +" @Last Change: 2012-06-08. +" @Revision: 37 + + +let s:restoreframecmd = '' +let s:fullscreen = 0 + +if has('win16') || has('win32') || has('win64') + + if !exists('g:tlib#vim#simalt_maximize') + " The alt-key for maximizing the window. + " CAUTION: The value of this paramter depends on your locale and + " maybe the windows version you are running. + let g:tlib#vim#simalt_maximize = 'x' "{{{2 + endif + + if !exists('g:tlib#vim#simalt_restore') + " The alt-key for restoring the window. + " CAUTION: The value of this paramter depends on your locale and + " maybe the windows version you are running. + let g:tlib#vim#simalt_restore = 'r' "{{{2 + endif + + if !exists('g:tlib#vim#use_vimtweak') + " If true, use the vimtweak.dll for windows. This will enable + " tlib to remove the caption for fullscreen windows. + let g:tlib#vim#use_vimtweak = 0 "{{{2 + endif + + " Maximize the window. + " You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + " work for you. + fun! tlib#vim#Maximize(fullscreen) "{{{3 + if !has("gui_running") + return + endif + call s:SaveFrameParams() + let s:fullscreen = a:fullscreen + if g:tlib#vim#use_vimtweak && a:fullscreen + call libcallnr("vimtweak.dll", "EnableCaption", 0) + endif + exec 'simalt ~'. g:tlib#vim#simalt_maximize + endf + + " Restore the original vimsize after having called |tlib#vim#Maximize()|. + function! tlib#vim#RestoreWindow() "{{{3 + if !has("gui_running") + return + endif + if g:tlib#vim#use_vimtweak + call libcallnr("vimtweak.dll", "EnableCaption", 1) + endif + exec 'simalt ~'. g:tlib#vim#simalt_restore + call s:RestoreFrameParams() + endf + +else + + if !exists('g:tlib#vim#use_wmctrl') + " If true, use wmctrl for X windows to make a window + " maximized/fullscreen. + " + " This is the preferred method for maximizing windows under X + " windows. Some window managers have problem coping with the + " default method of setting 'lines' and 'columns' to a large + " value. + let g:tlib#vim#use_wmctrl = executable('wmctrl') "{{{2 + endif + + " :nodoc: + fun! tlib#vim#Maximize(fullscreen) "{{{3 + if !has("gui_running") + return + endif + call s:SaveFrameParams() + let s:fullscreen = a:fullscreen + if g:tlib#vim#use_wmctrl + if a:fullscreen + silent !wmctrl -r :ACTIVE: -b add,fullscreen + else + silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz + endif + else + set lines=1000 columns=1000 + endif + endf + + " :nodoc: + function! tlib#vim#RestoreWindow() "{{{3 + if !has("gui_running") + return + endif + if g:tlib#vim#use_wmctrl + if s:fullscreen + silent !wmctrl -r :ACTIVE: -b remove,fullscreen + else + silent !wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz + endif + endif + call s:RestoreFrameParams() + endf + +endif + + +function! s:SaveFrameParams() "{{{3 + let s:restoreframecmd = printf("set lines=%d columns=%d | winpos %d %d", &lines, &columns, getwinposx(), getwinposy()) +endf + + +function! s:RestoreFrameParams() "{{{3 + if !empty(s:restoreframecmd) + exec s:restoreframecmd + let s:restoreframecmd = '' + endif +endf + + +" :display: tlib#vim##CopyFunction(old, new, overwrite=0) +function! tlib#vim#CopyFunction(old, new, ...) "{{{3 + let overwrite = a:0 >= 1 ? a:1 : 0 + redir => oldfn + exec 'silent function' a:old + redir END + if exists('*'. a:new) + if overwrite > 0 + exec 'delfunction' a:new + elseif overwrite < 0 + throw 'tlib#vim##CopyFunction: Function already exists: '. a:old .' -> '. a:new + else + return + endif + endif + let fn = split(oldfn, '\n') + let fn = map(fn, 'substitute(v:val, ''^\d\+'', "", "")') + let fn[0] = substitute(fn[0], '\V\^\s\*fu\%[nction]!\?\s\+\zs'. a:old, a:new, '') + let t = @t + try + let @t = join(fn, "\n") + redir => out + @t + redir END + finally + let @t = t + endtry +endf + diff --git a/vim/.vim/autoload/tlib/win.vim b/vim/.vim/autoload/tlib/win.vim new file mode 100755 index 0000000..4963af1 --- /dev/null +++ b/vim/.vim/autoload/tlib/win.vim @@ -0,0 +1,128 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 55 + + +" Return vim code to jump back to the original window. +function! tlib#win#Set(winnr) "{{{3 + if a:winnr > 0 + " TLogVAR a:winnr + " TLogDBG winnr() + " TLogDBG string(tlib#win#List()) + if winnr() != a:winnr && winbufnr(a:winnr) != -1 + let rv = winnr().'wincmd w' + exec a:winnr .'wincmd w' + " TLogVAR rv + " TLogDBG string(tlib#win#List()) + return rv + endif + endif + return '' +endf + + +" :def: function! tlib#win#GetLayout(?save_view=0) +function! tlib#win#GetLayout(...) "{{{3 + TVarArg ['save_view', 0] + let views = {} + if save_view + let winnr = winnr() + windo let views[winnr()] = winsaveview() + " for w in range(1, winnr('$')) + " call tlib#win#Set(w) + " let views[w] = winsaveview() + " endfor + call tlib#win#Set(winnr) + endif + return {'winnr': winnr('$'), 'winrestcmd': winrestcmd(), 'views': views, 'cmdheight': &cmdheight, 'guioptions': &guioptions, 'tabpagenr': tabpagenr()} +endf + + +function! tlib#win#SetLayout(layout) "{{{3 + if a:layout.tabpagenr == tabpagenr() && a:layout.winnr == winnr('$') + " TLogVAR a:layout.winrestcmd + " TLogDBG string(tlib#win#List()) + exec a:layout.winrestcmd + if !empty(a:layout.views) + let winnr = winnr() + " TLogVAR winnr + for [w, v] in items(a:layout.views) + " TLogVAR w, v + call tlib#win#Set(w) + call winrestview(v) + endfor + call tlib#win#Set(winnr) + endif + if a:layout.cmdheight != &cmdheight + let &cmdheight = a:layout.cmdheight + endif + " TLogDBG string(tlib#win#List()) + return 1 + endif + return 0 +endf + + +function! tlib#win#List() "{{{3 + let wl = {} + for wn in range(1, winnr('$')) + let wl[wn] = bufname(winbufnr(wn)) + endfor + return wl +endf + + +" " :def: function! tlib#win#GetLayout1(?save_view=0) +" " Contrary to |tlib#win#GetLayout|, this version doesn't use +" " |winrestcmd()|. It can also save windows views. +" function! tlib#win#GetLayout1(...) "{{{3 +" TVarArg ['save_view', 0] +" let winnr = winnr() +" let acc = {} +" for w in range(1, winnr('$')) +" let def = {'h': winheight(w), 'w': winwidth(w)} +" if save_view +" call tlib#win#Set(w) +" let def.view = winsaveview() +" endif +" let acc[w] = def +" endfor +" call tlib#win#Set(winnr) +" return acc +" endf +" +" +" " Reset layout from the value of |tlib#win#GetLayout1|. +" function! tlib#win#SetLayout1(layout) "{{{3 +" if len(a:layout) != winnr('$') +" return 0 +" endif +" let winnr = winnr() +" for [w, def] in items(a:layout) +" if tlib#win#Set(w) +" exec 'resize '. def.h +" exec 'vertical resize '. def.w +" if has_key(def, 'view') +" call winrestview(def.view) +" endif +" else +" break +" endif +" endfor +" call tlib#win#Set(winnr) +" return 1 +" endf + + +function! tlib#win#Width(wnr) "{{{3 + return winwidth(a:wnr) - &fdc +endf + + +function! tlib#win#WinDo(ex) "{{{3 + let w = winnr() + exec 'windo '. a:ex + exec w .'wincmd w' +endf + diff --git a/vim/.vim/autoload/tovl/scratch_buffer.vim b/vim/.vim/autoload/tovl/scratch_buffer.vim new file mode 100644 index 0000000..217dca1 --- /dev/null +++ b/vim/.vim/autoload/tovl/scratch_buffer.vim @@ -0,0 +1,103 @@ +" old code + +augroup TOVLWrite +augroup end + +" =========== scratch buffer ========================================= +" a scratch buffer is a temporary buffer where the user can enter some text +" It can be used to get commit messages, edit configuration options and so on + +function! tovl#scratch_buffer#KeepIntactLineNr() + let i = 0 + while getline(i)!= b:keepIntact && i < line('$') + let i = i+1 + endwhile + if i > line('$') + return -1 + else + return i + endif +endfunction + +" opens a buffer and runs an action when the buffer is written +" keys: +" name : the name of the buffer +" onWrite : will be called on write +" onWrite is responsible for setlocal nomodified to indicate that +" saving has been successful +" help : callback returning additional information lines +" getContent : callback returning lines +" cmds : extra commands to be run (optional) +" (maybe you prefer adding them the default way afer the +" ScratchBuffer call. They'll be rerun on GetContents +" sp_cmd : the command to use to create the new buffer. Defaults to :e +" buftype : ... +" modifiable : 1 / 0 defaults to 1 +function! tovl#scratch_buffer#ScratchBuffer(opts) + let a:opts['name'] = get(a:opts,'name', 'strach_buffer_without_name') + exec get(a:opts, 'sp_cmd', 'e').' '.escape(a:opts['name'],' ') + let b:settings = a:opts + let b:settings['modifiable'] = get(a:opts,'modifiable', 1) + setlocal buftype=acwrite + command! -buffer -nargs=0 Help call tovl#scratch_buffer#Help() + + " setup write notification + au TOVLWrite BufWriteCmd call tovl#scratch_buffer#Write() + + if has_key(a:opts,'getContent') + command! -buffer -nargs=0 GetContents call tovl#scratch_buffer#GetContents() + GetContents + if !b:settings['modifiable'] + setlocal nomodifiable + endif + endif + "let u=&undolevels + "setlocal undolevels=-1 + "exec 'setlocal undolevels='.u + + " mark buffer as not modified + setlocal nomodified + + au BufReadCmd GetContents + + " run addittional commands + for cmd in get(a:opts,'cmds',[]) + exec cmd + endfor + silent echo get(a:opts,'echo_help', "type :Help for help") +endfunction + +" =========== utility functions ====================================== + +function! tovl#scratch_buffer#Write() + if has_key(b:settings, 'onWrite') + call funcref#Call(b:settings['onWrite']) + else + echo "don't know how to write. Option hasn't been passed" + endif +endfunction + +function! tovl#scratch_buffer#GetContents() + setlocal modifiable + " empty buffer + %g!//d + call append(0, funcref#Call(b:settings['getContent'])) + if !b:settings['modifiable'] + setlocal nomodifiable + endif + for cmd in get(b:settings,'cmds',[]) + exec cmd + endfor +endfunction + +function! tovl#scratch_buffer#Help() + let help = ["use :e! to reload contents, ZZ or :w(q) to write and quit" + \ ,"" + \ ,"Help for this scratch buffer:" + \ ,"=======================================================","",""] + \ + funcref#Call(get(b:settings, 'help', [])) + call tovl#scratch_buffer#ScratchBuffer({ + \ 'name' : "return Help of ".b:settings['name'], + \ 'getContent' : help + \ }) +endfunction diff --git a/vim/.vim/autoload/tovl/ui/filter_list.vim b/vim/.vim/autoload/tovl/ui/filter_list.vim new file mode 100644 index 0000000..74b2ab4 --- /dev/null +++ b/vim/.vim/autoload/tovl/ui/filter_list.vim @@ -0,0 +1,473 @@ +" OLD CODE ! +" I should contribute the multiple filter feature to tlib + +" filter list displays a list of items +" you can white / black filter them by regular expressions (similar to the +" tlib TToC command +" However you can edit the filters afterwards and select the cols which should +" be shown + +fun! tovl#ui#filter_list#ListTest() + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 1, + \ 'Continuation' : funcref#Function('echo string(ARGS[0])'), + \ 'items' : [ {"aa" : "a\nAAAAAAAAAAA", 'bb' : "bbbbbbbbbbbbb\nB" }, + \ {"aa" : "2a\n2AAAAAAAAAAAA", "bb" : "2 bbbbbbbbbbbbb\n2B"}, + \ {"aa" : "XXX", "bb" : "YY"} ], + \ }) + +endfun + +fun! s:Intersection(a, b) + return filter(copy(a:a), 'index(a:b, v:val) >= 0') +endf + +fun! tovl#ui#filter_list#ListTestGotoLineCurrentBuf() + let nr=1 + let lines = [] + for l in getline(0,line('$')) + call add(lines, {'nr': nr, 'line' :l}) + let nr = nr +1 + endfor + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 0, + \ 'keys' : ['nr','line'], + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec ARGS[0]["nr"]'), + \ 'items' : lines, + \ }) +endfun + +" opens a new filtered list +" keys of opts parameters: +" Continuation: This function will be called with the selected items +" items: { key : (string or dict) } +" items willl be modified. use copy(youritems) as argument to prevent +" this. An item is either a string or a dict +" (eg {'file' : .., 'line': ... , 'msg' : .. ) +" keys: list of keys to be shown (optional) +" filter: list of inital filters which must be applied +" contains [ { filter: .. , keep : .. }, ] see FilterItems() below +" aligned: default 0 +" sp_cmd: the command to be used to create the new buffer (default ':e') +" init : 0 / 1 (default 1): wether to show the view right now +" number: 0 /1 (default 1): number items ? +" selectByIdOrFilter: 1: start in getchar() loop so that the user can select +" the item even faster +" auto: only do this if all items fit on screen +" (recommend) +" cmds: extra cmds to be run +" cursorAt : at which item to put the cursor? +" +" If you don't like the default view you can override UpdateDisplay +" +" Usage examples of this list control: +" - db results +" - replacement of the quickfix window +" - select a buffer etc +fun! tovl#ui#filter_list#ListView(opts) + " ActivateAddons theonevimlib + let d = {} + let d.items = a:opts.items + let d.cursorAt = get(a:opts, 'cursorAt', 0) + let d.aligned = get(a:opts, 'aligned', 0) + let d.sep = ' ' + let d.filter = get(a:opts, 'filter', []) + " using sp because of bd! (FIXME) + let d.sp_cmd = get(a:opts, 'sp_cmd', 'sp') + let d.allKeys = {} + let d.closeOnContinuation = get(a:opts,'closeOnContinuation',1) + " don't recommend OnSingleMatch, use OnSingleMatchCR instead + let d.continueOnSingleMatch = get(a:opts, 'continueOnSingleMatch',0) + let d.continueOnSingleMatchCR = get(a:opts, 'continueOnSingleMatchCR',1) + let d.selectByIdOrFilter = get(a:opts, 'selectByIdOrFilter', 0) + let d.linesToItems = {} + let d.number = get(a:opts, 'number', 1) + let d.cmds = get(a:opts, 'cmds', []) + let d.syn_cmds = get(a:opts, 'syn_cmds', []) + + if has_key(a:opts,'keys') | let d.keys = a:opts.keys | endif + if has_key(a:opts,'Continuation') | let d.Continuation = a:opts.Continuation | endif + + " cache already filtered items in case we want to view really long results + " contains [ { filter : { regex: .. , keep : .. } , items : .. , cursorAt :}, + " { filter : { ... } , items: .. , cursorAt : } + let d.cached = [] + " id of buffer + let d.buffer = -1 + let d.modeText = '' + + fun d.HelpText() + return [ "you've entered the the help of the powerful filtered view buffer", + \ "", + \ "type f to start filtering items by regex", + \ "type F to start dropping items by regex", + \ "k / K will ask you for the key to apply the filter to first", + \ "apply the filter by and press again to select item", + \ "", + \ "use :ShowAppliedFilters to list active filters", + \ "use :ToggleAlignment to toggle alignment", + \ "", + \ "TODO: Implement sorting, implement interface to change keys (displayed columns)" + \ ] + endfun + + " create new scratch buffer + " preprocess items calculating line count and maxwidth for all items + fun d.NewBufferAndInit() + let self.bufferId = bufnr(bufname('%')) + for idx in range(0,len(self.items)-1) + if type(self.items[idx]) != 4 + " no dict yet, make it one + let self.items[idx] = {'string_line' : self.items[idx]} + endif + let new = {} + for [k,v] in items(self.items[idx]) + let lines = split(v,"\n") + let self.items[idx][k] = { 'text' : v, 'rows' : len(lines), 'cols' : max(map(copy(lines),'len(v:val)')), 'lines' : lines } + let self.allKeys[k] = 1 + unlet k v + endfor + endfor + call tovl#scratch_buffer#ScratchBuffer({ + \ 'help' : funcref#Function(self.HelpText,{ 'self' : self }), + \ 'sp_cmd' : self.sp_cmd, + \ 'cmds' : self.cmds + \ }) + " I assume we have some kind of formatting anyway. Thus breaking lines is bad! + set nowrap + setlocal cursorline + let b:filtered_view = self + command! -buffer -nargs=0 ToggleAlignment call b:filtered_view.ToggleAlignment() + command! -buffer -nargs=0 ShowAppliedFilters call b:filtered_view.ShowAppliedFilters() + command! -buffer -nargs=0 RemoveFilters call b:filtered_view.RemoveFilters() + noremap f :call b:filtered_view.FilterFromKeyboard(1,'') + " noremap f :call b:filtered_view.FilterFromKeyboard(1) + noremap F :call b:filtered_view.FilterFromKeyboard(0,'') + if has_key(self,'Continuation') + nnoremap :call b:filtered_view.Continue() + endif + "noremap k + "noremap K + + let [items, cursorAt] = self.FilteredItems() + " len(items) is an approximation because one item can have multiple + " lines.. However adding the lines first to check takes too much time + if self.selectByIdOrFilter == 1 || (self.selectByIdOrFilter == 'auto' && winheight('%') > len(items) ) + call self.SelectByIdOrFilter() + else + " user should choose how to proceed + call self.UpdateDisplay() + endif + endfun + + " user interface + fun d.ToggleAlignment() + let self.aligned = !self.aligned + call self.UpdateDisplay() + endfun + fun d.ShowAppliedFilters() + for i in self.filter | echo string(i) | endfor + endfun + fun d.RemoveFilters() + let self.filter = [] + call self.UpdateDisplay() + endfun + fun d.Continue() + let item = self.CurrentItem() + call self.DoContinue(item) + endfun + fun d.DoContinue(v) + if self.closeOnContinuation | bw! | endif + call funcref#Call(self.Continuation,[a:v]) + endfun + + fun d.MapToOriginal(v) + if has_key(a:v, 'string_line') + return a:v.string_line.text + else + let d = {} + for [k,v] in items(a:v) + let d[k] = v.text + unlet k v + endfor + return d + endif + endfun + + fun d.CurrentItem() + let idx=line('.')-len(self.headerLines) + while idx >= 0 + if has_key(self.linesToItems, idx) + return self.MapToOriginal(self.FilteredItems()[0][self.linesToItems[idx]]) + else + let idx = idx -1 + endif + endwhile + throw "internal error, couldn't determine selected item!" + endfun + + " updates the filter cache and returns the final filtered items + fun d.FilteredItems() + " update cache + let idx = 0 + let [items, cursorAt] = [self.items, self.cursorAt] + for idx in range(0, len(self.filter)-1) + if idx +1 > len(self.cached) || self.cached[idx]['filter'] != self.filter[idx] + let self.cached = self.cached[:idx-1] + let [items, cursorAt] = self.FilterItem(copy(items), self.filter[idx], cursorAt) + call add(self.cached, { 'cursorAt' : cursorAt, 'items' : items, 'filter' : self.filter[idx]}) + else + let ci = self.cached[idx] + let [items, cursorAt] = [ci['items'], ci['cursorAt']] + endif + endfor + return [items, cursorAt] + endfun + + " calling this will return a set of lines which are expected to be the new + " buffer contents. The self.linesToItems dict is updated + fun d.UpdateDisplay() + + if empty(self.filter) + let self.statusline= 'no filter applied, :Help for help' + else + let self.statusline = len(self.filter).' '.string(self.filter[-1]) + endif + + let self.linesToItems = {} + let [items, cursorAt] = self.FilteredItems() + "let num_width = printf('%.0f', trunc(log10(len(items))+1)) + let num_width = 4 + if self.aligned + " get column width.. (probably will not work with unicde characters.. I + " don't have a better solution) + let maxlens={} + for i in items + for [k,v] in items(i) + if get(maxlens,k,0) < v.cols + let maxlens[k] = v.cols + endif + endfor + endfor + endif + + " format lines + let self.headerLines = [self.modeText] + let lines = copy(self.headerLines) + let lines_count = 0 + if self.number + let fmt_startA = '%'.num_width.'s)' + let fmt_startB = '%'.num_width.'s' + else + let fmt_startA = '' | let fmt_startB = '' + endif + let cursorAtLine = 1 " sane default + for idx in range(0,len(items)-1) + let self.linesToItems[lines_count + 1] = idx + let i = items[idx] + let keys = has_key(self,'keys') + \ ? s:Intersection(self.keys, keys(i)) + \ : keys(i) + let fmt = '' + let args = [i] + let cols = [] + for k in keys + let fmt .= self.sep.'%-'.(self.aligned ? maxlens[k] : i[k]['cols']).'s' + call add(cols, i[k]) + endfor + for row in range(0, max([1] + map(copy(cols),'v:val["rows"]'))-1) + let fmt_args = row == 0 ? [fmt_startA.fmt] : [fmt_startB.fmt] + if self.number + call add(fmt_args, row == 0 ? idx : '') + endif + for c in cols + call add(fmt_args, c.rows <= row ? '' : c.lines[row]) + endfor + call add(lines, call('printf', fmt_args)) + let lines_count += 1 + endfor + if idx == cursorAt + let cursorAtLine = lines_count + endif + endfor + " update stauts line to show last applied filter + " disabled cause it causes trouble on :wincmd w + " setlocal statusline=%!b:filtered_view.statusline + + " syntax + syn clear + for s in self.syn_cmds | exec s | endfor + let id = 0 + " highlight filter regex in buffer as well + let syn_ids = [ 'Underlined', 'Todo', 'Error', 'Type', 'Statement' ] + for f in self.filter + if !f.keep || !has_key(f, 'regex') | continue | endif + if f.regex != '' + try + exec 'syn match '.syn_ids[id % len(syn_ids)].' '.string(f.regex) + catch /.*/ + " ignore errors such as \ without following characters. Thus just + " ignore and wait for the next character + endtry + endif + let id = id +1 + endfor + if len(lines) > winheight('%') + call extend(lines, self.headerLines) + endif + normal ggdG + call append(0, lines) + " place cursor + exec (cursorAtLine+1) + " move cursor into the middle of the window + normal zz + endf + + " filter = keys : + " filter = string to be executed containing Val + " keep = 1 keep on match + " = 0 drop on match + " key (optional) + " cursorAt: at which item to put the cursor + " if that item is deleted it will be placed at the item above + " optional: key of dict if dict + fun d.FilterItem(items, filter, cursorAt) + let filter = 'Val =~ '.string(a:filter.regex) + let keep = a:filter.keep + let cursorAt = a:cursorAt + + for idx in reverse(range(0, len(a:items)-1)) + let i = a:items[idx] + if has_key(a:filter,'key') + let key = a:filter.key + if has_key(i, key) + " key given, only filter by this column + let Val = i[key]['text'] + exec 'let any = '.filter + else + let any = 0 + endif + else + let any = 0 + " no key given, try all + for x in values(i) + let Val = x['text'] + exec 'let any = '.filter + if any | break | endif + endfor + endif + if any != keep + call remove(a:items, idx) + if idx <= cursorAt + let cursorAt = cursorAt -1 + endif + endif + endfor + return [a:items, cursorAt] + endfun + + " if the user enters a number select by index else start filtering.. + fun d.SelectByIdOrFilter() + let idx='' + let items = self.FilteredItems()[0] + try + let self.modeText = '[0-9]* : select by index| : escape getchar() loop, any char: start filtering' + call self.UpdateDisplay() | redraw + while 1 + let c=getchar() + if index([13,10],c) >= 0 + return self.DoContinue(self.MapToOriginal(items[idx])) + elseif index([27], c) >=0 + " esc, abort + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" || index(map(range(0,10),'v:val.""'),c) >= 0 + if c == "\" + let idx = idx[:-2] + else + let idx .= c + endif + if idx < len(items) && idx.'0' > len(items) || idx == 0 && len(items) < 10 + " only match + return self.DoContinue(self.MapToOriginal(items[idx])) + endif + else + return self.FilterFromKeyboard(1,c) + endif + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + " gets a regular expresion filter by keybaord and updates the display while + " you're typing. The regex ist shown in the statusline + fun d.FilterFromKeyboard(keep, start, ...) + let self.modeText = 'press ESC to exit getchar() loop' + call self.UpdateDisplay() | redraw + + try + let key_text = a:0 > 0 ? 'key : '.a:1 : '' + let filter_bak = self.filter + let filter = copy(self.filter) + let start = a:start + let filter_new = '' + while 1 + if start != '' + " use c= last char to force updating display etc + let filter_new = start[:-2] + let c = start[-1:] + let start = '' + else + let c=getchar() + endif + if index([13,10],c) >= 0 + " c-j or return, accept new filter + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatchCR + call self.DoContinue(self.MapToOriginal(items[0])) + endif + return + elseif index([27], c) >=0 + " esc, abort + let self.filter = filter_bak + call self.UpdateDisplay() + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" + let filter_new = filter_new[:-2] + else + let filter_new .= c + endif + let d = {'keep' : a:keep, 'regex' : filter_new } + if a:0 > 0 + let d['key'] = a:1 + endif + let self.filter = copy(filter_bak) + call add(self.filter, d) + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatch + call self.DoContinue(self.MapToOriginal(items[0])) + return + endif + call self.UpdateDisplay() | redraw + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + if get(a:opts,'init',1) + call d.NewBufferAndInit() + endif +endfun diff --git a/vim/.vim/doc/SnipMate.txt b/vim/.vim/doc/SnipMate.txt new file mode 100644 index 0000000..1a2c802 --- /dev/null +++ b/vim/.vim/doc/SnipMate.txt @@ -0,0 +1,634 @@ +*SnipMate.txt* Plugin for using TextMate-style snippets in Vim. + +SnipMate *snippet* *snippets* *SnipMate* +Last Change: December 27, 2009 + +1. Description |SnipMate-description| +2. Usage |SnipMate-usage| +3. Interface and Settings |SnipMate-interface| |SnipMate-settings| +4. Snippets |SnipMate-snippets| + - Snippet files |SnipMate-snippet-files| + - Snippet syntax |SnipMate-syntax| +5. Snippet sources |SnipMate-snippet-sources| +6. Disadvantages to TextMate |SnipMate-disadvantages| +7. Contact |SnipMate-contact| +8. License |SnipMate-license| + +For Vim version 7.0 or later. +This plugin only works if 'compatible' is not set. +{Vi does not have any of these features.} + +SnipMate depends on vim-addon-mw-utils and tlib. + +============================================================================== +DESCRIPTION *SnipMate-description* + +SnipMate implements snippet features in Vim. A snippet is like a template, +reducing repetitive insertion of pieces of text. Snippets can contain +placeholders for modifying the text if necessary or interpolated code for +evaluation. For example, in C, typing "for" then pushing could expand +to: > + + for (i = 0; i < count; i++) { + /* code */ + } + +SnipMate is inspired by TextMate's snippet features. + +============================================================================== +USAGE *SnipMate-usage* + +Every snippet consists of an expansion and a trigger. Typing a trigger into +your buffer and then hitting your trigger key ( by default, see +|SnipMate-mappings|) will replace the trigger with the expansion text. + +The expansion text can optionally include tab stops. When it does, upon +expansion of the snippet, the cursor is placed at the first one, and the user +can jump between each tab stop. Each of these tab stops can be represented by +default placeholder text. If such a placeholder is provided, then the text of +the placeholder can be repeated in the snippet at specified mirrors. Any edits +to the placeholder are instantly updated at every mirror. + +SnipMate allows multiple snippets to use the same trigger. When triggered, +a list of all snippets with that trigger is provided and prompts for which +snippet to use. + + *SnipMate-scopes* +SnipMate searches for snippets inside a directory named "snippets" inside each +entry in 'runtimepath'. Which files are loaded depends on 'filetype' and +'syntax'; see |SnipMate-syntax| for more information. Snippets are loaded and +refreshed automatically on demand. + +Note: SnipMate does not ship with any snippets. In order to use it, the user +must either write their own snippets or obtain some from a repository like +https://github.com/honza/vim-snippets + +============================================================================== +INTERFACE AND SETTINGS *SnipMate-interface* *SnipMate-settings* + + *SnipMate-commands* +Commands~ + + *:SnipMateOpenSnippetFiles* +:SnipMateOpenSnippetFiles Opens a list of all valid snippet locations + based on the current scope |SnipMate-scopes|. + Only existing files and non-existing .snippets + files will be shown, with the existing files + shown first. + +:SnipMateLoadScope[!] scope [scope ...] + Load snippets from additional scopes. Without + [!] the additional scopes are loaded only in + the current buffer. For example > + :SnipMateLoadScopes rails +< will load all rails.snippets in the current + buffer. + + *SnipMate-options* +Options~ + +g:snips_author A variable used in some snippets in place of + the author's (your) name. Similar to + $TM_FULLNAME in TextMate. For example, > + snippet name + `g:snips_author` +< creates a snippet "name" that expands to your + name. + +g:snipMate This |Dictionary| contains other SnipMate + options. In short add > + let g:snipMate = {} +< to your .vimrc before setting other SnipMate + options. + +g:snipMate.scope_aliases A |Dictionary| associating certain filetypes + with other scopes |SnipMate-scopes|. The + entries consist of a filetype as the key and + a comma-separated list of aliases as the + value. For example, > + let g:snipMate.scope_aliases = {} + let g:snipMate.scope_aliases['ruby'] + \ = 'ruby,ruby-rails' +< tells SnipMate that "ruby-rails" snippets in + addition to "ruby" snippets should be loaded + when editing files with 'filetype' set to + "ruby" or contains "ruby" as an entry in the + case of dotted filetypes. A buffer local + variant b:snipMate_scope_aliases is merged + with the global variant. + +g:snipMate_no_default_aliases Note: This has been renamed to the following. + +g:snipMate.no_default_aliases + When set to 1, prevents SnipMate from loading + default scope aliases. The defaults are: + Filetype Alias ~ + cpp c + cu c + eruby eruby-rails,html + html javascript + mxml actionscript + objc c + php php,html,javascript + ur html,javascript + xhtml html + Individual defaults can be disabled by setting + them to an empty value: > + let g:snipMate.scope_aliases.php = '' +< will disable the default PHP alias. + Note: Setting this option does not disable + scope aliases entirely, only those made by + SnipMate itself. Any scope aliases created by + the user or someone else will still be in + effect. + +g:snipMate.snippet_version + The snippet parser version to use. The + possible values are: + 0 Use the older parser + 1 Use the newer parser + If unset, SnipMate defaults to version 0. The + value of this option is also used for all + .snippet files. + +g:snipMate.override + As detailed below, when two snippets with the + same name and description are loaded, both are + kept and differentiated by the location of the + file they were in. When this option is enabled + (set to 1), the snippet originating in the + last loaded file is kept, similar to how Vim + maps and other settings work. + +g:snipMate['no_match_completion_feedkeys_chars'] + A string inserted when no match for a trigger + is found. By default a tab is inserted + according to 'expandtab', 'tabstop', and + 'softtabstop'. Set it to the empty string to + prevent anything from being inserted. + + *SnipMate-mappings* +Mappings~ + +The mappings SnipMate uses can be customized with the |:map| commands. For +example, to change the key that triggers snippets and moves to the next +tab stop, > + + :imap snipMateNextOrTrigger + :smap snipMateNextOrTrigger + +Note: The noremap variants of the map commands must NOT be used. + +The list of possible mappings is as follows: + +snipMateNextOrTrigger Default: Mode: Insert, Select + Jumps to the next tab stop or, if none exists, + try to expand a snippet. Use in both insert + and select modes. + +snipMateTrigger Default: unmapped Mode: Insert + Try to expand a snippet regardless of any + existing snippet expansion. If done within an + expanded snippet, the outer snippet's tab + stops are lost, unless expansion failed. + +snipMateBack Default: Mode: Insert, Select + Jump to the previous tab stop, if it exists. + Use in both insert and select modes. + +snipMateShow Default: Mode: Insert + Show all available snippets (that start with + the previous text, if it exists). Use in + insert mode. + +snipMateVisual Default: Mode: Visual + See |SnipMate-visual|. + +Additionally, is mapped in visual mode in .snippets files for retabbing +snippets. + +============================================================================== +SNIPPETS *SnipMate-snippets* + + *SnipMate-snippet-files* +Snippet Files ~ + +Note: SnipMate does not ship with any snippets. + +SnipMate looks inside of each entry of 'rtp' (or |SnipMate-snippet-sources|) +for a directory named /snippets/. Based on the 'filetype' and 'syntax' +settings (dotted filetypes are parsed), the following files are read for +snippets: > + + .../snippets/.snippets + .../snippets/_.snippets + .../snippets//.snippets + .../snippets//.snippet + .../snippets///.snippet + +where is a scope or 'filetype' or 'syntax', is an arbitrary +name, is the trigger for a snippet, and is +a description used for |SnipMate-multisnip|. + +A .snippet file defines a single snippet with the trigger (and description) +determined by the filename. The entire contents of the file are used as the +snippet expansion text. + +Multiple snippets can be defined in *.snippets files. Each snippet definition +looks something like: > + + snippet trigger optional description + expanded text + more expanded text + +< *SnipMate-multisnip* +The description is optional. If it is left out, the description "default" is +used. When two snippets in the same scope have the same name and the same +description, SnipMate will try to preserve both. The g:snipMate.override +option disables this, in favor of keeping the last-loaded snippet. This can be +overridden on a per-snippet basis by defining the snippet with a bang (!): > + + snippet! trigger optional description + expanded text + more expanded text + +Note: Hard tabs in the expansion text are required. When the snippet is +expanded in the text and 'expandtab' is set, each tab will be replaced with +spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise. + +Which version parser the snippets in a file should be used with can be +specified with a version line, e.g.: > + + version 1 + +Specification of a version applies to the snippets following it. Multiple +version specifications can appear in a single file to intermix version 0 and +version 1 snippets. + +Comments can be made in .snippets files by starting a line with a # character. +However these can't be used inside of snippet definitions: > + + # this is a correct comment + snippet trigger + expanded text + snippet another_trigger + # this isn't a comment! + expanded text + +This should hopefully be clear with the included syntax highlighting. + + *snipMate-extends* +Borrowing from UltiSnips, .snippets files can also contain an extends +directive, for example: > + + extends html, javascript, css + +will tell SnipMate to also read html, javascript, and css snippets. + +SNIPPET SYNTAX *snippet-syntax* *SnipMate-syntax* + +Anywhere in a snippet, a backslash escapes the character following it, +regardless of whether that character is special or not. That is, '\a' will +always result in an 'a' in the output. A single backslash can be output by +using '\\'. + + *SnipMate-tabstops* +Tab stops~ + +When triggering a snippet, SnipMate will by default jump to the very end of +the snippet text. This can be changed through the use of tab stops: $1, $2, +and so on. After expansion, SnipMate will jump to the first tab stop. From +then on, the snipMateNextOrTrigger map will jump to the next higher +numbered tabs top. + +In the case of an ambiguity, for example if a stop occurs just before +a literal number, braces may be placed around the stop number to resolve it: +${3}79 is the third tab stop followed by the string "79". + +NOTE: In the version 0 snippet parser, the braces are mandatory. + + *SnipMate-zero-tabstop* +SnipMate will always stop at the special zero tab stop $0. Once it jumps to +the zero tab stop, snippet expansion is finished. If the zero tab stop is not +present in a definition, it will be put at the end. + +For example, to place the cursor first on the id of a
tag, then on its +class, and finally end editing its contents: > + + snippet div +
+ $0 +
+ +< *SnipMate-placeholders* +In addition to being simply a location, each tab stop contains a placeholder, +or some default text. The placeholder can be specified for every tab stop +(including the zero tab stop) with a colon after the stop ID, as in +${1:default text}. The braces are required only when specifying a placeholder. +Once a tab stop with a placeholder is reached, the placeholder will be +selected in |Select-mode|. For example, > + + snippet div +
+ $0 +
+ +Finally, placeholders can contain mirrors and evaluations (detailed below) and +even entire other tab stops. If the placeholder is edited, then these nested +tab stops are removed and skipped entirely. For example, > + + snippet div + + $0 +
+ +When expanded, this snippet selects the entirety of the id attribute. If this +stop is edited, then the second tab stop is removed and the third tab stop +becomes the next one. If the first tab stop is left unedited, then SnipMate +jumps to the second tab stop. This allows the user to use a single div snippet +that can be used for instances where the id or class attributes are desired +and those where they are not. + + *SnipMate-mirrors* +Mirrors~ + +A mirror is simply a copy of a tab stop's text, updated as the tab stop is +edited. These look like a tab stop without a placeholder; $1 for example. In +the event that no placeholder is specified for a certain tab stop--say $1--the +first instance becomes the tab stop and the rest become mirrors. + +Additionally substitutions similar to |:substitute| can be performed. For +instance ${1/foo/bar/g} will replace all instances of "foo" in the $1 mirror +with "bar". This uses |substitute()| behind the scenes. + +Note: Just like with tab stops, braces can be used to avoid ambiguities: ${1}2 +is a mirror of the first tab stop followed by a 2. Version 0 of the snippet +parser offers no way to resolve such ambiguities. + +As an example, > + + snippet for + for ($1 = ${2:start}; ${1:i} < ${3:end}; $1${4:++}) { + ${0:/* code */} + } + +< *SnipMate-eval* +Expression Evaluation~ + +Snippets can contain Vim script expressions that are evaluated as the snippet +is expanded. Expressions are specified inside backticks: > + + snippet date + `strftime("%Y-%m-%d")` + +If the expression results in any Vim error, the error will be displayed (or +found in :messages) and the result of the expression will be the empty string. + +Filename([{expr}] [, {defaultText}]) *SnipMate-Filename()* + +Since the current filename is used often in snippets, a default function +has been defined for it in SnipMate.vim, appropriately called Filename(). + +With no arguments, the default filename without an extension is returned; +the first argument specifies what to place before or after the filename, +and the second argument supplies the default text to be used if the file +has not been named. "$1" in the first argument is replaced with the filename; +if you only want the filename to be returned, the first argument can be left +blank. Examples: > + + snippet filename + `Filename()` + snippet filename_with_default + `Filename('', 'name')` + snippet filename_foo + `Filename('$1_foo')` + +The first example returns the filename if it the file has been named, and an +empty string if it hasn't. The second returns the filename if it's been named, +and "name" if it hasn't. The third returns the filename followed by "_foo" if +it has been named, and an empty string if it hasn't. + + *SnipMate-visual* +The VISUAL Stop~ + +While tab stops have numeric IDs, a special one exists with the ID 'VISUAL'. +When a snippet is expanded, if any text had been grabbed with the +snipMateVisual mapping (see |SnipMate-mappings|), all instances of the VISUAL +stop will be replaced with it. Both transformations as well as a default +placeholder can be used with the VISUAL stop. + +Note: Both $VISUAL and ${VISUAL} are valid in version 1 of the snippet parser. +In version 0, only {VISUAL} is valid (without the $), and neither +transformations nor a default placeholder can be used. + +Example: > + + snippet div +
+ ${0:${VISUAL:}} +
+ +============================================================================== +SNIPPET SOURCES *SnipMate-snippet-sources* + +SnipMate is configurable. + +plugin/SnipMate.vim assigns a couple important keys: > + + " default implementation collecting snippets by handlers + let g:SnipMate['get_snippets'] = SnipMate#GetSnippets + " default handler: + let g:SnipMateSources['default'] = SnipMate#DefaultPool + +You can override both of those settings. + +You can see that the default set of snippets is determined by Vim's 'rtp'. + +Example 1:~ +autoload/SnipMate_python_demo.vim shows how you can register additional +sources such as creating snippets on the fly representing python function +definitions found in the current file. + +Example 2:~ +Add to your ~/.vimrc: For each know snippet add a second version ending in _ +adding folding markers > + + let g:commentChar = { + \ 'vim': '"', + \ 'c': '//', + \ 'cpp': '//', + \ 'sh': '#', + \ 'python': '#' + \ } + " url https://github.com/garbas/vim-snipmate/issues/49 + fun! AddFolding(text) + return substitute(a:text,'\n'," ".g:commentChar[&ft]." {{{\n",1)."\n".g:commentChar[&ft]." }}}" + endf + + fun! SnippetsWithFolding(scopes, trigger, result) + " hacky: temporarely remove this function to prevent infinite recursion: + call remove(g:SnipMateSources, 'with_folding') + " get list of snippets: + let result = SnipMate#GetSnippets(a:scopes, substitute(a:trigger,'_\(\*\)\?$','\1','')) + let g:SnipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding') + + " add folding: + for k in keys(result) + let a:result[k.'_'] = map(result[k],'AddFolding(v:val)') + endfor + endf + + " force setting default: + runtime plugin/SnipMate.vim + " add our own source + let g:SnipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding') + +See |SnipMate-syntax| for more details about all possible relative locations +to 'rtp' can be found in. + +============================================================================== +KNOWN ISSUES *SnipMate-known-issues* + +SnipMate.vim currently has the following disadvantages to TextMate's snippets: + - Placeholders cannot span multiple lines. + - Activating snippets in different scopes of the same file is + not possible. + - Vim formatting with fo=t or fo=a can mess up SnipMate. + +Perhaps some of these features will be added in a later release. + +============================================================================== +CHANGELOG *SnipMate-changelog* + +0.88 - 2015-04-04 +----------------- + +* Implement simple caching +* Remove expansion guards +* Add `:SnipMateLoadScope` command and buffer-local scope aliases +* Load `_*.snippets` files +* Use CursorMoved autocmd events entirely + +* The nested branch has been merged + * A new snippet parser has been added. The g:snipmate.version as well as + version lines in snippet files determines which is used + * The new parser supports tab stops placed within placeholders, + substitutions, non-consecutive stop numbers, and fewer ambiguities + * The stop jumping code has been updated + * Tests have been added for the jumping code and the new parser + +* The override branch has been merged + * The g:snipMate.override option is added. When enabled, if two snippets + share the same name, the later-loaded one is kept and the other discarded + * Override behavior can be enabled on a per-snippet basis with a bang (!) in + the snippet file + * Otherwise, SnipMate tries to preserve all snippets loaded + +* Fix bug with mirrors in the first column +* Fix bug with tabs in indents + +* Fix bug with mirrors in placeholders +* Fix reading single snippet files +* Fix the use of the visual map at the end of a line +* Fix expansion of stops containing only the zero tab stop +* Remove select mode mappings +* Indent visual placeholder expansions and remove extraneous lines + + + +0.87 - 2014-01-04 +----------------- + +* Stop indenting empty lines when expanding snippets +* Support extends keyword in .snippets files +* Fix visual placeholder support +* Add zero tabstop support +* Support negative 'softtabstop' +* Add g:snipMate_no_default_aliases option +* Add snipMateTrigger for triggering an expansion inside a snippet +* Add snipMate#CanBeTriggered() function + +0.86 - 2013-06-15 +----------------- +* Use more idiomatic maps +* Remove most select mode mappings + +* Fix disappearing variables bug (hpesoj) +* Fix cursor position bug when a variable is on the same line as the stop +* Fix undo point creation causing problems with Supertab +* Fix bug where SnipMate would use a typed trigger as a regular expression + +0.85 - 2013-04-03 +----------------- + +* Allow trigger key customization +* Enable undoing of snippet expansion +* Support backslash escaping in snippets +* Add support for {VISUAL} +* Expand filetype extension with scope_aliases +* Add expansion guards +* Enable per-buffer expansion of snippets +* Fix 'cpo' compatibility +* Update supertab compatibility +* Enable customization of various things through g:SnipMate + +* Disable spelling in snippet files +* Highlight trigger names in .snippets files + +* Update many snippets +* Separate sample snippets into separate repository + +0.84 +---- + +* Unreleased version by Michael Sanders, available on his GitHub, + + +0.83 - 2009-07-13 +----------------- + +* Last release done by Michael Sanders, available at + + +============================================================================== +CONTACT *SnipMate-contact* *SnipMate-author* + +SnipMate is currently maintained by: + - Rok Garbas + - Marc Weber (marco-oweber@gmx.de) + - Adnan Zafar + +For bug reports, issues, or questions, check out the Issues page on GitHub: +https://github.com/garbas/vim-snipmate/issues + +The original author, Michael Sanders, can be reached at: +msanders42+snipmate gmail com + + +============================================================================== +LICENSE *SnipMate-license* + +SnipMate is released under the MIT license: + +Copyright 2009-2010 Michael Sanders. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall the +authors or copyright holders be liable for any claim, damages or other +liability, whether in an action of contract, tort or otherwise, arising from, +out of or in connection with the software or the use or other dealings in the +software. + +============================================================================== + vim:tw=78:ts=8:ft=help:norl: diff --git a/vim/.vim/doc/cached_file_contents.txt b/vim/.vim/doc/cached_file_contents.txt new file mode 100644 index 0000000..a47a8cf --- /dev/null +++ b/vim/.vim/doc/cached_file_contents.txt @@ -0,0 +1,7 @@ +*cached_file_contents* read contents of a file then cache extracted data + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + + see cached_file_contents#Test() diff --git a/vim/.vim/doc/funcref.txt b/vim/.vim/doc/funcref.txt new file mode 100644 index 0000000..cb366d0 --- /dev/null +++ b/vim/.vim/doc/funcref.txt @@ -0,0 +1,35 @@ +*funcref* create lazier function references. Pass arguments to create closure + like function calls + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Use *funcref#Function* to create a special dict called +*faked-function-reference* which can be called by *funcref#Call* +> + { 'faked_function_reference': 'file#FuncName' } +< passing some arguments and / or self: > + { 'faked_function_reference': 'MyFunc', 'args': [1,2], 'self' : { a object ] } +< You can also create lambda like functions which will be evaled: > + { 'faked_function_reference': 'return ARGS[1]' } + +REASONS ~ + Creating a Vim funcref pointing to an autoload function will make Vim source + that file. This is not lazy enough. (Seems to be no longer true? Has this changed?) + + A Vim function reference neither allows attaching arguments nor self. + + Don't care about case of variables. Normally when using Vim function + references you have to use variable names starting with an upper case letter + (E704) + +Example: ~ +> + let f = funcref#Function('return ARGS[0].ARGS[1].SELF["key"]',{'args':[3], 'self':{'key': 'value'} }) + echo funcref#Call(f, [2]) + " prints "32value" + + echo funcref#Call('no value') +< + echo funcref#Call(f, [2]) diff --git a/vim/.vim/doc/supertab.txt b/vim/.vim/doc/supertab.txt new file mode 100644 index 0000000..14892a8 --- /dev/null +++ b/vim/.vim/doc/supertab.txt @@ -0,0 +1,473 @@ +*supertab.txt* + +Author: Eric Van Dewoestine + Original concept and versions up to 0.32 written by + Gergely Kontra + +This plugin is licensed under the terms of the BSD License. Please see +supertab.vim for the license in its entirety. + +============================================================================== +Supertab *supertab* + +1. Introduction |supertab-intro| +2. Supertab Usage |supertab-usage| +3. Supertab Options |supertab-options| + Default completion type |supertab-defaultcompletion| + Secondary default completion type |supertab-contextdefault| + Completion contexts |supertab-completioncontexts| + Context text |supertab-contexttext| + Context Discover |supertab-contextdiscover| + Example |supertab-contextexample| + Completion Duration |supertab-duration| + Preventing Completion After/Before... |supertab-preventcomplete| + Changing default mapping |supertab-forwardbackward| + Inserting true tabs |supertab-mappingtabliteral| + Enhanced longest match support |supertab-longestenhanced| + Preselecting the first entry |supertab-longesthighlight| + Mapping to end completion |supertab-crmapping| + Auto close the preview window |supertab-closepreviewonpopupclose| + Keyword completion ignore/match case |supertab-completecase| + Completion Chaining |supertab-completionchaining| + +============================================================================== +1. Introduction *supertab-intro* + +Supertab is a plugin which allows you to perform all your insert completion +(|ins-completion|) using the tab key. + +Supertab requires Vim version 7.0 or above. + +============================================================================== +2. Supertab usage *supertab-usage* + +Using Supertab is as easy as hitting or (shift+tab) while in +insert mode, with at least one non whitespace character before the cursor, to +start the completion and then or again to cycle forwards or +backwards through the available completions. + +Example ('|' denotes the cursor location): + +bar +baz +b| Hitting here will start the completion, allowing you to + then cycle through the suggested words ('bar' and 'baz'). + +============================================================================== +3. Supertab Options *supertab-options* + +Supertab is configured via several global variables that you can set in your +|vimrc| file according to your needs. Below is a comprehensive list of +the variables available. + + +Default Completion Type *supertab-defaultcompletion* + *g:SuperTabDefaultCompletionType* + +g:SuperTabDefaultCompletionType (default value: "") + +Used to set the default completion type. There is no need to escape this +value as that will be done for you when the type is set. + + Example: setting the default completion to 'user' completion: + +> + let g:SuperTabDefaultCompletionType = "" +< + +Note: a special value of 'context' is supported which will result in +super tab attempting to use the text preceding the cursor to decide which +type of completion to attempt. Currently supertab can recognize method calls +or attribute references via '.', '::' or '->', and file path references +containing '/'. If the language you are using doesn't use any of the member +reference characters listed above, or you'd like to add additional patterns, +you can write a custom context function also described in the next section +(Completion context). + + Example: setting the default completion to supertab's 'context' completion: +> + let g:SuperTabDefaultCompletionType = "context" +< + + /usr/l # will use filename completion + myvar.t # will use user completion if completefunc set, + # or omni completion if omnifunc set. + myvar-> # same as above + +When using context completion, super tab will fall back to a secondary default +completion type set by |g:SuperTabContextDefaultCompletionType|. + +Note: once the buffer has been initialized, changing the value of this setting +will not change the default complete type used. If you want to change the +default completion type for the current buffer after it has been set, perhaps +in an ftplugin, you'll need to call *SuperTabSetDefaultCompletionType* like so, +supplying the completion type you wish to switch to: + +> + call SuperTabSetDefaultCompletionType("") +< + + +Secondary default completion type *supertab-contextdefault* + *g:SuperTabContextDefaultCompletionType* + +g:SuperTabContextDefaultCompletionType (default value: "") + +Sets the default completion type used when g:SuperTabDefaultCompletionType is +set to 'context' and no completion type is returned by any of the configured +contexts. + + Note: supertab also supports the b:SuperTabContextDefaultCompletionType + variable allowing you to set the default type separately for the current + buffer, like from an ftplugin for example. + + +Completion contexts *supertab-completioncontexts* + *g:SuperTabCompletionContexts* + +g:SuperTabCompletionContexts (default value: ['s:ContextText']) + +Sets the list of contexts used for context completion. This value should +be a list of function names which provide the context implementation. + +When supertab starts context completion, each of these contexts will be +consulted, in the order they were supplied, to determine the completion type +to use. If a context returns a completion type, that type will be used, +otherwise the next context in the list will be consulted. If after executing +all the context functions, no completion type has been determined, then the +value of |g:SuperTabContextDefaultCompletionType| will be used. + + Note: supertab also supports the b:SuperTabCompletionContexts variable + allowing you to set the list of contexts separately for the current buffer, + like from an ftplugin for example. + +Built in completion contexts: + + s:ContextText *supertab-contexttext* + + The text context will examine the text near the cursor to decide which type + of completion to attempt. Currently the text context can recognize method + calls or attribute references via '.', '::' or '->', and file path + references containing '/'. + + /usr/l # will use filename completion + myvar.t # will use user completion if completefunc set, or + # omni completion if omnifunc set. + myvar-> # same as above + + Supported configuration attributes: + + *g:SuperTabContextTextFileTypeExclusions* + List of file types for which the text context will be skipped. + + *g:SuperTabContextTextOmniPrecedence* (default: ['&completefunc', '&omnifunc']) + *b:SuperTabContextTextOmniPrecedence* + List of omni completion option names in the order of precedence that they + should be used if available. By default, user completion will be given + precedence over omni completion, but you can use this variable to give + omni completion higher precedence by placing it first in the list. + + *g:SuperTabContextTextMemberPatterns* (default: ['\.', '>\?::', '->']) + *b:SuperTabContextTextMemberPatterns* + List of patterns used to determine when omni/user completion should be + used. The default list consists of the most common patterns used to access + module/class/object members. + + Note: For html and xml based files, the buffer local version of the above + two settings are set to trigger omni completion first when encountering a + potential end tag pattern of ' + let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover'] + let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc'] + let g:SuperTabContextDiscoverDiscovery = + \ ["&completefunc:", "&omnifunc:"] +< + + In addition to the default completion contexts, you can plug in your own + implementation by creating a globally accessible function that returns + the completion type to use (eg. "\\"). + +> + function MyTagContext() + if filereadable(expand('%:p:h') . '/tags') + return "\\" + endif + " no return will result in the evaluation of the next + " configured context + endfunction + let g:SuperTabCompletionContexts = + \ ['MyTagContext', 's:ContextText', 's:ContextDiscover'] +< + + Here is another example that could be used to add context support for + clojure, and perhaps other lisp variants: + +> + let b:SuperTabCompletionContexts = + \ ['ClojureContext'] + g:SuperTabCompletionContexts + + function! ClojureContext() + let curline = getline('.') + let cnum = col('.') + let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name') + if curline =~ '(\S\+\%' . cnum . 'c' && synname !~ '\(String\|Comment\)' + return "\\" + endif + endfunction +< + + +Completion Duration *supertab-duration* + *g:SuperTabRetainCompletionDuration* + +g:SuperTabRetainCompletionDuration (default value: 'insert') + +Determines if, and for how long, the current completion type is retained. +The possible values include: +'completion' - The current completion type is only retained for the + current completion. Once you have chosen a completion + result or exited the completion mode, the default + completion type is restored. +'insert' - The current completion type is saved until you exit insert + mode (via ESC). Once you exit insert mode the default + completion type is restored. (supertab default) +'session' - The current completion type is saved for the duration of + your vim session or until you enter a different completion + mode. + + +Preventing completion after... *supertab-preventcomplete* + *g:SuperTabNoCompleteBefore* + *g:SuperTabNoCompleteAfter* + +g:SuperTabNoCompleteBefore (default value: []) +g:SuperTabNoCompleteAfter (default value: ['^', '\s']) + +These two variables are used to control when supertab will attempt completion +or instead fall back to inserting a literal . There are two possible ways +to define these variables: + + 1) by specifying a list of patterns which are tested against the text before + and after the current cursor position that when matched, prevent completion. + So if you don't want supertab to start completion at the start of a line, + after a comma, or after a space, you can set g:SuperTabNoCompleteAfter + to ['^', ',', '\s']. + + 2) by specifying a funcref to a global accessible function which expects + as parameter the text to be inspected (before or after) and, based on that (or + other factors), it returns 1 if completion must be prevented, 0 otherwise. + +Note: That a buffer local version of these variables +(b:SuperTabNoCompleteBefore, b:SuperTabNoCompleteAfter) are also supported +should you wish to have different values depending on the file type for +instance. + +Changing the default mapping *supertab-forwardbackward* + *g:SuperTabMappingForward* + *g:SuperTabMappingBackward* + +g:SuperTabMappingForward (default value: '') +g:SuperTabMappingBackward (default value: '') + +These two variables allow you to set the keys used to kick off the current +completion. By default this is and . To change to something +like and , you can add the following to your |vimrc|. + +> + let g:SuperTabMappingForward = '' + let g:SuperTabMappingBackward = '' +> + +Note: if the above does not have the desired effect (which may happen in +console version of vim), you can try the following mappings. Although the +backwards mapping still doesn't seem to work in the console for me, your +milage may vary. + +> + let g:SuperTabMappingForward = '' + let g:SuperTabMappingBackward = '' +< + + +Inserting true tabs *supertab-mappingtabliteral* + *g:SuperTabMappingTabLiteral* + +g:SuperTabMappingTabLiteral (default value: '') + +Sets the key mapping used to insert a literal tab where supertab would +otherwise attempt to kick off insert completion. The default is '' +(ctrl-tab) which unfortunately might not work at the console. So if you are +using a console vim and want this functionality, you may have to change it to +something that is supported. Alternatively, you can escape the with + (see |i_CTRL-V| for more infos). + +See also |supertab-preventcomplete|. + + +Enhanced longest match support *supertab-longestenhanced* + *g:SuperTabLongestEnhanced* + +g:SuperTabLongestEnhanced (default value: 0) + +When enabled and 'longest' is in your |completeopt| setting, supertab will +provide an enhanced longest match support where typing one or more letters and +hitting tab again while in a completion mode will complete the longest common +match using the new text in the buffer. + +For example, say you have a buffer with the following contents: + FooBarFoo + FooBar + Foo + FooBarBaz +And you then type F. Vim's builtin longest support will complete the +longest common text 'Foo' and offer 'FooBarFoo', 'FooBar', 'Foo', and +'FooBarBaz' as possible completions. With supertab's longest match +enhancement disabled, typing B while still in the completion mode will +end up completing 'FooBarBaz' or 'FooBarFoo' depending your settings, instead +of the next longest common match of 'FooBar'. With supertab's enhanced +longest match feature enabled, the typing of B will result in the next +longest text being completed. + + +Preselecting the first entry *supertab-longesthighlight* + *g:SuperTabLongestHighlight* + +g:SuperTabLongestHighlight (default value: 0) + +Sets whether or not to pre-highlight the first match when completeopt has the +popup menu enabled and the 'longest' option as well. When enabled, will +kick off completion and pre-select the first entry in the popup menu, allowing +you to simply hit to use it. + + +Mapping to end completion *supertab-crmapping* + *g:SuperTabCrMapping* + +g:SuperTabCrMapping (default value: 0) + +When enabled, will cancel completion mode preserving the current text. + +Compatibility with other plugins: + - endwise: compatible + - delimitMate: not compatible (disabled if the delimitMate mapping is + detected.) + +Note: if you have an insert expression mapping with a in it or an insert +abbreviation containing a , then supertab will not create a mapping +which could potentially cause problems with those. + + +Auto close the preview window *supertab-closepreviewonpopupclose* + *g:SuperTabClosePreviewOnPopupClose* + +g:SuperTabClosePreviewOnPopupClose (default value: 0) + +When enabled, supertab will attempt to close vim's completion preview window +when the completion popup closes (completion is finished or canceled). + + +Completion ignore/match case *supertab-completecase* + *g:SuperTabCompleteCase* + +g:SuperTabCompleteCase (default value: 'inherit') + +When issuing completions (keyword and potentially others), the value of your +|'ignorecase'| setting will determine what results are returned based on +whether or not you've chosen to ignore case or not. However, you may have +|'ignorecase'| set or unset for other reasons and don't want that value +considered when using insert completion. SuperTab allows you temporarily +override |'ignorecase'| by setting g:SuperTabCompleteCase to either 'ignore' +or 'match' depending on whether you want to always ignore or match case when +using insert completion. + +Note: third party omni/user completion plugins may or may not honor +|'ignorecase'|. If they do not, then you can probably contact them to add that +support. + +Completion Chaining *supertab-completionchaining* + +SuperTab provides the ability to chain one of the completion functions +(|completefunc| or |omnifunc|) together with one of the default vim +completion key sequences (|ins-completion|), giving you the ability to attempt +completion with the first, and upon no results, fall back to the second. + +To utilize this feature you need to call the *SuperTabChain* function where +the first argument is the name of a vim compatible |complete-function| and the +second is one of vim's insert completion (|ins-completion|) key bindings +(, , , etc). Calling this function will set the current +buffer's |completefunc| option to a supertab provided implementation which +utilizes the supplied arguments to perform the completion. + +Here is an example that can be added to your .vimrc which will setup the +supertab chaining for any filetype that has a provided |omnifunc| to first +try that, then fall back to supertab's default, , completion: + +> + autocmd FileType * + \ if &omnifunc != '' | + \ call SuperTabChain(&omnifunc, "") + \ endif +< + +You can also specify whether or not the 'context' completion method will +be used as part of your completion chaining. If you've already set your +default completion type to 'context', then no further action is needed. If +however you haven't set that or don't want to use 'context' completion in this +case, then you can supply a third argument to SuperTabChain which is a boolean +(1 or 0) indicationg whether you want to use 'context' completion (1) or not +(0). + +Here is an example where 'context' is the global default and completion +chaining is enabled for file types that have omni completion support: + +> + let g:SuperTabDefaultCompletionType = 'context' + autocmd FileType * + \ if &omnifunc != '' | + \ call SuperTabChain(&omnifunc, "") | + \ endif +< + +This configuration will result in a completion flow like so: + + if text before the cursor looks like a file path: + use file completion + elif text before the cursor looks like an attempt to access a member + (method, field, etc): + use user completion + where user completion is currently set to supertab's + completion chaining, resulting in: + if omni completion has results: + use omni completion + else: + use keyword completion + else: + use keyword completion + +Note: Completion chaining only supports chaining 1 completion function (omni +or user) with 1 regular completion keybinding. All other combinations of +completions (2 or more completion functions, 2 or more key bindings, etc.) are +not supported due to limitations imposed by vim's code completion +implementation. + +Note: If the |completefunc| or |omnifunc| use vim's |complete_add()| instead +of returning completion results as a list, then Supertab's completion chaining +won't work properly with it since Supertab uses the function result to +determine if it should fallback to the next completion type. + +vim:tw=78:ts=8:ft=help:norl: diff --git a/vim/.vim/doc/tags b/vim/.vim/doc/tags new file mode 100644 index 0000000..74ea2ed --- /dev/null +++ b/vim/.vim/doc/tags @@ -0,0 +1,406 @@ +:SnipMateOpenSnippetFiles SnipMate.txt /*:SnipMateOpenSnippetFiles* +:TBrowseOutput tlib.txt /*:TBrowseOutput* +:TBrowseScriptnames tlib.txt /*:TBrowseScriptnames* +:TKeyArg tlib.txt /*:TKeyArg* +:TLet tlib.txt /*:TLet* +:TRequire tlib.txt /*:TRequire* +:TScratch tlib.txt /*:TScratch* +:TTimeCommand tlib.txt /*:TTimeCommand* +:TVarArg tlib.txt /*:TVarArg* +Add() tlib.txt /*Add()* +SnipMate SnipMate.txt /*SnipMate* +SnipMate-Filename() SnipMate.txt /*SnipMate-Filename()* +SnipMate-author SnipMate.txt /*SnipMate-author* +SnipMate-changelog SnipMate.txt /*SnipMate-changelog* +SnipMate-commands SnipMate.txt /*SnipMate-commands* +SnipMate-contact SnipMate.txt /*SnipMate-contact* +SnipMate-description SnipMate.txt /*SnipMate-description* +SnipMate-eval SnipMate.txt /*SnipMate-eval* +SnipMate-interface SnipMate.txt /*SnipMate-interface* +SnipMate-known-issues SnipMate.txt /*SnipMate-known-issues* +SnipMate-license SnipMate.txt /*SnipMate-license* +SnipMate-mappings SnipMate.txt /*SnipMate-mappings* +SnipMate-mirrors SnipMate.txt /*SnipMate-mirrors* +SnipMate-multisnip SnipMate.txt /*SnipMate-multisnip* +SnipMate-options SnipMate.txt /*SnipMate-options* +SnipMate-placeholders SnipMate.txt /*SnipMate-placeholders* +SnipMate-scopes SnipMate.txt /*SnipMate-scopes* +SnipMate-settings SnipMate.txt /*SnipMate-settings* +SnipMate-snippet-files SnipMate.txt /*SnipMate-snippet-files* +SnipMate-snippet-sources SnipMate.txt /*SnipMate-snippet-sources* +SnipMate-snippets SnipMate.txt /*SnipMate-snippets* +SnipMate-syntax SnipMate.txt /*SnipMate-syntax* +SnipMate-tabstops SnipMate.txt /*SnipMate-tabstops* +SnipMate-usage SnipMate.txt /*SnipMate-usage* +SnipMate-visual SnipMate.txt /*SnipMate-visual* +SnipMate-zero-tabstop SnipMate.txt /*SnipMate-zero-tabstop* +SnipMate.txt SnipMate.txt /*SnipMate.txt* +SuperTabChain supertab.txt /*SuperTabChain* +SuperTabSetDefaultCompletionType supertab.txt /*SuperTabSetDefaultCompletionType* +TestArgs() tlib.txt /*TestArgs()* +TestArgs1() tlib.txt /*TestArgs1()* +TestArgs2() tlib.txt /*TestArgs2()* +TestArgs3() tlib.txt /*TestArgs3()* +TestGetArg() tlib.txt /*TestGetArg()* +TestGetArg1() tlib.txt /*TestGetArg1()* +b:SuperTabContextTextMemberPatterns supertab.txt /*b:SuperTabContextTextMemberPatterns* +b:SuperTabContextTextOmniPrecedence supertab.txt /*b:SuperTabContextTextOmniPrecedence* +cached_file_contents cached_file_contents.txt /*cached_file_contents* +faked-function-reference funcref.txt /*faked-function-reference* +funcref funcref.txt /*funcref* +funcref#Call funcref.txt /*funcref#Call* +funcref#Function funcref.txt /*funcref#Function* +g:SuperTabClosePreviewOnPopupClose supertab.txt /*g:SuperTabClosePreviewOnPopupClose* +g:SuperTabCompleteCase supertab.txt /*g:SuperTabCompleteCase* +g:SuperTabCompletionContexts supertab.txt /*g:SuperTabCompletionContexts* +g:SuperTabContextDefaultCompletionType supertab.txt /*g:SuperTabContextDefaultCompletionType* +g:SuperTabContextTextFileTypeExclusions supertab.txt /*g:SuperTabContextTextFileTypeExclusions* +g:SuperTabContextTextMemberPatterns supertab.txt /*g:SuperTabContextTextMemberPatterns* +g:SuperTabContextTextOmniPrecedence supertab.txt /*g:SuperTabContextTextOmniPrecedence* +g:SuperTabCrMapping supertab.txt /*g:SuperTabCrMapping* +g:SuperTabDefaultCompletionType supertab.txt /*g:SuperTabDefaultCompletionType* +g:SuperTabLongestEnhanced supertab.txt /*g:SuperTabLongestEnhanced* +g:SuperTabLongestHighlight supertab.txt /*g:SuperTabLongestHighlight* +g:SuperTabMappingBackward supertab.txt /*g:SuperTabMappingBackward* +g:SuperTabMappingForward supertab.txt /*g:SuperTabMappingForward* +g:SuperTabMappingTabLiteral supertab.txt /*g:SuperTabMappingTabLiteral* +g:SuperTabNoCompleteAfter supertab.txt /*g:SuperTabNoCompleteAfter* +g:SuperTabNoCompleteBefore supertab.txt /*g:SuperTabNoCompleteBefore* +g:SuperTabRetainCompletionDuration supertab.txt /*g:SuperTabRetainCompletionDuration* +g:tlib#Filter_glob#char tlib.txt /*g:tlib#Filter_glob#char* +g:tlib#Filter_glob#seq tlib.txt /*g:tlib#Filter_glob#seq* +g:tlib#cache#dont_purge tlib.txt /*g:tlib#cache#dont_purge* +g:tlib#cache#max_filename tlib.txt /*g:tlib#cache#max_filename* +g:tlib#cache#purge_days tlib.txt /*g:tlib#cache#purge_days* +g:tlib#cache#purge_every_days tlib.txt /*g:tlib#cache#purge_every_days* +g:tlib#cache#run_script tlib.txt /*g:tlib#cache#run_script* +g:tlib#cache#script_encoding tlib.txt /*g:tlib#cache#script_encoding* +g:tlib#cache#verbosity tlib.txt /*g:tlib#cache#verbosity* +g:tlib#debug tlib.txt /*g:tlib#debug* +g:tlib#dir#sep tlib.txt /*g:tlib#dir#sep* +g:tlib#file#absolute_filename_rx tlib.txt /*g:tlib#file#absolute_filename_rx* +g:tlib#file#drop tlib.txt /*g:tlib#file#drop* +g:tlib#file#edit_cmds tlib.txt /*g:tlib#file#edit_cmds* +g:tlib#file#use_tabs tlib.txt /*g:tlib#file#use_tabs* +g:tlib#hash#use_adler32 tlib.txt /*g:tlib#hash#use_adler32* +g:tlib#hash#use_crc32 tlib.txt /*g:tlib#hash#use_crc32* +g:tlib#input#and tlib.txt /*g:tlib#input#and* +g:tlib#input#filename_max_width tlib.txt /*g:tlib#input#filename_max_width* +g:tlib#input#filename_padding_r tlib.txt /*g:tlib#input#filename_padding_r* +g:tlib#input#filter_mode tlib.txt /*g:tlib#input#filter_mode* +g:tlib#input#format_filename tlib.txt /*g:tlib#input#format_filename* +g:tlib#input#handlers_EditList tlib.txt /*g:tlib#input#handlers_EditList* +g:tlib#input#higroup tlib.txt /*g:tlib#input#higroup* +g:tlib#input#keyagents_InputList_m tlib.txt /*g:tlib#input#keyagents_InputList_m* +g:tlib#input#keyagents_InputList_s tlib.txt /*g:tlib#input#keyagents_InputList_s* +g:tlib#input#livesearch_threshold tlib.txt /*g:tlib#input#livesearch_threshold* +g:tlib#input#not tlib.txt /*g:tlib#input#not* +g:tlib#input#numeric_chars tlib.txt /*g:tlib#input#numeric_chars* +g:tlib#input#or tlib.txt /*g:tlib#input#or* +g:tlib#input#sortprefs_threshold tlib.txt /*g:tlib#input#sortprefs_threshold* +g:tlib#input#use_popup tlib.txt /*g:tlib#input#use_popup* +g:tlib#input#user_shortcuts tlib.txt /*g:tlib#input#user_shortcuts* +g:tlib#scratch#hidden tlib.txt /*g:tlib#scratch#hidden* +g:tlib#sys#check_cygpath tlib.txt /*g:tlib#sys#check_cygpath* +g:tlib#sys#cygwin_expr tlib.txt /*g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_path_rx tlib.txt /*g:tlib#sys#cygwin_path_rx* +g:tlib#sys#null tlib.txt /*g:tlib#sys#null* +g:tlib#sys#special_protocols tlib.txt /*g:tlib#sys#special_protocols* +g:tlib#sys#special_suffixes tlib.txt /*g:tlib#sys#special_suffixes* +g:tlib#sys#system_browser tlib.txt /*g:tlib#sys#system_browser* +g:tlib#sys#system_browser tlib.txt /*g:tlib#sys#system_browser* +g:tlib#sys#system_rx tlib.txt /*g:tlib#sys#system_rx* +g:tlib#sys#windows tlib.txt /*g:tlib#sys#windows* +g:tlib#vcs#check tlib.txt /*g:tlib#vcs#check* +g:tlib#vcs#def tlib.txt /*g:tlib#vcs#def* +g:tlib#vcs#executables tlib.txt /*g:tlib#vcs#executables* +g:tlib#vim#simalt_maximize tlib.txt /*g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_restore tlib.txt /*g:tlib#vim#simalt_restore* +g:tlib#vim#use_vimtweak tlib.txt /*g:tlib#vim#use_vimtweak* +g:tlib#vim#use_wmctrl tlib.txt /*g:tlib#vim#use_wmctrl* +g:tlib_cache tlib.txt /*g:tlib_cache* +g:tlib_inputlist_filename_indicators tlib.txt /*g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_pct tlib.txt /*g:tlib_inputlist_pct* +g:tlib_inputlist_shortmessage tlib.txt /*g:tlib_inputlist_shortmessage* +g:tlib_inputlist_width_filename tlib.txt /*g:tlib_inputlist_width_filename* +g:tlib_persistent tlib.txt /*g:tlib_persistent* +g:tlib_pick_last_item tlib.txt /*g:tlib_pick_last_item* +g:tlib_scratch_pos tlib.txt /*g:tlib_scratch_pos* +g:tlib_scroll_lines tlib.txt /*g:tlib_scroll_lines* +g:tlib_tag_substitute tlib.txt /*g:tlib_tag_substitute* +g:tlib_tags_extra tlib.txt /*g:tlib_tags_extra* +g:tlib_viewline_position tlib.txt /*g:tlib_viewline_position* +o_sp tlib.txt /*o_sp* +snipMate-extends SnipMate.txt /*snipMate-extends* +snippet SnipMate.txt /*snippet* +snippet-syntax SnipMate.txt /*snippet-syntax* +snippets SnipMate.txt /*snippets* +standard-paragraph tlib.txt /*standard-paragraph* +supertab supertab.txt /*supertab* +supertab-closepreviewonpopupclose supertab.txt /*supertab-closepreviewonpopupclose* +supertab-completecase supertab.txt /*supertab-completecase* +supertab-completionchaining supertab.txt /*supertab-completionchaining* +supertab-completioncontexts supertab.txt /*supertab-completioncontexts* +supertab-contextdefault supertab.txt /*supertab-contextdefault* +supertab-contextdiscover supertab.txt /*supertab-contextdiscover* +supertab-contextexample supertab.txt /*supertab-contextexample* +supertab-contexttext supertab.txt /*supertab-contexttext* +supertab-crmapping supertab.txt /*supertab-crmapping* +supertab-defaultcompletion supertab.txt /*supertab-defaultcompletion* +supertab-duration supertab.txt /*supertab-duration* +supertab-forwardbackward supertab.txt /*supertab-forwardbackward* +supertab-intro supertab.txt /*supertab-intro* +supertab-longestenhanced supertab.txt /*supertab-longestenhanced* +supertab-longesthighlight supertab.txt /*supertab-longesthighlight* +supertab-mappingtabliteral supertab.txt /*supertab-mappingtabliteral* +supertab-options supertab.txt /*supertab-options* +supertab-preventcomplete supertab.txt /*supertab-preventcomplete* +supertab-usage supertab.txt /*supertab-usage* +supertab.txt supertab.txt /*supertab.txt* +tiny-cmd tiny_cmd.txt /*tiny-cmd* +tlib#Filter_cnf#New() tlib.txt /*tlib#Filter_cnf#New()* +tlib#Filter_cnfd#New() tlib.txt /*tlib#Filter_cnfd#New()* +tlib#Filter_fuzzy#New() tlib.txt /*tlib#Filter_fuzzy#New()* +tlib#Filter_glob#New() tlib.txt /*tlib#Filter_glob#New()* +tlib#Object#Methods() tlib.txt /*tlib#Object#Methods()* +tlib#Object#New() tlib.txt /*tlib#Object#New()* +tlib#World#New() tlib.txt /*tlib#World#New()* +tlib#agent#AND() tlib.txt /*tlib#agent#AND()* +tlib#agent#CompleteAgentNames() tlib.txt /*tlib#agent#CompleteAgentNames()* +tlib#agent#Copy() tlib.txt /*tlib#agent#Copy()* +tlib#agent#CopyItems() tlib.txt /*tlib#agent#CopyItems()* +tlib#agent#Cut() tlib.txt /*tlib#agent#Cut()* +tlib#agent#Debug() tlib.txt /*tlib#agent#Debug()* +tlib#agent#DeleteItems() tlib.txt /*tlib#agent#DeleteItems()* +tlib#agent#DoAtLine() tlib.txt /*tlib#agent#DoAtLine()* +tlib#agent#Down() tlib.txt /*tlib#agent#Down()* +tlib#agent#DownN() tlib.txt /*tlib#agent#DownN()* +tlib#agent#EditFile() tlib.txt /*tlib#agent#EditFile()* +tlib#agent#EditFileInSplit() tlib.txt /*tlib#agent#EditFileInSplit()* +tlib#agent#EditFileInTab() tlib.txt /*tlib#agent#EditFileInTab()* +tlib#agent#EditFileInVSplit() tlib.txt /*tlib#agent#EditFileInVSplit()* +tlib#agent#EditItem() tlib.txt /*tlib#agent#EditItem()* +tlib#agent#EditReturnValue() tlib.txt /*tlib#agent#EditReturnValue()* +tlib#agent#End() tlib.txt /*tlib#agent#End()* +tlib#agent#ExecAgentByName() tlib.txt /*tlib#agent#ExecAgentByName()* +tlib#agent#Exit() tlib.txt /*tlib#agent#Exit()* +tlib#agent#GotoLine() tlib.txt /*tlib#agent#GotoLine()* +tlib#agent#Help() tlib.txt /*tlib#agent#Help()* +tlib#agent#Home() tlib.txt /*tlib#agent#Home()* +tlib#agent#Input() tlib.txt /*tlib#agent#Input()* +tlib#agent#NewItem() tlib.txt /*tlib#agent#NewItem()* +tlib#agent#Null() tlib.txt /*tlib#agent#Null()* +tlib#agent#OR() tlib.txt /*tlib#agent#OR()* +tlib#agent#PageDown() tlib.txt /*tlib#agent#PageDown()* +tlib#agent#PageUp() tlib.txt /*tlib#agent#PageUp()* +tlib#agent#Paste() tlib.txt /*tlib#agent#Paste()* +tlib#agent#PopFilter() tlib.txt /*tlib#agent#PopFilter()* +tlib#agent#PreviewLine() tlib.txt /*tlib#agent#PreviewLine()* +tlib#agent#ReduceFilter() tlib.txt /*tlib#agent#ReduceFilter()* +tlib#agent#Reset() tlib.txt /*tlib#agent#Reset()* +tlib#agent#RestrictView() tlib.txt /*tlib#agent#RestrictView()* +tlib#agent#Select() tlib.txt /*tlib#agent#Select()* +tlib#agent#SelectAll() tlib.txt /*tlib#agent#SelectAll()* +tlib#agent#SelectDown() tlib.txt /*tlib#agent#SelectDown()* +tlib#agent#SelectUp() tlib.txt /*tlib#agent#SelectUp()* +tlib#agent#ShiftLeft() tlib.txt /*tlib#agent#ShiftLeft()* +tlib#agent#ShiftRight() tlib.txt /*tlib#agent#ShiftRight()* +tlib#agent#ShowInfo() tlib.txt /*tlib#agent#ShowInfo()* +tlib#agent#Suspend() tlib.txt /*tlib#agent#Suspend()* +tlib#agent#SuspendToParentWindow() tlib.txt /*tlib#agent#SuspendToParentWindow()* +tlib#agent#ToggleRestrictView() tlib.txt /*tlib#agent#ToggleRestrictView()* +tlib#agent#ToggleScrollbind() tlib.txt /*tlib#agent#ToggleScrollbind()* +tlib#agent#ToggleStickyList() tlib.txt /*tlib#agent#ToggleStickyList()* +tlib#agent#UnrestrictView() tlib.txt /*tlib#agent#UnrestrictView()* +tlib#agent#Up() tlib.txt /*tlib#agent#Up()* +tlib#agent#UpN() tlib.txt /*tlib#agent#UpN()* +tlib#agent#ViewFile() tlib.txt /*tlib#agent#ViewFile()* +tlib#agent#Wildcard() tlib.txt /*tlib#agent#Wildcard()* +tlib#arg#Ex() tlib.txt /*tlib#arg#Ex()* +tlib#arg#Get() tlib.txt /*tlib#arg#Get()* +tlib#arg#Key() tlib.txt /*tlib#arg#Key()* +tlib#arg#Let() tlib.txt /*tlib#arg#Let()* +tlib#arg#StringAsKeyArgs() tlib.txt /*tlib#arg#StringAsKeyArgs()* +tlib#arg#StringAsKeyArgsEqual() tlib.txt /*tlib#arg#StringAsKeyArgsEqual()* +tlib#autocmdgroup#Init() tlib.txt /*tlib#autocmdgroup#Init()* +tlib#balloon#Expr() tlib.txt /*tlib#balloon#Expr()* +tlib#balloon#Register() tlib.txt /*tlib#balloon#Register()* +tlib#balloon#Remove() tlib.txt /*tlib#balloon#Remove()* +tlib#bitwise#AND() tlib.txt /*tlib#bitwise#AND()* +tlib#bitwise#Add() tlib.txt /*tlib#bitwise#Add()* +tlib#bitwise#Bits2Num() tlib.txt /*tlib#bitwise#Bits2Num()* +tlib#bitwise#Num2Bits() tlib.txt /*tlib#bitwise#Num2Bits()* +tlib#bitwise#OR() tlib.txt /*tlib#bitwise#OR()* +tlib#bitwise#ShiftLeft() tlib.txt /*tlib#bitwise#ShiftLeft()* +tlib#bitwise#ShiftRight() tlib.txt /*tlib#bitwise#ShiftRight()* +tlib#bitwise#Sub() tlib.txt /*tlib#bitwise#Sub()* +tlib#bitwise#XOR() tlib.txt /*tlib#bitwise#XOR()* +tlib#buffer#BufDo() tlib.txt /*tlib#buffer#BufDo()* +tlib#buffer#CurrentByte() tlib.txt /*tlib#buffer#CurrentByte()* +tlib#buffer#DeleteRange() tlib.txt /*tlib#buffer#DeleteRange()* +tlib#buffer#DisableMRU() tlib.txt /*tlib#buffer#DisableMRU()* +tlib#buffer#EnableMRU() tlib.txt /*tlib#buffer#EnableMRU()* +tlib#buffer#Eval() tlib.txt /*tlib#buffer#Eval()* +tlib#buffer#GetList() tlib.txt /*tlib#buffer#GetList()* +tlib#buffer#HighlightLine() tlib.txt /*tlib#buffer#HighlightLine()* +tlib#buffer#InsertText() tlib.txt /*tlib#buffer#InsertText()* +tlib#buffer#InsertText0() tlib.txt /*tlib#buffer#InsertText0()* +tlib#buffer#KeepCursorPosition() tlib.txt /*tlib#buffer#KeepCursorPosition()* +tlib#buffer#ReplaceRange() tlib.txt /*tlib#buffer#ReplaceRange()* +tlib#buffer#ScratchEnd() tlib.txt /*tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchStart() tlib.txt /*tlib#buffer#ScratchStart()* +tlib#buffer#Set() tlib.txt /*tlib#buffer#Set()* +tlib#buffer#ViewLine() tlib.txt /*tlib#buffer#ViewLine()* +tlib#cache#Dir() tlib.txt /*tlib#cache#Dir()* +tlib#cache#Filename() tlib.txt /*tlib#cache#Filename()* +tlib#cache#Get() tlib.txt /*tlib#cache#Get()* +tlib#cache#ListFilesInCache() tlib.txt /*tlib#cache#ListFilesInCache()* +tlib#cache#MTime() tlib.txt /*tlib#cache#MTime()* +tlib#cache#MaybePurge() tlib.txt /*tlib#cache#MaybePurge()* +tlib#cache#Purge() tlib.txt /*tlib#cache#Purge()* +tlib#cache#Save() tlib.txt /*tlib#cache#Save()* +tlib#cache#Value() tlib.txt /*tlib#cache#Value()* +tlib#char#Get() tlib.txt /*tlib#char#Get()* +tlib#char#GetWithTimeout() tlib.txt /*tlib#char#GetWithTimeout()* +tlib#char#IsAvailable() tlib.txt /*tlib#char#IsAvailable()* +tlib#cmd#BrowseOutput() tlib.txt /*tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutputWithCallback() tlib.txt /*tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#Capture() tlib.txt /*tlib#cmd#Capture()* +tlib#cmd#DefaultBrowseOutput() tlib.txt /*tlib#cmd#DefaultBrowseOutput()* +tlib#cmd#OutputAsList() tlib.txt /*tlib#cmd#OutputAsList()* +tlib#cmd#ParseScriptname() tlib.txt /*tlib#cmd#ParseScriptname()* +tlib#cmd#Time() tlib.txt /*tlib#cmd#Time()* +tlib#cmd#UseVertical() tlib.txt /*tlib#cmd#UseVertical()* +tlib#comments#Comments() tlib.txt /*tlib#comments#Comments()* +tlib#date#DiffInDays() tlib.txt /*tlib#date#DiffInDays()* +tlib#date#Parse() tlib.txt /*tlib#date#Parse()* +tlib#date#SecondsSince1970() tlib.txt /*tlib#date#SecondsSince1970()* +tlib#dir#CD() tlib.txt /*tlib#dir#CD()* +tlib#dir#CanonicName() tlib.txt /*tlib#dir#CanonicName()* +tlib#dir#Ensure() tlib.txt /*tlib#dir#Ensure()* +tlib#dir#MyRuntime() tlib.txt /*tlib#dir#MyRuntime()* +tlib#dir#NativeName() tlib.txt /*tlib#dir#NativeName()* +tlib#dir#PlainName() tlib.txt /*tlib#dir#PlainName()* +tlib#dir#Pop() tlib.txt /*tlib#dir#Pop()* +tlib#dir#Push() tlib.txt /*tlib#dir#Push()* +tlib#eval#FormatValue() tlib.txt /*tlib#eval#FormatValue()* +tlib#file#Absolute() tlib.txt /*tlib#file#Absolute()* +tlib#file#Canonic() tlib.txt /*tlib#file#Canonic()* +tlib#file#Edit() tlib.txt /*tlib#file#Edit()* +tlib#file#Join() tlib.txt /*tlib#file#Join()* +tlib#file#Relative() tlib.txt /*tlib#file#Relative()* +tlib#file#Split() tlib.txt /*tlib#file#Split()* +tlib#file#With() tlib.txt /*tlib#file#With()* +tlib#fixes#Winpos() tlib.txt /*tlib#fixes#Winpos()* +tlib#grep#Do() tlib.txt /*tlib#grep#Do()* +tlib#grep#List() tlib.txt /*tlib#grep#List()* +tlib#grep#LocList() tlib.txt /*tlib#grep#LocList()* +tlib#grep#QuickFixList() tlib.txt /*tlib#grep#QuickFixList()* +tlib#hash#Adler32() tlib.txt /*tlib#hash#Adler32()* +tlib#hash#Adler32_tlib() tlib.txt /*tlib#hash#Adler32_tlib()* +tlib#hash#Adler32_vim() tlib.txt /*tlib#hash#Adler32_vim()* +tlib#hash#CRC32B() tlib.txt /*tlib#hash#CRC32B()* +tlib#hash#CRC32B_ruby() tlib.txt /*tlib#hash#CRC32B_ruby()* +tlib#hash#CRC32B_vim() tlib.txt /*tlib#hash#CRC32B_vim()* +tlib#hook#Run() tlib.txt /*tlib#hook#Run()* +tlib#input#CommandSelect() tlib.txt /*tlib#input#CommandSelect()* +tlib#input#Dialog() tlib.txt /*tlib#input#Dialog()* +tlib#input#Edit() tlib.txt /*tlib#input#Edit()* +tlib#input#EditList() tlib.txt /*tlib#input#EditList()* +tlib#input#List() tlib.txt /*tlib#input#List()* +tlib#input#ListD() tlib.txt /*tlib#input#ListD()* +tlib#input#ListW() tlib.txt /*tlib#input#ListW()* +tlib#input#Resume() tlib.txt /*tlib#input#Resume()* +tlib#list#All() tlib.txt /*tlib#list#All()* +tlib#list#Any() tlib.txt /*tlib#list#Any()* +tlib#list#Compact() tlib.txt /*tlib#list#Compact()* +tlib#list#Find() tlib.txt /*tlib#list#Find()* +tlib#list#FindAll() tlib.txt /*tlib#list#FindAll()* +tlib#list#Flatten() tlib.txt /*tlib#list#Flatten()* +tlib#list#Inject() tlib.txt /*tlib#list#Inject()* +tlib#list#Remove() tlib.txt /*tlib#list#Remove()* +tlib#list#RemoveAll() tlib.txt /*tlib#list#RemoveAll()* +tlib#list#ToDictionary() tlib.txt /*tlib#list#ToDictionary()* +tlib#list#Uniq() tlib.txt /*tlib#list#Uniq()* +tlib#list#Zip() tlib.txt /*tlib#list#Zip()* +tlib#map#PumAccept() tlib.txt /*tlib#map#PumAccept()* +tlib#normal#WithRegister() tlib.txt /*tlib#normal#WithRegister()* +tlib#notify#Echo() tlib.txt /*tlib#notify#Echo()* +tlib#notify#TrimMessage() tlib.txt /*tlib#notify#TrimMessage()* +tlib#number#ConvertBase() tlib.txt /*tlib#number#ConvertBase()* +tlib#paragraph#GetMetric() tlib.txt /*tlib#paragraph#GetMetric()* +tlib#paragraph#Move() tlib.txt /*tlib#paragraph#Move()* +tlib#persistent#Dir() tlib.txt /*tlib#persistent#Dir()* +tlib#persistent#Filename() tlib.txt /*tlib#persistent#Filename()* +tlib#persistent#Get() tlib.txt /*tlib#persistent#Get()* +tlib#persistent#MTime() tlib.txt /*tlib#persistent#MTime()* +tlib#persistent#Save() tlib.txt /*tlib#persistent#Save()* +tlib#persistent#Value() tlib.txt /*tlib#persistent#Value()* +tlib#progressbar#Display() tlib.txt /*tlib#progressbar#Display()* +tlib#progressbar#Init() tlib.txt /*tlib#progressbar#Init()* +tlib#progressbar#Restore() tlib.txt /*tlib#progressbar#Restore()* +tlib#rx#Escape() tlib.txt /*tlib#rx#Escape()* +tlib#rx#EscapeReplace() tlib.txt /*tlib#rx#EscapeReplace()* +tlib#rx#Suffixes() tlib.txt /*tlib#rx#Suffixes()* +tlib#scratch#CloseScratch() tlib.txt /*tlib#scratch#CloseScratch()* +tlib#scratch#UseScratch() tlib.txt /*tlib#scratch#UseScratch()* +tlib#signs#ClearAll() tlib.txt /*tlib#signs#ClearAll()* +tlib#signs#ClearBuffer() tlib.txt /*tlib#signs#ClearBuffer()* +tlib#signs#Mark() tlib.txt /*tlib#signs#Mark()* +tlib#string#Chomp() tlib.txt /*tlib#string#Chomp()* +tlib#string#Count() tlib.txt /*tlib#string#Count()* +tlib#string#Format() tlib.txt /*tlib#string#Format()* +tlib#string#Printf1() tlib.txt /*tlib#string#Printf1()* +tlib#string#RemoveBackslashes() tlib.txt /*tlib#string#RemoveBackslashes()* +tlib#string#Strip() tlib.txt /*tlib#string#Strip()* +tlib#string#TrimLeft() tlib.txt /*tlib#string#TrimLeft()* +tlib#string#TrimRight() tlib.txt /*tlib#string#TrimRight()* +tlib#syntax#Collect() tlib.txt /*tlib#syntax#Collect()* +tlib#syntax#Names() tlib.txt /*tlib#syntax#Names()* +tlib#sys#ConvertPath() tlib.txt /*tlib#sys#ConvertPath()* +tlib#sys#FileArgs() tlib.txt /*tlib#sys#FileArgs()* +tlib#sys#GetCmd() tlib.txt /*tlib#sys#GetCmd()* +tlib#sys#IsCygwinBin() tlib.txt /*tlib#sys#IsCygwinBin()* +tlib#sys#IsExecutable() tlib.txt /*tlib#sys#IsExecutable()* +tlib#sys#IsSpecial() tlib.txt /*tlib#sys#IsSpecial()* +tlib#sys#MaybeUseCygpath() tlib.txt /*tlib#sys#MaybeUseCygpath()* +tlib#sys#Open() tlib.txt /*tlib#sys#Open()* +tlib#tab#BufMap() tlib.txt /*tlib#tab#BufMap()* +tlib#tab#Set() tlib.txt /*tlib#tab#Set()* +tlib#tab#TabWinNr() tlib.txt /*tlib#tab#TabWinNr()* +tlib#tag#Collect() tlib.txt /*tlib#tag#Collect()* +tlib#tag#Format() tlib.txt /*tlib#tag#Format()* +tlib#tag#Retrieve() tlib.txt /*tlib#tag#Retrieve()* +tlib#textobjects#Init() tlib.txt /*tlib#textobjects#Init()* +tlib#time#Diff() tlib.txt /*tlib#time#Diff()* +tlib#time#DiffMSecs() tlib.txt /*tlib#time#DiffMSecs()* +tlib#time#MSecs() tlib.txt /*tlib#time#MSecs()* +tlib#time#Now() tlib.txt /*tlib#time#Now()* +tlib#type#IsDictionary() tlib.txt /*tlib#type#IsDictionary()* +tlib#type#IsFuncref() tlib.txt /*tlib#type#IsFuncref()* +tlib#type#IsList() tlib.txt /*tlib#type#IsList()* +tlib#type#IsNumber() tlib.txt /*tlib#type#IsNumber()* +tlib#type#IsString() tlib.txt /*tlib#type#IsString()* +tlib#url#Decode() tlib.txt /*tlib#url#Decode()* +tlib#url#DecodeChar() tlib.txt /*tlib#url#DecodeChar()* +tlib#url#Encode() tlib.txt /*tlib#url#Encode()* +tlib#url#EncodeChar() tlib.txt /*tlib#url#EncodeChar()* +tlib#var#EGet() tlib.txt /*tlib#var#EGet()* +tlib#var#Get() tlib.txt /*tlib#var#Get()* +tlib#var#Let() tlib.txt /*tlib#var#Let()* +tlib#var#List() tlib.txt /*tlib#var#List()* +tlib#vcs#Diff() tlib.txt /*tlib#vcs#Diff()* +tlib#vcs#Executable() tlib.txt /*tlib#vcs#Executable()* +tlib#vcs#FindVCS() tlib.txt /*tlib#vcs#FindVCS()* +tlib#vcs#Ls() tlib.txt /*tlib#vcs#Ls()* +tlib#vim#CopyFunction() tlib.txt /*tlib#vim#CopyFunction()* +tlib#vim#Maximize() tlib.txt /*tlib#vim#Maximize()* +tlib#vim#RestoreWindow() tlib.txt /*tlib#vim#RestoreWindow()* +tlib#win#GetLayout() tlib.txt /*tlib#win#GetLayout()* +tlib#win#List() tlib.txt /*tlib#win#List()* +tlib#win#Set() tlib.txt /*tlib#win#Set()* +tlib#win#SetLayout() tlib.txt /*tlib#win#SetLayout()* +tlib#win#Width() tlib.txt /*tlib#win#Width()* +tlib#win#WinDo() tlib.txt /*tlib#win#WinDo()* +tlib.txt tlib.txt /*tlib.txt* +v_sp tlib.txt /*v_sp* diff --git a/vim/.vim/doc/tiny_cmd.txt b/vim/.vim/doc/tiny_cmd.txt new file mode 100644 index 0000000..bc6e002 --- /dev/null +++ b/vim/.vim/doc/tiny_cmd.txt @@ -0,0 +1,18 @@ +*tiny-cmd* make long commands short so that they hopefully no longer trigger "press Enter .. [ok]" + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Problem: > + exec 'map :silent! let g:g="'.repeat('foobar ',200).'"' +Now run the mapping by pressing and you notice what I'm talking about + +Solution (Example): + + +Example usage: > + let nr = tiny_cmd#Put('let g:g="'.repeat('foobar ',200).'"') + exec 'map :exec tiny_cmd#Get('.nr.')' +< +Use Pop instead of Get if you use this command once only diff --git a/vim/.vim/doc/tlib.txt b/vim/.vim/doc/tlib.txt new file mode 100755 index 0000000..5c3eadf --- /dev/null +++ b/vim/.vim/doc/tlib.txt @@ -0,0 +1,2247 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +======================================================================== +Contents~ + + :TRequire .............................. |:TRequire| + :TLet .................................. |:TLet| + :TScratch .............................. |:TScratch| + :TVarArg ............................... |:TVarArg| + :TKeyArg ............................... |:TKeyArg| + :TBrowseOutput ......................... |:TBrowseOutput| + :TBrowseScriptnames .................... |:TBrowseScriptnames| + :TTimeCommand .......................... |:TTimeCommand| + Add .................................... |Add()| + TestGetArg ............................. |TestGetArg()| + TestGetArg1 ............................ |TestGetArg1()| + TestArgs ............................... |TestArgs()| + TestArgs1 .............................. |TestArgs1()| + TestArgs2 .............................. |TestArgs2()| + TestArgs3 .............................. |TestArgs3()| + g:tlib#debug ........................... |g:tlib#debug| + tlib#notify#Echo ....................... |tlib#notify#Echo()| + tlib#notify#TrimMessage ................ |tlib#notify#TrimMessage()| + g:tlib_persistent ...................... |g:tlib_persistent| + tlib#persistent#Dir .................... |tlib#persistent#Dir()| + tlib#persistent#Filename ............... |tlib#persistent#Filename()| + tlib#persistent#Get .................... |tlib#persistent#Get()| + tlib#persistent#MTime .................. |tlib#persistent#MTime()| + tlib#persistent#Value .................. |tlib#persistent#Value()| + tlib#persistent#Save ................... |tlib#persistent#Save()| + g:tlib#vim#simalt_maximize ............. |g:tlib#vim#simalt_maximize| + g:tlib#vim#simalt_restore .............. |g:tlib#vim#simalt_restore| + g:tlib#vim#use_vimtweak ................ |g:tlib#vim#use_vimtweak| + tlib#vim#Maximize ...................... |tlib#vim#Maximize()| + tlib#vim#RestoreWindow ................. |tlib#vim#RestoreWindow()| + g:tlib#vim#use_wmctrl .................. |g:tlib#vim#use_wmctrl| + tlib#vim#CopyFunction .................. |tlib#vim#CopyFunction()| + tlib#progressbar#Init .................. |tlib#progressbar#Init()| + tlib#progressbar#Display ............... |tlib#progressbar#Display()| + tlib#progressbar#Restore ............... |tlib#progressbar#Restore()| + tlib#eval#FormatValue .................. |tlib#eval#FormatValue()| + tlib#list#Inject ....................... |tlib#list#Inject()| + tlib#list#Compact ...................... |tlib#list#Compact()| + tlib#list#Flatten ...................... |tlib#list#Flatten()| + tlib#list#FindAll ...................... |tlib#list#FindAll()| + tlib#list#Find ......................... |tlib#list#Find()| + tlib#list#Any .......................... |tlib#list#Any()| + tlib#list#All .......................... |tlib#list#All()| + tlib#list#Remove ....................... |tlib#list#Remove()| + tlib#list#RemoveAll .................... |tlib#list#RemoveAll()| + tlib#list#Zip .......................... |tlib#list#Zip()| + tlib#list#Uniq ......................... |tlib#list#Uniq()| + tlib#list#ToDictionary ................. |tlib#list#ToDictionary()| + tlib#cmd#OutputAsList .................. |tlib#cmd#OutputAsList()| + tlib#cmd#BrowseOutput .................. |tlib#cmd#BrowseOutput()| + tlib#cmd#BrowseOutputWithCallback ...... |tlib#cmd#BrowseOutputWithCallback()| + tlib#cmd#DefaultBrowseOutput ........... |tlib#cmd#DefaultBrowseOutput()| + tlib#cmd#ParseScriptname ............... |tlib#cmd#ParseScriptname()| + tlib#cmd#UseVertical ................... |tlib#cmd#UseVertical()| + tlib#cmd#Time .......................... |tlib#cmd#Time()| + tlib#cmd#Capture ....................... |tlib#cmd#Capture()| + tlib#syntax#Collect .................... |tlib#syntax#Collect()| + tlib#syntax#Names ...................... |tlib#syntax#Names()| + tlib#balloon#Register .................. |tlib#balloon#Register()| + tlib#balloon#Remove .................... |tlib#balloon#Remove()| + tlib#balloon#Expr ...................... |tlib#balloon#Expr()| + g:tlib#vcs#def ......................... |g:tlib#vcs#def| + g:tlib#vcs#executables ................. |g:tlib#vcs#executables| + g:tlib#vcs#check ....................... |g:tlib#vcs#check| + tlib#vcs#Executable .................... |tlib#vcs#Executable()| + tlib#vcs#FindVCS ....................... |tlib#vcs#FindVCS()| + tlib#vcs#Ls ............................ |tlib#vcs#Ls()| + tlib#vcs#Diff .......................... |tlib#vcs#Diff()| + tlib#char#Get .......................... |tlib#char#Get()| + tlib#char#IsAvailable .................. |tlib#char#IsAvailable()| + tlib#char#GetWithTimeout ............... |tlib#char#GetWithTimeout()| + g:tlib#Filter_glob#seq ................. |g:tlib#Filter_glob#seq| + g:tlib#Filter_glob#char ................ |g:tlib#Filter_glob#char| + tlib#Filter_glob#New ................... |tlib#Filter_glob#New()| + g:tlib_scratch_pos ..................... |g:tlib_scratch_pos| + g:tlib#scratch#hidden .................. |g:tlib#scratch#hidden| + tlib#scratch#UseScratch ................ |tlib#scratch#UseScratch()| + tlib#scratch#CloseScratch .............. |tlib#scratch#CloseScratch()| + tlib#autocmdgroup#Init ................. |tlib#autocmdgroup#Init()| + g:tlib_cache ........................... |g:tlib_cache| + g:tlib#cache#purge_days ................ |g:tlib#cache#purge_days| + g:tlib#cache#purge_every_days .......... |g:tlib#cache#purge_every_days| + g:tlib#cache#script_encoding ........... |g:tlib#cache#script_encoding| + g:tlib#cache#run_script ................ |g:tlib#cache#run_script| + g:tlib#cache#verbosity ................. |g:tlib#cache#verbosity| + g:tlib#cache#dont_purge ................ |g:tlib#cache#dont_purge| + g:tlib#cache#max_filename .............. |g:tlib#cache#max_filename| + tlib#cache#Dir ......................... |tlib#cache#Dir()| + tlib#cache#Filename .................... |tlib#cache#Filename()| + tlib#cache#Save ........................ |tlib#cache#Save()| + tlib#cache#MTime ....................... |tlib#cache#MTime()| + tlib#cache#Get ......................... |tlib#cache#Get()| + tlib#cache#Value ....................... |tlib#cache#Value()| + tlib#cache#MaybePurge .................. |tlib#cache#MaybePurge()| + tlib#cache#Purge ....................... |tlib#cache#Purge()| + tlib#cache#ListFilesInCache ............ |tlib#cache#ListFilesInCache()| + tlib#normal#WithRegister ............... |tlib#normal#WithRegister()| + tlib#time#MSecs ........................ |tlib#time#MSecs()| + tlib#time#Now .......................... |tlib#time#Now()| + tlib#time#Diff ......................... |tlib#time#Diff()| + tlib#time#DiffMSecs .................... |tlib#time#DiffMSecs()| + tlib#var#Let ........................... |tlib#var#Let()| + tlib#var#EGet .......................... |tlib#var#EGet()| + tlib#var#Get ........................... |tlib#var#Get()| + tlib#var#List .......................... |tlib#var#List()| + g:tlib_scroll_lines .................... |g:tlib_scroll_lines| + tlib#agent#Exit ........................ |tlib#agent#Exit()| + tlib#agent#CopyItems ................... |tlib#agent#CopyItems()| + tlib#agent#PageUp ...................... |tlib#agent#PageUp()| + tlib#agent#PageDown .................... |tlib#agent#PageDown()| + tlib#agent#Home ........................ |tlib#agent#Home()| + tlib#agent#End ......................... |tlib#agent#End()| + tlib#agent#Up .......................... |tlib#agent#Up()| + tlib#agent#Down ........................ |tlib#agent#Down()| + tlib#agent#UpN ......................... |tlib#agent#UpN()| + tlib#agent#DownN ....................... |tlib#agent#DownN()| + tlib#agent#ShiftLeft ................... |tlib#agent#ShiftLeft()| + tlib#agent#ShiftRight .................. |tlib#agent#ShiftRight()| + tlib#agent#Reset ....................... |tlib#agent#Reset()| + tlib#agent#ToggleRestrictView .......... |tlib#agent#ToggleRestrictView()| + tlib#agent#RestrictView ................ |tlib#agent#RestrictView()| + tlib#agent#UnrestrictView .............. |tlib#agent#UnrestrictView()| + tlib#agent#Input ....................... |tlib#agent#Input()| + tlib#agent#SuspendToParentWindow ....... |tlib#agent#SuspendToParentWindow()| + tlib#agent#Suspend ..................... |tlib#agent#Suspend()| + tlib#agent#Help ........................ |tlib#agent#Help()| + tlib#agent#OR .......................... |tlib#agent#OR()| + tlib#agent#AND ......................... |tlib#agent#AND()| + tlib#agent#ReduceFilter ................ |tlib#agent#ReduceFilter()| + tlib#agent#PopFilter ................... |tlib#agent#PopFilter()| + tlib#agent#Debug ....................... |tlib#agent#Debug()| + tlib#agent#Select ...................... |tlib#agent#Select()| + tlib#agent#SelectUp .................... |tlib#agent#SelectUp()| + tlib#agent#SelectDown .................. |tlib#agent#SelectDown()| + tlib#agent#SelectAll ................... |tlib#agent#SelectAll()| + tlib#agent#ToggleStickyList ............ |tlib#agent#ToggleStickyList()| + tlib#agent#EditItem .................... |tlib#agent#EditItem()| + tlib#agent#NewItem ..................... |tlib#agent#NewItem()| + tlib#agent#DeleteItems ................. |tlib#agent#DeleteItems()| + tlib#agent#Cut ......................... |tlib#agent#Cut()| + tlib#agent#Copy ........................ |tlib#agent#Copy()| + tlib#agent#Paste ....................... |tlib#agent#Paste()| + tlib#agent#EditReturnValue ............. |tlib#agent#EditReturnValue()| + tlib#agent#ViewFile .................... |tlib#agent#ViewFile()| + tlib#agent#EditFile .................... |tlib#agent#EditFile()| + tlib#agent#EditFileInSplit ............. |tlib#agent#EditFileInSplit()| + tlib#agent#EditFileInVSplit ............ |tlib#agent#EditFileInVSplit()| + tlib#agent#EditFileInTab ............... |tlib#agent#EditFileInTab()| + tlib#agent#ToggleScrollbind ............ |tlib#agent#ToggleScrollbind()| + tlib#agent#ShowInfo .................... |tlib#agent#ShowInfo()| + tlib#agent#PreviewLine ................. |tlib#agent#PreviewLine()| + tlib#agent#GotoLine .................... |tlib#agent#GotoLine()| + tlib#agent#DoAtLine .................... |tlib#agent#DoAtLine()| + tlib#agent#Wildcard .................... |tlib#agent#Wildcard()| + tlib#agent#Null ........................ |tlib#agent#Null()| + tlib#agent#ExecAgentByName ............. |tlib#agent#ExecAgentByName()| + tlib#agent#CompleteAgentNames .......... |tlib#agent#CompleteAgentNames()| + tlib#bitwise#Num2Bits .................. |tlib#bitwise#Num2Bits()| + tlib#bitwise#Bits2Num .................. |tlib#bitwise#Bits2Num()| + tlib#bitwise#AND ....................... |tlib#bitwise#AND()| + tlib#bitwise#OR ........................ |tlib#bitwise#OR()| + tlib#bitwise#XOR ....................... |tlib#bitwise#XOR()| + tlib#bitwise#ShiftRight ................ |tlib#bitwise#ShiftRight()| + tlib#bitwise#ShiftLeft ................. |tlib#bitwise#ShiftLeft()| + tlib#bitwise#Add ....................... |tlib#bitwise#Add()| + tlib#bitwise#Sub ....................... |tlib#bitwise#Sub()| + tlib#url#Decode ........................ |tlib#url#Decode()| + tlib#url#DecodeChar .................... |tlib#url#DecodeChar()| + tlib#url#EncodeChar .................... |tlib#url#EncodeChar()| + tlib#url#Encode ........................ |tlib#url#Encode()| + tlib#signs#ClearAll .................... |tlib#signs#ClearAll()| + tlib#signs#ClearBuffer ................. |tlib#signs#ClearBuffer()| + tlib#signs#Mark ........................ |tlib#signs#Mark()| + tlib#rx#Escape ......................... |tlib#rx#Escape()| + tlib#rx#EscapeReplace .................. |tlib#rx#EscapeReplace()| + tlib#rx#Suffixes ....................... |tlib#rx#Suffixes()| + g:tlib_tags_extra ...................... |g:tlib_tags_extra| + g:tlib_tag_substitute .................. |g:tlib_tag_substitute| + tlib#tag#Retrieve ...................... |tlib#tag#Retrieve()| + tlib#tag#Collect ....................... |tlib#tag#Collect()| + tlib#tag#Format ........................ |tlib#tag#Format()| + tlib#map#PumAccept ..................... |tlib#map#PumAccept()| + tlib#Filter_cnfd#New ................... |tlib#Filter_cnfd#New()| + g:tlib#input#sortprefs_threshold ....... |g:tlib#input#sortprefs_threshold| + g:tlib#input#livesearch_threshold ...... |g:tlib#input#livesearch_threshold| + g:tlib#input#filter_mode ............... |g:tlib#input#filter_mode| + g:tlib#input#higroup ................... |g:tlib#input#higroup| + g:tlib_pick_last_item .................. |g:tlib_pick_last_item| + g:tlib#input#and ....................... |g:tlib#input#and| + g:tlib#input#or ........................ |g:tlib#input#or| + g:tlib#input#not ....................... |g:tlib#input#not| + g:tlib#input#numeric_chars ............. |g:tlib#input#numeric_chars| + g:tlib#input#keyagents_InputList_s ..... |g:tlib#input#keyagents_InputList_s| + g:tlib#input#keyagents_InputList_m ..... |g:tlib#input#keyagents_InputList_m| + g:tlib#input#handlers_EditList ......... |g:tlib#input#handlers_EditList| + g:tlib#input#user_shortcuts ............ |g:tlib#input#user_shortcuts| + g:tlib#input#use_popup ................. |g:tlib#input#use_popup| + g:tlib#input#format_filename ........... |g:tlib#input#format_filename| + g:tlib#input#filename_padding_r ........ |g:tlib#input#filename_padding_r| + g:tlib#input#filename_max_width ........ |g:tlib#input#filename_max_width| + tlib#input#List ........................ |tlib#input#List()| + tlib#input#ListD ....................... |tlib#input#ListD()| + tlib#input#ListW ....................... |tlib#input#ListW()| + tlib#input#EditList .................... |tlib#input#EditList()| + tlib#input#Resume ...................... |tlib#input#Resume()| + tlib#input#CommandSelect ............... |tlib#input#CommandSelect()| + tlib#input#Edit ........................ |tlib#input#Edit()| + tlib#input#Dialog ...................... |tlib#input#Dialog()| + tlib#number#ConvertBase ................ |tlib#number#ConvertBase()| + g:tlib#file#drop ....................... |g:tlib#file#drop| + g:tlib#file#use_tabs ................... |g:tlib#file#use_tabs| + g:tlib#file#edit_cmds .................. |g:tlib#file#edit_cmds| + g:tlib#file#absolute_filename_rx ....... |g:tlib#file#absolute_filename_rx| + tlib#file#Split ........................ |tlib#file#Split()| + tlib#file#Join ......................... |tlib#file#Join()| + tlib#file#Relative ..................... |tlib#file#Relative()| + tlib#file#Absolute ..................... |tlib#file#Absolute()| + tlib#file#Canonic ...................... |tlib#file#Canonic()| + tlib#file#With ......................... |tlib#file#With()| + tlib#file#Edit ......................... |tlib#file#Edit()| + g:tlib#sys#special_protocols ........... |g:tlib#sys#special_protocols| + g:tlib#sys#special_suffixes ............ |g:tlib#sys#special_suffixes| + g:tlib#sys#system_rx ................... |g:tlib#sys#system_rx| + g:tlib#sys#system_browser .............. |g:tlib#sys#system_browser| + g:tlib#sys#system_browser .............. |g:tlib#sys#system_browser| + g:tlib#sys#windows ..................... |g:tlib#sys#windows| + g:tlib#sys#null ........................ |g:tlib#sys#null| + tlib#sys#IsCygwinBin ................... |tlib#sys#IsCygwinBin()| + tlib#sys#IsExecutable .................. |tlib#sys#IsExecutable()| + g:tlib#sys#check_cygpath ............... |g:tlib#sys#check_cygpath| + g:tlib#sys#cygwin_path_rx .............. |g:tlib#sys#cygwin_path_rx| + g:tlib#sys#cygwin_expr ................. |g:tlib#sys#cygwin_expr| + tlib#sys#GetCmd ........................ |tlib#sys#GetCmd()| + tlib#sys#MaybeUseCygpath ............... |tlib#sys#MaybeUseCygpath()| + tlib#sys#ConvertPath ................... |tlib#sys#ConvertPath()| + tlib#sys#FileArgs ...................... |tlib#sys#FileArgs()| + tlib#sys#IsSpecial ..................... |tlib#sys#IsSpecial()| + tlib#sys#Open .......................... |tlib#sys#Open()| + tlib#paragraph#GetMetric ............... |tlib#paragraph#GetMetric()| + tlib#paragraph#Move .................... |tlib#paragraph#Move()| + g:tlib_inputlist_pct ................... |g:tlib_inputlist_pct| + g:tlib_inputlist_width_filename ........ |g:tlib_inputlist_width_filename| + g:tlib_inputlist_filename_indicators ... |g:tlib_inputlist_filename_indicators| + g:tlib_inputlist_shortmessage .......... |g:tlib_inputlist_shortmessage| + tlib#World#New ......................... |tlib#World#New()| + prototype.PrintLines + prototype.Suspend + tlib#tab#BufMap ........................ |tlib#tab#BufMap()| + tlib#tab#TabWinNr ...................... |tlib#tab#TabWinNr()| + tlib#tab#Set ........................... |tlib#tab#Set()| + tlib#date#DiffInDays ................... |tlib#date#DiffInDays()| + tlib#date#Parse ........................ |tlib#date#Parse()| + tlib#date#SecondsSince1970 ............. |tlib#date#SecondsSince1970()| + tlib#type#IsNumber ..................... |tlib#type#IsNumber()| + tlib#type#IsString ..................... |tlib#type#IsString()| + tlib#type#IsFuncref .................... |tlib#type#IsFuncref()| + tlib#type#IsList ....................... |tlib#type#IsList()| + tlib#type#IsDictionary ................. |tlib#type#IsDictionary()| + tlib#Filter_fuzzy#New .................. |tlib#Filter_fuzzy#New()| + tlib#textobjects#StandardParagraph ..... |standard-paragraph| + tlib#textobjects#Init .................. |tlib#textobjects#Init()| + v_sp ................................... |v_sp| + o_sp ................................... |o_sp| + tlib#arg#Get ........................... |tlib#arg#Get()| + tlib#arg#Let ........................... |tlib#arg#Let()| + tlib#arg#Key ........................... |tlib#arg#Key()| + tlib#arg#StringAsKeyArgs ............... |tlib#arg#StringAsKeyArgs()| + tlib#arg#StringAsKeyArgsEqual .......... |tlib#arg#StringAsKeyArgsEqual()| + tlib#arg#Ex ............................ |tlib#arg#Ex()| + tlib#fixes#Winpos ...................... |tlib#fixes#Winpos()| + g:tlib#dir#sep ......................... |g:tlib#dir#sep| + tlib#dir#CanonicName ................... |tlib#dir#CanonicName()| + tlib#dir#NativeName .................... |tlib#dir#NativeName()| + tlib#dir#PlainName ..................... |tlib#dir#PlainName()| + tlib#dir#Ensure ........................ |tlib#dir#Ensure()| + tlib#dir#MyRuntime ..................... |tlib#dir#MyRuntime()| + tlib#dir#CD ............................ |tlib#dir#CD()| + tlib#dir#Push .......................... |tlib#dir#Push()| + tlib#dir#Pop ........................... |tlib#dir#Pop()| + g:tlib#hash#use_crc32 .................. |g:tlib#hash#use_crc32| + g:tlib#hash#use_adler32 ................ |g:tlib#hash#use_adler32| + tlib#hash#CRC32B ....................... |tlib#hash#CRC32B()| + tlib#hash#CRC32B_ruby .................. |tlib#hash#CRC32B_ruby()| + tlib#hash#CRC32B_vim ................... |tlib#hash#CRC32B_vim()| + tlib#hash#Adler32 ...................... |tlib#hash#Adler32()| + tlib#hash#Adler32_vim .................. |tlib#hash#Adler32_vim()| + tlib#hash#Adler32_tlib ................. |tlib#hash#Adler32_tlib()| + tlib#win#Set ........................... |tlib#win#Set()| + tlib#win#GetLayout ..................... |tlib#win#GetLayout()| + tlib#win#SetLayout ..................... |tlib#win#SetLayout()| + tlib#win#List .......................... |tlib#win#List()| + tlib#win#Width ......................... |tlib#win#Width()| + tlib#win#WinDo ......................... |tlib#win#WinDo()| + tlib#comments#Comments ................. |tlib#comments#Comments()| + tlib#grep#Do ........................... |tlib#grep#Do()| + tlib#grep#LocList ...................... |tlib#grep#LocList()| + tlib#grep#QuickFixList ................. |tlib#grep#QuickFixList()| + tlib#grep#List ......................... |tlib#grep#List()| + tlib#Filter_cnf#New .................... |tlib#Filter_cnf#New()| + prototype.Pretty + tlib#Object#New ........................ |tlib#Object#New()| + prototype.New + prototype.Inherit + prototype.Extend + prototype.IsA + prototype.IsRelated + prototype.RespondTo + prototype.Super + tlib#Object#Methods .................... |tlib#Object#Methods()| + g:tlib_viewline_position ............... |g:tlib_viewline_position| + tlib#buffer#EnableMRU .................. |tlib#buffer#EnableMRU()| + tlib#buffer#DisableMRU ................. |tlib#buffer#DisableMRU()| + tlib#buffer#Set ........................ |tlib#buffer#Set()| + tlib#buffer#Eval ....................... |tlib#buffer#Eval()| + tlib#buffer#GetList .................... |tlib#buffer#GetList()| + tlib#buffer#ViewLine ................... |tlib#buffer#ViewLine()| + tlib#buffer#HighlightLine .............. |tlib#buffer#HighlightLine()| + tlib#buffer#DeleteRange ................ |tlib#buffer#DeleteRange()| + tlib#buffer#ReplaceRange ............... |tlib#buffer#ReplaceRange()| + tlib#buffer#ScratchStart ............... |tlib#buffer#ScratchStart()| + tlib#buffer#ScratchEnd ................. |tlib#buffer#ScratchEnd()| + tlib#buffer#BufDo ...................... |tlib#buffer#BufDo()| + tlib#buffer#InsertText ................. |tlib#buffer#InsertText()| + tlib#buffer#InsertText0 ................ |tlib#buffer#InsertText0()| + tlib#buffer#CurrentByte ................ |tlib#buffer#CurrentByte()| + tlib#buffer#KeepCursorPosition ......... |tlib#buffer#KeepCursorPosition()| + tlib#hook#Run .......................... |tlib#hook#Run()| + tlib#string#RemoveBackslashes .......... |tlib#string#RemoveBackslashes()| + tlib#string#Chomp ...................... |tlib#string#Chomp()| + tlib#string#Format ..................... |tlib#string#Format()| + tlib#string#Printf1 .................... |tlib#string#Printf1()| + tlib#string#TrimLeft ................... |tlib#string#TrimLeft()| + tlib#string#TrimRight .................. |tlib#string#TrimRight()| + tlib#string#Strip ...................... |tlib#string#Strip()| + tlib#string#Count ...................... |tlib#string#Count()| + + +======================================================================== +plugin/02tlib.vim~ + + *:TRequire* +:TRequire NAME [VERSION [FILE]] + Make a certain vim file is loaded. + + Conventions: If FILE isn't defined, plugin/NAME.vim is loaded. The + file must provide a variable loaded_{NAME} that represents the version + number. + + *:TLet* +:TLet VAR = VALUE + Set a variable only if it doesn't already exist. + EXAMPLES: > + TLet foo = 1 + TLet foo = 2 + echo foo + => 1 +< + + *:TScratch* +:TScratch + Open a scratch buffer (a buffer without a file). + TScratch ... use split window + TScratch! ... use the whole frame + This command takes an (inner) dictionary as optional argument. + EXAMPLES: > + TScratch 'scratch': '__FOO__' + => Open a scratch buffer named __FOO__ +< + + *:TVarArg* +:TVarArg VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(...) + TVarArg ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TKeyArg* +:TKeyArg DICT, VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(keyargs) + TKeyArg a:keyargs, ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TBrowseOutput* +:TBrowseOutput COMMAND + Ever wondered how to efficiently browse the output of a command + without redirecting it to a file? This command takes a command as + argument and presents the output via |tlib#input#List()| so that you + can easily search for a keyword (e.g. the name of a variable or + function) and the like. + + If you press enter, the selected line will be copied to the command + line. Press ESC to cancel browsing. + + EXAMPLES: > + TBrowseOutput 20verb TeaseTheCulprit +< + + *:TBrowseScriptnames* +:TBrowseScriptnames + List all sourced script names (the output of ':scriptnames'). + + When you press enter, the selected script will be opened in the current + window. Press ESC to cancel. + + EXAMPLES: > + TBrowseScriptnames +< + + *:TTimeCommand* +:TTimeCommand CMD + Time the execution time of CMD. + + +======================================================================== +test/tlib.vim~ + + *Add()* +Add(a,b) + List + + *TestGetArg()* +TestGetArg(...) + Optional arguments + + *TestGetArg1()* +TestGetArg1(...) + + *TestArgs()* +TestArgs(...) + + *TestArgs1()* +TestArgs1(...) + + *TestArgs2()* +TestArgs2(...) + + *TestArgs3()* +TestArgs3(...) + + +======================================================================== +autoload/tlib.vim~ + + *g:tlib#debug* +g:tlib#debug + + +======================================================================== +autoload/tlib/notify.vim~ + + *tlib#notify#Echo()* +tlib#notify#Echo(text, ?style='') + Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' + in order to prevent |press-enter| messages. + + *tlib#notify#TrimMessage()* +tlib#notify#TrimMessage(message) + Contributed by Erik Falor: + If the line containing the message is too long, echoing it will cause + a 'Hit ENTER' prompt to appear. This function cleans up the line so + that does not happen. + The echoed line is too long if it is wider than the width of the + window, minus cmdline space taken up by the ruler and showcmd + features. + + +======================================================================== +autoload/tlib/persistent.vim~ + + *g:tlib_persistent* +g:tlib_persistent (default: '') + The directory for persistent data files. If empty, use + |tlib#dir#MyRuntime|.'/share'. + + *tlib#persistent#Dir()* +tlib#persistent#Dir(?mode = 'bg') + Return the full directory name for persistent data files. + + *tlib#persistent#Filename()* +tlib#persistent#Filename(type, ?file=%, ?mkdir=0) + + *tlib#persistent#Get()* +tlib#persistent#Get(...) + + *tlib#persistent#MTime()* +tlib#persistent#MTime(cfile) + + *tlib#persistent#Value()* +tlib#persistent#Value(...) + + *tlib#persistent#Save()* +tlib#persistent#Save(cfile, dictionary) + + +======================================================================== +autoload/tlib/vim.vim~ + + *g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_maximize (default: 'x') + The alt-key for maximizing the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#simalt_restore* +g:tlib#vim#simalt_restore (default: 'r') + The alt-key for restoring the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#use_vimtweak* +g:tlib#vim#use_vimtweak (default: 0) + If true, use the vimtweak.dll for windows. This will enable + tlib to remove the caption for fullscreen windows. + + *tlib#vim#Maximize()* +tlib#vim#Maximize(fullscreen) + Maximize the window. + You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + work for you. + + *tlib#vim#RestoreWindow()* +tlib#vim#RestoreWindow() + Restore the original vimsize after having called |tlib#vim#Maximize()|. + + *g:tlib#vim#use_wmctrl* +g:tlib#vim#use_wmctrl (default: executable('wmctrl')) + If true, use wmctrl for X windows to make a window + maximized/fullscreen. + + This is the preferred method for maximizing windows under X + windows. Some window managers have problem coping with the + default method of setting 'lines' and 'columns' to a large + value. + + *tlib#vim#CopyFunction()* +tlib#vim##CopyFunction(old, new, overwrite=0) + + +======================================================================== +autoload/tlib/progressbar.vim~ + + *tlib#progressbar#Init()* +tlib#progressbar#Init(max, ...) + EXAMPLE: > + call tlib#progressbar#Init(20) + try + for i in range(20) + call tlib#progressbar#Display(i) + call DoSomethingThatTakesSomeTime(i) + endfor + finally + call tlib#progressbar#Restore() + endtry +< + + *tlib#progressbar#Display()* +tlib#progressbar#Display(value, ...) + + *tlib#progressbar#Restore()* +tlib#progressbar#Restore() + + +======================================================================== +autoload/tlib/eval.vim~ + + *tlib#eval#FormatValue()* +tlib#eval#FormatValue(value, ...) + + +======================================================================== +autoload/tlib/list.vim~ + + *tlib#list#Inject()* +tlib#list#Inject(list, initial_value, funcref) + EXAMPLES: > + echo tlib#list#Inject([1,2,3], 0, function('Add') + => 6 +< + + *tlib#list#Compact()* +tlib#list#Compact(list) + EXAMPLES: > + tlib#list#Compact([0,1,2,3,[], {}, ""]) + => [1,2,3] +< + + *tlib#list#Flatten()* +tlib#list#Flatten(list) + EXAMPLES: > + tlib#list#Flatten([0,[1,2,[3,""]]]) + => [0,1,2,3,""] +< + + *tlib#list#FindAll()* +tlib#list#FindAll(list, filter, ?process_expr="") + Basically the same as filter() + + EXAMPLES: > + tlib#list#FindAll([1,2,3], 'v:val >= 2') + => [2, 3] +< + + *tlib#list#Find()* +tlib#list#Find(list, filter, ?default="", ?process_expr="") + + EXAMPLES: > + tlib#list#Find([1,2,3], 'v:val >= 2') + => 2 +< + + *tlib#list#Any()* +tlib#list#Any(list, expr) + EXAMPLES: > + tlib#list#Any([1,2,3], 'v:val >= 2') + => 1 +< + + *tlib#list#All()* +tlib#list#All(list, expr) + EXAMPLES: > + tlib#list#All([1,2,3], 'v:val >= 2') + => 0 +< + + *tlib#list#Remove()* +tlib#list#Remove(list, element) + EXAMPLES: > + tlib#list#Remove([1,2,1,2], 2) + => [1,1,2] +< + + *tlib#list#RemoveAll()* +tlib#list#RemoveAll(list, element) + EXAMPLES: > + tlib#list#RemoveAll([1,2,1,2], 2) + => [1,1] +< + + *tlib#list#Zip()* +tlib#list#Zip(lists, ?default='') + EXAMPLES: > + tlib#list#Zip([[1,2,3], [4,5,6]]) + => [[1,4], [2,5], [3,6]] +< + + *tlib#list#Uniq()* +tlib#list#Uniq(list, ...) + + *tlib#list#ToDictionary()* +tlib#list#ToDictionary(list, default, ...) + + +======================================================================== +autoload/tlib/cmd.vim~ + + *tlib#cmd#OutputAsList()* +tlib#cmd#OutputAsList(command) + + *tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutput(command) + See |:TBrowseOutput|. + + *tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#BrowseOutputWithCallback(callback, command) + Execute COMMAND and present its output in a |tlib#input#List()|; + when a line is selected, execute the function named as the CALLBACK + and pass in that line as an argument. + + The CALLBACK function gives you an opportunity to massage the COMMAND output + and possibly act on it in a meaningful way. For example, if COMMAND listed + all URIs found in the current buffer, CALLBACK could validate and then open + the selected URI in the system's default browser. + + This function is meant to be a tool to help compose the implementations of + powerful commands that use |tlib#input#List()| as a common interface. See + |TBrowseScriptnames| as an example. + + EXAMPLES: > + call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +< + + *tlib#cmd#DefaultBrowseOutput()* +tlib#cmd#DefaultBrowseOutput(cmd) + + *tlib#cmd#ParseScriptname()* +tlib#cmd#ParseScriptname(line) + + *tlib#cmd#UseVertical()* +tlib#cmd#UseVertical(?rx='') + Look at the history whether the command was called with vertical. If + an rx is provided check first if the last entry in the history matches + this rx. + + *tlib#cmd#Time()* +tlib#cmd#Time(cmd) + Print the time in seconds or milliseconds (if your version of VIM + has |+reltime|) a command takes. + + *tlib#cmd#Capture()* +tlib#cmd#Capture(cmd) + + +======================================================================== +autoload/tlib/syntax.vim~ + + *tlib#syntax#Collect()* +tlib#syntax#Collect() + + *tlib#syntax#Names()* +tlib#syntax#Names(?rx='') + + +======================================================================== +autoload/tlib/balloon.vim~ + + *tlib#balloon#Register()* +tlib#balloon#Register(expr) + + *tlib#balloon#Remove()* +tlib#balloon#Remove(expr) + + *tlib#balloon#Expr()* +tlib#balloon#Expr() + + +======================================================================== +autoload/tlib/vcs.vim~ + + *g:tlib#vcs#def* +g:tlib#vcs#def {...} + A dictionarie of supported VCS (currently: git, hg, svn, bzr). + + *g:tlib#vcs#executables* +g:tlib#vcs#executables {...} + A dictionary of custom executables for VCS commands. If the value is + empty, support for that VCS will be removed. If no key is present, it + is assumed that the VCS "type" is the name of the executable. + + *g:tlib#vcs#check* +g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') + If non-empty, use it as a format string to check whether a VCS is + installed on your computer. + + *tlib#vcs#Executable()* +tlib#vcs#Executable(type) + + *tlib#vcs#FindVCS()* +tlib#vcs#FindVCS(filename) + + *tlib#vcs#Ls()* +tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) + Return the files under VCS. + + *tlib#vcs#Diff()* +tlib#vcs#Diff(filename, ?vcs=[type, dir]) + Return the diff for "filename" + + +======================================================================== +autoload/tlib/char.vim~ + + *tlib#char#Get()* +tlib#char#Get(?timeout=0) + Get a character. + + EXAMPLES: > + echo tlib#char#Get() + echo tlib#char#Get(5) +< + + *tlib#char#IsAvailable()* +tlib#char#IsAvailable() + + *tlib#char#GetWithTimeout()* +tlib#char#GetWithTimeout(timeout, ...) + + +======================================================================== +autoload/tlib/Filter_glob.vim~ + + *g:tlib#Filter_glob#seq* +g:tlib#Filter_glob#seq (default: '*') + A character that should be expanded to '\.\{-}'. + + *g:tlib#Filter_glob#char* +g:tlib#Filter_glob#char (default: '?') + A character that should be expanded to '\.\?'. + + *tlib#Filter_glob#New()* +tlib#Filter_glob#New(...) + The same as |tlib#Filter_cnf#New()| but a a customizable character + |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and + |g:tlib#Filter_glob#char| is expanded to '\.'. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +======================================================================== +autoload/tlib/scratch.vim~ + + *g:tlib_scratch_pos* +g:tlib_scratch_pos (default: 'botright') + Scratch window position. By default the list window is opened on the + bottom. Set this variable to 'topleft' or '' to change this behaviour. + See |tlib#input#List()|. + + *g:tlib#scratch#hidden* +g:tlib#scratch#hidden (default: 'hide') + If you want the scratch buffer to be fully removed, you might want to + set this variable to 'wipe'. + See also https://github.com/tomtom/tlib_vim/pull/16 + + *tlib#scratch#UseScratch()* +tlib#scratch#UseScratch(?keyargs={}) + Display a scratch buffer (a buffer with no file). See :TScratch for an + example. + Return the scratch buffer's number. + Values for keyargs: + scratch_split ... 1: split, 0: window, -1: tab + + *tlib#scratch#CloseScratch()* +tlib#scratch#CloseScratch(keyargs, ...) + Close a scratch buffer as defined in keyargs (usually a World). + Return 1 if the scratch buffer is closed (or if it already was + closed). + + +======================================================================== +autoload/tlib/autocmdgroup.vim~ + + *tlib#autocmdgroup#Init()* +tlib#autocmdgroup#Init() + + +======================================================================== +autoload/tlib/cache.vim~ + + *g:tlib_cache* +g:tlib_cache (default: '') + The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. + You might want to delete old files from this directory from time to + time with a command like: > + find ~/vimfiles/cache/ -atime +31 -type f -print -delete +< + + *g:tlib#cache#purge_days* +g:tlib#cache#purge_days (default: 31) + |tlib#cache#Purge()|: Remove cache files older than N days. + + *g:tlib#cache#purge_every_days* +g:tlib#cache#purge_every_days (default: 31) + Purge the cache every N days. Disable automatic purging by setting + this value to a negative value. + + *g:tlib#cache#script_encoding* +g:tlib#cache#script_encoding (default: &enc) + The encoding used for the purge-cache script. + Default: 'enc' + + *g:tlib#cache#run_script* +g:tlib#cache#run_script (default: 1) + Whether to run the directory removal script: + 0 ... No + 1 ... Query user + 2 ... Yes + + *g:tlib#cache#verbosity* +g:tlib#cache#verbosity (default: 1) + Verbosity level: + 0 ... Be quiet + 1 ... Display informative message + 2 ... Display detailed messages + + *g:tlib#cache#dont_purge* +g:tlib#cache#dont_purge (default: ['[\/]\.last_purge$']) + A list of regexps that are matched against partial filenames of the + cached files. If a regexp matches, the file won't be removed by + |tlib#cache#Purge()|. + + *g:tlib#cache#max_filename* +g:tlib#cache#max_filename (default: 200) + If the cache filename is longer than N characters, use + |pathshorten()|. + + *tlib#cache#Dir()* +tlib#cache#Dir(?mode = 'bg') + The default cache directory. + + *tlib#cache#Filename()* +tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') + + *tlib#cache#Save()* +tlib#cache#Save(cfile, dictionary) + + *tlib#cache#MTime()* +tlib#cache#MTime(cfile) + + *tlib#cache#Get()* +tlib#cache#Get(cfile, ...) + + *tlib#cache#Value()* +tlib#cache#Value(cfile, generator, ftime, ...) + Get a cached value from cfile. If it is outdated (compared to ftime) + or does not exist, create it calling a generator function. + + *tlib#cache#MaybePurge()* +tlib#cache#MaybePurge() + Call |tlib#cache#Purge()| if the last purge was done before + |g:tlib#cache#purge_every_days|. + + *tlib#cache#Purge()* +tlib#cache#Purge() + Delete old files. + + *tlib#cache#ListFilesInCache()* +tlib#cache#ListFilesInCache(...) + + +======================================================================== +autoload/tlib/normal.vim~ + + *tlib#normal#WithRegister()* +tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') + Execute a normal command while maintaining all registers. + + +======================================================================== +autoload/tlib/time.vim~ + + *tlib#time#MSecs()* +tlib#time#MSecs() + + *tlib#time#Now()* +tlib#time#Now() + + *tlib#time#Diff()* +tlib#time#Diff(a, b, ...) + + *tlib#time#DiffMSecs()* +tlib#time#DiffMSecs(a, b, ...) + + +======================================================================== +autoload/tlib/var.vim~ + + *tlib#var#Let()* +tlib#var#Let(name, val) + Define a variable called NAME if yet undefined. + You can also use the :TLLet command. + + EXAMPLES: > + exec tlib#var#Let('g:foo', 1) + TLet g:foo = 1 +< + + *tlib#var#EGet()* +tlib#var#EGet(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo eval(tlib#var#EGet('foo', 'vg')) => 1 + echo eval(tlib#var#EGet('foo', 'bg')) => 2 + echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +< + + *tlib#var#Get()* +tlib#var#Get(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo tlib#var#Get('foo', 'bg') => 1 + echo tlib#var#Get('foo', 'bg') => 2 + echo tlib#var#Get('foo', 'wbg') => 3 +< + + *tlib#var#List()* +tlib#var#List(rx, ?prefix='') + Get a list of variables matching rx. + EXAMPLE: + echo tlib#var#List('tlib_', 'g:') + + +======================================================================== +autoload/tlib/agent.vim~ +Various agents for use as key handlers in tlib#input#List() + + *g:tlib_scroll_lines* +g:tlib_scroll_lines (default: 10) + Number of items to move when pressing in the input list window. + + *tlib#agent#Exit()* +tlib#agent#Exit(world, selected) + + *tlib#agent#CopyItems()* +tlib#agent#CopyItems(world, selected) + + *tlib#agent#PageUp()* +tlib#agent#PageUp(world, selected) + + *tlib#agent#PageDown()* +tlib#agent#PageDown(world, selected) + + *tlib#agent#Home()* +tlib#agent#Home(world, selected) + + *tlib#agent#End()* +tlib#agent#End(world, selected) + + *tlib#agent#Up()* +tlib#agent#Up(world, selected, ...) + + *tlib#agent#Down()* +tlib#agent#Down(world, selected, ...) + + *tlib#agent#UpN()* +tlib#agent#UpN(world, selected) + + *tlib#agent#DownN()* +tlib#agent#DownN(world, selected) + + *tlib#agent#ShiftLeft()* +tlib#agent#ShiftLeft(world, selected) + + *tlib#agent#ShiftRight()* +tlib#agent#ShiftRight(world, selected) + + *tlib#agent#Reset()* +tlib#agent#Reset(world, selected) + + *tlib#agent#ToggleRestrictView()* +tlib#agent#ToggleRestrictView(world, selected) + + *tlib#agent#RestrictView()* +tlib#agent#RestrictView(world, selected) + + *tlib#agent#UnrestrictView()* +tlib#agent#UnrestrictView(world, selected) + + *tlib#agent#Input()* +tlib#agent#Input(world, selected) + + *tlib#agent#SuspendToParentWindow()* +tlib#agent#SuspendToParentWindow(world, selected) + Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the + original position in the parent window. + + *tlib#agent#Suspend()* +tlib#agent#Suspend(world, selected) + Suspend lets you temporarily leave the input loop of + |tlib#input#List|. You can resume editing the list by pressing , + . , or in the suspended window. + and will immediatly select the item under the cursor. + < will select the item but the window will remain opened. + + *tlib#agent#Help()* +tlib#agent#Help(world, selected) + + *tlib#agent#OR()* +tlib#agent#OR(world, selected) + + *tlib#agent#AND()* +tlib#agent#AND(world, selected) + + *tlib#agent#ReduceFilter()* +tlib#agent#ReduceFilter(world, selected) + + *tlib#agent#PopFilter()* +tlib#agent#PopFilter(world, selected) + + *tlib#agent#Debug()* +tlib#agent#Debug(world, selected) + + *tlib#agent#Select()* +tlib#agent#Select(world, selected) + + *tlib#agent#SelectUp()* +tlib#agent#SelectUp(world, selected) + + *tlib#agent#SelectDown()* +tlib#agent#SelectDown(world, selected) + + *tlib#agent#SelectAll()* +tlib#agent#SelectAll(world, selected) + + *tlib#agent#ToggleStickyList()* +tlib#agent#ToggleStickyList(world, selected) + + *tlib#agent#EditItem()* +tlib#agent#EditItem(world, selected) + + *tlib#agent#NewItem()* +tlib#agent#NewItem(world, selected) + Insert a new item below the current one. + + *tlib#agent#DeleteItems()* +tlib#agent#DeleteItems(world, selected) + + *tlib#agent#Cut()* +tlib#agent#Cut(world, selected) + + *tlib#agent#Copy()* +tlib#agent#Copy(world, selected) + + *tlib#agent#Paste()* +tlib#agent#Paste(world, selected) + + *tlib#agent#EditReturnValue()* +tlib#agent#EditReturnValue(world, rv) + + *tlib#agent#ViewFile()* +tlib#agent#ViewFile(world, selected) + + *tlib#agent#EditFile()* +tlib#agent#EditFile(world, selected) + + *tlib#agent#EditFileInSplit()* +tlib#agent#EditFileInSplit(world, selected) + + *tlib#agent#EditFileInVSplit()* +tlib#agent#EditFileInVSplit(world, selected) + + *tlib#agent#EditFileInTab()* +tlib#agent#EditFileInTab(world, selected) + + *tlib#agent#ToggleScrollbind()* +tlib#agent#ToggleScrollbind(world, selected) + + *tlib#agent#ShowInfo()* +tlib#agent#ShowInfo(world, selected) + + *tlib#agent#PreviewLine()* +tlib#agent#PreviewLine(world, selected) + + *tlib#agent#GotoLine()* +tlib#agent#GotoLine(world, selected) + If not called from the scratch, we assume/guess that we don't have to + suspend the input-evaluation loop. + + *tlib#agent#DoAtLine()* +tlib#agent#DoAtLine(world, selected) + + *tlib#agent#Wildcard()* +tlib#agent#Wildcard(world, selected) + + *tlib#agent#Null()* +tlib#agent#Null(world, selected) + + *tlib#agent#ExecAgentByName()* +tlib#agent#ExecAgentByName(world, selected) + + *tlib#agent#CompleteAgentNames()* +tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) + + +======================================================================== +autoload/tlib/bitwise.vim~ + + *tlib#bitwise#Num2Bits()* +tlib#bitwise#Num2Bits(num) + + *tlib#bitwise#Bits2Num()* +tlib#bitwise#Bits2Num(bits, ...) + + *tlib#bitwise#AND()* +tlib#bitwise#AND(num1, num2, ...) + + *tlib#bitwise#OR()* +tlib#bitwise#OR(num1, num2, ...) + + *tlib#bitwise#XOR()* +tlib#bitwise#XOR(num1, num2, ...) + + *tlib#bitwise#ShiftRight()* +tlib#bitwise#ShiftRight(bits, n) + + *tlib#bitwise#ShiftLeft()* +tlib#bitwise#ShiftLeft(bits, n) + + *tlib#bitwise#Add()* +tlib#bitwise#Add(num1, num2, ...) + + *tlib#bitwise#Sub()* +tlib#bitwise#Sub(num1, num2, ...) + + +======================================================================== +autoload/tlib/url.vim~ + + *tlib#url#Decode()* +tlib#url#Decode(url) + Decode an encoded URL. + + *tlib#url#DecodeChar()* +tlib#url#DecodeChar(char) + Decode a single character. + + *tlib#url#EncodeChar()* +tlib#url#EncodeChar(char) + Encode a single character. + + *tlib#url#Encode()* +tlib#url#Encode(url, ...) + Encode an URL. + + +======================================================================== +autoload/tlib/signs.vim~ + + *tlib#signs#ClearAll()* +tlib#signs#ClearAll(sign) + Clear all signs with name SIGN. + + *tlib#signs#ClearBuffer()* +tlib#signs#ClearBuffer(sign, bufnr) + Clear all signs with name SIGN in buffer BUFNR. + + *tlib#signs#Mark()* +tlib#signs#Mark(sign, list) + Add signs for all locations in LIST. LIST must adhere with the + quickfix list format (see |getqflist()|; only the fields lnum and + bufnr are required). + + list:: a quickfix or location list + sign:: a sign defined with |:sign-define| + + +======================================================================== +autoload/tlib/rx.vim~ + + *tlib#rx#Escape()* +tlib#rx#Escape(text, ?magic='m') + magic can be one of: m, M, v, V + See :help 'magic' + + *tlib#rx#EscapeReplace()* +tlib#rx#EscapeReplace(text, ?magic='m') + Escape return |sub-replace-special|. + + *tlib#rx#Suffixes()* +tlib#rx#Suffixes(...) + + +======================================================================== +autoload/tlib/tag.vim~ + + *g:tlib_tags_extra* +g:tlib_tags_extra (default: '') + Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. + + *g:tlib_tag_substitute* +g:tlib_tag_substitute + Filter the tag description through |substitute()| for these filetypes. + This applies only if the tag cmd field (see |taglist()|) is used. + + *tlib#tag#Retrieve()* +tlib#tag#Retrieve(rx, ?extra_tags=0) + Get all tags matching rx. Basically, this function simply calls + |taglist()|, but when extra_tags is true, the list of the tag files + (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. + + Example use: + If you want to include tags for, eg, JDK, normal tags use can become + slow. You could proceed as follows: + 1. Create a tags file for the JDK sources. When creating the tags + file, make sure to include inheritance information and the like + (command-line options like --fields=+iaSm --extra=+q should be ok). + In this example, we want tags only for public methods (there are + most likely better ways to do this): > + ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src + head -n 6 tags > tags0 + grep access:public tags >> tags0 +< 2. Make 'tags' include project specific tags files. In + ~/vimfiles/after/ftplugin/java.vim insert: > + let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +< 3. When this function is invoked as > + echo tlib#tag#Retrieve('print') +< it will return only project-local tags. If it is invoked as > + echo tlib#tag#Retrieve('print', 1) +< tags from the JDK will be included. + + *tlib#tag#Collect()* +tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) + Retrieve tags that meet the constraints (a dictionnary of fields and + regexp, with the exception of the kind field which is a list of chars). + For the use of the optional use_extra argument see + |tlib#tag#Retrieve()|. + + *tlib#tag#Format()* +tlib#tag#Format(tag) + + +======================================================================== +autoload/tlib/map.vim~ + + *tlib#map#PumAccept()* +tlib#map#PumAccept(key) + If |pumvisible()| is true, return "\". Otherwise return a:key. + For use in maps like: > + imap tlib#map#PumAccept("\") +< + + +======================================================================== +autoload/tlib/Filter_cnfd.vim~ + + *tlib#Filter_cnfd#New()* +tlib#Filter_cnfd#New(...) + The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. + As a consequence, patterns cannot match dots. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +======================================================================== +autoload/tlib/input.vim~ +Input-related, select from a list etc. + + *g:tlib#input#sortprefs_threshold* +g:tlib#input#sortprefs_threshold (default: 200) + If a list is bigger than this value, don't try to be smart when + selecting an item. Be slightly faster instead. + See |tlib#input#List()|. + + *g:tlib#input#livesearch_threshold* +g:tlib#input#livesearch_threshold (default: 1000) + If a list contains more items, |tlib#input#List()| does not perform an + incremental "live search" but uses |input()| to query the user for a + filter. This is useful on slower machines or with very long lists. + + *g:tlib#input#filter_mode* +g:tlib#input#filter_mode (default: 'glob') + Determine how |tlib#input#List()| and related functions work. + Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: + glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, + |g:tlib#Filter_glob#char|) are interpreted as glob-like + |wildcards| (this is the default method) + - Examples: + - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_glob#New()|. + cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is + expanded to "\.\{-}" + - A period character (".") acts as a wildcard as if ".\{-}" (see + |/\{-|) were entered. + - Examples: + - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_cnfd#New()|. + cnf .... Match substrings + - A blank creates an AND conjunction, i.e. the next pattern has to + match too. + - A pipe character ("|") creates an OR conjunction, either this or + the next next pattern has to match. + - Patterns are very 'nomagic' |regexp| with a |\V| prefix. + - A pattern starting with "-" makes the filter exclude items + matching that pattern. + - Examples: + - "foo bar" matches items that contain the strings "foo" AND + "bar". + - "foo|bar boo|far" matches items that contain either ("foo" OR + "bar") AND ("boo" OR "far"). + - See also |tlib#Filter_cnf#New()|. + seq .... Match sequences of characters + - |tlib#Filter_seq#New()| + fuzzy .. Match fuzzy character sequences + - |tlib#Filter_fuzzy#New()| + + *g:tlib#input#higroup* +g:tlib#input#higroup (default: 'IncSearch') + The highlight group to use for showing matches in the input list + window. + See |tlib#input#List()|. + + *g:tlib_pick_last_item* +g:tlib_pick_last_item (default: 1) + When 1, automatically select the last remaining item only if the list + had only one item to begin with. + When 2, automatically select a last remaining item after applying + any filters. + See |tlib#input#List()|. + + +Keys for |tlib#input#List|~ + + *g:tlib#input#and* +g:tlib#input#and (default: ' ') + + *g:tlib#input#or* +g:tlib#input#or (default: '|') + + *g:tlib#input#not* +g:tlib#input#not (default: '-') + + *g:tlib#input#numeric_chars* +g:tlib#input#numeric_chars + When editing a list with |tlib#input#List|, typing these numeric chars + (as returned by getchar()) will select an item based on its index, not + based on its name. I.e. in the default setting, typing a "4" will + select the fourth item, not the item called "4". + In order to make keys 0-9 filter the items in the list and make + select an item by its index, remove the keys 48 to 57 from + this dictionary. + Format: [KEY] = BASE ... the number is calculated as KEY - BASE. + + *g:tlib#input#keyagents_InputList_s* +g:tlib#input#keyagents_InputList_s + The default key bindings for single-item-select list views. + + This variable is best customized via the variable + g:tlib_extend_keyagents_InputList_s. If you want to use , + to move the cursor up and down, add these two lines to your |vimrc| + file: + + let g:tlib_extend_keyagents_InputList_s = { + \ 10: 'tlib#agent#Down', + \ 11: 'tlib#agent#Up' + \ } + + *g:tlib#input#keyagents_InputList_m* +g:tlib#input#keyagents_InputList_m + + *g:tlib#input#handlers_EditList* +g:tlib#input#handlers_EditList + + *g:tlib#input#user_shortcuts* +g:tlib#input#user_shortcuts (default: {}) + A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to + customize keyboard shortcuts in the list view. + + *g:tlib#input#use_popup* +g:tlib#input#use_popup (default: has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32'))) + If true, define a popup menu for |tlib#input#List()| and related + functions. + + *g:tlib#input#format_filename* +g:tlib#input#format_filename (default: 'l') + How to format filenames: + l ... Show basenames on the left side, separated from the + directory names + r ... Show basenames on the right side + + *g:tlib#input#filename_padding_r* +g:tlib#input#filename_padding_r (default: '&co / 10') + If g:tlib#input#format_filename == 'r', how much space should be kept + free on the right side. + + *g:tlib#input#filename_max_width* +g:tlib#input#filename_max_width (default: '&co / 2') + If g:tlib#input#format_filename == 'l', an expression that + |eval()|uates to the maximum display width of filenames. + + *tlib#input#List()* +tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) + Select a single or multiple items from a list. Return either the list + of selected elements or its indexes. + + By default, typing numbers will select an item by its index. See + |g:tlib#input#numeric_chars| to find out how to change this. + + The item is automatically selected if the numbers typed equals the + number of digits of the list length. I.e. if a list contains 20 items, + typing 1 will first highlight item 1 but it won't select/use it + because 1 is an ambiguous input in this context. If you press enter, + the first item will be selected. If you press another digit (e.g. 0), + item 10 will be selected. Another way to select item 1 would be to + type 01. If the list contains only 9 items, typing 1 would select the + first item right away. + + type can be: + s ... Return one selected element + si ... Return the index of the selected element + m ... Return a list of selected elements + mi ... Return a list of indexes + + Several pattern matching styles are supported. See + |g:tlib#input#filter_mode|. + + EXAMPLES: > + echo tlib#input#List('s', 'Select one item', [100,200,300]) + echo tlib#input#List('si', 'Select one item', [100,200,300]) + echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) + echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) + +< See ../samples/tlib/input/tlib_input_list.vim (move the cursor over + the filename and press gf) for a more elaborated example. + + *tlib#input#ListD()* +tlib#input#ListD(dict) + A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from + dict. + + *tlib#input#ListW()* +tlib#input#ListW(world, ?command='') + The second argument (command) is meant for internal use only. + The same as |tlib#input#List| but the arguments are packed into world + (an instance of tlib#World as returned by |tlib#World#New|). + + *tlib#input#EditList()* +tlib#input#EditList(query, list, ?timeout=0) + Edit a list. + + EXAMPLES: > + echo tlib#input#EditList('Edit:', [100,200,300]) +< + + *tlib#input#Resume()* +tlib#input#Resume(name, pick, bufnr) + + *tlib#input#CommandSelect()* +tlib#input#CommandSelect(command, ?keyargs={}) + Take a command, view the output, and let the user select an item from + its output. + + EXAMPLE: > + command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') + command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +< + + *tlib#input#Edit()* +tlib#input#Edit(name, value, callback, ?cb_args=[]) + + Edit a value (asynchronously) in a scratch buffer. Use name for + identification. Call callback when done (or on cancel). + In the scratch buffer: + Press or to enter the new value, c to cancel + editing. + EXAMPLES: > + fun! FooContinue(success, text) + if a:success + let b:var = a:text + endif + endf + call tlib#input#Edit('foo', b:var, 'FooContinue') +< + + *tlib#input#Dialog()* +tlib#input#Dialog(text, options, default) + + +======================================================================== +autoload/tlib/number.vim~ + + *tlib#number#ConvertBase()* +tlib#number#ConvertBase(num, base, ...) + + +======================================================================== +autoload/tlib/file.vim~ + + *g:tlib#file#drop* +g:tlib#file#drop (default: has('gui')) + If true, use |:drop| to edit loaded buffers (only available with GUI). + + *g:tlib#file#use_tabs* +g:tlib#file#use_tabs (default: 0) + + *g:tlib#file#edit_cmds* +g:tlib#file#edit_cmds (default: g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {}) + + *g:tlib#file#absolute_filename_rx* +g:tlib#file#absolute_filename_rx (default: '^\~\?[\/]') + + *tlib#file#Split()* +tlib#file#Split(filename) + EXAMPLES: > + tlib#file#Split('foo/bar/filename.txt') + => ['foo', 'bar', 'filename.txt'] +< + + *tlib#file#Join()* +tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) + EXAMPLES: > + tlib#file#Join(['foo', 'bar', 'filename.txt']) + => 'foo/bar/filename.txt' +< + + *tlib#file#Relative()* +tlib#file#Relative(filename, basedir) + EXAMPLES: > + tlib#file#Relative('foo/bar/filename.txt', 'foo') + => 'bar/filename.txt' +< + + *tlib#file#Absolute()* +tlib#file#Absolute(filename, ...) + + *tlib#file#Canonic()* +tlib#file#Canonic(filename, ...) + + *tlib#file#With()* +tlib#file#With(fcmd, bcmd, files, ?world={}) + + *tlib#file#Edit()* +tlib#file#Edit(fileid) + Return 0 if the file isn't readable/doesn't exist. + Otherwise return 1. + + +======================================================================== +autoload/tlib/sys.vim~ + + *g:tlib#sys#special_protocols* +g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) + A list of |regexp|s matching protocol names that should be handled + by |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#special_suffixes* +g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif']) + A list of |regexp|s matching suffixes that should be handled by + |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_rx* +g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) + Open links matching this |regexp| with |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_browser* +g:tlib#sys#system_browser (default: ...) + Open files in the system browser. + + *g:tlib#sys#system_browser* +g:tlib#sys#system_browser (default: "exec 'silent !'. g:netrw_browsex_viewer shellescape('%s')") + + *g:tlib#sys#windows* +g:tlib#sys#windows (default: &shell !~ 'sh' && (has('win16') || has('win32') || has('win64'))) + + *g:tlib#sys#null* +g:tlib#sys#null (default: g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '')) + + *tlib#sys#IsCygwinBin()* +tlib#sys#IsCygwinBin(cmd) + + *tlib#sys#IsExecutable()* +tlib#sys#IsExecutable(cmd, ...) + + *g:tlib#sys#check_cygpath* +g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) + If true, check whether we have to convert a path via cyppath -- + see |tlib#sys#MaybeUseCygpath| + + *g:tlib#sys#cygwin_path_rx* +g:tlib#sys#cygwin_path_rx (default: '/cygwin/') + If a full windows filename (with slashes instead of backslashes) + matches this |regexp|, it is assumed to be a cygwin executable. + + *g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') + For cygwin binaries, convert command calls using this vim + expression. + + *tlib#sys#GetCmd()* +tlib#sys#GetCmd(cmd) + + *tlib#sys#MaybeUseCygpath()* +tlib#sys#MaybeUseCygpath(cmd) + If cmd seems to be a cygwin executable, use cygpath to convert + filenames. This assumes that cygwin's which command returns full + filenames for non-cygwin executables. + + *tlib#sys#ConvertPath()* +tlib#sys#ConvertPath(converter, filename) + + *tlib#sys#FileArgs()* +tlib#sys#FileArgs(cmd, files) + + *tlib#sys#IsSpecial()* +tlib#sys#IsSpecial(filename) + Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it + is a special file that should not be opened in vim. + + *tlib#sys#Open()* +tlib#sys#Open(filename) + Open filename with the default OS application (see + |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. + Returns 1 if successful or 0 otherwise. + + +======================================================================== +autoload/tlib/paragraph.vim~ + + *tlib#paragraph#GetMetric()* +tlib#paragraph#GetMetric() + Return an object describing a |paragraph|. + + *tlib#paragraph#Move()* +tlib#paragraph#Move(direction, count) + This function can be used with the tinymode plugin to move around + paragraphs. + + Example configuration: > + + call tinymode#EnterMap("para_move", "gp") + call tinymode#ModeMsg("para_move", "Move paragraph: j/k") + call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") + call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") + call tinymode#ModeArg("para_move", "owncount", 1) +< + + +======================================================================== +autoload/tlib/World.vim~ +A prototype used by |tlib#input#List|. +Inherits from |tlib#Object#New|. + + *g:tlib_inputlist_pct* +g:tlib_inputlist_pct (default: 50) + Size of the input list window (in percent) from the main size (of &lines). + See |tlib#input#List()|. + + *g:tlib_inputlist_width_filename* +g:tlib_inputlist_width_filename (default: '&co / 3') + Size of filename columns when listing filenames. + See |tlib#input#List()|. + + *g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_filename_indicators (default: 0) + If true, |tlib#input#List()| will show some indicators about the + status of a filename (e.g. buflisted(), bufloaded() etc.). + This is disabled by default because vim checks also for the file on + disk when doing this. + + *g:tlib_inputlist_shortmessage* +g:tlib_inputlist_shortmessage (default: 0) + If not null, display only a short info about the filter. + + *tlib#World#New()* +tlib#World#New(...) + +prototype.PrintLines + +prototype.Suspend + + +======================================================================== +autoload/tlib/tab.vim~ + + *tlib#tab#BufMap()* +tlib#tab#BufMap() + Return a dictionary of bufnumbers => [[tabpage, winnr] ...] + + *tlib#tab#TabWinNr()* +tlib#tab#TabWinNr(buffer) + Find a buffer's window at some tab page. + + *tlib#tab#Set()* +tlib#tab#Set(tabnr) + + +======================================================================== +autoload/tlib/date.vim~ + + *tlib#date#DiffInDays()* +tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) + + *tlib#date#Parse()* +tlib#date#Parse(date, ?allow_zero=0) "{{{3 + + *tlib#date#SecondsSince1970()* +tlib#date#SecondsSince1970(date, ...) + tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) + + +======================================================================== +autoload/tlib/type.vim~ + + *tlib#type#IsNumber()* +tlib#type#IsNumber(expr) + + *tlib#type#IsString()* +tlib#type#IsString(expr) + + *tlib#type#IsFuncref()* +tlib#type#IsFuncref(expr) + + *tlib#type#IsList()* +tlib#type#IsList(expr) + + *tlib#type#IsDictionary()* +tlib#type#IsDictionary(expr) + + +======================================================================== +autoload/tlib/Filter_fuzzy.vim~ + + *tlib#Filter_fuzzy#New()* +tlib#Filter_fuzzy#New(...) + Support for "fuzzy" pattern matching in |tlib#input#List()|. + Patterns are interpreted as if characters were connected with '.\{-}'. + + In "fuzzy" mode, the pretty printing of filenames is disabled. + + +======================================================================== +autoload/tlib/textobjects.vim~ + + *standard-paragraph* +tlib#textobjects#StandardParagraph() + Select a "Standard Paragraph", i.e. a text block followed by blank + lines. Other than |ap|, the last paragraph in a document is handled + just the same. + + The |text-object| can be accessed as "sp". Example: > + + vsp ... select the current standard paragraph + +< Return 1, if the paragraph is the last one in the document. + + *tlib#textobjects#Init()* +tlib#textobjects#Init() + + *v_sp* +v_sp ... :call tlib#textobjects#StandardParagraph() + sp ... Standard paragraph (for use as |text-objects|). + + *o_sp* +o_sp ... :normal Vsp + + +======================================================================== +autoload/tlib/arg.vim~ + + *tlib#arg#Get()* +tlib#arg#Get(n, var, ?default="", ?test='') + Set a positional argument from a variable argument list. + See tlib#string#RemoveBackslashes() for an example. + + *tlib#arg#Let()* +tlib#arg#Let(list, ?default='') + Set a positional arguments from a variable argument list. + See tlib#input#List() for an example. + + *tlib#arg#Key()* +tlib#arg#Key(dict, list, ?default='') + See |:TKeyArg|. + + *tlib#arg#StringAsKeyArgs()* +tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':') + + *tlib#arg#StringAsKeyArgsEqual()* +tlib#arg#StringAsKeyArgsEqual(string) + + *tlib#arg#Ex()* +tlib#arg#Ex(arg, ?chars='%#! ') + Escape some characters in a string. + + Use |fnamescape()| if available. + + EXAMPLES: > + exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +< + + +======================================================================== +autoload/tlib/fixes.vim~ + + *tlib#fixes#Winpos()* +tlib#fixes#Winpos() + + +======================================================================== +autoload/tlib/dir.vim~ + + *g:tlib#dir#sep* +g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') + TLet g:tlib#dir#sep = '/' + + *tlib#dir#CanonicName()* +tlib#dir#CanonicName(dirname) + EXAMPLES: > + tlib#dir#CanonicName('foo/bar') + => 'foo/bar/' +< + + *tlib#dir#NativeName()* +tlib#dir#NativeName(dirname) + EXAMPLES: > + tlib#dir#NativeName('foo/bar/') + On Windows: + => 'foo\bar\' + On Linux: + => 'foo/bar/' +< + + *tlib#dir#PlainName()* +tlib#dir#PlainName(dirname) + EXAMPLES: > + tlib#dir#PlainName('foo/bar/') + => 'foo/bar' +< + + *tlib#dir#Ensure()* +tlib#dir#Ensure(dir) + Create a directory if it doesn't already exist. + + *tlib#dir#MyRuntime()* +tlib#dir#MyRuntime() + Return the first directory in &rtp. + + *tlib#dir#CD()* +tlib#dir#CD(dir, ?locally=0) + + *tlib#dir#Push()* +tlib#dir#Push(dir, ?locally=0) + + *tlib#dir#Pop()* +tlib#dir#Pop() + + +======================================================================== +autoload/tlib/hash.vim~ + + *g:tlib#hash#use_crc32* +g:tlib#hash#use_crc32 (default: '') + + *g:tlib#hash#use_adler32* +g:tlib#hash#use_adler32 (default: '') + + *tlib#hash#CRC32B()* +tlib#hash#CRC32B(chars) + + *tlib#hash#CRC32B_ruby()* +tlib#hash#CRC32B_ruby(chars) + + *tlib#hash#CRC32B_vim()* +tlib#hash#CRC32B_vim(chars) + + *tlib#hash#Adler32()* +tlib#hash#Adler32(chars) + + *tlib#hash#Adler32_vim()* +tlib#hash#Adler32_vim(chars) + + *tlib#hash#Adler32_tlib()* +tlib#hash#Adler32_tlib(chars) + + +======================================================================== +autoload/tlib/win.vim~ + + *tlib#win#Set()* +tlib#win#Set(winnr) + Return vim code to jump back to the original window. + + *tlib#win#GetLayout()* +tlib#win#GetLayout(?save_view=0) + + *tlib#win#SetLayout()* +tlib#win#SetLayout(layout) + + *tlib#win#List()* +tlib#win#List() + + *tlib#win#Width()* +tlib#win#Width(wnr) + + *tlib#win#WinDo()* +tlib#win#WinDo(ex) + + +======================================================================== +autoload/tlib/comments.vim~ + + *tlib#comments#Comments()* +tlib#comments#Comments(...) + function! tlib#comments#Comments(?rx='') + + +======================================================================== +autoload/tlib/grep.vim~ + + *tlib#grep#Do()* +tlib#grep#Do(cmd, rx, files) + + *tlib#grep#LocList()* +tlib#grep#LocList(rx, files) + + *tlib#grep#QuickFixList()* +tlib#grep#QuickFixList(rx, files) + + *tlib#grep#List()* +tlib#grep#List(rx, files) + + +======================================================================== +autoload/tlib/Filter_cnf.vim~ + + *tlib#Filter_cnf#New()* +tlib#Filter_cnf#New(...) + The search pattern for |tlib#input#List()| is in conjunctive normal + form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... + The pattern is a '/\V' very no-'/magic' regexp pattern. + + Pressing joins two patterns with AND. + Pressing | joins two patterns with OR. + I.e. In order to get "lala AND (foo OR bar)", you type + "lala foo|bar". + + This is also the base class for other filters. + +prototype.Pretty + + +======================================================================== +autoload/tlib/Object.vim~ +Provides a prototype plus some OO-like methods. + + *tlib#Object#New()* +tlib#Object#New(?fields={}) + This function creates a prototype that provides some kind of + inheritance mechanism and a way to call parent/super methods. + + The usage demonstrated in the following example works best when every + class/prototype is defined in a file of its own. + + The reason for why there is a dedicated constructor function is that + this layout facilitates the use of templates and that methods are + hidden from the user. Other solutions are possible. + + EXAMPLES: > + let s:prototype = tlib#Object#New({ + \ '_class': ['FooBar'], + \ 'foo': 1, + \ 'bar': 2, + \ }) + " Constructor + function! FooBar(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object + endf + function! s:prototype.babble() { + echo "I think, therefore I am ". (self.foo * self.bar) ." months old." + } + +< This could now be used like this: > + let myfoo = FooBar({'foo': 3}) + call myfoo.babble() + => I think, therefore I am 6 months old. + echo myfoo.IsA('FooBar') + => 1 + echo myfoo.IsA('object') + => 1 + echo myfoo.IsA('Foo') + => 0 + echo myfoo.RespondTo('babble') + => 1 + echo myfoo.RespondTo('speak') + => 0 +< + +prototype.New + +prototype.Inherit + +prototype.Extend + +prototype.IsA + +prototype.IsRelated + +prototype.RespondTo + +prototype.Super + + *tlib#Object#Methods()* +tlib#Object#Methods(object, ...) + + +======================================================================== +autoload/tlib/buffer.vim~ + + *g:tlib_viewline_position* +g:tlib_viewline_position (default: 'zz') + Where to display the line when using |tlib#buffer#ViewLine|. + For possible values for position see |scroll-cursor|. + + *tlib#buffer#EnableMRU()* +tlib#buffer#EnableMRU() + + *tlib#buffer#DisableMRU()* +tlib#buffer#DisableMRU() + + *tlib#buffer#Set()* +tlib#buffer#Set(buffer) + Set the buffer to buffer and return a command as string that can be + evaluated by |:execute| in order to restore the original view. + + *tlib#buffer#Eval()* +tlib#buffer#Eval(buffer, code) + Evaluate CODE in BUFFER. + + EXAMPLES: > + call tlib#buffer#Eval('foo.txt', 'echo b:bar') +< + + *tlib#buffer#GetList()* +tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') + Possible values for the "order" argument: + bufnr :: Default behaviour + mru :: Sort buffers according to most recent use + basename :: Sort by the file's basename (last component) + + NOTE: MRU order works on second invocation only. If you want to always + use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. + + *tlib#buffer#ViewLine()* +tlib#buffer#ViewLine(line, ?position='z') + line is either a number or a string that begins with a number. + For possible values for position see |scroll-cursor|. + See also |g:tlib_viewline_position|. + + *tlib#buffer#HighlightLine()* +tlib#buffer#HighlightLine(...) + + *tlib#buffer#DeleteRange()* +tlib#buffer#DeleteRange(line1, line2) + Delete the lines in the current buffer. Wrapper for |:delete|. + + *tlib#buffer#ReplaceRange()* +tlib#buffer#ReplaceRange(line1, line2, lines) + Replace a range of lines. + + *tlib#buffer#ScratchStart()* +tlib#buffer#ScratchStart() + Initialize some scratch area at the bottom of the current buffer. + + *tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchEnd() + Remove the in-buffer scratch area. + + *tlib#buffer#BufDo()* +tlib#buffer#BufDo(exec) + Run exec on all buffers via bufdo and return to the original buffer. + + *tlib#buffer#InsertText()* +tlib#buffer#InsertText(text, keyargs) + Keyargs: + 'shift': 0|N + 'col': col('.')|N + 'lineno': line('.')|N + 'indent': 0|1 + 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) + Insert text (a string) in the buffer. + + *tlib#buffer#InsertText0()* +tlib#buffer#InsertText0(text, ...) + + *tlib#buffer#CurrentByte()* +tlib#buffer#CurrentByte() + + *tlib#buffer#KeepCursorPosition()* +tlib#buffer#KeepCursorPosition(cmd) + Evaluate cmd while maintaining the cursor position and jump registers. + + +======================================================================== +autoload/tlib/hook.vim~ + + *tlib#hook#Run()* +tlib#hook#Run(hook, ?dict={}) + Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. + + +======================================================================== +autoload/tlib/string.vim~ + + *tlib#string#RemoveBackslashes()* +tlib#string#RemoveBackslashes(text, ?chars=' ') + Remove backslashes from text (but only in front of the characters in + chars). + + *tlib#string#Chomp()* +tlib#string#Chomp(string, ?max=0) + + *tlib#string#Format()* +tlib#string#Format(template, dict) + + *tlib#string#Printf1()* +tlib#string#Printf1(format, string) + This function deviates from |printf()| in certain ways. + Additional items: + %{rx} ... insert escaped regexp + %{fuzzyrx} ... insert typo-tolerant regexp + + *tlib#string#TrimLeft()* +tlib#string#TrimLeft(string) + + *tlib#string#TrimRight()* +tlib#string#TrimRight(string) + + *tlib#string#Strip()* +tlib#string#Strip(string) + + *tlib#string#Count()* +tlib#string#Count(string, rx) + + + +vim:tw=78:fo=w2croql:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/vim/.vim/etc/tpl_tlib.txt b/vim/.vim/etc/tpl_tlib.txt new file mode 100644 index 0000000..f805970 --- /dev/null +++ b/vim/.vim/etc/tpl_tlib.txt @@ -0,0 +1,30 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +%s diff --git a/vim/.vim/ftplugin/html_snip_helper.vim b/vim/.vim/ftplugin/html_snip_helper.vim new file mode 100644 index 0000000..4d52392 --- /dev/null +++ b/vim/.vim/ftplugin/html_snip_helper.vim @@ -0,0 +1,10 @@ +" Helper function for (x)html snippets +if exists('s:did_snip_helper') || &cp || !exists('loaded_snips') + finish +endif +let s:did_snip_helper = 1 + +" Automatically closes tag if in xhtml +fun! Close() abort + return stridx(&ft, 'xhtml') == -1 ? '' : ' /' +endf diff --git a/vim/.vim/ftplugin/snippets.vim b/vim/.vim/ftplugin/snippets.vim new file mode 100644 index 0000000..dde00e4 --- /dev/null +++ b/vim/.vim/ftplugin/snippets.vim @@ -0,0 +1,20 @@ +" Vim filetype plugin for SnipMate snippets (.snippets and .snippet files) + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl et< sts< cms< fdm< fde<" + +" Use hard tabs +setlocal noexpandtab softtabstop=0 + +setlocal foldmethod=expr foldexpr=getline(v:lnum)!~'^\\t\\\\|^$'?'>1':1 + +setlocal commentstring=#\ %s +setlocal nospell + +command! -buffer -range=% RetabSnip + \ echom "This command is deprecated. Use :retab and = instead. Doing that now." + \ | ,retab! | ,normal = diff --git a/vim/.vim/indent/snippets.vim b/vim/.vim/indent/snippets.vim new file mode 100644 index 0000000..0d28f32 --- /dev/null +++ b/vim/.vim/indent/snippets.vim @@ -0,0 +1,32 @@ +" Simple indent support for SnipMate snippets files + +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +setlocal nosmartindent +setlocal indentkeys=!^F,o,O,=snippet,=version,=extends +setlocal indentexpr=GetSnippetIndent() + +if exists("*GetSnippetIndent") + finish +endif + +function! GetSnippetIndent() + let line = getline(v:lnum) + let prev_lnum = v:lnum - 1 + let prev_line = prev_lnum != 0 ? getline(prev_lnum) : "" + + if line =~# '\v^(snippet|extends|version) ' + return 0 + elseif indent(v:lnum) > 0 + return indent(v:lnum) + elseif prev_line =~# '^snippet ' + return &sw + elseif indent(prev_lnum) > 0 + return indent(prev_lnum) + endif + + return 0 +endfunction diff --git a/vim/.vim/plugin/02tlib.vim b/vim/.vim/plugin/02tlib.vim new file mode 100755 index 0000000..283854b --- /dev/null +++ b/vim/.vim/plugin/02tlib.vim @@ -0,0 +1,118 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Created: 2007-04-10. +" @Last Change: 2015-10-13. +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 757 +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" GetLatestVimScripts: 1863 1 tlib.vim +" tlib.vim -- Some utility functions + +if &cp || exists("g:loaded_tlib") + finish +endif +if v:version < 700 "{{{2 + echoerr "tlib requires Vim >= 7" + finish +endif +let g:loaded_tlib = 115 + +let s:save_cpo = &cpo +set cpo&vim + + +" Init~ {{{1 +" call tlib#autocmdgroup#Init() + + +" Commands~ {{{1 + +" :display: :TRequire NAME [VERSION [FILE]] +" Make a certain vim file is loaded. +" +" Conventions: If FILE isn't defined, plugin/NAME.vim is loaded. The +" file must provide a variable loaded_{NAME} that represents the version +" number. +command! -nargs=+ TRequire let s:require = [] + \ | if !exists('loaded_'. get(s:require, 0)) + \ | exec 'runtime '. get(s:require, 2, 'plugin/'. get(s:require, 0) .'.vim') + \ | if !exists('loaded_'. get(s:require, 0)) || loaded_{get(s:require, 0)} < get(s:require, 1, loaded_{get(s:require, 0)}) + \ | echoerr 'Require '. get(s:require, 0) .' >= '. get(s:require, 1, 'any version will do') + \ | finish + \ | endif + \ | endif | unlet s:require + + +" :display: :TLet VAR = VALUE +" Set a variable only if it doesn't already exist. +" EXAMPLES: > +" TLet foo = 1 +" TLet foo = 2 +" echo foo +" => 1 +command! -nargs=+ TLet if !exists(matchstr(, '^[^=[:space:]]\+')) | exec 'let '. | endif + + +" Open a scratch buffer (a buffer without a file). +" TScratch ... use split window +" TScratch! ... use the whole frame +" This command takes an (inner) dictionary as optional argument. +" EXAMPLES: > +" TScratch 'scratch': '__FOO__' +" => Open a scratch buffer named __FOO__ +command! -bar -nargs=* -bang TScratch call tlib#scratch#UseScratch({'scratch_split': '' != '!', }) + + +" :display: :TVarArg VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(...) +" TVarArg ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TVarArg exec tlib#arg#Let([]) + + +" :display: :TKeyArg DICT, VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(keyargs) +" TKeyArg a:keyargs, ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TKeyArg exec tlib#arg#Key([]) + + +" :display: :TBrowseOutput COMMAND +" Ever wondered how to efficiently browse the output of a command +" without redirecting it to a file? This command takes a command as +" argument and presents the output via |tlib#input#List()| so that you +" can easily search for a keyword (e.g. the name of a variable or +" function) and the like. +" +" If you press enter, the selected line will be copied to the command +" line. Press ESC to cancel browsing. +" +" EXAMPLES: > +" TBrowseOutput 20verb TeaseTheCulprit +command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput() + +" :display: :TBrowseScriptnames +" List all sourced script names (the output of ':scriptnames'). +" +" When you press enter, the selected script will be opened in the current +" window. Press ESC to cancel. +" +" EXAMPLES: > +" TBrowseScriptnames +command! -nargs=0 -complete=command TBrowseScriptnames call + \ tlib#cmd#BrowseOutputWithCallback("tlib#cmd#ParseScriptname", "scriptnames") + +" :display: :TTimeCommand CMD +" Time the execution time of CMD. +command! -nargs=1 -complete=command TTimeCommand call tlib#cmd#Time() + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/plugin/snipMate.vim b/vim/.vim/plugin/snipMate.vim new file mode 100644 index 0000000..246b542 --- /dev/null +++ b/vim/.vim/plugin/snipMate.vim @@ -0,0 +1,135 @@ +" File: snipMate.vim +" Description: snipMate.vim implements some of TextMate's snippets features in +" Vim. A snippet is a piece of often-typed text that you can +" insert into your document using a trigger word followed by a "". +" +" For more help see snipMate.txt; you can do this by using: +" :helptags ~/.vim/doc +" :h SnipMate + +if exists('loaded_snips') || &cp || version < 700 + finish +endif +let loaded_snips = 1 + +" Save and reset 'cpo' +let s:save_cpo = &cpo +set cpo&vim + +try + call funcref#Function('') +catch /.*/ + echoe "you're missing vim-addon-mw-utils. See install instructions at ".expand(':h:h').'/README.md' +endtry + +if (!exists('g:snipMateSources')) + let g:snipMateSources = {} + " Default source: get snippets based on runtimepath + let g:snipMateSources['default'] = funcref#Function('snipMate#DefaultPool') +endif + +au BufRead,BufNewFile *.snippet,*.snippets setlocal filetype=snippets +au FileType snippets if expand(':e') =~# 'snippet$' + \ | setlocal syntax=snippet + \ | else + \ | setlocal syntax=snippets + \ | endif + +inoremap snipMateNextOrTrigger =snipMate#TriggerSnippet() +snoremap snipMateNextOrTrigger a=snipMate#TriggerSnippet() +inoremap snipMateTrigger =snipMate#TriggerSnippet(1) +inoremap snipMateBack =snipMate#BackwardsSnippet() +snoremap snipMateBack a=snipMate#BackwardsSnippet() +inoremap snipMateShow =snipMate#ShowAvailableSnips() +xnoremap snipMateVisual :call grab_visual()gv"_c + +" config variables +if !exists('g:snips_author') + let g:snips_author = 'Me' +endif +if !exists('g:snipMate') + let g:snipMate = {} +endif + +" SnipMate inserts this string when no snippet expansion can be done +let g:snipMate['no_match_completion_feedkeys_chars'] = + \ get(g:snipMate, 'no_match_completion_feedkeys_chars', "\t") + +" Add default scope aliases, without overriding user settings +let g:snipMate.scope_aliases = get(g:snipMate, 'scope_aliases', {}) +if exists('g:snipMate_no_default_aliases') + echom 'The g:snipMate_no_default_aliases option has been renamed.' + \ 'See :h snipMate-options.' +endif +if (!exists('g:snipMate_no_default_aliases') || !g:snipMate_no_default_aliases) + \ && (!exists('g:snipMate.no_default_aliases') + \ || !g:snipMate.no_default_aliases) + let g:snipMate.scope_aliases.objc = + \ get(g:snipMate.scope_aliases, 'objc', 'c') + let g:snipMate.scope_aliases.cpp = + \ get(g:snipMate.scope_aliases, 'cpp', 'c') + let g:snipMate.scope_aliases.cu = + \ get(g:snipMate.scope_aliases, 'cu', 'c') + let g:snipMate.scope_aliases.xhtml = + \ get(g:snipMate.scope_aliases, 'xhtml', 'html') + let g:snipMate.scope_aliases.html = + \ get(g:snipMate.scope_aliases, 'html', 'javascript') + let g:snipMate.scope_aliases.php = + \ get(g:snipMate.scope_aliases, 'php', 'php,html,javascript') + let g:snipMate.scope_aliases.ur = + \ get(g:snipMate.scope_aliases, 'ur', 'html,javascript') + let g:snipMate.scope_aliases.mxml = + \ get(g:snipMate.scope_aliases, 'mxml', 'actionscript') + let g:snipMate.scope_aliases.eruby = + \ get(g:snipMate.scope_aliases, 'eruby', 'eruby-rails,html') + let g:snipMate.scope_aliases.scss = + \ get(g:snipMate.scope_aliases, 'scss', 'css') + let g:snipMate.scope_aliases.less = + \ get(g:snipMate.scope_aliases, 'less', 'css') +endif + +let g:snipMate['get_snippets'] = get(g:snipMate, 'get_snippets', funcref#Function("snipMate#GetSnippets")) + +" List of paths where snippets/ dirs are located +let g:snipMate['snippet_dirs'] = get(g:snipMate, 'snippet_dirs', split(&rtp, ',')) +if type(g:snipMate['snippet_dirs']) != type([]) + echohl WarningMsg + echom "g:snipMate['snippet_dirs'] must be a List" + echohl None +endif + +" _ is default scope added always +" +" &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO +let g:snipMate['get_scopes'] = get(g:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]')) + +" Modified from Luc Hermitte's function on StackOverflow +" +function! s:grab_visual() abort + let a_save = @a + try + normal! gv"ay + let b:snipmate_visual = @a + finally + let @a = a_save + endtry +endfunction + +" TODO: Allow specifying an arbitrary snippets file +function! s:load_scopes(bang, ...) abort + let gb = a:bang ? g: : b: + let gb.snipMate = get(gb, 'snipMate', {}) + let gb.snipMate.scope_aliases = get(gb.snipMate, 'scope_aliases', {}) + let gb.snipMate.scope_aliases['_'] = join(split(get(gb.snipMate.scope_aliases, '_', ''), ',') + a:000, ',') +endfunction + +command! -bang -bar -nargs=+ SnipMateLoadScope + \ call s:load_scopes(0, ) + +" Edit snippet files +command! SnipMateOpenSnippetFiles call snipMate#OpenSnippetFiles() + +" restore 'cpo' +let &cpo = s:save_cpo + +" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/.vim/plugin/supertab.vim b/vim/.vim/plugin/supertab.vim new file mode 100644 index 0000000..5c15ea4 --- /dev/null +++ b/vim/.vim/plugin/supertab.vim @@ -0,0 +1,1144 @@ +" Author: Eric Van Dewoestine +" Original concept and versions up to 0.32 written by +" Gergely Kontra +" Version: 2.1 +" GetLatestVimScripts: 1643 1 :AutoInstall: supertab.vim +" +" Description: {{{ +" Use your tab key to do all your completion in insert mode! +" You can cycle forward and backward with the and keys +" Note: you must press once to be able to cycle back +" +" http://www.vim.org/scripts/script.php?script_id=1643 +" }}} +" +" License: {{{ +" Copyright (c) 2002 - 2015 +" All rights reserved. +" +" Redistribution and use of this software in source and binary forms, with +" or without modification, are permitted provided that the following +" conditions are met: +" +" * Redistributions of source code must retain the above +" copyright notice, this list of conditions and the +" following disclaimer. +" +" * Redistributions in binary form must reproduce the above +" copyright notice, this list of conditions and the +" following disclaimer in the documentation and/or other +" materials provided with the distribution. +" +" * Neither the name of Gergely Kontra or Eric Van Dewoestine nor the names +" of its contributors may be used to endorse or promote products derived +" from this software without specific prior written permission of Gergely +" Kontra or Eric Van Dewoestine. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +" }}} +" +" Testing Info: {{{ +" Running vim + supertab with the absolute bare minimum settings: +" $ vim -u NONE -U NONE -c "set nocp | runtime plugin/supertab.vim" +" }}} + +if v:version < 700 + finish +endif + +if exists('complType') " Integration with other completion functions. + finish +endif + +if exists("loaded_supertab") + finish +endif +let loaded_supertab = 1 + +let s:save_cpo=&cpo +set cpo&vim + +" Global Variables {{{ + + if !exists("g:SuperTabDefaultCompletionType") + let g:SuperTabDefaultCompletionType = "" + endif + + if !exists("g:SuperTabContextDefaultCompletionType") + let g:SuperTabContextDefaultCompletionType = "" + endif + + if !exists("g:SuperTabContextTextMemberPatterns") + let g:SuperTabContextTextMemberPatterns = ['\.', '>\?::', '->'] + endif + + if !exists("g:SuperTabCompletionContexts") + let g:SuperTabCompletionContexts = ['s:ContextText'] + endif + + if !exists("g:SuperTabRetainCompletionDuration") + let g:SuperTabRetainCompletionDuration = 'insert' + endif + + if !exists("g:SuperTabNoCompleteBefore") + " retain backwards compatability + if exists("g:SuperTabMidWordCompletion") && !g:SuperTabMidWordCompletion + let g:SuperTabNoCompleteBefore = ['\k'] + else + let g:SuperTabNoCompleteBefore = [] + endif + endif + + if !exists("g:SuperTabNoCompleteAfter") + " retain backwards compatability + if exists("g:SuperTabLeadingSpaceCompletion") && g:SuperTabLeadingSpaceCompletion + let g:SuperTabNoCompleteAfter = [] + else + let g:SuperTabNoCompleteAfter = ['^', '\s'] + endif + endif + + if !exists("g:SuperTabMappingForward") + let g:SuperTabMappingForward = '' + endif + if !exists("g:SuperTabMappingBackward") + let g:SuperTabMappingBackward = '' + endif + + if !exists("g:SuperTabMappingTabLiteral") + let g:SuperTabMappingTabLiteral = '' + endif + + if !exists("g:SuperTabLongestEnhanced") + let g:SuperTabLongestEnhanced = 0 + endif + + if !exists("g:SuperTabLongestHighlight") + let g:SuperTabLongestHighlight = 0 + endif + + if !exists("g:SuperTabCrMapping") + let g:SuperTabCrMapping = 0 + endif + + if !exists("g:SuperTabClosePreviewOnPopupClose") + let g:SuperTabClosePreviewOnPopupClose = 0 + endif + + if !exists("g:SuperTabUndoBreak") + let g:SuperTabUndoBreak = 0 + endif + + if !exists("g:SuperTabCompleteCase") + let g:SuperTabCompleteCase = 'inherit' + endif + +" }}} + +" Script Variables {{{ + + " construct the help text. + let s:tabHelp = + \ "Hit or CTRL-] on the completion type you wish to switch to.\n" . + \ "Use :help ins-completion for more information.\n" . + \ "\n" . + \ "|| - Keywords in 'complete' searching down.\n" . + \ "|| - Keywords in 'complete' searching up (SuperTab default).\n" . + \ "|| - Whole lines.\n" . + \ "|| - Keywords in current file.\n" . + \ "|| - Keywords in 'dictionary'.\n" . + \ "|| - Keywords in 'thesaurus', thesaurus-style.\n" . + \ "|| - Keywords in the current and included files.\n" . + \ "|| - Tags.\n" . + \ "|| - File names.\n" . + \ "|| - Definitions or macros.\n" . + \ "|| - Vim command-line.\n" . + \ "|| - User defined completion.\n" . + \ "|| - Omni completion.\n" . + \ "|s| - Spelling suggestions." + + " set the available completion types and modes. + let s:types = + \ "\\\\\\\\" . + \ "\\\\\\\\\s" + let s:modes = '/^E/^Y/^L/^N/^K/^T/^I/^]/^F/^D/^V/^P/^U/^O/s' + let s:types = s:types . "np" + let s:modes = s:modes . '/n/p' + +" }}} + +function! SuperTabSetDefaultCompletionType(type) " {{{ + " Globally available function that users can use to set the default + " completion type for the current buffer, like in an ftplugin. + + " don't allow overriding what SuperTabChain has set, otherwise chaining may + " not work. + if exists('b:SuperTabChain') + return + endif + + " init hack for workaround. + let b:complCommandLine = 0 + + let b:SuperTabDefaultCompletionType = a:type + + " set the current completion type to the default + call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType) +endfunction " }}} + +function! SuperTabSetCompletionType(type) " {{{ + " Globally available function that users can use to create mappings to quickly + " switch completion modes. Useful when a user wants to restore the default or + " switch to another mode without having to kick off a completion of that type + " or use SuperTabHelp. Note, this function only changes the current + " completion type, not the default, meaning that the default will still be + " restored once the configured retension duration has been met (see + " g:SuperTabRetainCompletionDuration). To change the default for the current + " buffer, use SuperTabDefaultCompletionType(type) instead. Example mapping to + " restore SuperTab default: + " nmap :call SetSuperTabCompletionType("") + + " don't allow overriding what SuperTabChain has set, otherwise chaining may + " not work. + if exists('b:SuperTabChain') + return + endif + + call s:InitBuffer() + exec "let b:complType = \"" . escape(a:type, '<') . "\"" +endfunction " }}} + +function! SuperTabAlternateCompletion(type) " {{{ + " Function which can be mapped to a key to kick off an alternate completion + " other than the default. For instance, if you have 'context' as the default + " and want to map ctrl+space to issue keyword completion. + " Note: due to the way vim expands ctrl characters in mappings, you cannot + " create the alternate mapping like so: + " imap =SuperTabAlternateCompletion("") + " instead, you have to use \ to prevent vim from expanding the key + " when creating the mapping. + " gvim: + " imap =SuperTabAlternateCompletion("\c-p>") + " console: + " imap =SuperTabAlternateCompletion("\c-p>") + + call SuperTabSetCompletionType(a:type) + " end any current completion before attempting to start the new one. + " use feedkeys to prevent possible remapping of from causing issues. + "call feedkeys("\", 'n') + " ^ since we can't detect completion mode vs regular insert mode, we force + " vim into keyword completion mode and end that mode to prevent the regular + " insert behavior of from occurring. + call feedkeys("\\\", 'n') + call feedkeys(b:complType, 'n') + return '' +endfunction " }}} + +function! SuperTabLongestHighlight(dir) " {{{ + " When longest highlight is enabled, this function is used to do the actual + " selection of the completion popup entry. + + if !s:CompletionMode() + return '' + endif + return a:dir == -1 ? "\" : "\" +endfunction " }}} + +function! s:Init() " {{{ + " Setup mechanism to restore original completion type upon leaving insert + " mode if configured to do so + if g:SuperTabRetainCompletionDuration == 'insert' + augroup supertab_retain + autocmd! + autocmd InsertLeave * call s:SetDefaultCompletionType() + augroup END + endif +endfunction " }}} + +function! s:InitBuffer() " {{{ + if exists('b:SuperTabNoCompleteBefore') + return + endif + + let b:complReset = 0 + let b:complTypeManual = !exists('b:complTypeManual') ? '' : b:complTypeManual + let b:complTypeContext = '' + + " init hack for workaround. + let b:complCommandLine = 0 + + if !exists('b:SuperTabNoCompleteBefore') + let b:SuperTabNoCompleteBefore = g:SuperTabNoCompleteBefore + endif + if !exists('b:SuperTabNoCompleteAfter') + let b:SuperTabNoCompleteAfter = g:SuperTabNoCompleteAfter + endif + + if !exists('b:SuperTabDefaultCompletionType') + let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType + endif + + if !exists('b:SuperTabContextDefaultCompletionType') + let b:SuperTabContextDefaultCompletionType = + \ g:SuperTabContextDefaultCompletionType + endif + + " set the current completion type to the default + call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType) + + " hack to programatically revert a change to snipmate that breaks supertab + " but which the new maintainers don't care about: + " http://github.com/garbas/vim-snipmate/issues/37 + let snipmate = maparg('', 'i') + if snipmate =~ 'u' && g:SuperTabMappingForward =~? '' + let snipmate = substitute(snipmate, 'u', '', '') + iunmap + exec "inoremap " . snipmate + endif +endfunction " }}} + +function! s:ManualCompletionEnter() " {{{ + " Handles manual entrance into completion mode. + + if &smd + echo '' | echohl ModeMsg | echo '-- ^X++ mode (' . s:modes . ')' | echohl None + endif + let complType = nr2char(getchar()) + if stridx(s:types, complType) != -1 + if !exists('b:supertab_close_preview') + let b:supertab_close_preview = !s:IsPreviewOpen() + endif + + if stridx("\\", complType) != -1 " no memory, just scroll... + return "\" . complType + elseif stridx('np', complType) != -1 + let complType = nr2char(char2nr(complType) - 96) + else + let complType = "\" . complType + endif + + let b:complTypeManual = complType + + if index(['insert', 'session'], g:SuperTabRetainCompletionDuration) != -1 + let b:complType = complType + endif + + " Hack to workaround bug when invoking command line completion via = + if complType == "\\" + return s:CommandLineCompletion() + endif + + call s:InitBuffer() + + " optionally enable enhanced longest completion + if g:SuperTabLongestEnhanced && &completeopt =~ 'longest' + call s:EnableLongestEnhancement() + " handle backspacing which triggers g:SuperTabNoCompleteAfter match + elseif s:IsNoCompleteAfterReset() + call s:EnableNoCompleteAfterReset() + endif + + if g:SuperTabLongestHighlight && + \ &completeopt =~ 'longest' && + \ &completeopt =~ 'menu' && + \ !s:CompletionMode() + let dir = (complType == "\\") ? -1 : 1 + call feedkeys("\=SuperTabLongestHighlight(" . dir . ")\", 'n') + endif + + call s:StartCompletionMode() + return complType + endif + + echohl "Unknown mode" + return complType +endfunction " }}} + +function! s:SetCompletionType() " {{{ + " Sets the completion type based on what the user has chosen from the help + " buffer. + + let chosen = substitute(getline('.'), '.*|\(.*\)|.*', '\1', '') + if chosen != getline('.') + let winnr = b:winnr + close + exec winnr . 'winc w' + call SuperTabSetCompletionType(chosen) + endif +endfunction " }}} + +function! s:SetDefaultCompletionType() " {{{ + if exists('b:SuperTabDefaultCompletionType') && + \ (!exists('b:complCommandLine') || !b:complCommandLine) + call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType) + endif +endfunction " }}} + +function! SuperTab(command) " {{{ + " Used to perform proper cycle navigation as the user requests the next or + " previous entry in a completion list, and determines whether or not to simply + " retain the normal usage of based on the cursor position. + + if exists('b:SuperTabDisabled') && b:SuperTabDisabled + if exists('s:Tab') + return s:Tab() + endif + return ( + \ g:SuperTabMappingForward ==? '' || + \ g:SuperTabMappingBackward ==? '' + \ ) ? "\" : '' + endif + + call s:InitBuffer() + + if s:WillComplete() + if !exists('b:supertab_close_preview') + let b:supertab_close_preview = !s:IsPreviewOpen() + endif + + " optionally enable enhanced longest completion + if g:SuperTabLongestEnhanced && &completeopt =~ 'longest' + call s:EnableLongestEnhancement() + " handle backspacing which triggers g:SuperTabNoCompleteAfter match + elseif s:IsNoCompleteAfterReset() + call s:EnableNoCompleteAfterReset() + endif + + if !s:CompletionMode() + let b:complTypeManual = '' + endif + + " exception: if in mode, then should move up the list, and + " down the list. + if a:command == 'p' && !b:complReset && + \ (b:complType == "\" || + \ (b:complType == 'context' && + \ b:complTypeManual == '' && + \ b:complTypeContext == "\")) + return "\" + + elseif a:command == 'p' && !b:complReset && + \ (b:complType == "\" || + \ (b:complType == 'context' && + \ b:complTypeManual == '' && + \ b:complTypeContext == "\")) + return "\" + + " already in completion mode and not resetting for longest enhancement, so + " just scroll to next/previous + elseif s:CompletionMode() && !b:complReset + let type = b:complType == 'context' ? b:complTypeContext : b:complType + if a:command == 'n' + return type == "\" || type == "\\" ? "\" : "\" + endif + return type == "\" || type == "\\" ? "\" : "\" + endif + + " handle 'context' completion. + if b:complType == 'context' + let complType = s:ContextCompletion() + if complType == '' + exec "let complType = \"" . + \ escape(b:SuperTabContextDefaultCompletionType, '<') . "\"" + endif + let b:complTypeContext = complType + + " Hack to workaround bug when invoking command line completion via = + elseif b:complType == "\\" + let complType = s:CommandLineCompletion() + else + let complType = b:complType + endif + + " switch / completion in mode + if a:command == 'p' + if complType == "\\" + let complType = "\\" + elseif complType == "\\" + let complType = "\\" + endif + endif + + " highlight first result if longest enabled + if g:SuperTabLongestHighlight && + \ &completeopt =~ 'longest' && + \ &completeopt =~ 'menu' && + \ (!s:CompletionMode() || b:complReset) + let dir = (complType == "\") ? -1 : 1 + call feedkeys("\=SuperTabLongestHighlight(" . dir . ")\", 'n') + endif + + if b:complReset + let b:complReset = 0 + " not an accurate condition for everyone, but better than sending + " at the wrong time. + if s:CompletionMode() + return "\" . complType + endif + endif + + if g:SuperTabUndoBreak && !s:CompletionMode() + call s:StartCompletionMode() + return "\u" . complType + endif + + if g:SuperTabCompleteCase == 'ignore' || + \ g:SuperTabCompleteCase == 'match' + if exists('##CompleteDone') + let ignorecase = g:SuperTabCompleteCase == 'ignore' ? 1 : 0 + if &ignorecase != ignorecase + let b:supertab_ignorecase_save = &ignorecase + let &ignorecase = ignorecase + augroup supertab_ignorecase + autocmd CompleteDone + \ let &ignorecase = b:supertab_ignorecase_save | + \ unlet b:supertab_ignorecase_save | + \ autocmd! supertab_ignorecase + augroup END + endif + endif + endif + + call s:StartCompletionMode() + return complType + endif + + if (a:command == 'n' && g:SuperTabMappingForward ==? '') || + \ (a:command == 'p' && g:SuperTabMappingBackward ==? '') + + " trigger our func ref to the smart tabs plugin if present. + if exists('s:Tab') + return s:Tab() + endif + + return "\" + endif + + if (a:command == 'n' && g:SuperTabMappingForward ==? '') || + \ (a:command == 'p' && g:SuperTabMappingBackward ==? '') + " support triggering mappings users might have. + if exists('s:ShiftTab') + if type(s:ShiftTab) == 2 + return s:ShiftTab() + else + call feedkeys(s:ShiftTab, 'n') + endif + endif + endif + + return '' +endfunction " }}} + +function! s:SuperTabHelp() " {{{ + " Opens a help window where the user can choose a completion type to enter. + + let winnr = winnr() + if bufwinnr("SuperTabHelp") == -1 + keepalt botright split SuperTabHelp + + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=wipe + + silent put =s:tabHelp + call cursor(1, 1) + silent 1,delete _ + call cursor(4, 1) + exec "resize " . line('$') + + syntax match Special "|.\{-}|" + + setlocal readonly + setlocal nomodifiable + + nmap :call SetCompletionType() + nmap :call SetCompletionType() + else + exec bufwinnr("SuperTabHelp") . "winc w" + endif + let b:winnr = winnr +endfunction " }}} + +function! s:CompletionMode() " {{{ + return pumvisible() || exists('b:supertab_completion_mode') +endfunction " }}} + +function! s:StartCompletionMode() " {{{ + if exists('##CompleteDone') + let b:supertab_completion_mode = 1 + augroup supertab_completion_mode + autocmd CompleteDone + \ if exists('b:supertab_completion_mode') | + \ unlet b:supertab_completion_mode | + \ endif | + \ autocmd! supertab_completion_mode + augroup END + endif +endfunction " }}} + +function! s:WillComplete(...) " {{{ + " Determines if completion should be kicked off at the current location. + " Optional arg: + " col: The column to check at, otherwise use the current column. + + " if an arg was supplied, then we will re-check even if already in + " completion mode. + if s:CompletionMode() && !a:0 + return 1 + endif + + let line = getline('.') + let cnum = a:0 ? a:1 : col('.') + + " honor SuperTabNoCompleteAfter + let pre = cnum >= 2 ? line[:cnum - 2] : '' + let complAfterType = type(b:SuperTabNoCompleteAfter) + if complAfterType == 3 + " the option was provided as a list of patterns + for pattern in b:SuperTabNoCompleteAfter + if pre =~ pattern . '$' + return 0 + endif + endfor + elseif complAfterType == 2 + " the option was provided as a funcref + return !b:SuperTabNoCompleteAfter(pre) + endif + + " honor SuperTabNoCompleteBefore + " Within a word, but user does not have mid word completion enabled. + let post = line[cnum - 1:] + let complBeforeType = type(b:SuperTabNoCompleteBefore) + if complBeforeType == 3 + " a list of patterns + for pattern in b:SuperTabNoCompleteBefore + if post =~ '^' . pattern + return 0 + endif + endfor + elseif complBeforeType == 2 + " the option was provided as a funcref + return !b:SuperTabNoCompleteBefore(post) + endif + + return 1 +endfunction " }}} + +function! s:EnableLongestEnhancement() " {{{ + augroup supertab_reset + autocmd! + autocmd InsertLeave,CursorMovedI + \ call s:ReleaseKeyPresses() | autocmd! supertab_reset + augroup END + call s:CaptureKeyPresses() +endfunction " }}} + +function! s:IsNoCompleteAfterReset() " {{{ + " if the user has g:SuperTabNoCompleteAfter set, then re-map so that + " backspacing to a point where one of the g:SuperTabNoCompleteAfter + " entries matches will cause completion mode to exit. + let complAfterType = type(b:SuperTabNoCompleteAfter) + if complAfterType == 2 + return 1 + endif + return len(g:SuperTabNoCompleteAfter) && g:SuperTabNoCompleteAfter != ['^', '\s'] +endfunction " }}} + +function! s:EnableNoCompleteAfterReset() " {{{ + augroup supertab_reset + autocmd! + autocmd InsertLeave,CursorMovedI + \ call s:ReleaseKeyPresses() | autocmd! supertab_reset + augroup END + + " short version of s:CaptureKeyPresses + if !exists('b:capturing') || !b:capturing + let b:capturing = 1 + let b:capturing_start = col('.') + let b:captured = { + \ '': s:CaptureKeyMap(''), + \ '': s:CaptureKeyMap(''), + \ } + imap =CompletionReset("\bs>") + imap =CompletionReset("\c-h>") + endif +endfunction " }}} + +function! s:CompletionReset(char) " {{{ + let b:complReset = 1 + + " handle exiting completion mode if user has g:SuperTabNoCompleteAfter set + " and they are about to backspace to a point where that maches one of the + " entries in that var. + if (a:char == "\" || a:char == "\") && s:IsNoCompleteAfterReset() + if !s:WillComplete(col('.') - 1) + " Exit from completion mode then issue the currently requested + " backspace (mapped). + call feedkeys("\\", 'n') + call s:ReleaseKeyPresses() + call feedkeys("\", 'mt') + return '' + endif + endif + + return a:char +endfunction " }}} + +function! s:CaptureKeyPresses() " {{{ + if !exists('b:capturing') || !b:capturing + let b:capturing = 1 + let b:capturing_start = col('.') + " save any previous mappings + let b:captured = { + \ '': s:CaptureKeyMap(''), + \ '': s:CaptureKeyMap(''), + \ } + " TODO: use &keyword to get an accurate list of chars to map + for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs') + let existing = s:CaptureKeyMap(c) + let b:captured[c] = existing + exec 'imap ' . c . ' =CompletionReset("' . c . '")' + endfor + imap =CompletionReset("\bs>") + imap =CompletionReset("\c-h>") + endif +endfunction " }}} + +function! s:CaptureKeyMap(key) " {{{ + " as of 7.3.032 maparg supports obtaining extended information about the + " mapping. + if s:has_dict_maparg + return maparg(a:key, 'i', 0, 1) + endif + return maparg(a:key, 'i') +endfunction " }}} + +function! s:IsPreviewOpen() " {{{ + let wins = tabpagewinnr(tabpagenr(), '$') + let winnr = 1 + while winnr <= wins + if getwinvar(winnr, '&previewwindow') == 1 + return 1 + endif + let winnr += 1 + endwhile + return 0 +endfunction " }}} + +function! s:ClosePreview() " {{{ + if exists('b:supertab_close_preview') && b:supertab_close_preview + let preview = 0 + for bufnum in tabpagebuflist() + if getwinvar(bufwinnr(bufnum), '&previewwindow') + let preview = 1 + break + endif + endfor + if preview + pclose + try + doautocmd supertab_preview_closed User + catch /E216/ + " ignore: no autocmds defined + endtry + endif + endif + silent! unlet b:supertab_close_preview +endfunction " }}} + +function! s:ReleaseKeyPresses() " {{{ + if exists('b:capturing') && b:capturing + let b:capturing = 0 + for c in keys(b:captured) + exec 'iunmap ' . c + endfor + + " restore any previous mappings + for [key, mapping] in items(b:captured) + if !len(mapping) + continue + endif + + if type(mapping) == 4 + let restore = mapping.noremap ? "inoremap" : "imap" + let restore .= " " + if mapping.silent + let restore .= " " + endif + if mapping.expr + let restore .= " " + endif + let rhs = substitute(mapping.rhs, '\c', '' . mapping.sid . '_', 'g') + let restore .= ' ' . key . ' ' . rhs + exec restore + elseif type(c) == 1 + let args = substitute(mapping, '.*\(".\{-}"\).*', '\1', '') + if args != mapping + let args = substitute(args, '<', '', 'g') + let expr = substitute(mapping, '\(.*\)".\{-}"\(.*\)', '\1%s\2', '') + let mapping = printf(expr, args) + endif + exec printf("imap %s %s", key, mapping) + endif + endfor + unlet b:captured + + if mode() == 'i' && &completeopt =~ 'menu' && b:capturing_start != col('.') + " force full exit from completion mode (don't exit insert mode since + " that will break repeating with '.') + call feedkeys("\\", 'n') + endif + unlet b:capturing_start + endif +endfunction " }}} + +function! s:CommandLineCompletion() " {{{ + " Hack needed to account for apparent bug in vim command line mode completion + " when invoked via = + + " This hack will trigger InsertLeave which will then invoke + " s:SetDefaultCompletionType. To prevent default completion from being + " restored prematurely, set an internal flag for s:SetDefaultCompletionType + " to check for. + let b:complCommandLine = 1 + return "\\:call feedkeys('\\\', 'n') | " . + \ "let b:complCommandLine = 0\" +endfunction " }}} + +function! s:ContextCompletion() " {{{ + let contexts = exists('b:SuperTabCompletionContexts') ? + \ b:SuperTabCompletionContexts : g:SuperTabCompletionContexts + + for context in contexts + try + let Context = function(context) + let complType = Context() + unlet Context + if type(complType) == 1 && complType != '' + return complType + endif + catch /E700/ + echohl Error + echom 'supertab: no context function "' . context . '" found.' + echohl None + endtry + endfor + return '' +endfunction " }}} + +function! s:ContextDiscover() " {{{ + let discovery = exists('g:SuperTabContextDiscoverDiscovery') ? + \ g:SuperTabContextDiscoverDiscovery : [] + + " loop through discovery list to find the default + if !empty(discovery) + for pair in discovery + let var = substitute(pair, '\(.*\):.*', '\1', '') + let type = substitute(pair, '.*:\(.*\)', '\1', '') + exec 'let value = ' . var + if value !~ '^\s*$' && value != '0' + exec "let complType = \"" . escape(type, '<') . "\"" + return complType + endif + endfor + endif +endfunction " }}} + +function! s:ContextText() " {{{ + let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ? + \ g:SuperTabContextTextFileTypeExclusions : [] + + if index(exclusions, &ft) == -1 + let curline = getline('.') + let cnum = col('.') + let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name') + + let member_patterns = exists('b:SuperTabContextTextMemberPatterns') ? + \ b:SuperTabContextTextMemberPatterns : g:SuperTabContextTextMemberPatterns + let member_pattern = join(member_patterns, '\|') + + " don't kick off file completion if the pattern is '\" + + elseif curline =~ '\(' . member_pattern . '\)\w*\%' . cnum . 'c' && + \ synname !~ '\(String\|Comment\)' + let omniPrecedence = exists('g:SuperTabContextTextOmniPrecedence') ? + \ g:SuperTabContextTextOmniPrecedence : ['&completefunc', '&omnifunc'] + let omniPrecedence = exists('b:SuperTabContextTextOmniPrecedence') ? + \ b:SuperTabContextTextOmniPrecedence : omniPrecedence + + for omniFunc in omniPrecedence + if omniFunc !~ '^&' + let omniFunc = '&' . omniFunc + endif + if getbufvar(bufnr('%'), omniFunc) != '' + return omniFunc == '&omnifunc' ? "\\" : "\\" + endif + endfor + endif + endif +endfunction " }}} + +function! s:ExpandMap(map) " {{{ + let map = a:map + if map =~ '' + let plug = substitute(map, '.\{-}\(\w\+\).*', '\1', '') + let plug_map = maparg(plug, 'i') + let map = substitute(map, '.\{-}\(\w\+\).*', plug_map, '') + endif + return map +endfunction " }}} + +function! SuperTabChain(completefunc, completekeys, ...) " {{{ + if a:completefunc != 'SuperTabCodeComplete' + call s:InitBuffer() + if (a:0 && a:1) || (!a:0 && b:SuperTabDefaultCompletionType == 'context') + let b:SuperTabContextTextOmniPrecedence = ['&completefunc', '&omnifunc'] + call SuperTabSetDefaultCompletionType("context") + else + call SuperTabSetDefaultCompletionType("") + endif + + let b:SuperTabChain = [a:completefunc, a:completekeys] + setlocal completefunc=SuperTabCodeComplete + endif +endfunction " }}} + +function! SuperTabCodeComplete(findstart, base) " {{{ + if !exists('b:SuperTabChain') + echoe 'No completion chain has been set.' + return -2 + endif + + if len(b:SuperTabChain) != 2 + echoe 'Completion chain can only be used with 1 completion function ' . + \ 'and 1 fallback completion key binding.' + return -2 + endif + + let Func = function(b:SuperTabChain[0]) + + if a:findstart + let start = Func(a:findstart, a:base) + if start >= 0 + return start + endif + + return col('.') - 1 + endif + + let results = Func(a:findstart, a:base) + " Handle dict case, with 'words' and 'refresh' (optional). + " This is used by YouCompleteMe. (See complete-functions). + if type(results) == type({}) && has_key(results, 'words') + if len(results.words) + return results + endif + elseif len(results) + return results + endif + + exec 'let keys = "' . escape(b:SuperTabChain[1], '<') . '"' + " : stop completion and go back to the originally typed text. + call feedkeys("\" . keys, 'nt') + return [] +endfunction " }}} + +" Autocmds {{{ + if g:SuperTabClosePreviewOnPopupClose + augroup supertab_close_preview + autocmd! + autocmd InsertLeave,CursorMovedI * call s:ClosePreview() + augroup END + endif +" }}} + +" Key Mappings {{{ + " map a regular tab to ctrl-tab (note: doesn't work in console vim) + exec 'inoremap ' . g:SuperTabMappingTabLiteral . ' ' + + inoremap =ManualCompletionEnter() + + imap ${2} +snippet scriptsrc + ${2} +snippet style + ${3} +snippet base + +snippet r + +snippet div +
+ ${2} +
+# Embed QT Movie +snippet movie + + + + + + ${6} +snippet fieldset +
+ ${1:name} + + ${3} +
+snippet form +
+ ${3} + + +

+
+snippet h1 +

${2:$1}

+snippet input + ${4} +snippet label + ${7} +snippet link + ${4} +snippet mailto + ${3:email me} +snippet meta + ${3} +snippet opt + ${3} +snippet optt + ${2} +snippet select + ${5} +snippet table + + + +
${2:Header}
${3:Data}
${4} +snippet textarea + ${5} +snippet todo + diff --git a/vim/.vim/snippets/java.snippets b/vim/.vim/snippets/java.snippets new file mode 100644 index 0000000..03aeb6b --- /dev/null +++ b/vim/.vim/snippets/java.snippets @@ -0,0 +1,80 @@ +snippet main + public static void main (String [] args) + { + ${1:/* code */} + } +snippet pu + public +snippet po + protected +snippet pr + private +snippet st + static +snippet fi + final +snippet ab + abstract +snippet re + return +snippet br + break; +snippet de + default: + ${1} +snippet ca + catch(${1:Exception} ${2:e}) ${3} +snippet th + throw +snippet sy + synchronized +snippet im + import +snippet j.u + java.util +snippet j.i + java.io. +snippet j.b + java.beans. +snippet j.n + java.net. +snippet j.m + java.math. +snippet if + if (${1}) ${2} +snippet el + else +snippet elif + else if (${1}) ${2} +snippet wh + while (${1}) ${2} +snippet for + for (${1}; ${2}; ${3}) ${4} +snippet fore + for (${1} : ${2}) ${3} +snippet sw + switch (${1}) ${2} +snippet cs + case ${1}: + ${2} + ${3} +snippet tc + public class ${1:`Filename()`} extends ${2:TestCase} +snippet t + public void test${1:Name}() throws Exception ${2} +snippet cl + class ${1:`Filename("", "untitled")`} ${2} +snippet in + interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} +snippet m + ${1:void} ${2:method}(${3}) ${4:throws }${5} +snippet v + ${1:String} ${2:var}${3: = null}${4};${5} +snippet co + static public final ${1:String} ${2:var} = ${3};${4} +snippet cos + static public final String ${1:var} = "${2}";${3} +snippet as + assert ${1:test} : "${2:Failure message}";${3} +snippet todo + // TODO: $1 diff --git a/vim/.vim/snippets/javascript.snippets b/vim/.vim/snippets/javascript.snippets new file mode 100644 index 0000000..5563c39 --- /dev/null +++ b/vim/.vim/snippets/javascript.snippets @@ -0,0 +1,77 @@ +# Prototype +snippet proto + ${1:class_name}.prototype.${2:method_name} = + function(${3:first_argument}) { + ${4:// body...} + }; +# Function +snippet fun + function ${1:function_name} (${2:argument}) { + ${3:// body...} + } +# Anonymous Function +snippet f + function(${1}) {${2}}; +# if +snippet if + if (${1:true}) {${2}}; +# if ... else +snippet ife + if (${1:true}) {${2}} + else{${3}}; +# tertiary conditional +snippet t + ${1:/* condition */} ? ${2:a} : ${3:b} +# switch +snippet switch + switch(${1:expression}) { + case '${3:case}': + ${4:// code} + break; + ${5} + default: + ${2:// code} + } +# case +snippet case + case '${1:case}': + ${2:// code} + break; + ${3} +# for (...) {...} +snippet for + for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { + ${4:$1[$2]} + }; +# for (...) {...} (Improved Native For-Loop) +snippet forr + for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) { + ${4:$1[$2]} + }; +# while (...) {...} +snippet wh + while (${1:/* condition */}) { + ${2:/* code */} + } +# do...while +snippet do + do { + ${2:/* code */} + } while (${1:/* condition */}); +# Object Method +snippet :f + ${1:method_name}: function(${2:attribute}) { + ${4} + }${3:,} +# setTimeout function +snippet timeout + setTimeout(function() {${3}}${2}, ${1:10}; +# Get Elements +snippet get + getElementsBy${1:TagName}('${2}')${3} +# Get Element +snippet gett + getElementBy${1:Id}('${2}')${3} +snippet todo + // TODO: $1 + diff --git a/vim/.vim/snippets/perl.snippets b/vim/.vim/snippets/perl.snippets new file mode 100644 index 0000000..80f776f --- /dev/null +++ b/vim/.vim/snippets/perl.snippets @@ -0,0 +1,93 @@ +# #!/usr/bin/perl +snippet #! + #!/usr/bin/perl + +# Hash Pointer +snippet . + => +# Function +snippet sub + sub ${1:function_name} { + ${2:#body ...} + } +# Conditional +snippet if + if (${1}) { + ${2:# body...} + } +# Conditional if..else +snippet ife + if (${1}) { + ${2:# body...} + } else { + ${3:# else...} + } +# Conditional if..elsif..else +snippet ifee + if (${1}) { + ${2:# body...} + } elsif (${3}) { + ${4:# elsif...} + } else { + ${5:# else...} + } +# Conditional One-line +snippet xif + ${1:expression} if ${2:condition};${3} +# Unless conditional +snippet unless + unless (${1}) { + ${2:# body...} + } +# Unless conditional One-line +snippet xunless + ${1:expression} unless ${2:condition};${3} +# Try/Except +snippet eval + eval { + ${1:# do something risky...} + }; + if ($@) { + ${2:# handle failure...} + } +# While Loop +snippet wh + while (${1}) { + ${2:# body...} + } +# While Loop One-line +snippet xwh + ${1:expression} while ${2:condition};${3} +# For Loop +snippet for + for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { + ${4:# body...} + } +# Foreach Loop +snippet fore + foreach my $${1:x} (@${2:array}) { + ${3:# body...} + } +# Foreach Loop One-line +snippet xfore + ${1:expression} foreach @${2:array};${3} +# Package +snippet cl + package ${1:ClassName}; + + use base qw(${2:ParentClass}); + + sub new { + my $class = shift; + $class = ref $class if ref $class; + my $self = bless {}, $class; + $self; + } + + 1;${3} +# Read File +snippet slurp + my $${1:var}; + { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE }${3} +snippet todo + # TODO: $1 diff --git a/vim/.vim/snippets/php.snippets b/vim/.vim/snippets/php.snippets new file mode 100644 index 0000000..70ee390 --- /dev/null +++ b/vim/.vim/snippets/php.snippets @@ -0,0 +1,219 @@ +snippet php + +snippet ec + echo "${1:string}"${2}; +snippet inc + include '${1:file}';${2} +snippet inc1 + include_once '${1:file}';${2} +snippet req + require '${1:file}';${2} +snippet req1 + require_once '${1:file}';${2} +# $GLOBALS['...'] +snippet globals + $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5} +snippet $_ COOKIE['...'] + $_COOKIE['${1:variable}']${2} +snippet $_ ENV['...'] + $_ENV['${1:variable}']${2} +snippet $_ FILES['...'] + $_FILES['${1:variable}']${2} +snippet $_ Get['...'] + $_GET['${1:variable}']${2} +snippet $_ POST['...'] + $_POST['${1:variable}']${2} +snippet $_ REQUEST['...'] + $_REQUEST['${1:variable}']${2} +snippet $_ SERVER['...'] + $_SERVER['${1:variable}']${2} +snippet $_ SESSION['...'] + $_SESSION['${1:variable}']${2} +# Start Docblock +snippet /* + /** + * ${1} + **/ +# Class - post doc +snippet doc_cp + /** + * ${1:undocumented class} + * + * @package ${2:default} + * @author ${3:`g:snips_author`} + **/${4} +# Class Variable - post doc +snippet doc_vp + /** + * ${1:undocumented class variable} + * + * @var ${2:string} + **/${3} +# Class Variable +snippet doc_v + /** + * ${3:undocumented class variable} + * + * @var ${4:string} + **/ + ${1:var} $${2};${5} +# Class +snippet doc_c + /** + * ${3:undocumented class} + * + * @packaged ${4:default} + * @author ${5:`g:snips_author`} + **/ + ${1:}class ${2:} + {${6} + } // END $1class $2 +# Constant Definition - post doc +snippet doc_dp + /** + * ${1:undocumented constant} + **/${2} +# Constant Definition +snippet doc_d + /** + * ${3:undocumented constant} + **/ + define(${1}, ${2});${4} +# Function - post doc +snippet doc_fp + /** + * ${1:undocumented function} + * + * @return ${2:void} + * @author ${3:`g:snips_author`} + **/${4} +# Function signature +snippet doc_s + /** + * ${4:undocumented function} + * + * @return ${5:void} + * @author ${6:`g:snips_author`} + **/ + ${1}function ${2}(${3});${7} +# Function +snippet doc_f + /** + * ${4:undocumented function} + * + * @return ${5:void} + * @author ${6:`g:snips_author`} + **/ + ${1}function ${2}(${3}) + {${7} + } +# Header +snippet doc_h + /** + * ${1} + * + * @author ${2:`g:snips_author`} + * @version ${3:$Id$} + * @copyright ${4:$2}, `strftime('%d %B, %Y')` + * @package ${5:default} + **/ + + /** + * Define DocBlock + *// +# Interface +snippet doc_i + /** + * ${2:undocumented class} + * + * @package ${3:default} + * @author ${4:`g:snips_author`} + **/ + interface ${1:} + {${5} + } // END interface $1 +# class ... +snippet class + /** + * ${1} + **/ + class ${2:ClassName} + { + ${3} + function ${4:__construct}(${5:argument}) + { + ${6:// code...} + } + } +# define(...) +snippet def + define('${1}'${2});${3} +# defined(...) +snippet def? + ${1}defined('${2}')${3} +snippet wh + while (${1:/* condition */}) { + ${2:// code...} + } +# do ... while +snippet do + do { + ${2:// code... } + } while (${1:/* condition */}); +snippet if + if (${1:/* condition */}) { + ${2:// code...} + } +snippet ife + if (${1:/* condition */}) { + ${2:// code...} + } else { + ${3:// code...} + } + ${4} +snippet else + else { + ${1:// code...} + } +snippet elseif + elseif (${1:/* condition */}) { + ${2:// code...} + } +# Tertiary conditional +snippet t + $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} +snippet switch + switch ($${1:variable}) { + case '${2:value}': + ${3:// code...} + break; + ${5} + default: + ${4:// code...} + break; + } +snippet case + case '${1:value}': + ${2:// code...} + break;${3} +snippet for + for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { + ${4: // code...} + } +snippet foreach + foreach ($${1:variable} as $${2:key}) { + ${3:// code...} + } +snippet fun + ${1:public }function ${2:FunctionName}(${3}) + { + ${4:// code...} + } +# $... = array (...) +snippet array + $${1:arrayName} = array('${2}' => ${3});${4} +snippet todo + // TODO: $1 + diff --git a/vim/.vim/snippets/python.snippets b/vim/.vim/snippets/python.snippets new file mode 100644 index 0000000..30f8238 --- /dev/null +++ b/vim/.vim/snippets/python.snippets @@ -0,0 +1,91 @@ +snippet #! + #!/usr/bin/python + +snippet from + from ${1:module} import ${2:*} + +snippet imp + import ${1:module} +# Module Docstring +snippet docs + ''' + File: ${1:`Filename('$1.py', 'foo.py')`} + Author: ${2:`g:snips_author`} + Description: ${3} + ''' +snippet wh + while ${1:condition}: + ${2:# code...} +snippet for + for ${1:needle} in ${2:haystack}: + ${3:# code...} +# New Class +snippet cl + class ${1:ClassName}(${2:object}): + """${3:docstring for $1}""" + def __init__(self, ${4:arg}): + ${5:super($1, self).__init__()} + self.$4 = $4 + ${6} +# New Function +snippet def + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + """${3:docstring for $1}""" + ${4:pass} +snippet deff + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + ${3} +# New Method +snippet defs + def ${1:mname}(self, ${2:arg}): + ${3:pass} +# New Property +snippet property + def ${1:foo}(): + doc = "${2:The $1 property.}" + def fget(self): + ${3:return self._$1} + def fset(self, value): + ${4:self._$1 = value} +# Lambda +snippet ld + ${1:var} = lambda ${2:vars} : ${3:action} +snippet . + self. +snippet try Try/Except + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} +snippet try Try/Except/Else + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} + else: + ${5:pass} +snippet try Try/Except/Finally + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} + finally: + ${5:pass} +snippet try Try/Except/Else/Finally + try: + ${1:pass} + except ${2:Exception}, ${3:e}: + ${4:raise $3} + else: + ${5:pass} + finally: + ${6:pass} +# if __name__ == '__main__': +snippet ifmain + if __name__ == '__main__': + ${1:main()} +# __magic__ +snippet _ + __${1:init}__${2} +snippet todo + # TODO: $1 diff --git a/vim/.vim/snippets/ruby.snippets b/vim/.vim/snippets/ruby.snippets new file mode 100644 index 0000000..749e73a --- /dev/null +++ b/vim/.vim/snippets/ruby.snippets @@ -0,0 +1,422 @@ +# #!/usr/bin/ruby +snippet #! + #!/usr/bin/ruby + +# New Block +snippet =b + =begin rdoc + ${1} + =end +snippet y + :yields: ${1:arguments} +snippet rb + #!/usr/bin/env ruby -wKU + +snippet req + require "${1}"${2} +snippet # + # => +snippet end + __END__ +snippet case + case ${1:object} + when ${2:condition} + ${3} + end +snippet when + when ${1:condition} + ${2} +snippet def + def ${1:method_name} + ${2} + end +snippet deft + def test_${1:case_name} + ${2} + end +snippet if + if ${1:condition} + ${2} + end +snippet ife + if ${1:condition} + ${2} + else + ${3} + end +snippet elsif + elsif ${1:condition} + ${2} +snippet unless + unless ${1:condition} + ${2} + end +snippet while + while ${1:condition} + ${2} + end +snippet until + until ${1:condition} + ${2} + end +snippet cla class .. end + class ${1:`substitute(Filename(), '^.', '\u&', '')`} + ${2} + end +snippet cla class .. initialize .. end + class ${1:`substitute(Filename(), '^.', '\u&', '')`} + def initialize(${2:args}) + ${3} + end + + + end +snippet cla class .. < ParentClass .. initialize .. end + class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass} + def initialize(${3:args}) + ${4} + end + + + end +snippet cla ClassName = Struct .. do .. end + ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do + def ${3:method_name} + ${4} + end + + + end +snippet cla class BlankSlate .. initialize .. end + class ${1:BlankSlate} + instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } +snippet cla class << self .. end + class << ${1:self} + ${2} + end +# class .. < DelegateClass .. initialize .. end +snippet cla- + class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass}) + def initialize(${3:args}) + super(${4:del_obj}) + + ${5} + end + + + end +snippet mod module .. end + module ${1:`substitute(Filename(), '^.', '\u&', '')`} + ${2} + end +snippet mod module .. module_function .. end + module ${1:`substitute(Filename(), '^.', '\u&', '')`} + module_function + + ${2} + end +snippet mod module .. ClassMethods .. end + module ${1:`substitute(Filename(), '^.', '\u&', '')`} + module ClassMethods + ${2} + end + + module InstanceMethods + + end + + def self.included(receiver) + receiver.extend ClassMethods + receiver.send :include, InstanceMethods + end + end +# attr_reader +snippet r + attr_reader :${1:attr_names} +# attr_writer +snippet w + attr_writer :${1:attr_names} +# attr_accessor +snippet rw + attr_accessor :${1:attr_names} +# include Enumerable +snippet Enum + include Enumerable + + def each(&block) + ${1} + end +# include Comparable +snippet Comp + include Comparable + + def <=>(other) + ${1} + end +# extend Forwardable +snippet Forw- + extend Forwardable +# def self +snippet defs + def self.${1:class_method_name} + ${2} + end +# def method_missing +snippet defmm + def method_missing(meth, *args, &blk) + ${1} + end +snippet defd + def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name} +snippet defds + def_delegators :${1:@del_obj}, :${2:del_methods} +snippet am + alias_method :${1:new_name}, :${2:old_name} +snippet app + if __FILE__ == $PROGRAM_NAME + ${1} + end +# usage_if() +snippet usai + if ARGV.${1} + abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} + end +# usage_unless() +snippet usau + unless ARGV.${1} + abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} + end +snippet array + Array.new(${1:10}) { |${2:i}| ${3} } +snippet hash + Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} } +snippet file File.foreach() { |line| .. } + File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} } +snippet file File.read() + File.read(${1:"path/to/file"})${2} +snippet Dir Dir.global() { |file| .. } + Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} } +snippet Dir Dir[".."] + Dir[${1:"glob/**/*.rb"}]${2} +snippet dir + Filename.dirname(__FILE__) +snippet deli + delete_if { |${1:e}| ${2} } +snippet fil + fill(${1:range}) { |${2:i}| ${3} } +# flatten_once() +snippet flao + inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3} +snippet zip + zip(${1:enums}) { |${2:row}| ${3} } +# downto(0) { |n| .. } +snippet dow + downto(${1:0}) { |${2:n}| ${3} } +snippet ste + step(${1:2}) { |${2:n}| ${3} } +snippet tim + times { |${1:n}| ${2} } +snippet upt + upto(${1:1.0/0.0}) { |${2:n}| ${3} } +snippet loo + loop { ${1} } +snippet ea + each { |${1:e}| ${2} } +snippet eab + each_byte { |${1:byte}| ${2} } +snippet eac- each_char { |chr| .. } + each_char { |${1:chr}| ${2} } +snippet eac- each_cons(..) { |group| .. } + each_cons(${1:2}) { |${2:group}| ${3} } +snippet eai + each_index { |${1:i}| ${2} } +snippet eak + each_key { |${1:key}| ${2} } +snippet eal + each_line { |${1:line}| ${2} } +snippet eap + each_pair { |${1:name}, ${2:val}| ${3} } +snippet eas- + each_slice(${1:2}) { |${2:group}| ${3} } +snippet eav + each_value { |${1:val}| ${2} } +snippet eawi + each_with_index { |${1:e}, ${2:i}| ${3} } +snippet reve + reverse_each { |${1:e}| ${2} } +snippet inj + inject(${1:init}) { |${2:mem}, ${3:var}| ${4} } +snippet map + map { |${1:e}| ${2} } +snippet mapwi- + enum_with_index.map { |${1:e}, ${2:i}| ${3} } +snippet sor + sort { |a, b| ${1} } +snippet sorb + sort_by { |${1:e}| ${2} } +snippet ran + sort_by { rand } +snippet all + all? { |${1:e}| ${2} } +snippet any + any? { |${1:e}| ${2} } +snippet cl + classify { |${1:e}| ${2} } +snippet col + collect { |${1:e}| ${2} } +snippet det + detect { |${1:e}| ${2} } +snippet fet + fetch(${1:name}) { |${2:key}| ${3} } +snippet fin + find { |${1:e}| ${2} } +snippet fina + find_all { |${1:e}| ${2} } +snippet gre + grep(${1:/pattern/}) { |${2:match}| ${3} } +snippet sub + ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} } +snippet sca + scan(${1:/pattern/}) { |${2:match}| ${3} } +snippet max + max { |a, b|, ${1} } +snippet min + min { |a, b|, ${1} } +snippet par + partition { |${1:e}|, ${2} } +snippet rej + reject { |${1:e}|, ${2} } +snippet sel + select { |${1:e}|, ${2} } +snippet lam + lambda { |${1:args}| ${2} } +snippet do + do |${1:variable}| + ${2} + end +snippet : + :${1:key} => ${2:"value"}${3} +snippet ope + open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} } +# path_from_here() +snippet patfh + File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2} +# unix_filter {} +snippet unif + ARGF.each_line${1} do |${2:line}| + ${3} + end +# option_parse {} +snippet optp + require "optparse" + + options = {${1:default => "args"}} + + ARGV.options do |opts| + opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} +snippet opt + opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String}, + "${4:Option description.}") do |${5:opt}| + ${6} + end +snippet tc + require "test/unit" + + require "${1:library_file_name}" + + class Test${2:$1} < Test::Unit::TestCase + def test_${3:case_name} + ${4} + end + end +snippet ts + require "test/unit" + + require "tc_${1:test_case_file}" + require "tc_${2:test_case_file}"${3} +snippet as + assert(${1:test}, "${2:Failure message.}")${3} +snippet ase + assert_equal(${1:expected}, ${2:actual})${3} +snippet asne + assert_not_equal(${1:unexpected}, ${2:actual})${3} +snippet asid + assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4} +snippet asio + assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3} +snippet asko + assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3} +snippet asn + assert_nil(${1:instance})${2} +snippet asnn + assert_not_nil(${1:instance})${2} +snippet asm + assert_match(/${1:expected_pattern}/, ${2:actual_string})${3} +snippet asnm + assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3} +snippet aso + assert_operator(${1:left}, :${2:operator}, ${3:right})${4} +snippet asr + assert_raise(${1:Exception}) { ${2} } +snippet asnr + assert_nothing_raised(${1:Exception}) { ${2} } +snippet asrt + assert_respond_to(${1:object}, :${2:method})${3} +snippet ass assert_same(..) + assert_same(${1:expected}, ${2:actual})${3} +snippet ass assert_send(..) + assert_send([${1:object}, :${2:message}, ${3:args}])${4} +snippet asns + assert_not_same(${1:unexpected}, ${2:actual})${3} +snippet ast + assert_throws(:${1:expected}) { ${2} } +snippet asnt + assert_nothing_thrown { ${1} } +snippet fl + flunk("${1:Failure message.}")${2} +# Benchmark.bmbm do .. end +snippet bm- + TESTS = ${1:10_000} + Benchmark.bmbm do |results| + ${2} + end +snippet rep + results.report("${1:name}:") { TESTS.times { ${2} }} +# Marshal.dump(.., file) +snippet Md + File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4} +# Mashal.load(obj) +snippet Ml + File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3} +# deep_copy(..) +snippet deec + Marshal.load(Marshal.dump(${1:obj_to_copy}))${2} +snippet Pn- + PStore.new(${1:"file_name.pstore"})${2} +snippet tra + transaction(${1:true}) { ${2} } +# xmlread(..) +snippet xml- + REXML::Document.new(File.read(${1:"path/to/file"}))${2} +# xpath(..) { .. } +snippet xpa + elements.each(${1:"//Xpath"}) do |${2:node}| + ${3} + end +# class_from_name() +snippet clafn + split("::").inject(Object) { |par, const| par.const_get(const) } +# singleton_class() +snippet sinc + class << self; self end +snippet nam + namespace :${1:`Filename()`} do + ${2} + end +snippet tas + desc "${1:Task description\}" + task :${2:task_name => [:dependent, :tasks]} do + ${3} + end +snippet todo + # TODO: $1 diff --git a/vim/.vim/snippets/sh.snippets b/vim/.vim/snippets/sh.snippets new file mode 100644 index 0000000..11e2776 --- /dev/null +++ b/vim/.vim/snippets/sh.snippets @@ -0,0 +1,34 @@ +# #!/bin/bash +snippet #! + #!/bin/bash + +snippet if + if [[ ${1:condition} ]]; then + ${2:#statements} + fi +snippet elif + elif [[ ${1:condition} ]]; then + ${2:#statements} +snippet for + for (( ${1:i} = 0; $1 < ${2:count}; $1++ )); do + ${3:#statements} + done +snippet wh + while [[ ${1:condition} ]]; do + ${2:#statements} + done +snippet until + until [[ ${1:condition} ]]; do + ${2:#statements} + done +snippet case + case ${1:word} in + ${2:pattern}) + ${3};; + esac +snippet func + ${1:function}() { + ${2} + } +snippet todo + # TODO: $1 diff --git a/vim/.vim/snippets/snippet.snippets b/vim/.vim/snippets/snippet.snippets new file mode 100644 index 0000000..34d68a4 --- /dev/null +++ b/vim/.vim/snippets/snippet.snippets @@ -0,0 +1,8 @@ +# snippets for making snippets :) +snippet snip + snippet ${1:trigger} + ${2} +snippet msnip + snippet ${1:trigger} ${2:description} + ${3} + diff --git a/vim/.vim/snippets/tex.snippets b/vim/.vim/snippets/tex.snippets new file mode 100644 index 0000000..22f7316 --- /dev/null +++ b/vim/.vim/snippets/tex.snippets @@ -0,0 +1,115 @@ +# \begin{}...\end{} +snippet begin + \begin{${1:env}} + ${2} + \end{$1} +# Tabular +snippet tab + \begin{${1:tabular}}{${2:c}} + ${3} + \end{$1} +# Align(ed) +snippet ali + \begin{align${1:ed}} + ${2} + \end{align$1} +# Gather(ed) +snippet gat + \begin{gather${1:ed}} + ${2} + \end{gather$1} +# Equation +snippet eq + \begin{equation} + ${1} + \end{equation} +# Unnumbered Equation +snippet \ + \\[ + ${1} + \\] +# Enumerate +snippet enum + \begin{enumerate} + \item ${1} + \end{enumerate} +# Itemize +snippet item + \begin{itemize} + \item ${1} + \end{itemize} +# Description +snippet desc + \begin{description} + \item[${1}] ${2} + \end{description} +# Matrix +snippet mat + \begin{${1:p/b/v/V/B/small}matrix} + ${2} + \end{$1matrix} +# Cases +snippet cas + \begin{cases} + ${1:equation}, &\text{ if }${2:case}\\ + ${3} + \end{cases} +# Split +snippet spl + \begin{split} + ${1} + \end{split} +# Part +snippet part + \part{${1:part name}} % (fold) + \label{prt:${2:$1}} + ${3} + % part $2 (end) +# Chapter +snippet cha + \chapter{${1:chapter name}} % (fold) + \label{cha:${2:$1}} + ${3} + % chapter $2 (end) +# Section +snippet sec + \section{${1:section name}} % (fold) + \label{sec:${2:$1}} + ${3} + % section $2 (end) +# Sub Section +snippet sub + \subsection{${1:subsection name}} % (fold) + \label{sub:${2:$1}} + ${3} + % subsection $2 (end) +# Sub Sub Section +snippet subs + \subsubsection{${1:subsubsection name}} % (fold) + \label{ssub:${2:$1}} + ${3} + % subsubsection $2 (end) +# Paragraph +snippet par + \paragraph{${1:paragraph name}} % (fold) + \label{par:${2:$1}} + ${3} + % paragraph $2 (end) +# Sub Paragraph +snippet subp + \subparagraph{${1:subparagraph name}} % (fold) + \label{subp:${2:$1}} + ${3} + % subparagraph $2 (end) +snippet itd + \item[${1:description}] ${2:item} +snippet figure + ${1:Figure}~\ref{${2:fig:}}${3} +snippet table + ${1:Table}~\ref{${2:tab:}}${3} +snippet listing + ${1:Listing}~\ref{${2:list}}${3} +snippet section + ${1:Section}~\ref{${2:sec:}}${3} +snippet page + ${1:page}~\pageref{${2}}${3} diff --git a/vim/.vim/snippets/vim.snippets b/vim/.vim/snippets/vim.snippets new file mode 100644 index 0000000..e40a5f3 --- /dev/null +++ b/vim/.vim/snippets/vim.snippets @@ -0,0 +1,34 @@ +snippet header + " File: ${1:`expand('%:t')`} + " Author: ${2:`g:snips_author`} + " Description: ${3} + ${4:" Last Modified: `strftime("%B %d, %Y")`} +snippet guard + if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} + finish + endif + let $1 = 1${3} +snippet f + fun ${1:function_name}(${2}) + ${3:" code} + endf +snippet for + for ${1:needle} in ${2:haystack} + ${3:" code} + endfor +snippet wh + while ${1:condition} + ${2:" code} + endw +snippet if + if ${1:condition} + ${2:" code} + endif +snippet ife + if ${1:condition} + ${2} + else + ${3} + endif +snippet todo + # TODO: $1 diff --git a/vim/.vim/snippets/zsh.snippets b/vim/.vim/snippets/zsh.snippets new file mode 100644 index 0000000..333db2c --- /dev/null +++ b/vim/.vim/snippets/zsh.snippets @@ -0,0 +1,60 @@ +# #!/bin/zsh +snippet #! + #!/bin/zsh + +snippet if + if ${1:condition}; then + ${2:# statements} + fi +snippet ife + if ${1:condition}; then + ${2:# statements} + else + ${3:# statements} + fi +snippet elif + elif ${1:condition} ; then + ${2:# statements} +snippet for + for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do + ${3:# statements} + done +snippet fore + for ${1:item} in ${2:list}; do + ${3:# statements} + done +snippet wh + while ${1:condition}; do + ${2:# statements} + done +snippet until + until ${1:condition}; do + ${2:# statements} + done +snippet repeat + repeat ${1:integer}; do + ${2:# statements} + done +snippet case + case ${1:word} in + ${2:pattern}) + ${3};; + esac +snippet select + select ${1:answer} in ${2:choices}; do + ${3:# statements} + done +snippet ( + ( ${1:#statements} ) +snippet { + { ${1:#statements} } +snippet [ + [[ ${1:test} ]] +snippet always + { ${1:try} } always { ${2:always} } +snippet fun + function ${1:name} (${2:args}) { + ${3:# body} + } +snippet todo + # TODO: $1 diff --git a/vim/.vim/spec/tlib/arg.vim b/vim/.vim/spec/tlib/arg.vim new file mode 100755 index 0000000..cf060a2 --- /dev/null +++ b/vim/.vim/spec/tlib/arg.vim @@ -0,0 +1,66 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 1 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#arg' + +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +Should be equal TestGetArg(), 1 +Should be equal TestGetArg(''), '' +Should be equal TestGetArg(2), 2 +Should be equal TestGetArg1(), 1 +Should be equal TestGetArg1(''), 1 +Should be equal TestGetArg1(2), 2 + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs(), 'oo' +Should be equal TestArgs('a'), 'aa' +Should be equal TestArgs('a', 3), 'aaa' + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs1(), '' +Should be equal TestArgs1('a'), 'aa' +Should be equal TestArgs1('a', 3), 'aaa' + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +Should be equal TestArgs2(), '1' +Should be equal TestArgs2('a'), 'a' +Should be equal TestArgs2('a', 3), 'aaa' + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +Should be equal TestArgs3(), '1' +Should be equal TestArgs3('a'), 'a' +Should be equal TestArgs3('a', 3), 'a3' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/spec/tlib/date.vim b/vim/.vim/spec/tlib/date.vim new file mode 100644 index 0000000..d5a451c --- /dev/null +++ b/vim/.vim/spec/tlib/date.vim @@ -0,0 +1,40 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-09-17. +" @Last Change: 2010-09-17. +" @Revision: 16 + +SpecBegin 'title': 'tlib#date' + +Should be equal tlib#date#Parse('2000-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('2000-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('00-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2000/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2.1.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('2. 1. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02.01.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02. 01. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('20.10.2000'), [2000, 10, 20] +Should be equal tlib#date#Parse('20. 10. 2000'), [2000, 10, 20] + +Should throw exception "tlib#date#Parse('2000-14-2')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-011-02')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-40')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-0')", 'TLib: Invalid date' + diff --git a/vim/.vim/spec/tlib/file.vim b/vim/.vim/spec/tlib/file.vim new file mode 100755 index 0000000..f692abf --- /dev/null +++ b/vim/.vim/spec/tlib/file.vim @@ -0,0 +1,59 @@ +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-25. +" @Last Change: 2010-04-03. +" @Revision: 13 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib/file', + \ 'sfile': 'autoload/tlib/file.vim' + + + +It should split filenames. +Should be equal tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt'] + + +It should join filenames. +Should be#Equal tlib#file#Join(['foo', 'bar']), 'foo/bar' +Should be#Equal tlib#file#Join(['foo/', 'bar'], 1), 'foo/bar' +Should be#Equal tlib#file#Join(['', 'bar']), '/bar' +Should be#Equal tlib#file#Join(['/', 'bar'], 1), '/bar' +Should be#Equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp://', 'foo', 'bar', 'filename.txt'], 1), 'ftp://foo/bar/filename.txt' + +Should be equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' + + +It should construct relative path names. +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be#Equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/spec/tlib/hash.vim b/vim/.vim/spec/tlib/hash.vim new file mode 100644 index 0000000..a2403a3 --- /dev/null +++ b/vim/.vim/spec/tlib/hash.vim @@ -0,0 +1,58 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +SpecBegin 'title': 'tlib#hash' + + +It should calculate CRC32B checksums. + +let g:tlib_hash_use_crc32 = g:tlib#hash#use_crc32 + +let g:tlib#hash#use_crc32 = 'ruby' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + +let g:tlib#hash#use_crc32 = 'vim' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + + +function! s:CompareHash(text) "{{{3 + if !empty(a:text) + exec 'It should calculate the crc32b checksum for:' a:text + let crc32ruby = tlib#hash#CRC32B_ruby(a:text) + let crc32vim = tlib#hash#CRC32B_vim(a:text) + exec 'Should be equal' string(crc32ruby) ',' string(crc32vim) + exec 'It should calculate the adler32 checksum for:' a:text + let adler32tlib = tlib#hash#Adler32_tlib(a:text) + let adler32vim = tlib#hash#Adler32_vim(a:text) + exec 'Should be equal' string(adler32tlib) ',' string(adler32vim) + endif +endf + +redir => s:scriptnames +silent scriptnames +redir END +for s:script in split(s:scriptnames, '\n') + let s:scriptfile = matchstr(s:script, '^\s*\d\+:\s\+\zs.*$') + call s:CompareHash(s:scriptfile) + try + let s:scriptlines = readfile(s:scriptfile) + call s:CompareHash(join(s:scriptlines, "\n")) + for s:scriptline in s:scriptlines + call s:CompareHash(s:scriptline) + endfor + catch /^Vim\%((\a\+)\)\=:E484/ + endtry +endfor +unlet s:scriptnames, :script, s:scriptfile, s:scriptlines, s:scriptline +delf s:CompareHash + + +let g:tlib#hash#use_crc32 = g:tlib_hash_use_crc32 + diff --git a/vim/.vim/spec/tlib/input.vim b/vim/.vim/spec/tlib/input.vim new file mode 100755 index 0000000..f82aea6 --- /dev/null +++ b/vim/.vim/spec/tlib/input.vim @@ -0,0 +1,127 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-28. +" @Last Change: 2009-03-14. +" @Revision: 73 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib: Input', 'scratch': '%', + \ 'after': ':unlet! g:spec_lib_rv', + \ 'options': [ + \ 'vim', + \ ] + + +let g:spec_tlib_list = [10, 20, 30, 40, 'a50', 'aa60', 'b70', 'ba80', 90] + + + +It should return empty values when the user presses . +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, '' + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, [] + +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 0 + + + +It should pick an item from s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 30 + + + +It should return an index from si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 3 + + + +It should return a list from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 40] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + + + +It should return a list of indices from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 4] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + + + +It should filter items from a s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 'aa60' + + + +It should filter items from a si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 6 + + + +It should filter items from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + + + +It should filter items from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + + + +let &cpo = s:save_cpo diff --git a/vim/.vim/spec/tlib/list.vim b/vim/.vim/spec/tlib/list.vim new file mode 100755 index 0000000..d4aae54 --- /dev/null +++ b/vim/.vim/spec/tlib/list.vim @@ -0,0 +1,67 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib: List' + " \, 'options': [vim, <+SET+>] + " \, 'sfile': '<+SCRIPT CONTEXT+>' + " \, 'scratch': '<+SCRATCH FILE+>' + " \, 'before': '<+BEFORE EX COMMANDS+>' + " \, 'after': '<+AFTER EX COMMANDS+>' + " \, 'cleanup': ['<+FUNCTION+>()'] + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf + +Should be equal tlib#list#Inject([], 0, function('Add')), 0 +Should be equal tlib#list#Inject([1,2,3], 0, function('Add')), 6 + +Should be equal tlib#list#Compact([]), [] +Should be equal tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3] + +Should be equal tlib#list#Flatten([]), [] +Should be equal tlib#list#Flatten([1,2,3]), [1,2,3] +Should be equal tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3] +Should be equal tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""] + +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3] +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30] + +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2'), 2 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10 + +Should be equal tlib#list#Any([1,2,3], 'v:val >= 2'), 1 +Should be equal tlib#list#Any([1,2,3], 'v:val >= 5'), 0 + +Should be equal tlib#list#All([1,2,3], 'v:val < 5'), 1 +Should be equal tlib#list#All([1,2,3], 'v:val >= 2'), 0 + +Should be equal tlib#list#Remove([1,2,1,2], 2), [1,1,2] +Should be equal tlib#list#RemoveAll([1,2,1,2], 2), [1,1] + +Should be equal tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]] +Should be equal tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]] + + +Should be equal tlib#list#Uniq([]), [] +Should be equal tlib#list#Uniq([1,1]), [1] +Should be equal tlib#list#Uniq([1,2,2,3,2,3,4,2,1,7,2,3,2,3,7]), [1,2,3,4,7] + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/spec/tlib/rx.vim b/vim/.vim/spec/tlib/rx.vim new file mode 100755 index 0000000..fc28103 --- /dev/null +++ b/vim/.vim/spec/tlib/rx.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#rx' + + +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + Should be like s, '\m^'. tlib#rx#Escape(s, 'm') .'$' + Should be like s, '\M^'. tlib#rx#Escape(s, 'M') .'$' + Should be like s, '\v^'. tlib#rx#Escape(s, 'v') .'$' + Should be like s, '\V\^'. tlib#rx#Escape(s, 'V') .'\$' +endfor + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/spec/tlib/string.vim b/vim/.vim/spec/tlib/string.vim new file mode 100755 index 0000000..4329d94 --- /dev/null +++ b/vim/.vim/spec/tlib/string.vim @@ -0,0 +1,29 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#string' + +Should be equal tlib#string#RemoveBackslashes('foo bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar' + + +Should be equal tlib#string#Count("fooo", "o"), 3 +Should be equal tlib#string#Count("***", "\\*"), 3 +Should be equal tlib#string#Count("***foo", "\\*"), 3 +Should be equal tlib#string#Count("foo***", "\\*"), 3 + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/spec/tlib/url.vim b/vim/.vim/spec/tlib/url.vim new file mode 100755 index 0000000..80783e9 --- /dev/null +++ b/vim/.vim/spec/tlib/url.vim @@ -0,0 +1,23 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#url' + +Should be equal tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar' +Should be equal tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.' + +Should be equal tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar' +Should be equal tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/spec/tlib/var.vim b/vim/.vim/spec/tlib/var.vim new file mode 100755 index 0000000..28e3fac --- /dev/null +++ b/vim/.vim/spec/tlib/var.vim @@ -0,0 +1,37 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#var' + + +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +Should be equal tlib#var#Get('bar', 'bg'), 3 +Should be equal tlib#var#Get('bar', 'g'), 2 +Should be equal tlib#var#Get('foo', 'bg'), 1 +Should be equal tlib#var#Get('foo', 'g'), 1 +Should be equal tlib#var#Get('none', 'l'), '' + +Should be equal eval(tlib#var#EGet('bar', 'bg')), 3 +Should be equal eval(tlib#var#EGet('bar', 'g')), 2 +" Should be equal eval(tlib#var#EGet('bar', 'sg')), 4 +Should be equal eval(tlib#var#EGet('foo', 'bg')), 1 +Should be equal eval(tlib#var#EGet('foo', 'g')), 1 +Should be equal eval(tlib#var#EGet('none', 'l')), '' + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/vim/.vim/syntax/snippet.vim b/vim/.vim/syntax/snippet.vim new file mode 100644 index 0000000..a947356 --- /dev/null +++ b/vim/.vim/syntax/snippet.vim @@ -0,0 +1,11 @@ +" Syntax highlighting for .snippet files (used for snipMate.vim) +" Hopefully this should make snippets a bit nicer to write! +syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand +syn match tabStop '\$\d\+' +syn match snipEscape '\\\\\|\\`' +syn match snipCommand '\%(\\\@ autocmds + 0verbose au snipmate_changes * + redir END + return split(autocmds, "\n") + endfunction + aug snipmate_changes + au CursorMoved,CursorMovedI echo 'event' + aug END + + Expect len(ReadAutocmds()) > 1 + call b:snip_state.remove() + Expect len(ReadAutocmds()) == 1 + end + + end + + describe '.find_next_stop()' + + it 'increments/decrements the stop_no' + let b:snip_state.stops = { 1 : {}, 2 : {} } + let b:snip_state.stop_no = 1 + let b:snip_state.stop_count = 4 + + call b:snip_state.find_next_stop(0) + Expect b:snip_state.stop_no == 2 + call b:snip_state.find_next_stop(1) + Expect b:snip_state.stop_no == 1 + end + + it 'continues iterating if the next/previous stop does not exist' + let b:snip_state.stops = { 3 : {} } + let b:snip_state.stop_count = 6 + let b:snip_state.stop_no = 1 + call b:snip_state.find_next_stop(0) + Expect b:snip_state.stop_no == 3 + let b:snip_state.stop_no = 5 + call b:snip_state.find_next_stop(1) + Expect b:snip_state.stop_no == 3 + end + + it 'does something at the ends' + " + end + + end + + describe '.remove_nested()' + + it 'removes nested mirrors and only nested mirrors' + let mirror = { 'line' : 0 } + let b:snip_state.stops = { 1 : { 'placeholder' : [[2, mirror]] }, + \ 2 : { 'mirrors' : [mirror, {}] } } + + call b:snip_state.remove_nested(1) + Expect len(b:snip_state.stops[2].mirrors) == 1 + Expect b:snip_state.stops[2].mirrors[0] isnot mirror + end + + it 'removes nested stops' + let stop = [2, 'abc'] + let b:snip_state.stops = { 1 : { 'placeholder' : [stop] }, + \ 2 : { 'placeholder' : stop[1:1] } } + + call b:snip_state.remove_nested(1) + Expect len(b:snip_state.stops) == 1 + Expect keys(b:snip_state.stops) == ['1'] + end + + end + + describe '.find_update_objects()' + + it 'finds mirrors/stops on the same line and after cur_stop' + let b:snip_state.stops = { + \ 1 : { 'line' : 1, 'col' : 5, + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 1, 'col' : 7, + \ 'mirrors' : [{ 'line' : 1, 'col' : 7 }] } + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + for obj in stop.update_objects + Expect obj to_be_in [ b:snip_state.stops[2], + \ b:snip_state.stops[2].mirrors[0] ] + endfor + end + + it 'finds mirrors/stops on the same line and after cur_stop mirrors' + let b:snip_state.stops = { + \ 1 : { 'line' : 1, 'col' : 5, + \ 'mirrors' : [{ 'line' : 2, 'col' : 5 }], + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 2, 'col' : 7, + \ 'mirrors' : [{ 'line' : 2, 'col' : 7 }] } + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + for obj in stop.update_objects + Expect obj to_be_in [ b:snip_state.stops[2], + \ b:snip_state.stops[2].mirrors[0] ] + endfor + end + + it 'ignores mirrors/stops on other lines' + let b:snip_state.stops = { + \ 1 : { 'line' : 2, 'col' : 5, + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 1, 'col' : 7, + \ 'mirrors' : [{ 'line' : 1, 'col' : 7 }] }, + \ 3 : { 'line' : 3, 'col' : 7, + \ 'mirrors' : [{ 'line' : 3, 'col' : 7 }] } + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + Expect empty(stop.update_objects) to_be_true + end + + it 'ignores mirrors/stops on the same line but before cur_stop/mirrors' + let b:snip_state.stops = { + \ 1 : { 'line' : 1, 'col' : 5, + \ 'mirrors' : [{ 'line' : 2, 'col' : 5 }], + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 1, 'col' : 1, + \ 'mirrors' : [{ 'line' : 2, 'col' : 1 }] }, + \ 3 : { 'line' : 2, 'col' : 3, + \ 'mirrors' : [{ 'line' : 1, 'col' : 3 }] }, + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + Expect empty(stop.update_objects) to_be_true + end + + end + +end diff --git a/vim/.vim/t/parser.vim b/vim/.vim/t/parser.vim new file mode 100644 index 0000000..053bad8 --- /dev/null +++ b/vim/.vim/t/parser.vim @@ -0,0 +1,116 @@ +describe 'snippet parser' + + before + function! Parse(snippet, ...) + let [snip, stops] = snipmate#parse#snippet(a:snippet) + return a:0 ? [snip, stops] : snip + endfunction + let b:snipmate_visual = 'testvisual' + end + + it 'parses numeric $id and ${id} vars as [id] lists' + let expect = [[1234567890]] + Expect Parse('$1234567890') == expect + Expect Parse('${1234567890}') == expect + end + + it 'disregards $ or ${ followed by a non-id' + Expect Parse('$x1') == ['x1'] + Expect Parse('${x}1') == ['x}1'] + Expect Parse('$VISUA1') == ['VISUA1'] + Expect Parse('${VISUA}1') == ['VISUA}1'] + end + + it 'gathers references to each instance of each stop id' + let [snip, b:stops] = Parse('x$1x${2:x$1x}x$1x${1/a/b}x$VISUALx', 1) + function! InstanceFound(list) + return !empty(filter(copy(b:stops[a:list[0]].instances), + \ 'v:val is a:list')) + endfunction + function! CheckList(list) + for item in a:list + if type(item) == type([]) + Expect InstanceFound(item) to_be_true + call CheckList(item) + endif + unlet item " E732 + endfor + endfunction + call CheckList(snip) + end + + it 'parses mirror substitutions ${n/pat/sub} as [n, {...}]' + let expect = [[1, { 'pat' : 'abc', 'sub' : 'def' }]] + Expect Parse('${1/abc/def}') == expect + let expect[0][1].flags = '' + Expect Parse('${1/abc/def/}') == expect + let expect[0][1].flags = 'g' + Expect Parse('${1/abc/def/g}') == expect + end + + it 'parses vars with placeholders as [id, placeholder] lists' + Expect Parse('${1:abc}') == [[1, 'abc']] + end + + it 'evaluates backtick expressions' + Expect Parse('`fnamemodify("x.y", ":r")`') == ['x'] + end + + it 'parses placeholders for vars and other specials' + let text = 'a `fnamemodify("x.y", ":r")` ${2:(${3/a/b})}' + let expect = ['a x ', [2, '(', [3, { 'pat' : 'a', 'sub' : 'b' }], ')']] + Expect Parse(text) == expect + Expect Parse(printf('${1:%s}', text)) == [[1] + expect] + end + + it 'converts tabs according to &et, &sts, &sw' + " &noet -> leave tabs alone + setl noet + Expect Parse("abc\tdef\n\t\tghi") == ["abc\tdef", "\t\tghi"] + + " &et -> &sts or &sw + setl et sts=2 sw=3 + Expect Parse("abc\tdef\n\t\tghi") == ["abc def", " ghi"] + + setl et sts=0 sw=3 + Expect Parse("abc\tdef\n\t\tghi") == ["abc def", " ghi"] + + setl et sts=-1 sw=3 + Expect Parse("abc\tdef\n\t\tghi") == ["abc def", " ghi"] + end + + it 'parses backslashes as escaping the next character or joining lines' + Expect Parse('x\x') == ['xx'] + Expect Parse('x\\x') == ['x\x'] + Expect Parse("x\\\nx") == ['xx'] + Expect Parse('x\$1') == ['x$1'] + Expect Parse('${1:\}}') == [[1, '}']] + Expect Parse('${1/\//\}}') == [[1, { 'pat' : '/', 'sub' : '}' }]] + Expect Parse('`fnamemodify("\`.x", ":r")`') == ['`'] + Expect Parse('\`x\`') == ['`x`'] + end + + it 'splits text at newlines' + Expect Parse("x\nx") == ['x', 'x'] + end + + it 'joins evaluated expressions to surrounding text on the same line' + let g:foo = 'bar' + Expect Parse("x`g:foo`x") == ['xbarx'] + Expect Parse("x`g:foo`\nx") == ['xbar', 'x'] + Expect Parse("x\n`g:foo`x") == ['x', 'barx'] + end + + it 'adds empty strings before/after vars if at the start/end of a line' + Expect Parse("x$1\nx") == ['x', [1], '', 'x'] + Expect Parse("x\n$1x") == ['x', '', [1], 'x'] + end + + it 'expands $VISUAL placeholders with any indents' + Expect Parse("x$VISUALx") == ['xtestvisualx'] + let b:snipmate_visual = " foo\nbar\n baz" + setl noet + Expect Parse("\tx\n\t$VISUAL\nx") == ["\tx", "\t foo", "\tbar", "\t baz", "x"] + end + +end diff --git a/vim/.vim/t/tests.sh b/vim/.vim/t/tests.sh new file mode 100755 index 0000000..c1da250 --- /dev/null +++ b/vim/.vim/t/tests.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +tmp="$(mktemp || tmpfile)" +vim -Es $tmp <<- EOF + source ~/.vimrc + %delete _ + call append(0, split(&rtp, ',')) + delete _ + wq +EOF + +rtp="$(grep -iE 'vspec|snipmate|tlib|mw-utils' < $tmp | grep -v after)" +vspec="$(grep -iE 'vspec' < $tmp | grep -v after)" +test_files="${*:-parser jumping}" + +for test in $test_files; do + $vspec/bin/vspec $rtp ${test%%.vim}.vim +done + +rm $tmp diff --git a/vim/.vim/templates/c b/vim/.vim/templates/c new file mode 100644 index 0000000..a4c8c7d --- /dev/null +++ b/vim/.vim/templates/c @@ -0,0 +1,7 @@ +#include + +int main( int argc, char *argv[] ) { + + return 0; +} +# cursor: 4 del diff --git a/vim/.vim/templates/cuda b/vim/.vim/templates/cuda new file mode 100644 index 0000000..dd7fddf --- /dev/null +++ b/vim/.vim/templates/cuda @@ -0,0 +1,16 @@ +#define ERRCHECK(err) (HandleError( err , __FILE__, __LINE__)) + +static void HandleError( cudaError_t err, const char *file, int line ) { + if(err != cudaSuccess) { + fprintf(stderr, "Cuda Error: %s in %s at line %d\n", + cudaGetErrorString( err ), + file, + line ); + exit( EXIT_FAILURE ); + } +} + +int main( int argc, char *argv[] ) { + + return 0; +} diff --git a/vim/.vim/templates/html b/vim/.vim/templates/html new file mode 100644 index 0000000..e2c2bcf --- /dev/null +++ b/vim/.vim/templates/html @@ -0,0 +1,16 @@ + + + +FIXME + + + + + + +# cursor: 15 del diff --git a/vim/.vim/templates/perl b/vim/.vim/templates/perl new file mode 100644 index 0000000..24eb976 --- /dev/null +++ b/vim/.vim/templates/perl @@ -0,0 +1,6 @@ +#!/usr/bin/env perl +use 5.014; +use warnings; + + +# cursor: 5 del diff --git a/vim/.vim/templates/python b/vim/.vim/templates/python new file mode 100644 index 0000000..cbeed8c --- /dev/null +++ b/vim/.vim/templates/python @@ -0,0 +1,7 @@ +#!/usr/bin/env python + + + +if __name__ == '__main__': + main() +# cursor: 3 del diff --git a/vim/.vim/templates/sh b/vim/.vim/templates/sh new file mode 100644 index 0000000..f3135f6 --- /dev/null +++ b/vim/.vim/templates/sh @@ -0,0 +1,4 @@ +#!/bin/bash + + +# cursor: 3 del diff --git a/vim/.vim/templates/xhtml b/vim/.vim/templates/xhtml new file mode 100644 index 0000000..363fd6a --- /dev/null +++ b/vim/.vim/templates/xhtml @@ -0,0 +1,18 @@ + + + +FIXME + + + + + + +# cursor: 15 del diff --git a/vim/.vim/templates/xslt b/vim/.vim/templates/xslt new file mode 100644 index 0000000..5769149 --- /dev/null +++ b/vim/.vim/templates/xslt @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + diff --git a/vim/.vim/test/tlib.vim b/vim/.vim/test/tlib.vim new file mode 100755 index 0000000..2277d36 --- /dev/null +++ b/vim/.vim/test/tlib.vim @@ -0,0 +1,219 @@ +" tLib.vim +" @Author: Thomas Link (mailto:micathom AT gmail com?subject=vim-tLib) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2006-12-17. +" @Last Change: 2008-11-23. +" @Revision: 129 + +if !exists("loaded_tassert") + echoerr 'tAssert (vimscript #1730) is required' +endif + + +TAssertBegin! "tlib" + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf +TAssert IsEqual(tlib#list#Inject([], 0, function('Add')), 0) +TAssert IsEqual(tlib#list#Inject([1,2,3], 0, function('Add')), 6) +delfunction Add + +TAssert IsEqual(tlib#list#Compact([]), []) +TAssert IsEqual(tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3]) + +TAssert IsEqual(tlib#list#Flatten([]), []) +TAssert IsEqual(tlib#list#Flatten([1,2,3]), [1,2,3]) +TAssert IsEqual(tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3]) +TAssert IsEqual(tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""]) + +TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3]) +TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30]) + +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2'), 2) +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20) +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10) + +TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 2'), 1) +TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 5'), 0) + +TAssert IsEqual(tlib#list#All([1,2,3], 'v:val < 5'), 1) +TAssert IsEqual(tlib#list#All([1,2,3], 'v:val >= 2'), 0) + +TAssert IsEqual(tlib#list#Remove([1,2,1,2], 2), [1,1,2]) +TAssert IsEqual(tlib#list#RemoveAll([1,2,1,2], 2), [1,1]) + +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]]) + + +" Vars {{{2 +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +TAssert IsEqual(tlib#var#Get('bar', 'bg'), 3) +TAssert IsEqual(tlib#var#Get('bar', 'g'), 2) +TAssert IsEqual(tlib#var#Get('foo', 'bg'), 1) +TAssert IsEqual(tlib#var#Get('foo', 'g'), 1) +TAssert IsEqual(tlib#var#Get('none', 'l'), '') + +TAssert IsEqual(eval(tlib#var#EGet('bar', 'bg')), 3) +TAssert IsEqual(eval(tlib#var#EGet('bar', 'g')), 2) +" TAssert IsEqual(eval(tlib#var#EGet('bar', 'sg')), 4) +TAssert IsEqual(eval(tlib#var#EGet('foo', 'bg')), 1) +TAssert IsEqual(eval(tlib#var#EGet('foo', 'g')), 1) +TAssert IsEqual(eval(tlib#var#EGet('none', 'l')), '') + +unlet g:foo +unlet g:bar +unlet b:bar + + + +" Filenames {{{2 +TAssert IsEqual(tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt']) +TAssert IsEqual(tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt']) +TAssert IsEqual(tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt']) + +TAssert IsEqual(tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt') + +TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt') +TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt') + + + +" Prototype-based programming {{{2 +let test = tlib#Test#New() +TAssert test.IsA('Test') +TAssert !test.IsA('foo') +TAssert test.RespondTo('RespondTo') +TAssert !test.RespondTo('RespondToNothing') +let test1 = tlib#Test#New() +TAssert test.IsRelated(test1) +let testworld = tlib#World#New() +TAssert !test.IsRelated(testworld) + +let testc = tlib#TestChild#New() +TAssert IsEqual(testc.Dummy(), 'TestChild.vim') +TAssert IsEqual(testc.Super('Dummy', []), 'Test.vim') + + + +" Optional arguments {{{2 +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +TAssert IsEqual(TestGetArg(), 1) +TAssert IsEqual(TestGetArg(''), '') +TAssert IsEqual(TestGetArg(2), 2) +TAssert IsEqual(TestGetArg1(), 1) +TAssert IsEqual(TestGetArg1(''), 1) +TAssert IsEqual(TestGetArg1(2), 2) + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs(), 'oo') +TAssert IsEqual(TestArgs('a'), 'aa') +TAssert IsEqual(TestArgs('a', 3), 'aaa') + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs1(), '') +TAssert IsEqual(TestArgs1('a'), 'aa') +TAssert IsEqual(TestArgs1('a', 3), 'aaa') + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs2(), '1') +TAssert IsEqual(TestArgs2('a'), 'a') +TAssert IsEqual(TestArgs2('a', 3), 'aaa') + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +TAssert IsEqual(TestArgs3(), '1') +TAssert IsEqual(TestArgs3('a'), 'a') +TAssert IsEqual(TestArgs3('a', 3), 'a3') + +delfunction TestGetArg +delfunction TestGetArg1 +delfunction TestArgs +delfunction TestArgs1 +delfunction TestArgs2 +delfunction TestArgs3 + + + +" Strings {{{2 +TAssert IsString(tlib#string#RemoveBackslashes('foo bar')) +TAssert IsEqual(tlib#string#RemoveBackslashes('foo bar'), 'foo bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar') + + + +" Regexp {{{2 +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + TAssert (s =~ '\m^'. tlib#rx#Escape(s, 'm') .'$') + TAssert (s =~ '\M^'. tlib#rx#Escape(s, 'M') .'$') + TAssert (s =~ '\v^'. tlib#rx#Escape(s, 'v') .'$') + TAssert (s =~ '\V\^'. tlib#rx#Escape(s, 'V') .'\$') +endfor + + +" Encode, decode +TAssert IsEqual(tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar') +TAssert IsEqual(tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.') + +TAssert IsEqual(tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar') +TAssert IsEqual(tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.') + +TAssertEnd test test1 testc testworld + + +TAssert IsEqual(tlib#string#Count("fooo", "o"), 3) +TAssert IsEqual(tlib#string#Count("***", "\\*"), 3) +TAssert IsEqual(tlib#string#Count("***foo", "\\*"), 3) +TAssert IsEqual(tlib#string#Count("foo***", "\\*"), 3) + + +finish "{{{1 + + +" Input {{{2 +echo tlib#input#List('s', 'Test', ['barfoobar', 'barFoobar']) +echo tlib#input#List('s', 'Test', ['barfoobar', 'bar foo bar', 'barFoobar']) +echo tlib#input#List('s', 'Test', ['barfoobar', 'bar1Foo1bar', 'barFoobar']) +echo tlib#input#EditList('Test', ['bar1', 'bar2', 'bar3', 'foo1', 'foo2', 'foo3']) + + diff --git a/vim/.vimrc b/vim/.vimrc index 5c80609..9f2b5cf 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -115,7 +115,11 @@ hi StatusLine cterm=None ctermfg=green ctermbg=none hi Search cterm=NONE ctermbg=yellow ctermfg=black hi IncSearch cterm=None ctermbg=yellow ctermfg=black -hi Pmenu ctermfg=green ctermbg=black -hi PmenuSel ctermfg=white ctermbg=black -hi PmenuSbar ctermfg=white ctermbg=black cterm=none set t_Co=256 + +"Supertab +"hi Pmenu ctermfg=green ctermbg=black +"hi PmenuSel ctermfg=white ctermbg=black +"hi PmenuSbar ctermfg=white ctermbg=black cterm=none + +"let g:SuperTabNoCompleteAfter = ['^',',','\s']