Permalink
Browse files

Initial

  • Loading branch information...
0 parents commit b67ea6b8c3e363deddadb36f63f71b70666f0c69 tom committed Aug 20, 2010
Showing with 8,031 additions and 0 deletions.
  1. +20 −0 README
  2. +12 −0 autoload/tlib.vim
  3. +141 −0 autoload/tlib/Filter_cnf.vim
  4. +54 −0 autoload/tlib/Filter_cnfd.vim
  5. +64 −0 autoload/tlib/Filter_fuzzy.vim
  6. +94 −0 autoload/tlib/Filter_seq.vim
  7. +163 −0 autoload/tlib/Object.vim
  8. +27 −0 autoload/tlib/Test.vim
  9. +27 −0 autoload/tlib/TestChild.vim
  10. +961 −0 autoload/tlib/World.vim
  11. +491 −0 autoload/tlib/agent.vim
  12. +102 −0 autoload/tlib/arg.vim
  13. +23 −0 autoload/tlib/autocmdgroup.vim
  14. +373 −0 autoload/tlib/buffer.vim
  15. +253 −0 autoload/tlib/cache.vim
  16. +58 −0 autoload/tlib/char.vim
  17. +64 −0 autoload/tlib/cmd.vim
  18. +57 −0 autoload/tlib/comments.vim
  19. +97 −0 autoload/tlib/date.vim
  20. +83 −0 autoload/tlib/dir.vim
  21. +55 −0 autoload/tlib/eval.vim
  22. +127 −0 autoload/tlib/file.vim
  23. +33 −0 autoload/tlib/hook.vim
  24. +740 −0 autoload/tlib/input.vim
  25. +169 −0 autoload/tlib/list.vim
  26. +23 −0 autoload/tlib/map.vim
  27. +26 −0 autoload/tlib/normal.vim
  28. +103 −0 autoload/tlib/notify.vim
  29. +87 −0 autoload/tlib/paragraph.vim
  30. +79 −0 autoload/tlib/progressbar.vim
  31. +63 −0 autoload/tlib/rx.vim
  32. +108 −0 autoload/tlib/scratch.vim
  33. +103 −0 autoload/tlib/signs.vim
  34. +156 −0 autoload/tlib/string.vim
  35. +51 −0 autoload/tlib/syntax.vim
  36. +55 −0 autoload/tlib/tab.vim
  37. +122 −0 autoload/tlib/tag.vim
  38. +45 −0 autoload/tlib/textobjects.vim
  39. +60 −0 autoload/tlib/time.vim
  40. +34 −0 autoload/tlib/type.vim
  41. +52 −0 autoload/tlib/url.vim
  42. +85 −0 autoload/tlib/var.vim
  43. +136 −0 autoload/tlib/win.vim
  44. +1,557 −0 doc/tlib.txt
  45. +579 −0 plugin/02tlib.vim
  46. +219 −0 test/tlib.vim
20 README
@@ -0,0 +1,20 @@
+*tlib.txt* tlib -- A library of vim functions
+
+
+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)
+
+
+-----------------------------------------------------------------------
+
+Status: Works for me (there may be some minor quirks)
+Install: See http://github.com/tomtom/vimtlib/blob/master/INSTALL.TXT
+See http://github.com/tomtom for related plugins.
+
@@ -0,0 +1,12 @@
+" tlib.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-07-17.
+" @Last Change: 2010-01-03.
+" @Revision: 0.0.7
+
+" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
+
+" Dummy file for backwards compatibility.
+
@@ -0,0 +1,141 @@
+" 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: 2010-03-22.
+" @Revision: 0.0.66
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2
+
+" 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.
+"
+" 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.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
+
+ " if a:name =~ '\^'. flt .'\|'. flt .'\$'
+ " let xa += 4
+ " elseif a:name =~ '\<'. flt .'\|'. flt .'\>'
+ " let xa += 3
+ " " elseif a:name =~ flt .'\>'
+ " " let xa += 2
+ " elseif a:name =~ '\A'. flt .'\|'. flt .'\A'
+ " let xa += 1
+ " endif
+ " if flt[0] =~# '\u' && matchstr(a:name, '\V\.\ze'. flt) =~# '\U'
+ " let xa += 1
+ " endif
+ " if flt[0] =~# '\U' && matchstr(a:name, '\V\.\ze'. flt) =~# '\u'
+ " let xa += 1
+ " endif
+ " if flt[-1] =~# '\u' && matchstr(a:name, '\V'. flt .'\zs\.') =~# '\U'
+ " let xa += 1
+ " endif
+ " if flt[-1] =~# '\U' && matchstr(a:name, '\V'. flt .'\zs\.') =~# '\u'
+ " 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
+ for rx in a:world.filter_neg
+ " TLogVAR rx
+ if a:text =~ rx
+ return 0
+ endif
+ endfor
+ for rx in a:world.filter_pos
+ " TLogVAR rx
+ if a:text !~ rx
+ return 0
+ endif
+ endfor
+ " 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(v:val), " OR ") .")"')
+ return join(reverse(filter1), ' AND ')
+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 a:world.filter[0][0] = a:world.filter[0][0][0:-2]
+endf
+
+
+" :nodoc:
+function! s:prototype.FilterRxPrefix() dict "{{{3
+ return '\V'
+endf
+
+
+" :nodoc:
+function! s:prototype.CleanFilter(filter) dict "{{{3
+ return a:filter
+endf
+
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
@@ -0,0 +1,54 @@
+" 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: 2009-02-15.
+" @Revision: 0.0.32
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2
+
+" The same as |tlib#FilterCNF#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.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.ReduceFrontFilter(world) dict "{{{3
+ let flt = a:world.filter[0][0]
+ if flt =~ '\\\.\\{-}$'
+ let a:world.filter[0][0] = flt[0:-7]
+ else
+ let a:world.filter[0][0] = flt[0:-2]
+ endif
+endf
+
+" :nodoc:
+function! s:prototype.CleanFilter(filter) dict "{{{3
+ return substitute(a:filter, '\\.\\{-}', '.', 'g')
+endf
+
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
@@ -0,0 +1,64 @@
+" 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: 2009-02-15.
+" @Revision: 0.0.31
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2
+
+" Support for "fuzzy" pattern matching in |tlib#input#List()|.
+" Characters are interpreted as if connected with '.\{-}'.
+function! tlib#Filter_fuzzy#New(...) "{{{3
+ let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
+ return object
+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
+
+
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
@@ -0,0 +1,94 @@
+" Filter_seq.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: 2009-02-15.
+" @Revision: 0.0.22
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_seq'], 'name': 'seq'}) "{{{2
+
+" The search pattern for |tlib#input#List()| is interpreted as a
+" disjunction of 'magic' regular expressions with the exception of a dot
+" ".", which is interpreted as ".\{-}".
+" The pattern is a '/magic' regexp pattern.
+function! tlib#Filter_seq#New(...) "{{{3
+ let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
+ return object
+endf
+
+
+" :nodoc:
+function! s:prototype.Match(world, text) dict "{{{3
+ " TLogVAR a:text
+ for rx in a:world.filter_neg
+ if a:text !~ rx
+ " TLogDBG "filter_neg ". rx
+ return 1
+ endif
+ endfor
+ for rx in a:world.filter_pos
+ if a:text =~ rx
+ " TLogDBG "filter_pos ". rx
+ return 1
+ endif
+ endfor
+ return 0
+endf
+
+
+" :nodoc:
+function! s:prototype.DisplayFilter(filter) dict "{{{3
+ let filter1 = deepcopy(a:filter)
+ call map(filter1, '"(". join(reverse(v:val), "_") .")"')
+ return join(reverse(filter1), ' OR ')
+endf
+
+
+" :nodoc:
+function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3
+ let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(split(v:val, ''\.''), ''.\{-}'')') + a:world.filter[0][1 : -1]
+endf
+
+
+" :nodoc:
+function! s:prototype.PushFrontFilter(world, char) dict "{{{3
+ let cc = nr2char(a:char)
+ if cc == '.'
+ let a:world.filter[0][0] .= '.\{-}'
+ else
+ let a:world.filter[0][0] .= nr2char(a:char)
+ endif
+endf
+
+
+" :nodoc:
+function! s:prototype.ReduceFrontFilter(world) dict "{{{3
+ let flt = a:world.filter[0][0]
+ if flt =~ '\.\\{-}$'
+ let a:world.filter[0][0] = flt[0:-6]
+ else
+ let a:world.filter[0][0] = flt[0:-2]
+ endif
+endf
+
+
+" :nodoc:
+function! s:prototype.FilterRxPrefix() dict "{{{3
+ return ''
+endf
+
+
+" :nodoc:
+function! s:prototype.CleanFilter(filter) dict "{{{3
+ return substitute(a:filter, '.\\{-}', '.', 'g')
+endf
+
+
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
Oops, something went wrong.

0 comments on commit b67ea6b

Please sign in to comment.