0.1.0 Initial Commit

This commit is contained in:
2020-09-29 23:22:33 +02:00
commit d5c2147ed1
765 changed files with 131666 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1863
This library provides some utility functions. There isn't much need to
install it unless another plugin requires you to do so.
The most useful functions provided by this library probably are:
tlib#input#List(), tlib#input#ListW()
- Display a list
- Dynamically filter items matching a pattern (somethat like google)
- E.g. you filter for "foo -bar": show all entries containing foo but not bar.
- Select items from a list
- Do stuff
- Developers can define keys that trigger some action with the
selected items
- Demo: http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html
tlib#input#EditList
+ Edit a list (copy, cut, paste, delete, edit ...)
:TLet VAR = VALUE
Set a variable only if it doesn't already exist.
:TScratch
Open a scratch buffer (a buffer without a file).
:TVarArg VAR1, [VAR2, DEFAULT2] ...
Handle "rest" (variable) arguments in functions.
EXAMPLES:
function! Foo(...)
TVarArg ['a', 1], 'b'
echo 'a='. a
echo 'b='. b
endf
TBrowseOutput COMMAND
Every wondered how to effciently 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
TBrowseOutput let
TBrowseOutput map
Related (small) plugins that utilize tlib and thus provide some degree of uniform user experience:
tbibtools (vimscript #1915): bibtex-related utilities (sort, reformat, list contents ...)
tmarks (vimscript #2594): Browse, place, & delete marks
tmboxbrowser (vimscript #1906): A mbox browser -- Read your e-mails with vim
tmru (vimscript #1864): Most Recently Used Files
trag (vimscript #2033): A slightly language-aware alternative to grep
tregisters (vimscript #2017): List, edit, and run/execute registers/clipboards
tselectbuffer (vimscript #1866): A quick buffer selector/switcher
tselectfiles (vimscript #1865): A quick file selector/browser/explorer (sort of)
ttagecho (vimscript #2055): Show current tag information
ttagcomplete (vimscript #2069): Context-sensitive tags-based completion and code skeletons
ttags (vimscript #2018): Tag list browser (List, filter, preview, jump to tags)
ttoc (vimscript #2014): A regexp-based table of contents of the current buffer
vikitasks (vimscript #2894): Search viki files for tasks and display them in a list
For full details, please see:
http://github.com/tomtom/tlib_vim/blob/master/doc/tlib.txt
Also available via git
http://github.com/tomtom/tlib_vim

View File

@@ -0,0 +1,8 @@
" @Author: Tom Link (micathom AT gmail com?subject=[vim])
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 13
" :nodefault:
TLet g:tlib#debug = 0

View File

@@ -0,0 +1,376 @@
:TBrowseOutput tlib.txt /*:TBrowseOutput*
:TBrowseScriptnames tlib.txt /*:TBrowseScriptnames*
:TLet tlib.txt /*:TLet*
:TScratch tlib.txt /*:TScratch*
:TVarArg tlib.txt /*:TVarArg*
:Tlibassert tlib.txt /*:Tlibassert*
:Tlibtrace tlib.txt /*:Tlibtrace*
:Tlibtraceset tlib.txt /*:Tlibtraceset*
Add() tlib.txt /*Add()*
TestArgs() tlib.txt /*TestArgs()*
TestArgs1() tlib.txt /*TestArgs1()*
TestArgs2() tlib.txt /*TestArgs2()*
TestArgs3() tlib.txt /*TestArgs3()*
TestGetArg() tlib.txt /*TestGetArg()*
TestGetArg1() tlib.txt /*TestGetArg1()*
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_rx tlib.txt /*g:tlib#sys#system_rx*
g:tlib#sys#windows tlib.txt /*g:tlib#sys#windows*
g:tlib#trace#backtrace tlib.txt /*g:tlib#trace#backtrace*
g:tlib#trace#printf tlib.txt /*g:tlib#trace#printf*
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*
standard-paragraph tlib.txt /*standard-paragraph*
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#Complete() tlib.txt /*tlib#agent#Complete()*
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#GetOpts() tlib.txt /*tlib#arg#GetOpts()*
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#assert#All() tlib.txt /*tlib#assert#All()*
tlib#assert#Assert() tlib.txt /*tlib#assert#Assert()*
tlib#assert#Disable() tlib.txt /*tlib#assert#Disable()*
tlib#assert#Enable() tlib.txt /*tlib#assert#Enable()*
tlib#assert#Map() tlib.txt /*tlib#assert#Map()*
tlib#autocmdgroup#Init() tlib.txt /*tlib#autocmdgroup#Init()*
tlib#balloon#Expand() tlib.txt /*tlib#balloon#Expand()*
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#TBrowseScriptnames() tlib.txt /*tlib#cmd#TBrowseScriptnames()*
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#Format() tlib.txt /*tlib#date#Format()*
tlib#date#IsDate() tlib.txt /*tlib#date#IsDate()*
tlib#date#Parse() tlib.txt /*tlib#date#Parse()*
tlib#date#SecondsSince1970() tlib.txt /*tlib#date#SecondsSince1970()*
tlib#date#Shift() tlib.txt /*tlib#date#Shift()*
tlib#dictionary#Rev() tlib.txt /*tlib#dictionary#Rev()*
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#Extend() tlib.txt /*tlib#eval#Extend()*
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#Glob() tlib.txt /*tlib#file#Glob()*
tlib#file#Globpath() tlib.txt /*tlib#file#Globpath()*
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#loclist#Browse() tlib.txt /*tlib#loclist#Browse()*
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#qfl#AgentEditLine() tlib.txt /*tlib#qfl#AgentEditLine()*
tlib#qfl#AgentEditQFE() tlib.txt /*tlib#qfl#AgentEditQFE()*
tlib#qfl#AgentGotoQFE() tlib.txt /*tlib#qfl#AgentGotoQFE()*
tlib#qfl#AgentPreviewQFE() tlib.txt /*tlib#qfl#AgentPreviewQFE()*
tlib#qfl#AgentSplitBuffer() tlib.txt /*tlib#qfl#AgentSplitBuffer()*
tlib#qfl#AgentTabBuffer() tlib.txt /*tlib#qfl#AgentTabBuffer()*
tlib#qfl#AgentVSplitBuffer() tlib.txt /*tlib#qfl#AgentVSplitBuffer()*
tlib#qfl#AgentWithSelected() tlib.txt /*tlib#qfl#AgentWithSelected()*
tlib#qfl#Balloon() tlib.txt /*tlib#qfl#Balloon()*
tlib#qfl#Browse() tlib.txt /*tlib#qfl#Browse()*
tlib#qfl#EditLine() tlib.txt /*tlib#qfl#EditLine()*
tlib#qfl#FormatQFLE() tlib.txt /*tlib#qfl#FormatQFLE()*
tlib#qfl#InitListBuffer() tlib.txt /*tlib#qfl#InitListBuffer()*
tlib#qfl#QfeFilename() tlib.txt /*tlib#qfl#QfeFilename()*
tlib#qfl#QflList() tlib.txt /*tlib#qfl#QflList()*
tlib#qfl#RunCmdOnSelected() tlib.txt /*tlib#qfl#RunCmdOnSelected()*
tlib#qfl#SetFollowCursor() tlib.txt /*tlib#qfl#SetFollowCursor()*
tlib#qfl#SetSyntax() tlib.txt /*tlib#qfl#SetSyntax()*
tlib#rx#Escape() tlib.txt /*tlib#rx#Escape()*
tlib#rx#EscapeReplace() tlib.txt /*tlib#rx#EscapeReplace()*
tlib#rx#LooksLikeRegexp() tlib.txt /*tlib#rx#LooksLikeRegexp()*
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#SplitCommaList() tlib.txt /*tlib#string#SplitCommaList()*
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#sys#SystemInDir() tlib.txt /*tlib#sys#SystemInDir()*
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#FormatNow() tlib.txt /*tlib#time#FormatNow()*
tlib#time#MSecs() tlib.txt /*tlib#time#MSecs()*
tlib#time#Now() tlib.txt /*tlib#time#Now()*
tlib#trace#Backtrace() tlib.txt /*tlib#trace#Backtrace()*
tlib#trace#Disable() tlib.txt /*tlib#trace#Disable()*
tlib#trace#Enable() tlib.txt /*tlib#trace#Enable()*
tlib#trace#Print() tlib.txt /*tlib#trace#Print()*
tlib#trace#PrintToFile() tlib.txt /*tlib#trace#PrintToFile()*
tlib#trace#Set() tlib.txt /*tlib#trace#Set()*
tlib#type#Are() tlib.txt /*tlib#type#Are()*
tlib#type#Has() tlib.txt /*tlib#type#Has()*
tlib#type#Have() tlib.txt /*tlib#type#Have()*
tlib#type#Is() tlib.txt /*tlib#type#Is()*
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#GitLsPostprocess() tlib.txt /*tlib#vcs#GitLsPostprocess()*
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*

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
" @Author: Tom Link (micathom AT gmail com?subject=[vim])
" @Created: 2007-04-10.
" @Last Change: 2015-11-23.
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 808
" @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 = 117
let s:save_cpo = &cpo
set cpo&vim
" :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': empty('<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: :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#TBrowseScriptnames()
" :display: :Tlibtrace GUARD, VAR1, VAR2...
" Do nothing unless |tlib#trace#Enable()| was called.
"
" When |:Tlibtraceset| or |tlib#trace#Enable()| were called:
"
" If GUARD is a number that evaluates to true or if it is a string that
" matches a |regexp|, which was added using Tlibtrace! (with '!'),
" display the values of VAR1, VAR2 ...
command! -nargs=+ -bang -bar Tlibtrace :
" :Tlibtraceset +RX1, -RX2...
" If |tlib#trace#Enable()| was called: With the optional <bang>, users
" can add and remove GUARDs (actually a |regexp|) that should be traced.
command! -nargs=+ -bang -bar Tlibtraceset call tlib#trace#Set(<q-args>)
" :display: :Tlibtrace ASSERTION
command! -nargs=+ -bang -bar Tlibassert :
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@@ -0,0 +1,219 @@
" tLib.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=vim-tLib)
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2006-12-17.
" @Last Change: 2008-11-23.
" @Revision: 129
if !exists("loaded_tassert")
echoerr 'tAssert (vimscript #1730) is required'
endif
TAssertBegin! "tlib"
" List {{{2
fun! Add(a,b)
return a:a + a:b
endf
TAssert IsEqual(tlib#list#Inject([], 0, function('Add')), 0)
TAssert IsEqual(tlib#list#Inject([1,2,3], 0, function('Add')), 6)
delfunction Add
TAssert IsEqual(tlib#list#Compact([]), [])
TAssert IsEqual(tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3])
TAssert IsEqual(tlib#list#Flatten([]), [])
TAssert IsEqual(tlib#list#Flatten([1,2,3]), [1,2,3])
TAssert IsEqual(tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3])
TAssert IsEqual(tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""])
TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3])
TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30])
TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2'), 2)
TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20)
TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10)
TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 2'), 1)
TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 5'), 0)
TAssert IsEqual(tlib#list#All([1,2,3], 'v:val < 5'), 1)
TAssert IsEqual(tlib#list#All([1,2,3], 'v:val >= 2'), 0)
TAssert IsEqual(tlib#list#Remove([1,2,1,2], 2), [1,1,2])
TAssert IsEqual(tlib#list#RemoveAll([1,2,1,2], 2), [1,1])
TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]])
TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]])
TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]])
TAssert IsEqual(tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]])
" Vars {{{2
let g:foo = 1
let g:bar = 2
let b:bar = 3
let s:bar = 4
TAssert IsEqual(tlib#var#Get('bar', 'bg'), 3)
TAssert IsEqual(tlib#var#Get('bar', 'g'), 2)
TAssert IsEqual(tlib#var#Get('foo', 'bg'), 1)
TAssert IsEqual(tlib#var#Get('foo', 'g'), 1)
TAssert IsEqual(tlib#var#Get('none', 'l'), '')
TAssert IsEqual(eval(tlib#var#EGet('bar', 'bg')), 3)
TAssert IsEqual(eval(tlib#var#EGet('bar', 'g')), 2)
" TAssert IsEqual(eval(tlib#var#EGet('bar', 'sg')), 4)
TAssert IsEqual(eval(tlib#var#EGet('foo', 'bg')), 1)
TAssert IsEqual(eval(tlib#var#EGet('foo', 'g')), 1)
TAssert IsEqual(eval(tlib#var#EGet('none', 'l')), '')
unlet g:foo
unlet g:bar
unlet b:bar
" Filenames {{{2
TAssert IsEqual(tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt'])
TAssert IsEqual(tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt'])
TAssert IsEqual(tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt'])
TAssert IsEqual(tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt')
TAssert IsEqual(tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt')
TAssert IsEqual(tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt')
TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt')
TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt')
TAssert IsEqual(tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt')
TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt')
TAssert IsEqual(tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt')
TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt')
TAssert IsEqual(tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt')
" Prototype-based programming {{{2
let test = tlib#Test#New()
TAssert test.IsA('Test')
TAssert !test.IsA('foo')
TAssert test.RespondTo('RespondTo')
TAssert !test.RespondTo('RespondToNothing')
let test1 = tlib#Test#New()
TAssert test.IsRelated(test1)
let testworld = tlib#World#New()
TAssert !test.IsRelated(testworld)
let testc = tlib#TestChild#New()
TAssert IsEqual(testc.Dummy(), 'TestChild.vim')
TAssert IsEqual(testc.Super('Dummy', []), 'Test.vim')
" Optional arguments {{{2
function! TestGetArg(...) "{{{3
exec tlib#arg#Get(1, 'foo', 1)
return foo
endf
function! TestGetArg1(...) "{{{3
exec tlib#arg#Get(1, 'foo', 1, '!= ""')
return foo
endf
TAssert IsEqual(TestGetArg(), 1)
TAssert IsEqual(TestGetArg(''), '')
TAssert IsEqual(TestGetArg(2), 2)
TAssert IsEqual(TestGetArg1(), 1)
TAssert IsEqual(TestGetArg1(''), 1)
TAssert IsEqual(TestGetArg1(2), 2)
function! TestArgs(...) "{{{3
exec tlib#arg#Let([['foo', "o"], ['bar', 2]])
return repeat(foo, bar)
endf
TAssert IsEqual(TestArgs(), 'oo')
TAssert IsEqual(TestArgs('a'), 'aa')
TAssert IsEqual(TestArgs('a', 3), 'aaa')
function! TestArgs1(...) "{{{3
exec tlib#arg#Let(['foo', ['bar', 2]])
return repeat(foo, bar)
endf
TAssert IsEqual(TestArgs1(), '')
TAssert IsEqual(TestArgs1('a'), 'aa')
TAssert IsEqual(TestArgs1('a', 3), 'aaa')
function! TestArgs2(...) "{{{3
exec tlib#arg#Let(['foo', 'bar'], 1)
return repeat(foo, bar)
endf
TAssert IsEqual(TestArgs2(), '1')
TAssert IsEqual(TestArgs2('a'), 'a')
TAssert IsEqual(TestArgs2('a', 3), 'aaa')
function! TestArgs3(...)
TVarArg ['a', 1], 'b'
return a . b
endf
TAssert IsEqual(TestArgs3(), '1')
TAssert IsEqual(TestArgs3('a'), 'a')
TAssert IsEqual(TestArgs3('a', 3), 'a3')
delfunction TestGetArg
delfunction TestGetArg1
delfunction TestArgs
delfunction TestArgs1
delfunction TestArgs2
delfunction TestArgs3
" Strings {{{2
TAssert IsString(tlib#string#RemoveBackslashes('foo bar'))
TAssert IsEqual(tlib#string#RemoveBackslashes('foo bar'), 'foo bar')
TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar')
TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar')
TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar')
" Regexp {{{2
for c in split('^$.*+\()|{}[]~', '\zs')
let s = printf('%sfoo%sbar%s', c, c, c)
TAssert (s =~ '\m^'. tlib#rx#Escape(s, 'm') .'$')
TAssert (s =~ '\M^'. tlib#rx#Escape(s, 'M') .'$')
TAssert (s =~ '\v^'. tlib#rx#Escape(s, 'v') .'$')
TAssert (s =~ '\V\^'. tlib#rx#Escape(s, 'V') .'\$')
endfor
" Encode, decode
TAssert IsEqual(tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar')
TAssert IsEqual(tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.')
TAssert IsEqual(tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar')
TAssert IsEqual(tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.')
TAssertEnd test test1 testc testworld
TAssert IsEqual(tlib#string#Count("fooo", "o"), 3)
TAssert IsEqual(tlib#string#Count("***", "\\*"), 3)
TAssert IsEqual(tlib#string#Count("***foo", "\\*"), 3)
TAssert IsEqual(tlib#string#Count("foo***", "\\*"), 3)
finish "{{{1
" Input {{{2
echo tlib#input#List('s', 'Test', ['barfoobar', 'barFoobar'])
echo tlib#input#List('s', 'Test', ['barfoobar', 'bar foo bar', 'barFoobar'])
echo tlib#input#List('s', 'Test', ['barfoobar', 'bar1Foo1bar', 'barFoobar'])
echo tlib#input#EditList('Test', ['bar1', 'bar2', 'bar3', 'foo1', 'foo2', 'foo3'])