Cleaning up vim

This commit is contained in:
madmaurice 2015-10-28 19:20:32 +01:00
parent 8c7ddfa29f
commit b8812e8fb0
104 changed files with 0 additions and 17535 deletions

View file

@ -1,48 +0,0 @@
if !exists(':Tabularize') || get(g:, 'no_default_tabular_maps', 0)
finish " Tabular.vim wasn't loaded or the default maps are unwanted
endif
let s:save_cpo = &cpo
set cpo&vim
AddTabularPattern! assignment /[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1
AddTabularPattern! two_spaces / /l0
AddTabularPipeline! multiple_spaces / / map(a:lines, "substitute(v:val, ' *', ' ', 'g')") | tabular#TabularizeStrings(a:lines, ' ', 'l0')
AddTabularPipeline! argument_list /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')')
\ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0')
\ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")')
\ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")')
function! SplitCDeclarations(lines)
let rv = []
for line in a:lines
" split the line into declaractions
let split = split(line, '\s*[,;]\s*')
" separate the type from the first declaration
let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '')
" add the ; back on every declaration
call map(split, 'v:val . ";"')
" add the first element to the return as-is, and remove it from the list
let rv += [ remove(split, 0) ]
" transform the other elements by adding the type on at the beginning
call map(split, 'type . v:val')
" and add them all to the return
let rv += split
endfor
return rv
endfunction
AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines)
AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1
AddTabularPattern! cpp_io /<<\|>>/l1
AddTabularPattern! pascal_assign /:=/l1
AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,46 +0,0 @@
" 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 ? '' : ' <unique>'
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 <unique>' g:snips_trigger_key '<Plug>snipMateTrigger'
exec 'smap <unique>' g:snips_trigger_key '<Plug>snipMateSNext'
exec 'xmap <unique>' g:snips_trigger_key '<Plug>snipMateVisual'
else
" Remove SuperTab map if it exists
let s:overwrite = maparg('<Tab>', 'i') ==? '<Plug>SuperTabForward'
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateNextOrTrigger', 'i')
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateNextOrTrigger', 's')
let s:overwrite = 0
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateVisual', 'x')
endif
if exists('g:snips_trigger_key_backwards')
echom 'g:snips_trigger_key_backwards is deprecated. See :h snipMate-mappings'
exec 'imap <unique>' g:snips_trigger_key_backwards '<Plug>snipMateIBack'
exec 'smap <unique>' g:snips_trigger_key_backwards '<Plug>snipMateSBack'
else
let s:overwrite = maparg('<S-Tab>', 'i') ==? '<Plug>SuperTabBackward'
call s:map_if_not_mapped('<S-Tab>', '<Plug>snipMateBack', 'i')
call s:map_if_not_mapped('<S-Tab>', '<Plug>snipMateBack', 's')
let s:overwrite = 0
endif
call s:map_if_not_mapped('<C-R><Tab>', '<Plug>snipMateShow', 'i')
endif
let &cpo = s:save_cpo
" vim:noet:

View file

@ -1,24 +0,0 @@
" 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

View file

@ -1,104 +0,0 @@
" 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

View file

@ -1,12 +0,0 @@
" 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

View file

@ -1,95 +0,0 @@
" 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

View file

@ -1,27 +0,0 @@
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

View file

@ -1,622 +0,0 @@
" 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('<sfile>: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 <buffer> if exists('b:snip_state') |
\ call b:snip_state.update_changes() |
\ else |
\ silent! au! snipmate_changes * <buffer> |
\ 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('<afile>: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 == "<tab>"
let SuperTabPlug = maparg('<Plug>SuperTabForward', 'i')
if SuperTabPlug == ""
let SuperTabKey = "\<c-n>"
else
exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\""
endif
elseif g:SuperTabMappingBackward == "<tab>"
let SuperTabPlug = maparg('<Plug>SuperTabBackward', 'i')
if SuperTabPlug == ""
let SuperTabKey = "\<c-p>"
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("\<esc>a", 'n') " Close completion menu
call feedkeys("\<tab>") | 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 == ''
\ ? "\<tab>"
\ : "\<c-r>=snipMate#ShowAvailableSnips()\<cr>"
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 == "<s-tab>"
let SuperTabPlug = maparg('<Plug>SuperTabForward', 'i')
if SuperTabPlug == ""
let SuperTabKey = "\<c-n>"
else
exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\""
endif
elseif g:SuperTabMappingBackward == "<s-tab>"
let SuperTabPlug = maparg('<Plug>SuperTabBackward', 'i')
if SuperTabPlug == ""
let SuperTabKey = "\<c-p>"
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 "\<s-tab>"
endf
" vim:noet:sw=4:ts=4:ft=vim

View file

@ -1,47 +0,0 @@
" 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

View file

@ -1,205 +0,0 @@
function! s:sfile() abort
return expand('<sfile>')
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 * <buffer>
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 "\<esc>".l.'v'.len."l\<c-g>"
endif
return len == 1 ? "\<esc>".l.'gh' : "\<esc>".l.'v'.(len - 1)."l\<c-g>"
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

View file

@ -1,130 +0,0 @@
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 = '\%(\\\@<!\%(\\\\\)*\)\@<='
if exists('b:snipmate_visual')
let visual = substitute(b:snipmate_visual, "\n$", '', '')
unlet b:snipmate_visual
else
let visual = ''
endif
let snippet = substitute(snippet, '\n\(\t\+\).\{-\}\zs{VISUAL}',
\ substitute(escape(visual, '%\'), "\n", "\n\\\\1", 'g'), 'g')
" Evaluate eval (`...`) expressions.
" Backquotes prefixed with a backslash "\" are ignored.
" And backslash can be escaped by doubling it.
" Using a loop here instead of a regex fixes a bug with nested "\=".
if stridx(snippet, '`') != -1
let new = []
let snip = split(snippet, esc_bslash . '`', 1)
let isexp = 0
for i in snip
if isexp
call add(new, substitute(snipmate#util#eval(i),
\ "\n\\%$", '', ''))
else
call add(new, i)
endif
let isexp = !isexp
endfor
let snippet = join(new, '')
let snippet = substitute(snippet, "\r", "\n", 'g')
let snippet = substitute(snippet, '\\`', "`", 'g')
endif
" Place all text after a colon in a tab stop after the tab stop
" (e.g. "${#:foo}" becomes "${:foo}foo").
" This helps tell the position of the tab stops later.
let snippet = substitute(snippet, esc_bslash . '\$\({\d\+:\(.\{-}\)}\|{\d\+}\)', s:sigil . '\1\2', 'g')
let snippet = substitute(snippet, esc_bslash . '\$\(\d\+\)', s:sigil . '\1', 'g')
let snippet = substitute(snippet, esc_bslash . '\\\$', '$', 'g')
let snippet = substitute(snippet, '\\\\', "\\", 'g')
" Update the a:snip so that all the $# become the text after
" the colon in their associated ${#}.
" (e.g. "${1:foo}" turns all "$1"'s into "foo")
let i = 0
if snippet !~ s:sigil . '{0'
let snippet .= s:sigil . '{0}'
endif
while snippet =~ s:sigil.'{'.i
let s = matchstr(snippet, s:sigil . '{' . i . ':\zs.\{-}\ze}')
if s != ''
let snippet = substitute(snippet, s:sigil . i, s.'&', 'g')
endif
let i += 1
endw
if &et " Expand tabs to spaces if 'expandtab' is set.
return substitute(snippet, '\t', repeat(' ', (&sts > 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

View file

@ -1,219 +0,0 @@
" Snippet definition parsing code
function! s:sfile() abort
return expand('<sfile>')
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

View file

@ -1,22 +0,0 @@
" The next function was based on s:function and s:add_methods in fugitive
" <https://github.com/tpope/vim-fugitive/blob/master/plugin/fugitive.vim>
function! snipmate#util#add_methods(sfile, namespace, methods) abort
let dict = {}
for name in a:methods
let dict[name] = function(join([matchstr(a:sfile, '<SNR>\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

View file

@ -1,409 +0,0 @@
" Tabular: Align columnar data using regex-designated column boundaries
" Maintainer: Matthew Wozniski (godlygeek@gmail.com)
" Date: Thu, 03 May 2012 20:49:32 -0400
" Version: 1.0
"
" Long Description:
" Sometimes, it's useful to line up text. Naturally, it's nicer to have the
" computer do this for you, since aligning things by hand quickly becomes
" unpleasant. While there are other plugins for aligning text, the ones I've
" tried are either impossibly difficult to understand and use, or too simplistic
" to handle complicated tasks. This plugin aims to make the easy things easy
" and the hard things possible, without providing an unnecessarily obtuse
" interface. It's still a work in progress, and criticisms are welcome.
"
" License:
" Copyright (c) 2012, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use 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.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``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 HOLDER 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.
" Stupid vimscript crap {{{1
let s:savecpo = &cpo
set cpo&vim
" Private Functions {{{1
" Return the number of bytes in a string after expanding tabs to spaces. {{{2
" This expansion is done based on the current value of 'tabstop'
if exists('*strdisplaywidth')
" Needs vim 7.3
let s:Strlen = function("strdisplaywidth")
else
function! s:Strlen(string)
" Implement the tab handling part of strdisplaywidth for vim 7.2 and
" earlier - not much that can be done about handling doublewidth
" characters.
let rv = 0
let i = 0
for char in split(a:string, '\zs')
if char == "\t"
let rv += &ts - i
let i = 0
else
let rv += 1
let i = (i + 1) % &ts
endif
endfor
return rv
endfunction
endif
" Align a string within a field {{{2
" These functions do not trim leading and trailing spaces.
" Right align 'string' in a field of size 'fieldwidth'
function! s:Right(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '')
endfunction
" Left align 'string' in a field of size 'fieldwidth'
function! s:Left(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
return a:string . repeat(" ", spaces)
endfunction
" Center align 'string' in a field of size 'fieldwidth'
function! s:Center(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
let right = spaces / 2
let left = right + (right * 2 != spaces)
return repeat(" ", left) . a:string . repeat(" ", right)
endfunction
" Remove spaces around a string {{{2
" Remove all trailing spaces from a string.
function! s:StripTrailingSpaces(string)
return matchstr(a:string, '^.\{-}\ze\s*$')
endfunction
" Remove all leading spaces from a string.
function! s:StripLeadingSpaces(string)
return matchstr(a:string, '^\s*\zs.*$')
endfunction
" Split a string into fields and delimiters {{{2
" Like split(), but include the delimiters as elements
" All odd numbered elements are delimiters
" All even numbered elements are non-delimiters (including zero)
function! s:SplitDelim(string, delim)
let rv = []
let beg = 0
let len = len(a:string)
let searchoff = 0
while 1
let mid = match(a:string, a:delim, beg + searchoff, 1)
if mid == -1 || mid == len
break
endif
let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1)
let length = strlen(matchstr)
if length == 0 && beg == mid
" Zero-length match for a zero-length delimiter - advance past it
let searchoff += 1
continue
endif
if beg == mid
let rv += [ "" ]
else
let rv += [ a:string[beg : mid-1] ]
endif
let rv += [ matchstr ]
let beg = mid + length
let searchoff = 0
endwhile
let rv += [ strpart(a:string, beg) ]
return rv
endfunction
" Replace lines from `start' to `start + len - 1' with the given strings. {{{2
" If more lines are needed to show all strings, they will be added.
" If there are too few strings to fill all lines, lines will be removed.
function! s:SetLines(start, len, strings)
if a:start > line('$') + 1 || a:start < 1
throw "Invalid start line!"
endif
if len(a:strings) > a:len
let fensave = &fen
let view = winsaveview()
call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len))
call winrestview(view)
let &fen = fensave
elseif len(a:strings) < a:len
let fensave = &fen
let view = winsaveview()
sil exe (a:start + len(a:strings)) . ',' . (a:start + a:len - 1) . 'd_'
call winrestview(view)
let &fen = fensave
endif
call setline(a:start, a:strings)
endfunction
" Runs the given commandstring argument as an expression. {{{2
" The commandstring expression is expected to reference the a:lines argument.
" If the commandstring expression returns a list the items of that list will
" replace the items in a:lines, otherwise the expression is assumed to have
" modified a:lines itself.
function! s:FilterString(lines, commandstring)
exe 'let rv = ' . a:commandstring
if type(rv) == type(a:lines) && rv isnot a:lines
call filter(a:lines, 0)
call extend(a:lines, rv)
endif
endfunction
" Public API {{{1
if !exists("g:tabular_default_format")
let g:tabular_default_format = "l1"
endif
let s:formatelempat = '\%([lrc]\d\+\)'
function! tabular#ElementFormatPattern()
return s:formatelempat
endfunction
" Given a list of strings and a delimiter, split each string on every
" occurrence of the delimiter pattern, format each element according to either
" the provided format (optional) or the default format, and join them back
" together with enough space padding to guarantee that the nth delimiter of
" each string is aligned.
function! tabular#TabularizeStrings(strings, delim, ...)
if a:0 > 1
echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")"
return 1
endif
let formatstr = (a:0 ? a:1 : g:tabular_default_format)
if formatstr !~? s:formatelempat . '\+'
echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!"
return 1
endif
let format = split(formatstr, s:formatelempat . '\zs')
let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)')
" Strip spaces
" - Only from non-delimiters; spaces in delimiters must have been matched
" intentionally
" - Don't strip leading spaces from the first element; we like indenting.
for line in lines
if len(line) == 1 && s:do_gtabularize
continue " Leave non-matching lines unchanged for GTabularize
endif
if line[0] !~ '^\s*$'
let line[0] = s:StripTrailingSpaces(line[0])
endif
if len(line) >= 3
for i in range(2, len(line)-1, 2)
let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i]))
endfor
endif
endfor
" Find the max length of each field
let maxes = []
for line in lines
if len(line) == 1 && s:do_gtabularize
continue " non-matching lines don't affect field widths for GTabularize
endif
for i in range(len(line))
if i == len(maxes)
let maxes += [ s:Strlen(line[i]) ]
else
let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] )
endif
endfor
endfor
let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"'))
" Concatenate the fields, according to the format pattern.
for idx in range(len(lines))
let line = lines[idx]
if len(line) == 1 && s:do_gtabularize
let lines[idx] = line[0] " GTabularize doesn't change non-matching lines
continue
endif
for i in range(len(line))
let how = format[i % len(format)][0]
let pad = format[i % len(format)][1:-1]
if how =~? 'l'
let field = s:Left(line[i], maxes[i])
elseif how =~? 'r'
let field = s:Right(line[i], maxes[i])
elseif how =~? 'c'
let field = s:Center(line[i], maxes[i])
endif
let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad))
endfor
let lines[idx] = s:StripTrailingSpaces(join(line, ''))
endfor
endfunction
" Apply 0 or more filters, in sequence, to selected text in the buffer {{{2
" The lines to be filtered are determined as follows:
" If the function is called with a range containing multiple lines, then
" those lines will be used as the range.
" If the function is called with no range or with a range of 1 line, then
" if GTabularize mode is being used,
" the range will not be adjusted
" if "includepat" is not specified,
" that 1 line will be filtered,
" if "includepat" is specified and that line does not match it,
" no lines will be filtered
" if "includepat" is specified and that line does match it,
" all contiguous lines above and below the specified line matching the
" pattern will be filtered.
"
" The remaining arguments must each be a filter to apply to the text.
" Each filter must either be a String evaluating to a function to be called.
function! tabular#PipeRange(includepat, ...) range
exe a:firstline . ',' . a:lastline
\ . 'call tabular#PipeRangeWithOptions(a:includepat, a:000, {})'
endfunction
" Extended version of tabular#PipeRange, which
" 1) Takes the list of filters as an explicit list rather than as varargs
" 2) Supports passing a dictionary of options to control the routine.
" Currently, the only supported option is 'mode', which determines whether
" to behave as :Tabularize or as :GTabularize
" This allows me to add new features here without breaking API compatibility
" in the future.
function! tabular#PipeRangeWithOptions(includepat, filterlist, options) range
let top = a:firstline
let bot = a:lastline
let s:do_gtabularize = (get(a:options, 'mode', '') ==# 'GTabularize')
if !s:do_gtabularize
" In the default mode, apply range extension logic
if a:includepat != '' && top == bot
if top < 0 || top > line('$') || getline(top) !~ a:includepat
return
endif
while top > 1 && getline(top-1) =~ a:includepat
let top -= 1
endwhile
while bot < line('$') && getline(bot+1) =~ a:includepat
let bot += 1
endwhile
endif
endif
let lines = map(range(top, bot), 'getline(v:val)')
for filter in a:filterlist
if type(filter) != type("")
echoerr "PipeRange: Bad filter: " . string(filter)
endif
call s:FilterString(lines, filter)
unlet filter
endfor
call s:SetLines(top, bot - top + 1, lines)
endfunction
" Part of the public interface so interested pipelines can query this and
" adjust their behavior appropriately.
function! tabular#DoGTabularize()
return s:do_gtabularize
endfunction
function! s:SplitDelimTest(string, delim, expected)
let result = s:SplitDelim(a:string, a:delim)
if result !=# a:expected
echomsg 'Test failed!'
echomsg ' string=' . string(a:string) . ' delim=' . string(a:delim)
echomsg ' Returned=' . string(result)
echomsg ' Expected=' . string(a:expected)
endif
endfunction
function! tabular#SplitDelimUnitTest()
let assignment = '[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*='
let two_spaces = ' '
let ternary_operator = '^.\{-}\zs?\|:'
let cpp_io = '<<\|>>'
let pascal_assign = ':='
let trailing_c_comments = '\/\*\|\*\/\|\/\/'
call s:SplitDelimTest('a+=b', assignment, ['a', '+=', 'b'])
call s:SplitDelimTest('a-=b', assignment, ['a', '-=', 'b'])
call s:SplitDelimTest('a!=b', assignment, ['a!=b'])
call s:SplitDelimTest('a==b', assignment, ['a==b'])
call s:SplitDelimTest('a&=b', assignment, ['a', '&=', 'b'])
call s:SplitDelimTest('a|=b', assignment, ['a', '|=', 'b'])
call s:SplitDelimTest('a=b=c', assignment, ['a', '=', 'b', '=', 'c'])
call s:SplitDelimTest('a b c', two_spaces, ['a', ' ', 'b', ' ', 'c'])
call s:SplitDelimTest('a b c', two_spaces, ['a b', ' ', ' c'])
call s:SplitDelimTest('ab c', two_spaces, ['ab', ' ', '', ' ', 'c'])
call s:SplitDelimTest('a?b:c', ternary_operator, ['a', '?', 'b', ':', 'c'])
call s:SplitDelimTest('a<<b<<c', cpp_io, ['a', '<<', 'b', '<<', 'c'])
call s:SplitDelimTest('a:=b=c', pascal_assign, ['a', ':=', 'b=c'])
call s:SplitDelimTest('x//foo', trailing_c_comments, ['x', '//', 'foo'])
call s:SplitDelimTest('x/*foo*/',trailing_c_comments, ['x', '/*', 'foo', '*/', ''])
call s:SplitDelimTest('#ab#cd#ef', '[^#]*', ['#', 'ab', '#', 'cd', '#', 'ef', ''])
call s:SplitDelimTest('#ab#cd#ef', '#\zs', ['#', '', 'ab#', '', 'cd#', '', 'ef'])
endfunction
" Stupid vimscript crap, part 2 {{{1
let &cpo = s:savecpo
unlet s:savecpo
" vim:set sw=2 sts=2 fdm=marker:

View file

@ -1,19 +0,0 @@
" 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

View file

@ -1,12 +0,0 @@
" 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', '<count>')")
call tinykeymap#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '<count>')")

View file

@ -1,8 +0,0 @@
" @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

View file

@ -1,151 +0,0 @@
" 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 <space> 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

View file

@ -1,53 +0,0 @@
" 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

View file

@ -1,83 +0,0 @@
" 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

View file

@ -1,68 +0,0 @@
" @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

View file

@ -1,154 +0,0 @@
" @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

View file

@ -1,19 +0,0 @@
" @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

View file

@ -1,19 +0,0 @@
" @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

File diff suppressed because it is too large Load diff

View file

@ -1,614 +0,0 @@
" @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 <c-up/down> 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 =~ '\<suspend\>'
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 <c-z>,
" <m-z>. <space>, <c-LeftMouse> or <MiddleMouse> in the suspended window.
" <cr> and <LeftMouse> 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 <buffer='. a:world.scratch .'> 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 !~ '\<exit\>', 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

View file

@ -1,103 +0,0 @@
" @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, '\\\@<! ')
let arglist = map(args, 'matchlist(v:val, ''^\%(\(\w\+\)'. sep .'\(.*\)\|\(.*\)\)$'')')
" TLogVAR a:string, args, arglist
let pos = 0
for matchlist in arglist
if !empty(matchlist[3])
let keyargs[pos] = matchlist[3]
let pos += 1
else
let [match, key, val; rest] = matchlist
if empty(keys) || has_key(keys, key)
let val = substitute(val, '\\\\', '\\', 'g')
if evaluate
let val = eval(val)
endif
let keyargs[key] = val
else
echom 'Unknown key: '. key .'='. val
endif
endif
endfor
return keyargs
endf
function! tlib#arg#StringAsKeyArgsEqual(string) "{{{1
return tlib#arg#StringAsKeyArgs(a:string, [], 0, '=')
endf
""" Command line {{{1
" :def: function! tlib#arg#Ex(arg, ?chars='%#! ')
" Escape some characters in a string.
"
" Use |fnamescape()| if available.
"
" EXAMPLES: >
" 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

View file

@ -1,14 +0,0 @@
" 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

View file

@ -1,54 +0,0 @@
" @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

View file

@ -1,141 +0,0 @@
" @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

View file

@ -1,400 +0,0 @@
" 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 <buffer>
autocmd! TLib CursorHold,CursorHoldI <buffer>
autocmd! TLib InsertEnter,InsertChange,InsertLeave <buffer>
autocmd! TLib BufLeave,BufWinLeave,WinLeave,BufHidden <buffer>
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 <buffer> if line(".") != '. line .' | call s:UndoHighlightLine() | endif'
autocmd TLib CursorHold,CursorHoldI <buffer> call s:UndoHighlightLine()
autocmd TLib InsertEnter <buffer> call s:UndoHighlightLine()
" autocmd TLib BufLeave,BufWinLeave,WinLeave,BufHidden <buffer> 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

View file

@ -1,335 +0,0 @@
" 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

View file

@ -1,59 +0,0 @@
" @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

View file

@ -1,111 +0,0 @@
" @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\<vert\%[ical]\>\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

View file

@ -1,26 +0,0 @@
" @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

View file

@ -1,120 +0,0 @@
" 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

View file

@ -1,93 +0,0 @@
" @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

View file

@ -1,47 +0,0 @@
" @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

View file

@ -1,253 +0,0 @@
" @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("<afile>: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

View file

@ -1,14 +0,0 @@
" @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

View file

@ -1,38 +0,0 @@
" @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

View file

@ -1,145 +0,0 @@
" @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

View file

@ -1,25 +0,0 @@
" @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

File diff suppressed because it is too large Load diff

View file

@ -1,182 +0,0 @@
" 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

View file

@ -1,23 +0,0 @@
" 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 "\<c-y>". Otherwise return a:key.
" For use in maps like: >
" imap <expr> <cr> tlib#map#PumAccept("\<cr>")
function! tlib#map#PumAccept(key) "{{{3
return pumvisible() ? "\<c-y>" : a:key
endf
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,34 +0,0 @@
" 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

View file

@ -1,105 +0,0 @@
" 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

View file

@ -1,30 +0,0 @@
" @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

View file

@ -1,97 +0,0 @@
" 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

View file

@ -1,47 +0,0 @@
" 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

View file

@ -1,72 +0,0 @@
" @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

View file

@ -1,55 +0,0 @@
" @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

View file

@ -1,136 +0,0 @@
" @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

View file

@ -1,103 +0,0 @@
" @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

View file

@ -1,150 +0,0 @@
" @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, '%\@<!%s', 1)) - 1
" let f = a:format
" if f =~ '%\@<!%{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 f = s:RewriteFormatString(f, '%{fuzzyrx}', join(frx, ''))
" endif
" if f =~ '%\@<!%{rx}'
" let f = s:RewriteFormatString(f, '%{rx}', tlib#rx#Escape(a:string))
" endif
" if n == 0
" return substitute(f, '%%', '%', 'g')
" else
" let a = repeat([a:string], n)
" return call('printf', insert(a, f))
" endif
" endf
function! s:RewriteFormatString(format, pattern, string) "{{{3
let string = substitute(a:string, '%', '%%', 'g')
return substitute(a:format, tlib#rx#Escape(a:pattern), escape(string, '\'), 'g')
endf
function! tlib#string#TrimLeft(string) "{{{3
return substitute(a:string, '^[[:space:][:cntrl:]]\+', '', '')
endf
function! tlib#string#TrimRight(string) "{{{3
return substitute(a:string, '[[:space:][:cntrl:]]\+$', '', '')
endf
function! tlib#string#Strip(string) "{{{3
return tlib#string#TrimRight(tlib#string#TrimLeft(a:string))
endf
function! tlib#string#Count(string, rx) "{{{3
let s:count = 0
call substitute(a:string, a:rx, '\=s:CountHelper()', 'g')
return s:count
endf
function! s:CountHelper() "{{{3
let s:count += 1
endf

View file

@ -1,38 +0,0 @@
" @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: 13
function! tlib#syntax#Collect() "{{{3
let acc = {}
let syn = ''
for line in tlib#cmd#OutputAsList('syntax')
if line =~ '^---'
continue
elseif line =~ '^\w'
let ml = matchlist(line, '^\(\w\+\)\s\+\(xxx\s\+\(.*\)\|\(cluster.*\)\)$')
if empty(ml)
" echoerr 'Internal error: '. string(line)
else
let [m_0, syn, m_1, m_def1, m_def2; m_rest] = ml
let acc[syn] = [empty(m_def1) ? m_def2 : m_def1]
endif
else
call add(acc[syn], matchstr(line, '^\s\+\zs.*$'))
endif
endfor
return acc
endf
" :def: function! tlib#syntax#Names(?rx='')
function! tlib#syntax#Names(...) "{{{3
TVarArg 'rx'
let names = keys(tlib#syntax#Collect())
if !empty(rx)
call filter(names, 'v:val =~ rx')
endif
return names
endf

View file

@ -1,198 +0,0 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Last Change: 2015-10-13.
" @Revision: 38
if !exists('g:tlib#sys#special_protocols')
" A list of |regexp|s matching protocol names that should be handled
" by |g:tlib#sys#system_browser|.
" CAVEAT: Must be a |\V| |regexp|.
let g:tlib#sys#special_protocols = ['https\?', 'nntp', 'mailto'] "{{{2
endif
if !exists('g:tlib#sys#special_suffixes')
" A list of |regexp|s matching suffixes that should be handled by
" |g:tlib#sys#system_browser|.
" CAVEAT: Must be a |\V| |regexp|.
let g:tlib#sys#special_suffixes = ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif'] "{{{2
endif
if !exists('g:tlib#sys#system_rx')
" Open links matching this |regexp| with |g:tlib#sys#system_browser|.
" CAVEAT: Must be a |\V| |regexp|.
let g:tlib#sys#system_rx = printf('\V\%(\^\%(%s\):\|.\%(%s\)\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|')) "{{{2
endif
if !exists("g:tlib#sys#system_browser")
if exists('g:netrw_browsex_viewer')
" Open files in the system browser.
" :read: let g:tlib#sys#system_browser = ... "{{{2
let g:tlib#sys#system_browser = "exec 'silent !'. g:netrw_browsex_viewer shellescape('%s')" "{{{2
elseif has("win32") || has("win16") || has("win64")
" let g:tlib#sys#system_browser = "exec 'silent ! start \"\"' shellescape('%s')"
let g:tlib#sys#system_browser = "exec 'silent ! RunDll32.EXE URL.DLL,FileProtocolHandler' shellescape('%s')"
elseif has("mac")
let g:tlib#sys#system_browser = "exec 'silent !open' shellescape('%s')"
elseif exists('$XDG_CURRENT_DESKTOP') && !empty($XDG_CURRENT_DESKTOP)
let g:tlib#sys#system_browser = "exec 'silent !xdg-open' shellescape('%s') .'&'"
elseif $GNOME_DESKTOP_SESSION_ID != "" || $DESKTOP_SESSION == 'gnome'
let g:tlib#sys#system_browser = "exec 'silent !gnome-open' shellescape('%s')"
elseif exists("$KDEDIR") && !empty($KDEDIR)
let g:tlib#sys#system_browser = "exec 'silent !kfmclient exec' shellescape('%s')"
else
let g:tlib#sys#system_browser = ''
endif
endif
if !exists('g:tlib#sys#windows')
let g:tlib#sys#windows = &shell !~ 'sh' && (has('win16') || has('win32') || has('win64')) "{{{2
endif
if !exists('g:tlib#sys#null')
let g:tlib#sys#null = g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '') "{{{2
endif
let s:cygwin = {}
function! tlib#sys#IsCygwinBin(cmd) "{{{3
" TLogVAR a:cmd
if !g:tlib#sys#windows
return 0
elseif has_key(s:cygwin, a:cmd)
let rv = s:cygwin[a:cmd]
else
if !tlib#sys#IsExecutable('cygpath', 1) || !tlib#sys#IsExecutable('which', 1)
let rv = 0
else
let which = substitute(system('which '. shellescape(a:cmd)), '\n$', '', '')
" echom "DBG which:" which
if which =~ '^/'
let filename = system('cygpath -ma '. shellescape(which))
" echom "DBG filename:" filename
let rv = filename =~ g:tlib#sys#cygwin_path_rx
else
let rv = 0
endif
endif
let s:cygwin[a:cmd] = rv
endif
" TLogVAR rv
return rv
endf
let s:executables = {}
function! tlib#sys#IsExecutable(cmd, ...) "{{{3
" TLogVAR a:cmd
" echom "DBG has_key(s:executables, a:cmd)" has_key(s:executables, a:cmd)
if !has_key(s:executables, a:cmd)
let executable = executable(a:cmd)
" TLogVAR 1, executable
let ignore_cyg = a:0 >= 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

View file

@ -1,49 +0,0 @@
" @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

View file

@ -1,132 +0,0 @@
" @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

View file

@ -1,45 +0,0 @@
" 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 <silent> sp <Esc>:call tlib#textobjects#StandardParagraph()<CR>
onoremap <silent> sp :<C-u>normal Vsp<CR>
let s:tlib_done_textobjects = 1
endif
endf
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,52 +0,0 @@
" @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

View file

@ -1,29 +0,0 @@
" 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

View file

@ -1,52 +0,0 @@
" 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

View file

@ -1,83 +0,0 @@
" @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

View file

@ -1,160 +0,0 @@
" 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

View file

@ -1,152 +0,0 @@
" @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

View file

@ -1,128 +0,0 @@
" @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

View file

@ -1,103 +0,0 @@
" 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 <buffer> 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 <buffer> 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

View file

@ -1,473 +0,0 @@
" 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 <cr> and press <cr> 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 <buffer> f :call b:filtered_view.FilterFromKeyboard(1,'')<cr>
" noremap <buffer> f :call b:filtered_view.FilterFromKeyboard(1)<cr>
noremap <buffer> F :call b:filtered_view.FilterFromKeyboard(0,'')<cr>
if has_key(self,'Continuation')
nnoremap <buffer> <cr> :call b:filtered_view.Continue()<cr>
endif
"noremap <buffer> k
"noremap <buffer> 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| <esc>: 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 == "\<bs>" || index(map(range(0,10),'v:val.""'),c) >= 0
if c == "\<bs>"
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 == "\<bs>"
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

View file

@ -1,634 +0,0 @@
*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 <Tab> 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 (<Tab> 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 <C-J> <Plug>snipMateNextOrTrigger
:smap <C-J> <Plug>snipMateNextOrTrigger
Note: The noremap variants of the map commands must NOT be used.
The list of possible <Plug> mappings is as follows:
<Plug>snipMateNextOrTrigger Default: <Tab> 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.
<Plug>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.
<Plug>snipMateBack Default: <S-Tab> Mode: Insert, Select
Jump to the previous tab stop, if it exists.
Use in both insert and select modes.
<Plug>snipMateShow Default: <C-R><Tab> Mode: Insert
Show all available snippets (that start with
the previous text, if it exists). Use in
insert mode.
<Plug>snipMateVisual Default: <Tab> Mode: Visual
See |SnipMate-visual|.
Additionally, <CR> 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/<scope>.snippets
.../snippets/<scope>_<name>.snippets
.../snippets/<scope>/<name>.snippets
.../snippets/<scope>/<trigger>.snippet
.../snippets/<scope>/<trigger>/<description>.snippet
where <scope> is a scope or 'filetype' or 'syntax', <name> is an arbitrary
name, <trigger> is the trigger for a snippet, and <description> 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 <Plug>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 <div> tag, then on its
class, and finally end editing its contents: >
snippet div
<div id="$1" class="$2">
$0
</div>
< *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
<div id="${1:id}" class="${2:class}">
$0
</div>
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
<div${1: id="${2:id}"}${3: class="${4:class}"}>
$0
</div>
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
<div>
${0:${VISUAL:<!-- content -->}}
</div>
==============================================================================
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 `<scope>_*.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
<http://github.com/garbas/vim-snipmate/issues/143>
* 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
<http://github.com/garbas/vim-snipmate/issues/177>
<http://github.com/garbas/vim-snipmate/issues/178>
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 <Plug>snipMateTrigger for triggering an expansion inside a snippet
* Add snipMate#CanBeTriggered() function
0.86 - 2013-06-15
-----------------
* Use more idiomatic <Plug> 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,
<https://github.com/msanders/snipmate.vim>
0.83 - 2009-07-13
-----------------
* Last release done by Michael Sanders, available at
<http://www.vim.org/scripts/script.php?script_id=2540>
==============================================================================
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 <at> gmail <dot> 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:

View file

@ -1,7 +0,0 @@
*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()

View file

@ -1,35 +0,0 @@
*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])

View file

@ -1,473 +0,0 @@
*supertab.txt*
Author: Eric Van Dewoestine <ervandew@gmail.com>
Original concept and versions up to 0.32 written by
Gergely Kontra <kgergely@mcl.hu>
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 <cr> 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 <Tab> or <S-Tab> (shift+tab) while in
insert mode, with at least one non whitespace character before the cursor, to
start the completion and then <Tab> or <S-Tab> again to cycle forwards or
backwards through the available completions.
Example ('|' denotes the cursor location):
bar
baz
b|<Tab> Hitting <Tab> 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: "<c-p>")
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 = "<c-x><c-u>"
<
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<tab> # will use filename completion
myvar.t<tab> # will use user completion if completefunc set,
# or omni completion if omnifunc set.
myvar-><tab> # 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("<c-x><c-u>")
<
Secondary default completion type *supertab-contextdefault*
*g:SuperTabContextDefaultCompletionType*
g:SuperTabContextDefaultCompletionType (default value: "<c-p>")
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<tab> # will use filename completion
myvar.t<tab> # will use user completion if completefunc set, or
# omni completion if omnifunc set.
myvar-><tab> # 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 '</'.
s:ContextDiscover *supertab-contextdiscover*
This context will use the 'g:SuperTabContextDiscoverDiscovery' variable to
determine the completion type to use. It will evaluate each value, in the
order they were defined, until a variable evaluates to a non-zero or
non-empty value, then the associated completion type is used.
Supported configuration properties:
g:SuperTabContextDiscoverDiscovery
List of variable:completionType mappings.
Example context configuration: *supertab-contextexample*
>
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
let g:SuperTabContextDiscoverDiscovery =
\ ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]
<
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. "\<c-x>\<c-u>").
>
function MyTagContext()
if filereadable(expand('%:p:h') . '/tags')
return "\<c-x>\<c-]>"
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 "\<c-x>\<c-o>"
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 <tab>. 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: '<tab>')
g:SuperTabMappingBackward (default value: '<s-tab>')
These two variables allow you to set the keys used to kick off the current
completion. By default this is <tab> and <s-tab>. To change to something
like <c-space> and <s-c-space>, you can add the following to your |vimrc|.
>
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
>
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 = '<nul>'
let g:SuperTabMappingBackward = '<s-nul>'
<
Inserting true tabs *supertab-mappingtabliteral*
*g:SuperTabMappingTabLiteral*
g:SuperTabMappingTabLiteral (default value: '<c-tab>')
Sets the key mapping used to insert a literal tab where supertab would
otherwise attempt to kick off insert completion. The default is '<c-tab>'
(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 <tab> with
<c-v> (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<tab>. 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<tab> 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<tab> 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, <tab> will
kick off completion and pre-select the first entry in the popup menu, allowing
you to simply hit <enter> to use it.
Mapping <cr> to end completion *supertab-crmapping*
*g:SuperTabCrMapping*
g:SuperTabCrMapping (default value: 0)
When enabled, <cr> will cancel completion mode preserving the current text.
Compatibility with other plugins:
- endwise: compatible
- delimitMate: not compatible (disabled if the delimitMate <cr> mapping is
detected.)
Note: if you have an insert expression mapping with a <cr> in it or an insert
abbreviation containing a <cr>, then supertab will not create a <cr> 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
(<c-p>, <c-n>, <c-x><c-]>, 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, <c-p>, completion:
>
autocmd FileType *
\ if &omnifunc != '' |
\ call SuperTabChain(&omnifunc, "<c-p>")
\ 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, "<c-p>") |
\ 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:

View file

@ -1,406 +0,0 @@
: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*

View file

@ -1,18 +0,0 @@
*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 <F2> :silent! let g:g="'.repeat('foobar ',200).'"<cr>'
Now run the mapping by pressing <F2> 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 <F2> :exec tiny_cmd#Get('.nr.')<cr>'
<
Use Pop instead of Get if you use this command once only

File diff suppressed because it is too large Load diff

View file

@ -1,30 +0,0 @@
*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

View file

@ -1,10 +0,0 @@
" 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

View file

@ -1,20 +0,0 @@
" 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."
\ | <line1>,<line2>retab! | <line1>,<line2>normal =

View file

@ -1,32 +0,0 @@
" 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

View file

@ -1,118 +0,0 @@
" @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 = [<f-args>]
\ | 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(<q-args>, '^[^=[:space:]]\+')) | exec 'let '. <q-args> | 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': '<bang>' != '!', <args>})
" :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([<args>])
" :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([<args>])
" :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(<q-args>)
" :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(<q-args>)
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,346 +0,0 @@
" Tabular: Align columnar data using regex-designated column boundaries
" Maintainer: Matthew Wozniski (godlygeek@gmail.com)
" Date: Thu, 03 May 2012 20:49:32 -0400
" Version: 1.0
"
" Long Description:
" Sometimes, it's useful to line up text. Naturally, it's nicer to have the
" computer do this for you, since aligning things by hand quickly becomes
" unpleasant. While there are other plugins for aligning text, the ones I've
" tried are either impossibly difficult to understand and use, or too simplistic
" to handle complicated tasks. This plugin aims to make the easy things easy
" and the hard things possible, without providing an unnecessarily obtuse
" interface. It's still a work in progress, and criticisms are welcome.
"
" License:
" Copyright (c) 2012, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use 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.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``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 HOLDER 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.
" Abort if running in vi-compatible mode or the user doesn't want us.
if &cp || exists('g:tabular_loaded')
if &cp && &verbose
echo "Not loading Tabular in compatible mode."
endif
finish
endif
let g:tabular_loaded = 1
" Stupid vimscript crap {{{1
let s:savecpo = &cpo
set cpo&vim
" Private Things {{{1
" Dictionary of command name to command
let s:TabularCommands = {}
" Generate tab completion list for :Tabularize {{{2
" Return a list of commands that match the command line typed so far.
" NOTE: Tries to handle commands with spaces in the name, but Vim doesn't seem
" to handle that terribly well... maybe I should give up on that.
function! s:CompleteTabularizeCommand(argstart, cmdline, cursorpos)
let names = keys(s:TabularCommands)
if exists("b:TabularCommands")
let names += keys(b:TabularCommands)
endif
let cmdstart = substitute(a:cmdline, '^\s*\S\+\s*', '', '')
return filter(names, 'v:val =~# ''^\V'' . escape(cmdstart, ''\'')')
endfunction
" Choose the proper command map from the given command line {{{2
" Returns [ command map, command line with leading <buffer> removed ]
function! s:ChooseCommandMap(commandline)
let map = s:TabularCommands
let cmd = a:commandline
if cmd =~# '^<buffer>\s\+'
if !exists('b:TabularCommands')
let b:TabularCommands = {}
endif
let map = b:TabularCommands
let cmd = substitute(cmd, '^<buffer>\s\+', '', '')
endif
return [ map, cmd ]
endfunction
" Parse '/pattern/format' into separate pattern and format parts. {{{2
" If parsing fails, return [ '', '' ]
function! s:ParsePattern(string)
if a:string[0] != '/'
return ['','']
endif
let pat = '\\\@<!\%(\\\\\)\{-}\zs/' . tabular#ElementFormatPattern() . '*$'
let format = matchstr(a:string[1:-1], pat)
if !empty(format)
let format = format[1 : -1]
let pattern = a:string[1 : -len(format) - 2]
else
let pattern = a:string[1 : -1]
endif
return [pattern, format]
endfunction
" Split apart a list of | separated expressions. {{{2
function! s:SplitCommands(string)
if a:string =~ '^\s*$'
return []
endif
let end = match(a:string, "[\"'|]")
" Loop until we find a delimiting | or end-of-string
while end != -1 && (a:string[end] != '|' || a:string[end+1] == '|')
if a:string[end] == "'"
let end = match(a:string, "'", end+1) + 1
if end == 0
throw "No matching end single quote"
endif
elseif a:string[end] == '"'
" Find a " preceded by an even number of \ (or 0)
let pattern = '\%(\\\@<!\%(\\\\\)*\)\@<="'
let end = matchend(a:string, pattern, end+1) + 1
if end == 0
throw "No matching end double quote"
endif
else " Found ||
let end += 2
endif
let end = match(a:string, "[\"'|]", end)
endwhile
if end == 0 || a:string[0 : end - (end > 0)] =~ '^\s*$'
throw "Empty element"
endif
if end == -1
let rv = [ a:string ]
else
let rv = [ a:string[0 : end-1] ] + s:SplitCommands(a:string[end+1 : -1])
endif
return rv
endfunction
" Public Things {{{1
" Command associating a command name with a simple pattern command {{{2
" AddTabularPattern[!] [<buffer>] name /pattern[/format]
"
" If <buffer> is provided, the command will only be available in the current
" buffer, and will be used instead of any global command with the same name.
"
" If a command with the same name and scope already exists, it is an error,
" unless the ! is provided, in which case the existing command will be
" replaced.
"
" pattern is a regex describing the delimiter to be used.
"
" format describes the format pattern to be used. The default will be used if
" none is provided.
com! -nargs=+ -bang AddTabularPattern
\ call AddTabularPattern(<q-args>, <bang>0)
function! AddTabularPattern(command, force)
try
let [ commandmap, rest ] = s:ChooseCommandMap(a:command)
let name = matchstr(rest, '.\{-}\ze\s*/')
let pattern = substitute(rest, '.\{-}\s*\ze/', '', '')
let [ pattern, format ] = s:ParsePattern(pattern)
if empty(name) || empty(pattern)
throw "Invalid arguments!"
endif
if !a:force && has_key(commandmap, name)
throw string(name) . " is already defined, use ! to overwrite."
endif
let command = "tabular#TabularizeStrings(a:lines, " . string(pattern)
if !empty(format)
let command .= ", " . string(format)
endif
let command .= ")"
let commandmap[name] = { 'pattern' : pattern, 'commands' : [ command ] }
catch
echohl ErrorMsg
echomsg "AddTabularPattern: " . v:exception
echohl None
endtry
endfunction
" Command associating a command name with a pipeline of functions {{{2
" AddTabularPipeline[!] [<buffer>] name /pattern/ func [ | func2 [ | func3 ] ]
"
" If <buffer> is provided, the command will only be available in the current
" buffer, and will be used instead of any global command with the same name.
"
" If a command with the same name and scope already exists, it is an error,
" unless the ! is provided, in which case the existing command will be
" replaced.
"
" pattern is a regex that will be used to determine which lines will be
" filtered. If the cursor line doesn't match the pattern, using the command
" will be a no-op, otherwise the cursor and all contiguous lines matching the
" pattern will be filtered.
"
" Each 'func' argument represents a function to be called. This function
" will have access to a:lines, a List containing one String per line being
" filtered.
com! -nargs=+ -bang AddTabularPipeline
\ call AddTabularPipeline(<q-args>, <bang>0)
function! AddTabularPipeline(command, force)
try
let [ commandmap, rest ] = s:ChooseCommandMap(a:command)
let name = matchstr(rest, '.\{-}\ze\s*/')
let pattern = substitute(rest, '.\{-}\s*\ze/', '', '')
let commands = matchstr(pattern, '^/.\{-}\\\@<!\%(\\\\\)\{-}/\zs.*')
let pattern = matchstr(pattern, '/\zs.\{-}\\\@<!\%(\\\\\)\{-}\ze/')
if empty(name) || empty(pattern)
throw "Invalid arguments!"
endif
if !a:force && has_key(commandmap, name)
throw string(name) . " is already defined, use ! to overwrite."
endif
let commandlist = s:SplitCommands(commands)
if empty(commandlist)
throw "Must provide a list of functions!"
endif
let commandmap[name] = { 'pattern' : pattern, 'commands' : commandlist }
catch
echohl ErrorMsg
echomsg "AddTabularPipeline: " . v:exception
echohl None
endtry
endfunction
" Tabularize /pattern[/format] {{{2
" Tabularize name
"
" Align text, either using the given pattern, or the command associated with
" the given name.
com! -nargs=* -range -complete=customlist,<SID>CompleteTabularizeCommand
\ Tabularize <line1>,<line2>call Tabularize(<q-args>)
function! Tabularize(command, ...) range
let piperange_opt = {}
if a:0
let piperange_opt = a:1
endif
if empty(a:command)
if !exists("s:last_tabularize_command")
echohl ErrorMsg
echomsg "Tabularize hasn't been called yet; no pattern/command to reuse!"
echohl None
return
endif
else
let s:last_tabularize_command = a:command
endif
let command = s:last_tabularize_command
let range = a:firstline . ',' . a:lastline
try
let [ pattern, format ] = s:ParsePattern(command)
if !empty(pattern)
let cmd = "tabular#TabularizeStrings(a:lines, " . string(pattern)
if !empty(format)
let cmd .= "," . string(format)
endif
let cmd .= ")"
exe range . 'call tabular#PipeRangeWithOptions(pattern, [ cmd ], '
\ . 'piperange_opt)'
else
if exists('b:TabularCommands') && has_key(b:TabularCommands, command)
let usercmd = b:TabularCommands[command]
elseif has_key(s:TabularCommands, command)
let usercmd = s:TabularCommands[command]
else
throw "Unrecognized command " . string(command)
endif
exe range . 'call tabular#PipeRangeWithOptions(usercmd["pattern"], '
\ . 'usercmd["commands"], piperange_opt)'
endif
catch
echohl ErrorMsg
echomsg "Tabularize: " . v:exception
echohl None
return
endtry
endfunction
" GTabularize /pattern[/format] {{{2
" GTabularize name
"
" Align text on only matching lines, either using the given pattern, or the
" command associated with the given name. Mnemonically, this is similar to
" the :global command, which takes some action on all rows matching a pattern
" in a range. This command is different from normal :Tabularize in 3 ways:
" 1) If a line in the range does not match the pattern, it will be left
" unchanged, and not in any way affect the outcome of other lines in the
" range (at least, normally - but Pipelines can and will still look at
" non-matching rows unless they are specifically written to be aware of
" tabular#DoGTabularize() and handle it appropriately).
" 2) No automatic range determination - :Tabularize automatically expands
" a single-line range (or a call with no range) to include all adjacent
" matching lines. That behavior does not make sense for this command.
" 3) If called without a range, it will act on all lines in the buffer (like
" :global) rather than only a single line
com! -nargs=* -range=% -complete=customlist,<SID>CompleteTabularizeCommand
\ GTabularize <line1>,<line2>
\ call Tabularize(<q-args>, { 'mode': 'GTabularize' } )
" Stupid vimscript crap, part 2 {{{1
let &cpo = s:savecpo
unlet s:savecpo
" vim:set sw=2 sts=2 fdm=marker:

View file

@ -1,135 +0,0 @@
" 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 "<tab>".
"
" 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('<sfile>: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('<afile>:e') =~# 'snippet$'
\ | setlocal syntax=snippet
\ | else
\ | setlocal syntax=snippets
\ | endif
inoremap <silent> <Plug>snipMateNextOrTrigger <C-R>=snipMate#TriggerSnippet()<CR>
snoremap <silent> <Plug>snipMateNextOrTrigger <Esc>a<C-R>=snipMate#TriggerSnippet()<CR>
inoremap <silent> <Plug>snipMateTrigger <C-R>=snipMate#TriggerSnippet(1)<CR>
inoremap <silent> <Plug>snipMateBack <C-R>=snipMate#BackwardsSnippet()<CR>
snoremap <silent> <Plug>snipMateBack <Esc>a<C-R>=snipMate#BackwardsSnippet()<CR>
inoremap <silent> <Plug>snipMateShow <C-R>=snipMate#ShowAvailableSnips()<CR>
xnoremap <silent> <Plug>snipMateVisual :<C-U>call <SID>grab_visual()<CR>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
" <http://stackoverflow.com/a/1534347>
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(<bang>0, <f-args>)
" Edit snippet files
command! SnipMateOpenSnippetFiles call snipMate#OpenSnippetFiles()
" restore 'cpo'
let &cpo = s:save_cpo
" vim:noet:sw=4:ts=4:ft=vim

File diff suppressed because it is too large Load diff

View file

@ -1,62 +0,0 @@
" Vim global plugin for providing templates for new files
" Licence: The MIT License (MIT)
" Commit: $Format:%H$
" {{{ Copyright (c) 2015 Aristotle Pagaltzis <pagaltzis@gmx.de>
"
" 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.
" }}}
if exists( 'g:loaded_template' ) | finish | endif
let g:loaded_template = 1
augroup template
autocmd!
autocmd FileType * if line2byte( line( '$' ) + 1 ) == -1 | call s:loadtemplate( &filetype ) | endif
augroup END
function! s:globpathlist( path, ... )
let i = 1
let result = a:path
while i <= a:0
let result = substitute( escape( globpath( result, a:{i} ), ' ,\' ), "\n", ',', 'g' )
if strlen( result ) == 0 | return '' | endif
let i = i + 1
endwhile
return result
endfunction
function! s:loadtemplate( filetype )
let templatefile = matchstr( s:globpathlist( &runtimepath, 'templates', a:filetype ), '\(\\.\|[^,]\)*', 0 )
if strlen( templatefile ) == 0 | return | endif
silent execute 1 'read' templatefile
1 delete _
if search( 'cursor:', 'W' )
let cursorline = strpart( getline( '.' ), col( '.' ) - 1 )
let y = matchstr( cursorline, '^cursor:\s*\zs\d\+\ze' )
let x = matchstr( cursorline, '^cursor:\s*\d\+\s\+\zs\d\+\ze' )
let d = matchstr( cursorline, '^cursor:\s*\d\+\s\+\(\d\+\s\+\)\?\zsdel\>\ze' )
if ! strlen( x ) | let x = 0 | endif
if ! strlen( y ) | let y = 0 | endif
if d == 'del' | delete _ | endif
call cursor( y, x )
endif
set nomodified
endfunction
command -nargs=1 New new | set ft=<args>

View file

@ -1,50 +0,0 @@
" The following variable configures the way |tlib#input#ListD()| works.
" In this example, we allow selection of multiple items (we could also
" allow only a single choice and make |tlib#input#ListD()| work on the
" indices, not the items).
"
" We also set a prompt that will be displayed in the command area.
"
" By default, |tlib#input#ListD()| will automatically select an item if
" there is only one item left matching the filter. In this example, we
" disable this feature.
"
" For demonstration purposes, we also define a key handler that prints
" the selected items.
let s:state = {
\ 'type': 'm',
\ 'query': 'Select lines for command output',
\ 'pick_last_item': 0,
\ 'key_handlers': [
\ {'key': 16, 'agent': 'PrintMe', 'key_name': '<c-p>', 'help': 'Print line'},
\ ],
\ }
" A key handler takes two arguments: the current state of the list
" display and a list of selected items/indices (depending on the type
" parameter).
function! PrintMe(state, items) "{{{3
echom "You selected:"
for i in a:items
echom i
endfor
call input("Press ENTER to continue")
let a:state.state = 'redisplay'
return a:state
endf
" In this example, we evaluate an ex-command with |:execute| and display
" the command's output as list. The user can select certain lines by
" typing some pattern or by pressing <a-NUMBER> to select an item by
" number. The user can then press <c-p> to print the lines (see above)
" or <cr> to pick the selected lines.
function! SelectOutput(ex) "{{{3
redir => lines
silent exec a:ex
redir END
let state = copy(s:state)
let state.base = split(lines, '\n')
let picked = tlib#input#ListD(state)
echom "You picked: ". join(picked, ', ')
endf

View file

@ -1,67 +0,0 @@
# @Author: Tom Link (micathom AT gmail com)
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
# @Revision: 14
def crc_vim_table
tbl = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
0x2d02ef8d]
tbl.map! do |num|
b = "%b" % num
bits = b.split(//)
bits.map! {|b| b.to_i}
bits.reverse
end
VIM::command("let @t = '#{tbl.inspect}'")
end

View file

@ -1,66 +0,0 @@
" @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

View file

@ -1,40 +0,0 @@
" @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'

View file

@ -1,59 +0,0 @@
" @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

View file

@ -1,58 +0,0 @@
" @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

View file

@ -1,127 +0,0 @@
" @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 <escape>.
Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\<cr>
\ \<Down>\<Down>\<esc>
Should be#Equal g:spec_lib_rv, ''
Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\<cr>
\ \<Down>\<Down>\<esc>
Should be#Equal g:spec_lib_rv, []
Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\<cr>
\ \<Down>\<Down>\<esc>
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)\<cr>
\ \<Down>\<Down>\<cr>
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)\<cr>
\ \<Down>\<Down>\<cr>
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)\<cr>
\ \<Down>#\<Down>\<Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), [20, 40]
Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\<cr>
\ \<Down>\<S-Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), [20, 30]
Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\<cr>
\ \<Down>\<Down>\<S-up>\<cr>
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)\<cr>
\ \<Down>#\<Down>\<Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), [2, 4]
Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\<cr>
\ \<Down>\<S-Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), [2, 3]
Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\<cr>
\ \<Down>\<Down>\<S-up>\<cr>
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)\<cr>
\ \<Down>a\<Down>\<cr>
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)\<cr>
\ \<Down>a\<Down>\<cr>
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)\<cr>
\ a\<Down>#\<Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80']
Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\<cr>
\ a\<Down>\<S-Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80']
Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\<cr>
\ a\<Down>\<Down>\<S-up>\<cr>
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)\<cr>
\ a\<Down>#\<Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), [6, 8]
Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\<cr>
\ a\<Down>\<S-Down>\<cr>
Should be#Equal sort(g:spec_lib_rv), [6, 8]
Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\<cr>
\ a\<Down>\<Down>\<S-up>\<cr>
Should be#Equal sort(g:spec_lib_rv), [6, 8]
let &cpo = s:save_cpo

View file

@ -1,67 +0,0 @@
" @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

View file

@ -1,27 +0,0 @@
" @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

View file

@ -1,29 +0,0 @@
" @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

View file

@ -1,23 +0,0 @@
" @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

View file

@ -1,37 +0,0 @@
" @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

View file

@ -1,11 +0,0 @@
" 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 '\%(\\\@<!\%(\\\\\)*\)\@<=`.\{-}\%(\\\@<!\%(\\\\\)*\)\@<=`'
hi link placeHolder Special
hi link tabStop Special
hi link snipEscape SpecialChar
hi link snipCommand String

View file

@ -1,23 +0,0 @@
" Syntax highlighting for .snippets files (used for snipMate.vim)
" Hopefully this should make snippets a bit nicer to write!
syn match snipComment '^#.*'
syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
syn match tabStop '\$\d\+'
syn match snipEscape '\\\\\|\\`'
syn match snipCommand '\%(\\\@<!\%(\\\\\)*\)\@<=`.\{-}\%(\\\@<!\%(\\\\\)*\)\@<=`'
syn match snippet '^snippet.*' contains=multiSnipText,snipKeyword
syn match snippet '^extends.*' contains=snipKeyword
syn match snippet '^version.*' contains=snipKeyword
syn match multiSnipText '\S\+ \zs.*' contained
syn match snipKeyword '^(snippet|extends|version)'me=s+8 contained
syn match snipError "^[^#vse\t].*$"
hi link snippet Identifier
hi link snipComment Comment
hi link multiSnipText String
hi link snipKeyword Keyword
hi link snipEscape SpecialChar
hi link placeHolder Special
hi link tabStop Special
hi link snipCommand String
hi link snipError Error

Some files were not shown because too many files have changed in this diff Show more