diff options
83 files changed, 42 insertions, 27488 deletions
diff --git a/.vim/after/ftplugin/c.vim b/.vim/after/ftplugin/c.vim deleted file mode 100644 index 66dfc5e..0000000 --- a/.vim/after/ftplugin/c.vim +++ /dev/null @@ -1,2 +0,0 @@ -" OmniCppComplete initialization -call omni#cpp#complete#Init() diff --git a/.vim/after/ftplugin/cpp.vim b/.vim/after/ftplugin/cpp.vim deleted file mode 100644 index 66dfc5e..0000000 --- a/.vim/after/ftplugin/cpp.vim +++ /dev/null @@ -1,2 +0,0 @@ -" OmniCppComplete initialization -call omni#cpp#complete#Init() diff --git a/.vim/autoload/haskellmode.vim b/.vim/autoload/haskellmode.vim deleted file mode 100644 index 4a26cd5..0000000 --- a/.vim/autoload/haskellmode.vim +++ /dev/null @@ -1,191 +0,0 @@ -" -" utility functions for haskellmode plugins -" -" (Claus Reinke; last modified: 22/06/2010) -" -" part of haskell plugins: http://projects.haskell.org/haskellmode-vim -" please send patches to <claus.reinke@talk21.com> - - - -" find start/extent of name/symbol under cursor; -" return start, symbolic flag, qualifier, unqualified id -" (this is used in both haskell_doc.vim and in GHC.vim) -function! haskellmode#GetNameSymbol(line,col,off) - let name = "[a-zA-Z0-9_']" - let symbol = "[-!#$%&\*\+/<=>\?@\\^|~:.]" - "let [line] = getbufline(a:buf,a:lnum) - let line = a:line - - " find the beginning of unqualified id or qualified id component - let start = (a:col - 1) + a:off - if line[start] =~ name - let pattern = name - elseif line[start] =~ symbol - let pattern = symbol - else - return [] - endif - while start > 0 && line[start - 1] =~ pattern - let start -= 1 - endwhile - let id = matchstr(line[start :],pattern.'*') - " call confirm(id) - - " expand id to left and right, to get full id - let idPos = id[0] == '.' ? start+2 : start+1 - let posA = match(line,'\<\(\([A-Z]'.name.'*\.\)\+\)\%'.idPos.'c') - let start = posA>-1 ? posA+1 : idPos - let posB = matchend(line,'\%'.idPos.'c\(\([A-Z]'.name.'*\.\)*\)\('.name.'\+\|'.symbol.'\+\)') - let end = posB>-1 ? posB : idPos - - " special case: symbolic ids starting with . - if id[0]=='.' && posA==-1 - let start = idPos-1 - let end = posB==-1 ? start : end - endif - - " classify full id and split into qualifier and unqualified id - let fullid = line[ (start>1 ? start-1 : 0) : (end-1) ] - let symbolic = fullid[-1:-1] =~ symbol " might also be incomplete qualified id ending in . - let qualPos = matchend(fullid, '\([A-Z]'.name.'*\.\)\+') - let qualifier = qualPos>-1 ? fullid[ 0 : (qualPos-2) ] : '' - let unqualId = qualPos>-1 ? fullid[ qualPos : -1 ] : fullid - " call confirm(start.'/'.end.'['.symbolic.']:'.qualifier.' '.unqualId) - - return [start,symbolic,qualifier,unqualId] -endfunction - -function! haskellmode#GatherImports() - let imports={0:{},1:{}} - let i=1 - while i<=line('$') - let res = haskellmode#GatherImport(i) - if !empty(res) - let [i,import] = res - let prefixPat = '^import\s*\%({-#\s*SOURCE\s*#-}\)\?\(qualified\)\?\s\+' - let modulePat = '\([A-Z][a-zA-Z0-9_''.]*\)' - let asPat = '\(\s\+as\s\+'.modulePat.'\)\?' - let hidingPat = '\(\s\+hiding\s*\((.*)\)\)\?' - let listPat = '\(\s*\((.*)\)\)\?' - let importPat = prefixPat.modulePat.asPat.hidingPat.listPat ".'\s*$' - - let ml = matchlist(import,importPat) - if ml!=[] - let [_,qualified,module,_,as,_,hiding,_,explicit;x] = ml - let what = as=='' ? module : as - let hidings = split(hiding[1:-2],',') - let explicits = split(explicit[1:-2],',') - let empty = {'lines':[],'hiding':hidings,'explicit':[],'modules':[]} - let entry = has_key(imports[1],what) ? imports[1][what] : deepcopy(empty) - let imports[1][what] = haskellmode#MergeImport(deepcopy(entry),i,hidings,explicits,module) - if !(qualified=='qualified') - let imports[0][what] = haskellmode#MergeImport(deepcopy(entry),i,hidings,explicits,module) - endif - else - echoerr "haskellmode#GatherImports doesn't understand: ".import - endif - endif - let i+=1 - endwhile - if !has_key(imports[1],'Prelude') - let imports[0]['Prelude'] = {'lines':[],'hiding':[],'explicit':[],'modules':[]} - let imports[1]['Prelude'] = {'lines':[],'hiding':[],'explicit':[],'modules':[]} - endif - return imports -endfunction - -function! haskellmode#ListElem(list,elem) - for e in a:list | if e==a:elem | return 1 | endif | endfor - return 0 -endfunction - -function! haskellmode#ListIntersect(list1,list2) - let l = [] - for e in a:list1 | if index(a:list2,e)!=-1 | let l += [e] | endif | endfor - return l -endfunction - -function! haskellmode#ListUnion(list1,list2) - let l = [] - for e in a:list2 | if index(a:list1,e)==-1 | let l += [e] | endif | endfor - return a:list1 + l -endfunction - -function! haskellmode#ListWithout(list1,list2) - let l = [] - for e in a:list1 | if index(a:list2,e)==-1 | let l += [e] | endif | endfor - return l -endfunction - -function! haskellmode#MergeImport(entry,line,hiding,explicit,module) - let lines = a:entry['lines'] + [ a:line ] - let hiding = a:explicit==[] ? haskellmode#ListIntersect(a:entry['hiding'], a:hiding) - \ : haskellmode#ListWithout(a:entry['hiding'],a:explicit) - let explicit = haskellmode#ListUnion(a:entry['explicit'], a:explicit) - let modules = haskellmode#ListUnion(a:entry['modules'], [ a:module ]) - return {'lines':lines,'hiding':hiding,'explicit':explicit,'modules':modules} -endfunction - -" collect lines belonging to a single import statement; -" return number of last line and collected import statement -" (assume opening parenthesis, if any, is on the first line) -function! haskellmode#GatherImport(lineno) - let lineno = a:lineno - let import = getline(lineno) - if !(import=~'^import\s') | return [] | endif - let open = strlen(substitute(import,'[^(]','','g')) - let close = strlen(substitute(import,'[^)]','','g')) - while open!=close - let lineno += 1 - let linecont = getline(lineno) - let open += strlen(substitute(linecont,'[^(]','','g')) - let close += strlen(substitute(linecont,'[^)]','','g')) - let import .= linecont - endwhile - return [lineno,import] -endfunction - -function! haskellmode#UrlEncode(string) - let pat = '\([^[:alnum:]]\)' - let code = '\=printf("%%%02X",char2nr(submatch(1)))' - let url = substitute(a:string,pat,code,'g') - return url -endfunction - -" TODO: we could have buffer-local settings, at the expense of -" reconfiguring for every new buffer.. do we want to? -function! haskellmode#GHC() - if (!exists("g:ghc") || !executable(g:ghc)) - if !executable('ghc') - echoerr s:scriptname.": can't find ghc. please set g:ghc, or extend $PATH" - return 0 - else - let g:ghc = 'ghc' - endif - endif - return 1 -endfunction - -function! haskellmode#GHC_Version() - if !exists("g:ghc_version") - let g:ghc_version = substitute(system(g:ghc . ' --numeric-version'),'\n','','') - endif - return g:ghc_version -endfunction - -function! haskellmode#GHC_VersionGE(target) - let current = split(haskellmode#GHC_Version(), '\.' ) - let target = a:target - for i in current - if ((target==[]) || (i>target[0])) - return 1 - elseif (i==target[0]) - let target = target[1:] - else - return 0 - endif - endfor - return 1 -endfunction - diff --git a/.vim/autoload/omni/common/debug.vim b/.vim/autoload/omni/common/debug.vim deleted file mode 100644 index eded649..0000000 --- a/.vim/autoload/omni/common/debug.vim +++ /dev/null @@ -1,32 +0,0 @@ -" Description: Omni completion debug functions -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -let s:CACHE_DEBUG_TRACE = [] - -" Start debug, clear the debug file -function! omni#common#debug#Start() - let s:CACHE_DEBUG_TRACE = [] - call extend(s:CACHE_DEBUG_TRACE, ['============ Debug Start ============']) - call writefile(s:CACHE_DEBUG_TRACE, "Omni.dbg") -endfunc - -" End debug, write to debug file -function! omni#common#debug#End() - call extend(s:CACHE_DEBUG_TRACE, ["============= Debug End ============="]) - call extend(s:CACHE_DEBUG_TRACE, [""]) - call writefile(s:CACHE_DEBUG_TRACE, "Omni.dbg") -endfunc - -" Debug trace function -function! omni#common#debug#Trace(szFuncName, ...) - let szTrace = a:szFuncName - let paramNum = a:0 - if paramNum>0 - let szTrace .= ':' - endif - for i in range(paramNum) - let szTrace = szTrace .' ('. string(eval('a:'.string(i+1))).')' - endfor - call extend(s:CACHE_DEBUG_TRACE, [szTrace]) -endfunc diff --git a/.vim/autoload/omni/common/utils.vim b/.vim/autoload/omni/common/utils.vim deleted file mode 100644 index c880ad2..0000000 --- a/.vim/autoload/omni/common/utils.vim +++ /dev/null @@ -1,67 +0,0 @@ -" Description: Omni completion utils -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -" For sort numbers in list -function! omni#common#utils#CompareNumber(i1, i2) - let num1 = eval(a:i1) - let num2 = eval(a:i2) - return num1 == num2 ? 0 : num1 > num2 ? 1 : -1 -endfunc - -" TagList function calling the vim taglist() with try catch -" The only throwed exception is 'TagList:UserInterrupt' -" We also force the noignorecase option to avoid linear search when calling -" taglist() -function! omni#common#utils#TagList(szTagQuery) - let result = [] - let bUserIgnoreCase = &ignorecase - " Forcing noignorecase search => binary search can be used in taglist() - " if tags in the tag file are sorted - if bUserIgnoreCase - set noignorecase - endif - try - let result = taglist(a:szTagQuery) - catch /^Vim:Interrupt$/ - " Restoring user's setting - if bUserIgnoreCase - set ignorecase - endif - throw 'TagList:UserInterrupt' - catch - "Note: it seems that ctags can generate corrupted files, in this case - "taglist() will fail to read the tagfile and an exception from - "has_add() is thrown - endtry - - " Restoring user's setting - if bUserIgnoreCase - set ignorecase - endif - return result -endfunc - -" Same as TagList but don't throw exception -function! omni#common#utils#TagListNoThrow(szTagQuery) - let result = [] - try - let result = omni#common#utils#TagList(a:szTagQuery) - catch - endtry - return result -endfunc - -" Get the word under the cursor -function! omni#common#utils#GetWordUnderCursor() - let szLine = getline('.') - let startPos = getpos('.')[2]-1 - let startPos = (startPos < 0)? 0 : startPos - if szLine[startPos] =~ '\w' - let startPos = searchpos('\<\w\+', 'cbn', line('.'))[1] - 1 - endif - - let startPos = (startPos < 0)? 0 : startPos - let szResult = matchstr(szLine, '\w\+', startPos) - return szResult -endfunc diff --git a/.vim/autoload/omni/cpp/complete.vim b/.vim/autoload/omni/cpp/complete.vim deleted file mode 100644 index a7e4edc..0000000 --- a/.vim/autoload/omni/cpp/complete.vim +++ /dev/null @@ -1,569 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 27 sept. 2007 - -if v:version < 700 - echohl WarningMsg - echomsg "omni#cpp#complete.vim: Please install vim 7.0 or higher for omni-completion" - echohl None - finish -endif - -call omni#cpp#settings#Init() -let s:OmniCpp_ShowScopeInAbbr = g:OmniCpp_ShowScopeInAbbr -let s:OmniCpp_ShowPrototypeInAbbr = g:OmniCpp_ShowPrototypeInAbbr -let s:OmniCpp_ShowAccess = g:OmniCpp_ShowAccess -let s:szCurrentWorkingDir = getcwd() - -" Cache data -let s:CACHE_TAG_POPUP_ITEMS = {} -let s:CACHE_TAG_FILES = {} -let s:CACHE_TAG_ENV = '' -let s:CACHE_OVERLOADED_FUNCTIONS = {} - -" Has preview window? -let s:hasPreviewWindow = match(&completeopt, 'preview')>=0 -let s:hasPreviewWindowOld = s:hasPreviewWindow - -" Popup item list -let s:popupItemResultList = [] - -" May complete indicator -let s:bMayComplete = 0 - -" Init mappings -function! omni#cpp#complete#Init() - call omni#cpp#settings#Init() - set omnifunc=omni#cpp#complete#Main - inoremap <expr> <C-X><C-O> omni#cpp#maycomplete#Complete() - inoremap <expr> . omni#cpp#maycomplete#Dot() - inoremap <expr> > omni#cpp#maycomplete#Arrow() - inoremap <expr> : omni#cpp#maycomplete#Scope() -endfunc - -" Find the start position of the completion -function! s:FindStartPositionOfCompletion() - " Locate the start of the item, including ".", "->" and "[...]". - let line = getline('.') - let start = col('.') - 1 - - let lastword = -1 - while start > 0 - if line[start - 1] =~ '\w' - let start -= 1 - elseif line[start - 1] =~ '\.' - " Searching for dot '.' - if lastword == -1 - let lastword = start - endif - let start -= 1 - elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>' - " Searching for '->' - if lastword == -1 - let lastword = start - endif - let start -= 2 - elseif start > 1 && line[start - 2] == ':' && line[start - 1] == ':' - " Searching for '::' for namespaces and class - if lastword == -1 - let lastword = start - endif - let start -= 2 - elseif line[start - 1] == ']' - " Skip over [...]. - let n = 0 - let start -= 1 - while start > 0 - let start -= 1 - if line[start] == '[' - if n == 0 - break - endif - let n -= 1 - elseif line[start] == ']' " nested [] - let n += 1 - endif - endwhile - else - break - endif - endwhile - if lastword==-1 - " For completion on the current scope - let lastword = start - endif - return lastword -endfunc - -" Returns if szKey1.szKey2 is in the cache -" @return -" - 0 = key not found -" - 1 = szKey1.szKey2 found -" - 2 = szKey1.[part of szKey2] found -function! s:IsCached(cache, szKey1, szKey2) - " Searching key in the result cache - let szResultKey = a:szKey1 . a:szKey2 - let result = [0, szResultKey] - if a:szKey2 != '' - let szKey = a:szKey2 - while len(szKey)>0 - if has_key(a:cache, a:szKey1 . szKey) - let result[1] = a:szKey1 . szKey - if szKey != a:szKey2 - let result[0] = 2 - else - let result[0] = 1 - endif - break - endif - let szKey = szKey[:-2] - endwhile - else - if has_key(a:cache, szResultKey) - let result[0] = 1 - endif - endif - return result -endfunc - -" Extend a tag item to a popup item -function! s:ExtendTagItemToPopupItem(tagItem, szTypeName) - let tagItem = a:tagItem - - " Add the access - let szItemMenu = '' - let accessChar = {'public': '+','protected': '#','private': '-'} - if g:OmniCpp_ShowAccess - if has_key(tagItem, 'access') && has_key(accessChar, tagItem.access) - let szItemMenu = szItemMenu.accessChar[tagItem.access] - else - let szItemMenu = szItemMenu." " - endif - endif - - " Formating optional menu string we extract the scope information - let szName = substitute(tagItem.name, '.*::', '', 'g') - let szItemWord = szName - let szAbbr = szName - - if !g:OmniCpp_ShowScopeInAbbr - let szScopeOfTag = omni#cpp#utils#ExtractScope(tagItem) - let szItemMenu = szItemMenu.' '.szScopeOfTag[2:] - let szItemMenu = substitute(szItemMenu, '\s\+$', '', 'g') - else - let szAbbr = tagItem.name - endif - if g:OmniCpp_ShowAccess - let szItemMenu = substitute(szItemMenu, '^\s\+$', '', 'g') - else - let szItemMenu = substitute(szItemMenu, '\(^\s\+\)\|\(\s\+$\)', '', 'g') - endif - - " Formating information for the preview window - if index(['f', 'p'], tagItem.kind[0])>=0 - let szItemWord .= '(' - if g:OmniCpp_ShowPrototypeInAbbr && has_key(tagItem, 'signature') - let szAbbr .= tagItem.signature - else - let szAbbr .= '(' - endif - endif - let szItemInfo = '' - if s:hasPreviewWindow - let szItemInfo = omni#cpp#utils#GetPreviewWindowStringFromTagItem(tagItem) - endif - - " If a function is a ctor we add a new key in the tagItem - if index(['f', 'p'], tagItem.kind[0])>=0 - if match(szName, '^\~') < 0 && a:szTypeName =~ '\C\<'.szName.'$' - " It's a ctor - let tagItem['ctor'] = 1 - elseif has_key(tagItem, 'access') && tagItem.access == 'friend' - " Friend function - let tagItem['friendfunc'] = 1 - endif - endif - - " Extending the tag item to a popup item - let tagItem['word'] = szItemWord - let tagItem['abbr'] = szAbbr - let tagItem['menu'] = szItemMenu - let tagItem['info'] = szItemInfo - let tagItem['dup'] = (s:hasPreviewWindow && index(['f', 'p', 'm'], tagItem.kind[0])>=0) - return tagItem -endfunc - -" Get tag popup item list -function! s:TagPopupList(szTypeName, szBase) - let result = [] - - " Searching key in the result cache - let cacheResult = s:IsCached(s:CACHE_TAG_POPUP_ITEMS, a:szTypeName, a:szBase) - - " Building the tag query, we don't forget dtors when a:szBase=='' - if a:szTypeName!='' - " Scope search - let szTagQuery = '^' . a:szTypeName . '::' . a:szBase . '\~\?\w\+$' - else - " Global search - let szTagQuery = '^' . a:szBase . '\w\+$' - endif - - " If the result is already in the cache we return it - if cacheResult[0] - let result = s:CACHE_TAG_POPUP_ITEMS[ cacheResult[1] ] - if cacheResult[0] == 2 - let result = filter(copy(result), 'v:val.name =~ szTagQuery' ) - endif - return result - endif - - try - " Getting tags - let result = omni#common#utils#TagList(szTagQuery) - - " We extend tag items to popup items - call map(result, 's:ExtendTagItemToPopupItem(v:val, a:szTypeName)') - - " We store the result in a cache - if cacheResult[1] != '' - let s:CACHE_TAG_POPUP_ITEMS[ cacheResult[1] ] = result - endif - catch /^TagList:UserInterrupt$/ - endtry - - return result -endfunc - -" Find complete matches for a completion on the global scope -function! s:SearchGlobalMembers(szBase) - if a:szBase != '' - let tagPopupList = s:TagPopupList('', a:szBase) - let tagPopupList = filter(copy(tagPopupList), g:omni#cpp#utils#szFilterGlobalScope) - call extend(s:popupItemResultList, tagPopupList) - endif -endfunc - -" Search class, struct, union members -" @param resolvedTagItem: a resolved tag item -" @param szBase: string base -" @return list of tag items extended to popup items -function! s:SearchMembers(resolvedTagItem, szBase) - let result = [] - if a:resolvedTagItem == {} - return result - endif - - " Get type info without the starting '::' - let szTagName = omni#cpp#utils#ExtractTypeInfoFromTag(a:resolvedTagItem)[2:] - - " Unnamed type case. A tag item representing an unnamed type is a variable - " ('v') a member ('m') or a typedef ('t') - if index(['v', 't', 'm'], a:resolvedTagItem.kind[0])>=0 && has_key(a:resolvedTagItem, 'typeref') - " We remove the 'struct:' or 'class:' etc... - let szTagName = substitute(a:resolvedTagItem.typeref, '^\w\+:', '', 'g') - endif - - return copy(s:TagPopupList(szTagName, a:szBase)) -endfunc - -" Return if the tag env has changed -function! s:HasTagEnvChanged() - if s:CACHE_TAG_ENV == &tags - return 0 - else - let s:CACHE_TAG_ENV = &tags - return 1 - endif -endfunc - -" Return if a tag file has changed in tagfiles() -function! s:HasATagFileOrTagEnvChanged() - if s:HasTagEnvChanged() - let s:CACHE_TAG_FILES = {} - return 1 - endif - - let result = 0 - for tagFile in tagfiles() - if tagFile == "" - continue - endif - - if has_key(s:CACHE_TAG_FILES, tagFile) - let currentFiletime = getftime(tagFile) - if currentFiletime > s:CACHE_TAG_FILES[tagFile] - " The file has changed, updating the cache - let s:CACHE_TAG_FILES[tagFile] = currentFiletime - let result = 1 - endif - else - " We store the time of the file - let s:CACHE_TAG_FILES[tagFile] = getftime(tagFile) - let result = 1 - endif - endfor - return result -endfunc -" Initialization -call s:HasATagFileOrTagEnvChanged() - -" Filter same function signatures of base classes -function! s:FilterOverloadedFunctions(tagPopupList) - let result = [] - for tagPopupItem in a:tagPopupList - if has_key(tagPopupItem, 'kind') && index(['f', 'p'], tagPopupItem.kind[0])>=0 && has_key(tagPopupItem, 'signature') - if !has_key(s:CACHE_OVERLOADED_FUNCTIONS, tagPopupItem.word . tagPopupItem.signature) - let s:CACHE_OVERLOADED_FUNCTIONS[tagPopupItem.word . tagPopupItem.signature] = 1 - call extend(result, [tagPopupItem]) - endif - else - call extend(result, [tagPopupItem]) - endif - endfor - return result -endfunc - -" Access filter -function! s:GetAccessFilter(szFilter, szAccessFilter) - let szFilter = a:szFilter - if g:OmniCpp_DisplayMode == 0 - if a:szAccessFilter == 'public' - " We only get public members - let szFilter .= "&& v:val.access == 'public'" - elseif a:szAccessFilter == 'protected' - " We get public and protected members - let szFilter .= "&& v:val.access != 'private'" - endif - endif - return szFilter -endfunc - -" Filter class members in the popup menu after a completion with -> or . -function! s:FilterClassMembers(tagPopupList, szAccessFilter) - let szFilter = "(!has_key(v:val, 'friendfunc') && !has_key(v:val, 'ctor') && has_key(v:val, 'kind') && index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access'))" - call filter(a:tagPopupList, s:GetAccessFilter(szFilter, a:szAccessFilter)) - call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) -endfunc - -" Filter class scope members in the popup menu after a completion with :: -" We only display attribute and functions members that -" have an access information. We also display nested -" class, struct, union, and enums, typedefs -function! s:FilterClassScopeMembers(tagPopupList, szAccessFilter) - let szFilter = "!has_key(v:val, 'friendfunc') && has_key(v:val, 'kind') && (index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access'))" - let szFilter = s:GetAccessFilter(szFilter, a:szAccessFilter) - let szFilter .= "|| index(['c','e','g','s','t','u'], v:val.kind[0])>=0" - call filter(a:tagPopupList, szFilter) - call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) -endfunc - -" Filter static class members in the popup menu -function! s:FilterStaticClassMembers(tagPopupList, szAccessFilter) - let szFilter = "!has_key(v:val, 'friendfunc') && has_key(v:val, 'kind') && (index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access') && match(v:val.cmd, '\\Cstatic')!=-1)" - let szFilter = s:GetAccessFilter(szFilter, a:szAccessFilter) - let szFilter = szFilter . "|| index(['c','e','g','n','s','t','u','v'], v:val.kind[0])>=0" - call filter(a:tagPopupList, szFilter) - call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) -endfunc - -" Filter scope members in the popup menu -function! s:FilterNamespaceScopeMembers(tagPopupList) - call extend(s:popupItemResultList, a:tagPopupList) -endfunc - -" Init data at the start of completion -function! s:InitComplete() - " Reset the popup item list - let s:popupItemResultList = [] - let s:CACHE_OVERLOADED_FUNCTIONS = {} - - " Reset includes cache when the current working directory has changed - let szCurrentWorkingDir = getcwd() - if s:szCurrentWorkingDir != szCurrentWorkingDir - let s:szCurrentWorkingDir = szCurrentWorkingDir - let g:omni#cpp#includes#CACHE_INCLUDES = {} - let g:omni#cpp#includes#CACHE_FILE_TIME = {} - endif - - " Has preview window ? - let s:hasPreviewWindow = match(&completeopt, 'preview')>=0 - - let bResetCache = 0 - - " Reset tag env or tag files dependent caches - if s:HasATagFileOrTagEnvChanged() - let bResetCache = 1 - endif - - if (s:OmniCpp_ShowScopeInAbbr != g:OmniCpp_ShowScopeInAbbr) - \|| (s:OmniCpp_ShowPrototypeInAbbr != g:OmniCpp_ShowPrototypeInAbbr) - \|| (s:OmniCpp_ShowAccess != g:OmniCpp_ShowAccess) - - let s:OmniCpp_ShowScopeInAbbr = g:OmniCpp_ShowScopeInAbbr - let s:OmniCpp_ShowPrototypeInAbbr = g:OmniCpp_ShowPrototypeInAbbr - let s:OmniCpp_ShowAccess = g:OmniCpp_ShowAccess - let bResetCache = 1 - endif - - if s:hasPreviewWindow != s:hasPreviewWindowOld - let s:hasPreviewWindowOld = s:hasPreviewWindow - let bResetCache = 1 - endif - - if bResetCache - let g:omni#cpp#namespaces#CacheResolve = {} - let s:CACHE_TAG_POPUP_ITEMS = {} - let g:omni#cpp#utils#CACHE_TAG_INHERITS = {} - call garbagecollect() - endif - - " Check for updates - for szIncludeName in keys(g:omni#cpp#includes#CACHE_INCLUDES) - let fTime = getftime(szIncludeName) - let bNeedUpdate = 0 - if has_key(g:omni#cpp#includes#CACHE_FILE_TIME, szIncludeName) - if fTime != g:omni#cpp#includes#CACHE_FILE_TIME[szIncludeName] - let bNeedUpdate = 1 - endif - else - let g:omni#cpp#includes#CACHE_FILE_TIME[szIncludeName] = fTime - let bNeedUpdate = 1 - endif - - if bNeedUpdate - " We have to update include list and namespace map of this file - call omni#cpp#includes#GetList(szIncludeName, 1) - call omni#cpp#namespaces#GetMapFromBuffer(szIncludeName, 1) - endif - endfor - - let s:bDoNotComplete = 0 -endfunc - - -" This function is used for the 'omnifunc' option. -function! omni#cpp#complete#Main(findstart, base) - if a:findstart - "call omni#common#debug#Start() - - call s:InitComplete() - - " Note: if s:bMayComplete==1 g:omni#cpp#items#data is build by MayComplete functions - if !s:bMayComplete - " If the cursor is in a comment we go out - if omni#cpp#utils#IsCursorInCommentOrString() - " Returning -1 is not enough we have to set a variable to let - " the second call of omni#cpp#complete knows that the - " cursor was in a comment - " Why is there a second call when the first call returns -1 ? - let s:bDoNotComplete = 1 - return -1 - endif - - " We get items here (whend a:findstart==1) because GetItemsToComplete() - " depends on the cursor position. - " When a:findstart==0 the cursor position is modified - let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction()) - endif - - " Get contexts stack - let s:contextStack = omni#cpp#namespaces#GetContexts() - - " Reinit of may complete indicator - let s:bMayComplete = 0 - return s:FindStartPositionOfCompletion() - endif - - " If the cursor is in a comment we return an empty result - if s:bDoNotComplete - let s:bDoNotComplete = 0 - return [] - endif - - if len(g:omni#cpp#items#data)==0 - " A) CURRENT_SCOPE_COMPLETION_MODE - - " 1) Displaying data of each context - let szAccessFilter = 'all' - for szCurrentContext in s:contextStack - if szCurrentContext == '::' - continue - endif - - let resolvedTagItem = omni#cpp#utils#GetResolvedTagItem(s:contextStack, omni#cpp#utils#CreateTypeInfo(szCurrentContext)) - if resolvedTagItem != {} - " We don't search base classes because bases classes are - " already in the context stack - let tagPopupList = s:SearchMembers(resolvedTagItem, a:base) - if index(['c','s'], resolvedTagItem.kind[0])>=0 - " It's a class or struct - call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) - let szAccessFilter = 'protected' - else - " It's a namespace or union, we display all members - call s:FilterNamespaceScopeMembers(tagPopupList) - endif - endif - endfor - - " 2) Displaying global scope members - if g:OmniCpp_GlobalScopeSearch - call s:SearchGlobalMembers(a:base) - endif - else - let typeInfo = omni#cpp#items#ResolveItemsTypeInfo(s:contextStack, g:omni#cpp#items#data) - - if typeInfo != {} - if g:omni#cpp#items#data[-1].kind == 'itemScope' - " B) SCOPE_COMPLETION_MODE - if omni#cpp#utils#GetTypeInfoString(typeInfo)=='' - call s:SearchGlobalMembers(a:base) - else - for resolvedTagItem in omni#cpp#utils#GetResolvedTags(s:contextStack, typeInfo) - let tagPopupList = s:SearchMembers(resolvedTagItem, a:base) - if index(['c','s'], resolvedTagItem.kind[0])>=0 - let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(resolvedTagItem) - if g:OmniCpp_DisplayMode==0 - " We want to complete a class or struct - " If this class is a base class so we display all class members - if index(s:contextStack, szTypeInfo)<0 - let szAccessFilter = 'public' - call s:FilterStaticClassMembers(tagPopupList, szAccessFilter) - else - let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' - call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) - endif - else - if index(s:contextStack, szTypeInfo)<0 - let szAccessFilter = 'public' - else - let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' - endif - call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) - endif - else - " We want to complete a namespace - call s:FilterNamespaceScopeMembers(tagPopupList) - endif - endfor - endif - else - " C) CLASS_MEMBERS_COMPLETION_MODE - for resolvedTagItem in omni#cpp#utils#GetResolvedTags(s:contextStack, typeInfo) - let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(resolvedTagItem) - if index(s:contextStack, szTypeInfo)<0 - let szAccessFilter = 'public' - else - let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' - endif - call s:FilterClassMembers(s:SearchMembers(resolvedTagItem, a:base), szAccessFilter) - endfor - endif - endif - endif - - "call omni#common#debug#End() - - return s:popupItemResultList -endfunc diff --git a/.vim/autoload/omni/cpp/includes.vim b/.vim/autoload/omni/cpp/includes.vim deleted file mode 100644 index 10a89bc..0000000 --- a/.vim/autoload/omni/cpp/includes.vim +++ /dev/null @@ -1,126 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -let g:omni#cpp#includes#CACHE_INCLUDES = {} -let g:omni#cpp#includes#CACHE_FILE_TIME = {} - -let s:rePreprocIncludePart = '\C#\s*include\s*' -let s:reIncludeFilePart = '\(<\|"\)\(\f\|\s\)\+\(>\|"\)' -let s:rePreprocIncludeFile = s:rePreprocIncludePart . s:reIncludeFilePart - -" Get the include list of a file -function! omni#cpp#includes#GetList(...) - if a:0 > 0 - return s:GetIncludeListFromFile(a:1, (a:0 > 1)? a:2 : 0 ) - else - return s:GetIncludeListFromCurrentBuffer() - endif -endfunc - -" Get the include list from the current buffer -function! s:GetIncludeListFromCurrentBuffer() - let listIncludes = [] - let originalPos = getpos('.') - - call setpos('.', [0, 1, 1, 0]) - let curPos = [1,1] - let alreadyInclude = {} - while curPos != [0,0] - let curPos = searchpos('\C\(^'.s:rePreprocIncludeFile.'\)', 'W') - if curPos != [0,0] - let szLine = getline('.') - let startPos = curPos[1] - let endPos = matchend(szLine, s:reIncludeFilePart, startPos-1) - if endPos!=-1 - let szInclusion = szLine[startPos-1:endPos-1] - let szIncludeFile = substitute(szInclusion, '\('.s:rePreprocIncludePart.'\)\|[<>""]', '', 'g') - let szResolvedInclude = omni#cpp#utils#ResolveFilePath(szIncludeFile) - - " Protection over self inclusion - if szResolvedInclude != '' && szResolvedInclude != omni#cpp#utils#ResolveFilePath(getreg('%')) - let includePos = curPos - if !has_key(alreadyInclude, szResolvedInclude) - call extend(listIncludes, [{'pos' : includePos, 'include' : szResolvedInclude}]) - let alreadyInclude[szResolvedInclude] = 1 - endif - endif - endif - endif - endwhile - - call setpos('.', originalPos) - return listIncludes -endfunc - -" Get the include list from a file -function! s:GetIncludeListFromFile(szFilePath, bUpdate) - let listIncludes = [] - if a:szFilePath == '' - return listIncludes - endif - - if !a:bUpdate && has_key(g:omni#cpp#includes#CACHE_INCLUDES, a:szFilePath) - return copy(g:omni#cpp#includes#CACHE_INCLUDES[a:szFilePath]) - endif - - let g:omni#cpp#includes#CACHE_FILE_TIME[a:szFilePath] = getftime(a:szFilePath) - - let szFixedPath = escape(a:szFilePath, g:omni#cpp#utils#szEscapedCharacters) - execute 'silent! lvimgrep /\C\(^'.s:rePreprocIncludeFile.'\)/gj '.szFixedPath - - let listQuickFix = getloclist(0) - let alreadyInclude = {} - for qf in listQuickFix - let szLine = qf.text - let startPos = qf.col - let endPos = matchend(szLine, s:reIncludeFilePart, startPos-1) - if endPos!=-1 - let szInclusion = szLine[startPos-1:endPos-1] - let szIncludeFile = substitute(szInclusion, '\('.s:rePreprocIncludePart.'\)\|[<>""]', '', 'g') - let szResolvedInclude = omni#cpp#utils#ResolveFilePath(szIncludeFile) - - " Protection over self inclusion - if szResolvedInclude != '' && szResolvedInclude != a:szFilePath - let includePos = [qf.lnum, qf.col] - if !has_key(alreadyInclude, szResolvedInclude) - call extend(listIncludes, [{'pos' : includePos, 'include' : szResolvedInclude}]) - let alreadyInclude[szResolvedInclude] = 1 - endif - endif - endif - endfor - - let g:omni#cpp#includes#CACHE_INCLUDES[a:szFilePath] = listIncludes - - return copy(listIncludes) -endfunc - -" For debug purpose -function! omni#cpp#includes#Display() - let szPathBuffer = omni#cpp#utils#ResolveFilePath(getreg('%')) - call s:DisplayIncludeTree(szPathBuffer, 0) -endfunc - -" For debug purpose -function! s:DisplayIncludeTree(szFilePath, indent, ...) - let includeGuard = {} - if a:0 >0 - let includeGuard = a:1 - endif - let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) - if has_key(includeGuard, szFilePath) - return - else - let includeGuard[szFilePath] = 1 - endif - - let szIndent = repeat(' ', a:indent) - echo szIndent . a:szFilePath - let incList = omni#cpp#includes#GetList(a:szFilePath) - for inc in incList - call s:DisplayIncludeTree(inc.include, a:indent+1, includeGuard) - endfor -endfunc - - diff --git a/.vim/autoload/omni/cpp/items.vim b/.vim/autoload/omni/cpp/items.vim deleted file mode 100644 index b943ad4..0000000 --- a/.vim/autoload/omni/cpp/items.vim +++ /dev/null @@ -1,660 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -" Build the item list of an instruction -" An item is an instruction between a -> or . or ->* or .* -" We can sort an item in different kinds: -" eg: ((MyClass1*)(pObject))->_memberOfClass1.get() ->show() -" | cast | | member | | method | | method | -" @return a list of item -" an item is a dictionnary where keys are: -" tokens = list of token -" kind = itemVariable|itemCast|itemCppCast|itemTemplate|itemFunction|itemUnknown|itemThis|itemScope -function! omni#cpp#items#Get(tokens, ...) - let bGetWordUnderCursor = (a:0>0)? a:1 : 0 - - let result = [] - let itemsDelimiters = ['->', '.', '->*', '.*'] - - let tokens = reverse(omni#cpp#utils#BuildParenthesisGroups(a:tokens)) - - " fsm states: - " 0 = initial state - " TODO: add description of fsm states - let state=(bGetWordUnderCursor)? 1 : 0 - let item = {'tokens' : [], 'kind' : 'itemUnknown'} - let parenGroup=-1 - for token in tokens - if state==0 - if index(itemsDelimiters, token.value)>=0 - let item = {'tokens' : [], 'kind' : 'itemUnknown'} - let state = 1 - elseif token.value=='::' - let state = 9 - let item.kind = 'itemScope' - " Maybe end of tokens - elseif token.kind =='cppOperatorPunctuator' - " If it's a cppOperatorPunctuator and the current token is not - " a itemsDelimiters or '::' we can exit - let state=-1 - break - endif - elseif state==1 - call insert(item.tokens, token) - if token.kind=='cppWord' - " It's an attribute member or a variable - let item.kind = 'itemVariable' - let state = 2 - " Maybe end of tokens - elseif token.value=='this' - let item.kind = 'itemThis' - let state = 2 - " Maybe end of tokens - elseif token.value==')' - let parenGroup = token.group - let state = 3 - elseif token.value==']' - let parenGroup = token.group - let state = 4 - elseif token.kind == 'cppDigit' - let state = -1 - break - endif - elseif state==2 - if index(itemsDelimiters, token.value)>=0 - call insert(result, item) - let item = {'tokens' : [], 'kind' : 'itemUnknown'} - let state = 1 - elseif token.value == '::' - call insert(item.tokens, token) - " We have to get namespace or classscope - let state = 8 - " Maybe end of tokens - else - call insert(result, item) - let state=-1 - break - endif - elseif state==3 - call insert(item.tokens, token) - if token.value=='(' && token.group == parenGroup - let state = 5 - " Maybe end of tokens - endif - elseif state==4 - call insert(item.tokens, token) - if token.value=='[' && token.group == parenGroup - let state = 1 - endif - elseif state==5 - if token.kind=='cppWord' - " It's a function or method - let item.kind = 'itemFunction' - call insert(item.tokens, token) - let state = 2 - " Maybe end of tokens - elseif token.value == '>' - " Maybe a cpp cast or template - let item.kind = 'itemTemplate' - call insert(item.tokens, token) - let parenGroup = token.group - let state = 6 - else - " Perhaps it's a C cast eg: ((void*)(pData)) or a variable eg:(*pData) - let item.kind = omni#cpp#utils#GetCastType(item.tokens) - let state=-1 - call insert(result, item) - break - endif - elseif state==6 - call insert(item.tokens, token) - if token.value == '<' && token.group == parenGroup - " Maybe a cpp cast or template - let state = 7 - endif - elseif state==7 - call insert(item.tokens, token) - if token.kind=='cppKeyword' - " It's a cpp cast - let item.kind = omni#cpp#utils#GetCastType(item.tokens) - let state=-1 - call insert(result, item) - break - else - " Template ? - let state=-1 - call insert(result, item) - break - endif - elseif state==8 - if token.kind=='cppWord' - call insert(item.tokens, token) - let state = 2 - " Maybe end of tokens - else - let state=-1 - call insert(result, item) - break - endif - elseif state==9 - if token.kind == 'cppWord' - call insert(item.tokens, token) - let state = 10 - " Maybe end of tokens - else - let state=-1 - call insert(result, item) - break - endif - elseif state==10 - if token.value == '::' - call insert(item.tokens, token) - let state = 9 - " Maybe end of tokens - else - let state=-1 - call insert(result, item) - break - endif - endif - endfor - - if index([2, 5, 8, 9, 10], state)>=0 - if state==5 - let item.kind = omni#cpp#utils#GetCastType(item.tokens) - endif - call insert(result, item) - endif - - return result -endfunc - -" Resolve type information of items -" @param namespaces: list of namespaces used in the file -" @param szCurrentClassScope: the current class scope, only used for the first -" item to detect if this item is a class member (attribute, method) -" @param items: list of item, can be an empty list @see GetItemsToComplete -function! omni#cpp#items#ResolveItemsTypeInfo(contextStack, items) - " Note: kind = itemVariable|cCast|cppCast|template|function|itemUnknown|this - " For the first item, if it's a variable we try to detect the type of the - " variable with the function searchdecl. If it fails, thanks to the - " current class scope, we try to detect if the variable is an attribute - " member. - " If the kind of the item is a function, we have to first check if the - " function is a method of the class, if it fails we try to get a match in - " the global namespace. After that we get the returned type of the - " function. - " It the kind is a C cast or C++ cast, there is no problem, it's the - " easiest case. We just extract the type of the cast. - - let szCurrentContext = '' - let typeInfo = {} - " Note: We search the decl only for the first item - let bSearchDecl = 1 - for item in a:items - let curItem = item - if index(['itemVariable', 'itemFunction'], curItem.kind)>=0 - " Note: a variable can be : MyNs::MyClass::_var or _var or (*pVar) - " or _var[0][0] - let szSymbol = s:GetSymbol(curItem.tokens) - - " If we have MyNamespace::myVar - " We add MyNamespace in the context stack set szSymbol to myVar - if match(szSymbol, '::\w\+$') >= 0 - let szCurrentContext = substitute(szSymbol, '::\w\+$', '', 'g') - let szSymbol = matchstr(szSymbol, '\w\+$') - endif - let tmpContextStack = a:contextStack - if szCurrentContext != '' - let tmpContextStack = [szCurrentContext] + a:contextStack - endif - - if curItem.kind == 'itemVariable' - let typeInfo = s:GetTypeInfoOfVariable(tmpContextStack, szSymbol, bSearchDecl) - else - let typeInfo = s:GetTypeInfoOfReturnedType(tmpContextStack, szSymbol) - endif - - elseif curItem.kind == 'itemThis' - if len(a:contextStack) - let typeInfo = omni#cpp#utils#CreateTypeInfo(substitute(a:contextStack[0], '^::', '', 'g')) - endif - elseif curItem.kind == 'itemCast' - let typeInfo = omni#cpp#utils#CreateTypeInfo(s:ResolveCCast(curItem.tokens)) - elseif curItem.kind == 'itemCppCast' - let typeInfo = omni#cpp#utils#CreateTypeInfo(s:ResolveCppCast(curItem.tokens)) - elseif curItem.kind == 'itemScope' - let typeInfo = omni#cpp#utils#CreateTypeInfo(substitute(s:TokensToString(curItem.tokens), '\s', '', 'g')) - endif - - if omni#cpp#utils#IsTypeInfoValid(typeInfo) - let szCurrentContext = omni#cpp#utils#GetTypeInfoString(typeInfo) - endif - let bSearchDecl = 0 - endfor - - return typeInfo -endfunc - -" Get symbol name -function! s:GetSymbol(tokens) - let szSymbol = '' - let state = 0 - for token in a:tokens - if state == 0 - if token.value == '::' - let szSymbol .= token.value - let state = 1 - elseif token.kind == 'cppWord' - let szSymbol .= token.value - let state = 2 - " Maybe end of token - endif - elseif state == 1 - if token.kind == 'cppWord' - let szSymbol .= token.value - let state = 2 - " Maybe end of token - else - " Error - break - endif - elseif state == 2 - if token.value == '::' - let szSymbol .= token.value - let state = 1 - else - break - endif - endif - endfor - return szSymbol -endfunc - -" Search a declaration. -" eg: std::map -" can be empty -" Note: The returned type info can be a typedef -" The typedef resolution is done later -" @return -" - a dictionnary where keys are -" - type: the type of value same as type() -" - value: the value -function! s:GetTypeInfoOfVariable(contextStack, szVariable, bSearchDecl) - let result = {} - - if a:bSearchDecl - " Search type of declaration - "let result = s:SearchTypeInfoOfDecl(a:szVariable) - let result = s:SearchDecl(a:szVariable) - endif - - if result=={} - let szFilter = "index(['m', 'v'], v:val.kind[0])>=0" - let tagItem = s:ResolveSymbol(a:contextStack, a:szVariable, szFilter) - if tagItem=={} - return result - endif - - let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szVariable.'\>.*', '', 'g') - let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) - let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) - " TODO: Namespace resolution for result - - if result != {} && result.value=='' - " result.value=='' - " eg: - " struct - " { - " }gVariable; - if has_key(tagItem, 'typeref') - " Maybe the variable is a global var of an - " unnamed class, struct or union. - " eg: - " 1) - " struct - " { - " }gVariable; - " In this case we need the tags (the patched version) - " Note: We can have a named type like this: - " 2) - " class A - " { - " }gVariable; - if s:IsUnnamedType(tagItem) - " It's an unnamed type we are in the case 1) - let result = omni#cpp#utils#CreateTypeInfo(tagItem) - else - " It's not an unnamed type we are in the case 2) - - " eg: tagItem.typeref = 'struct:MY_STRUCT::MY_SUBSTRUCT' - let szTypeRef = substitute(tagItem.typeref, '^\w\+:', '', '') - - " eg: szTypeRef = 'MY_STRUCT::MY_SUBSTRUCT' - let result = omni#cpp#utils#CreateTypeInfo(szTypeRef) - endif - endif - endif - endif - return result -endfunc - -" Get the type info string from the returned type of function -function! s:GetTypeInfoOfReturnedType(contextStack, szFunctionName) - let result = {} - - let szFilter = "index(['f', 'p'], v:val.kind[0])>=0" - let tagItem = s:ResolveSymbol(a:contextStack, a:szFunctionName, szFilter) - - if tagItem != {} - let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szFunctionName.'\>.*', '', 'g') - let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) - let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) - " TODO: Namespace resolution for result - return result - endif - return result -endfunc - -" Resolve a symbol, return a tagItem -" Gets the first symbol found in the context stack -function! s:ResolveSymbol(contextStack, szSymbol, szTagFilter) - let tagItem = {} - for szCurrentContext in a:contextStack - if szCurrentContext != '::' - let szTagQuery = substitute(szCurrentContext, '^::', '', 'g').'::'.a:szSymbol - else - let szTagQuery = a:szSymbol - endif - - let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') - call filter(tagList, a:szTagFilter) - if len(tagList) - let tagItem = tagList[0] - break - endif - endfor - return tagItem -endfunc - -" Return if the tag item represent an unnamed type -function! s:IsUnnamedType(tagItem) - let bResult = 0 - if has_key(a:tagItem, 'typeref') - " Note: Thanks for __anon ! - let bResult = match(a:tagItem.typeref, '\C\<__anon') >= 0 - endif - return bResult -endfunc - -" Search the declaration of a variable and return the type info -function! s:SearchTypeInfoOfDecl(szVariable) - let szReVariable = '\C\<'.a:szVariable.'\>' - - let originalPos = getpos('.') - let origPos = originalPos[1:2] - let curPos = origPos - let stopPos = origPos - - while curPos !=[0,0] - " We go to the start of the current scope - let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) - if curPos != [0,0] - let matchPos = curPos - " Now want to search our variable but we don't want to go in child - " scope - while matchPos != [0,0] - let matchPos = searchpos('{\|'.szReVariable, 'W', stopPos[0]) - if matchPos != [0,0] - " We ignore matches under comment - if omni#cpp#utils#IsCursorInCommentOrString() - continue - endif - - " Getting the current line - let szLine = getline('.') - if match(szLine, szReVariable)>=0 - " We found our variable - " Check if the current instruction is a decl instruction - let tokens = omni#cpp#utils#TokenizeCurrentInstruction() - let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) - if szTypeInfo != '' - call setpos('.', originalPos) - return omni#cpp#utils#CreateTypeInfo(szTypeInfo) - endif - else - " We found a child scope, we don't want to go in, thus - " we search for the end } of this child scope - let bracketEnd = searchpairpos('{', '', '}', 'nW', g:omni#cpp#utils#expIgnoreComments) - if bracketEnd == [0,0] - break - endif - - if bracketEnd[0] >= stopPos[0] - " The end of the scope is after our cursor we stop - " the search - break - else - " We move the cursor and continue to search our - " variable - call setpos('.', [0, bracketEnd[0], bracketEnd[1], 0]) - endif - endif - endif - endwhile - - " Backing to the start of the scope - call setpos('.', [0,curPos[0], curPos[1], 0]) - let stopPos = curPos - endif - endwhile - - let result = {} - if s:LocalSearchDecl(a:szVariable)==0 && !omni#cpp#utils#IsCursorInCommentOrString() - let tokens = omni#cpp#utils#TokenizeCurrentInstruction() - let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) - if szTypeInfo != '' - let result = omni#cpp#utils#CreateTypeInfo(szTypeInfo) - endif - endif - - call setpos('.', originalPos) - - return result -endfunc - -" Search a declaration -" @return -" - tokens of the current instruction if success -" - empty list if failure -function! s:SearchDecl(szVariable) - let result = {} - let originalPos = getpos('.') - let searchResult = s:LocalSearchDecl(a:szVariable) - if searchResult==0 - " searchdecl() may detect a decl if the variable is in a conditional - " instruction (if, elseif, while etc...) - " We have to check if the detected decl is really a decl instruction - let tokens = omni#cpp#utils#TokenizeCurrentInstruction() - - for token in tokens - " Simple test - if index(['if', 'elseif', 'while', 'for', 'switch'], token.value)>=0 - " Invalid declaration instruction - call setpos('.', originalPos) - return result - endif - endfor - - let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) - if szTypeInfo != '' - let result = omni#cpp#utils#CreateTypeInfo(szTypeInfo) - endif - endif - call setpos('.', originalPos) - return result -endfunc - -" Extract the type info string from an instruction. -" We use a small parser to extract the type -" We parse the code according to a C++ BNF from: http://www.nongnu.org/hcb/#basic.link -" @param tokens: token list of the current instruction -function! s:ExtractTypeInfoFromDecl(tokens) - return omni#cpp#utils#ExtractTypeInfoFromTokens(a:tokens) -endfunc - -" Convert tokens to string -function! s:TokensToString(tokens) - let result = '' - for token in a:tokens - let result = result . token.value . ' ' - endfor - return result[:-2] -endfunc - -" Resolve a cast. -" Resolve a C++ cast -" @param list of token. tokens must be a list that represents -" a cast expression (C++ cast) the function does not control -" if it's a cast or not -" eg: static_cast<MyClass*>(something) -" @return type info string -function! s:ResolveCppCast(tokens) - return omni#cpp#utils#ExtractTypeInfoFromTokens(s:ResolveCast(a:tokens, '<', '>')) -endfunc - -" Resolve a cast. -" Resolve a C cast -" @param list of token. tokens must be a list that represents -" a cast expression (C cast) the function does not control -" if it's a cast or not -" eg: (MyClass*)something -" @return type info string -function! s:ResolveCCast(tokens) - return omni#cpp#utils#ExtractTypeInfoFromTokens(s:ResolveCast(a:tokens, '(', ')')) -endfunc - -" Resolve a cast. -" Resolve a C cast -" @param list of token. tokens must be a list that represents -" a cast expression (C cast) the function does not control -" if it's a cast or not -" eg: (MyClass*)something -" @return type tokens -function! s:ResolveCast(tokens, startChar, endChar) - let tokens = omni#cpp#utils#BuildParenthesisGroups(a:tokens) - - " We remove useless parenthesis eg: (((MyClass))) - let tokens = omni#cpp#utils#SimplifyParenthesis(tokens) - - let countItem=0 - let startIndex = -1 - let endIndex = -1 - let i = 0 - for token in tokens - if startIndex==-1 - if token.value==a:startChar - let countItem += 1 - let startIndex = i - endif - else - if token.value==a:startChar - let countItem += 1 - elseif token.value==a:endChar - let countItem -= 1 - endif - - if countItem==0 - let endIndex = i - break - endif - endif - let i+=1 - endfor - - return tokens[startIndex+1 : endIndex-1] -endfunc - -" Replacement for build-in function 'searchdecl' -" It does not require that the upper-level bracket is in the first column. -" Otherwise it should be equal to 'searchdecl(name, 0, 1)' -" @param name: name of variable to find declaration for -function! s:LocalSearchDecl(name) - - if g:OmniCpp_LocalSearchDecl == 0 - let bUserIgnoreCase = &ignorecase - - " Forcing the noignorecase option - " avoid bug when, for example, if we have a declaration like this : "A a;" - set noignorecase - - let result = searchdecl(a:name, 0, 1) - - " Restoring user's setting - let &ignorecase = bUserIgnoreCase - - return result - endif - - let lastpos = getpos('.') - let winview = winsaveview() - let lastfoldenable = &foldenable - let &foldenable = 0 - - " We add \C (noignorecase) to - " avoid bug when, for example, if we have a declaration like this : "A a;" - let varname = "\\C\\<" . a:name . "\\>" - - " Go to first blank line before begin of highest scope - normal 99[{ - let scopepos = getpos('.') - while (line('.') > 1) && (len(split(getline('.'))) > 0) - call cursor(line('.')-1, 0) - endwhile - - let declpos = [ 0, 0, 0, 0 ] - while search(varname, '', scopepos[1]) > 0 - " Check if we are a string or a comment - if omni#cpp#utils#IsCursorInCommentOrString() - continue - endif - - " Remember match - let declpos = getpos('.') - endwhile - if declpos[1] != 0 - " We found a match - call winrestview(winview) - call setpos('.', declpos) - let &foldenable = lastfoldenable - return 0 - endif - - while search(varname, '', lastpos[1]) > 0 - " Check if current scope is ending before variable - let old_cur = getpos('.') - normal ]} - let new_cur = getpos('.') - call setpos('.', old_cur) - if (new_cur[1] < lastpos[1]) || ((new_cur[1] == lastpos[1]) && (new_cur[2] < lastpos[2])) - continue - endif - - " Check if we are a string or a comment - if omni#cpp#utils#IsCursorInCommentOrString() - continue - endif - - " We found match - call winrestview(winview) - call setpos('.', old_cur) - let &foldenable = lastfoldenable - return 0 - endwhile - - " No match found. - call winrestview(winview) - let &foldenable = lastfoldenable - return 1 -endfunc diff --git a/.vim/autoload/omni/cpp/maycomplete.vim b/.vim/autoload/omni/cpp/maycomplete.vim deleted file mode 100644 index 610526b..0000000 --- a/.vim/autoload/omni/cpp/maycomplete.vim +++ /dev/null @@ -1,82 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -" Check if we can use omni completion in the current buffer -function! s:CanUseOmnicompletion() - " For C and C++ files and only if the omnifunc is omni#cpp#complete#Main - return (index(['c', 'cpp'], &filetype)>=0 && &omnifunc == 'omni#cpp#complete#Main' && !omni#cpp#utils#IsCursorInCommentOrString()) -endfunc - -" Return the mapping of omni completion -function! omni#cpp#maycomplete#Complete() - let szOmniMapping = "\<C-X>\<C-O>" - - " 0 = don't select first item - " 1 = select first item (inserting it to the text, default vim behaviour) - " 2 = select first item (without inserting it to the text) - if g:OmniCpp_SelectFirstItem == 0 - " We have to force the menuone option to avoid confusion when there is - " only one popup item - set completeopt-=menu - set completeopt+=menuone - let szOmniMapping .= "\<C-P>" - elseif g:OmniCpp_SelectFirstItem == 2 - " We have to force the menuone option to avoid confusion when there is - " only one popup item - set completeopt-=menu - set completeopt+=menuone - let szOmniMapping .= "\<C-P>" - let szOmniMapping .= "\<C-R>=pumvisible() ? \"\\<down>\" : \"\"\<cr>" - endif - return szOmniMapping -endfunc - -" May complete function for dot -function! omni#cpp#maycomplete#Dot() - if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteDot - let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction('.')) - if len(g:omni#cpp#items#data) - let s:bMayComplete = 1 - return '.' . omni#cpp#maycomplete#Complete() - endif - endif - return '.' -endfunc -" May complete function for arrow -function! omni#cpp#maycomplete#Arrow() - if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteArrow - let index = col('.') - 2 - if index >= 0 - let char = getline('.')[index] - if char == '-' - let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction('>')) - if len(g:omni#cpp#items#data) - let s:bMayComplete = 1 - return '>' . omni#cpp#maycomplete#Complete() - endif - endif - endif - endif - return '>' -endfunc - -" May complete function for double points -function! omni#cpp#maycomplete#Scope() - if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteScope - let index = col('.') - 2 - if index >= 0 - let char = getline('.')[index] - if char == ':' - let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction(':')) - if len(g:omni#cpp#items#data) - if len(g:omni#cpp#items#data[-1].tokens) && g:omni#cpp#items#data[-1].tokens[-1].value != '::' - let s:bMayComplete = 1 - return ':' . omni#cpp#maycomplete#Complete() - endif - endif - endif - endif - endif - return ':' -endfunc diff --git a/.vim/autoload/omni/cpp/namespaces.vim b/.vim/autoload/omni/cpp/namespaces.vim deleted file mode 100644 index 386b3f9..0000000 --- a/.vim/autoload/omni/cpp/namespaces.vim +++ /dev/null @@ -1,838 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -let g:omni#cpp#namespaces#CacheResolve = {} -let g:omni#cpp#namespaces#CacheUsing = {} -" TODO: For the next release -"let g:omni#cpp#namespaces#CacheAlias = {} - -" Get the using namespace list from a line -function! s:GetNamespaceAliasListFromLine(szLine) - let result = {} - let tokens = omni#cpp#tokenizer#Tokenize(a:szLine) - let szAlias = '' - let szNamespace = '' - let state = 0 - for token in tokens - if state==0 - let szAlias = '' - let szNamespace = '' - if token.value == '/*' - let state = 1 - elseif token.value == '//' - " It's a comment - let state = -1 - break - elseif token.value == 'namespace' - let state = 2 - endif - elseif state==1 - if token.value == '*/' - let state=0 - endif - elseif state==2 - if token.kind == 'cppWord' - let szAlias .= token.value - let state = 3 - else - let state = -1 - break - endif - elseif state == 3 - if token.value == '=' - let state = 4 - else - let state = -1 - break - endif - elseif state == 4 - if token.value == '::' - let szNamespace .= token.value - let state = 5 - elseif token.kind == 'cppWord' - let szNamespace .= token.value - let state = 6 - " Maybe end of tokens - endif - elseif state==5 - if token.kind == 'cppWord' - let szNamespace .= token.value - let state = 6 - " Maybe end of tokens - else - " Error, we can't have 'namespace ALIAS = Something::' - let state = -1 - break - endif - elseif state==6 - if token.value == '::' - let szNamespace .= token.value - let state = 5 - else - call extend(result, {szAlias : szNamespace}) - let state = 0 - endif - endif - endfor - - if state == 6 - call extend(result, {szAlias : szNamespace}) - endif - - return result -endfunc - -" Get the using namespace list from a line -function! s:GetNamespaceListFromLine(szLine) - let result = [] - let tokens = omni#cpp#tokenizer#Tokenize(a:szLine) - let szNamespace = '' - let state = 0 - for token in tokens - if state==0 - let szNamespace = '' - if token.value == '/*' - let state = 1 - elseif token.value == '//' - " It's a comment - let state = -1 - break - elseif token.value == 'using' - let state = 2 - endif - elseif state==1 - if token.value == '*/' - let state=0 - endif - elseif state==2 - if token.value == 'namespace' - let state = 3 - else - " Error, 'using' must be followed by 'namespace' - let state = -1 - break - endif - elseif state==3 - if token.value == '::' - let szNamespace .= token.value - let state = 4 - elseif token.kind == 'cppWord' - let szNamespace .= token.value - let state = 5 - " Maybe end of tokens - endif - elseif state==4 - if token.kind == 'cppWord' - let szNamespace .= token.value - let state = 5 - " Maybe end of tokens - else - " Error, we can't have 'using namespace Something::' - let state = -1 - break - endif - elseif state==5 - if token.value == '::' - let szNamespace .= token.value - let state = 4 - else - call extend(result, [szNamespace]) - let state = 0 - endif - endif - endfor - - if state == 5 - call extend(result, [szNamespace]) - endif - - return result -endfunc - -" Get the namespace list from a namespace map -function! s:GetUsingNamespaceListFromMap(namespaceMap, ...) - let stopLine = 0 - if a:0>0 - let stopLine = a:1 - endif - - let result = [] - let keys = sort(keys(a:namespaceMap), 'omni#common#utils#CompareNumber') - for i in keys - if stopLine != 0 && i > stopLine - break - endif - call extend(result, a:namespaceMap[i]) - endfor - return result -endfunc - -" Get global using namespace list from the current buffer -function! omni#cpp#namespaces#GetListFromCurrentBuffer(...) - let namespaceMap = s:GetAllUsingNamespaceMapFromCurrentBuffer() - let result = [] - if namespaceMap != {} - let result = s:GetUsingNamespaceListFromMap(namespaceMap, (a:0 > 0)? a:1 : line('.')) - endif - return result -endfunc - -" Get global using namespace map from the current buffer and include files recursively -function! s:GetAllUsingNamespaceMapFromCurrentBuffer(...) - let includeGuard = (a:0>0)? a:1 : {} - - let szBufferName = getreg("%") - let szFilePath = omni#cpp#utils#ResolveFilePath(szBufferName) - let szFilePath = (szFilePath=='')? szBufferName : szFilePath - - let namespaceMap = {} - if has_key(includeGuard, szFilePath) - return namespaceMap - else - let includeGuard[szFilePath] = 1 - endif - - let namespaceMap = omni#cpp#namespaces#GetMapFromCurrentBuffer() - - if g:OmniCpp_NamespaceSearch != 2 - " We don't search included files if OmniCpp_NamespaceSearch != 2 - return namespaceMap - endif - - for inc in omni#cpp#includes#GetList() - let lnum = inc.pos[0] - let tmpMap = s:GetAllUsingNamespaceMapFromFile(inc.include, includeGuard) - if tmpMap != {} - if has_key(namespaceMap, lnum) - call extend(namespaceMap[lnum], s:GetUsingNamespaceListFromMap(tmpMap)) - else - let namespaceMap[lnum] = s:GetUsingNamespaceListFromMap(tmpMap) - endif - endif - endfor - - return namespaceMap -endfunc - -" Get global using namespace map from a file and include files recursively -function! s:GetAllUsingNamespaceMapFromFile(szFilePath, ...) - let includeGuard = {} - if a:0 >0 - let includeGuard = a:1 - endif - - let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) - let szFilePath = (szFilePath=='')? a:szFilePath : szFilePath - - let namespaceMap = {} - if has_key(includeGuard, szFilePath) - return namespaceMap - else - let includeGuard[szFilePath] = 1 - endif - - " If g:OmniCpp_NamespaceSearch == 1 (search namespaces only in the current - " buffer) we don't use cache for the current buffer - let namespaceMap = omni#cpp#namespaces#GetMapFromBuffer(szFilePath, g:OmniCpp_NamespaceSearch==1) - - if g:OmniCpp_NamespaceSearch != 2 - " We don't search included files if OmniCpp_NamespaceSearch != 2 - return namespaceMap - endif - - for inc in omni#cpp#includes#GetList(szFilePath) - let lnum = inc.pos[0] - let tmpMap = s:GetAllUsingNamespaceMapFromFile(inc.include, includeGuard) - if tmpMap != {} - if has_key(namespaceMap, lnum) - call extend(namespaceMap[lnum], s:GetUsingNamespaceListFromMap(tmpMap)) - else - let namespaceMap[lnum] = s:GetUsingNamespaceListFromMap(tmpMap) - endif - endif - endfor - - return namespaceMap -endfunc - -" Get global using namespace map from a the current buffer -function! omni#cpp#namespaces#GetMapFromCurrentBuffer() - let namespaceMap = {} - let originalPos = getpos('.') - - call setpos('.', [0, 1, 1, 0]) - let curPos = [1,1] - while curPos != [0,0] - let curPos = searchpos('\C^using\s\+namespace', 'W') - if curPos != [0,0] - let szLine = getline('.') - let startPos = curPos[1] - let endPos = match(szLine, ';', startPos-1) - if endPos!=-1 - " We get the namespace list from the line - let namespaceMap[curPos[0]] = s:GetNamespaceListFromLine(szLine) - endif - endif - endwhile - - call setpos('.', originalPos) - return namespaceMap -endfunc - -" Get global using namespace map from a file -function! omni#cpp#namespaces#GetMapFromBuffer(szFilePath, ...) - let bUpdate = 0 - if a:0 > 0 - let bUpdate = a:1 - endif - - let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) - let szFilePath = (szFilePath=='')? a:szFilePath : szFilePath - - if !bUpdate && has_key(g:omni#cpp#namespaces#CacheUsing, szFilePath) - return copy(g:omni#cpp#namespaces#CacheUsing[szFilePath]) - endif - - let namespaceMap = {} - " The file exists, we get the global namespaces in this file - let szFixedPath = escape(szFilePath, g:omni#cpp#utils#szEscapedCharacters) - execute 'silent! lvimgrep /\C^using\s\+namespace/gj '.szFixedPath - - " key = line number - " value = list of namespaces - let listQuickFix = getloclist(0) - for qf in listQuickFix - let szLine = qf.text - let startPos = qf.col - let endPos = match(szLine, ';', startPos-1) - if endPos!=-1 - " We get the namespace list from the line - let namespaceMap[qf.lnum] = s:GetNamespaceListFromLine(szLine) - endif - endfor - - if szFixedPath != '' - let g:omni#cpp#namespaces#CacheUsing[szFixedPath] = namespaceMap - endif - - return copy(namespaceMap) -endfunc - -" Get the stop position when searching for local variables -function! s:GetStopPositionForLocalSearch() - " Stop position when searching a local variable - let originalPos = getpos('.') - let origPos = originalPos[1:2] - let stopPosition = origPos - let curPos = origPos - while curPos !=[0,0] - let stopPosition = curPos - let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) - endwhile - call setpos('.', originalPos) - - return stopPosition -endfunc - -" Get namespaces alias used at the cursor postion in a vim buffer -" Note: The result depends on the current cursor position -" @return -" - Map of namespace alias -function! s:GetNamespaceAliasMap() - " We store the cursor position because searchpairpos() moves the cursor - let result = {} - let originalPos = getpos('.') - let origPos = originalPos[1:2] - - let stopPos = s:GetStopPositionForLocalSearch() - let stopLine = stopPos[0] - let curPos = origPos - let lastLine = 0 - let nextStopLine = origPos[0] - let szReAlias = '\Cnamespace\s\+\w\+\s\+=' - while curPos !=[0,0] - let curPos = searchpos('}\|\('. szReAlias .'\)', 'bW',stopLine) - if curPos!=[0,0] && curPos[0]!=lastLine - let lastLine = curPos[0] - - let szLine = getline('.') - if origPos[0] == curPos[0] - " We get the line until cursor position - let szLine = szLine[:origPos[1]] - endif - - let szLine = omni#cpp#utils#GetCodeFromLine(szLine) - if match(szLine, szReAlias)<0 - " We found a '}' - let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) - else - " We get the namespace alias from the line - call extend(result, s:GetNamespaceAliasListFromLine(szLine)) - let nextStopLine = curPos[0] - endif - endif - endwhile - - " Setting the cursor to the original position - call setpos('.', originalPos) - - call s:ResolveAliasKeys(result) - return result -endfunc - -" Resolve an alias -" eg: namespace IAmAnAlias1 = Ns1 -" eg: namespace IAmAnAlias2 = IAmAnAlias1::Ns2 -" => IAmAnAlias2 = Ns1::Ns2 -function! s:ResolveAliasKey(mapNamespaceAlias, szAlias) - let szResult = a:mapNamespaceAlias[a:szAlias] - " ::Ns1::Ns2::Ns3 => ['Ns1', 'Ns2', 'Ns3'] - let listNamespace = split(szResult, '::') - if len(listNamespace) - " szBeginPart = 'Ns1' - let szBeginPart = remove(listNamespace, 0) - - " Is 'Ns1' an alias ? - if has_key(a:mapNamespaceAlias, szBeginPart) && szBeginPart != a:szAlias - " Resolving alias 'Ns1' - " eg: Ns1 = NsResolved - let szResult = s:ResolveAliasKey(a:mapNamespaceAlias, szBeginPart) - " szEndPart = 'Ns2::Ns3' - let szEndPart = join(listNamespace, '::') - if szEndPart != '' - " Concatenation => szResult = 'NsResolved::Ns2::Ns3' - let szResult .= '::' . szEndPart - endif - endif - endif - return szResult -endfunc - -" Resolve all keys in the namespace alias map -function! s:ResolveAliasKeys(mapNamespaceAlias) - let mapNamespaceAlias = a:mapNamespaceAlias - call map(mapNamespaceAlias, 's:ResolveAliasKey(mapNamespaceAlias, v:key)') -endfunc - -" Resolve namespace alias -function! omni#cpp#namespaces#ResolveAlias(mapNamespaceAlias, szNamespace) - let szResult = a:szNamespace - " ::Ns1::Ns2::Ns3 => ['Ns1', 'Ns2', 'Ns3'] - let listNamespace = split(a:szNamespace, '::') - if len(listNamespace) - " szBeginPart = 'Ns1' - let szBeginPart = remove(listNamespace, 0) - - " Is 'Ns1' an alias ? - if has_key(a:mapNamespaceAlias, szBeginPart) - " Resolving alias 'Ns1' - " eg: Ns1 = NsResolved - let szResult = a:mapNamespaceAlias[szBeginPart] - " szEndPart = 'Ns2::Ns3' - let szEndPart = join(listNamespace, '::') - if szEndPart != '' - " Concatenation => szResult = 'NsResolved::Ns2::Ns3' - let szResult .= '::' . szEndPart - endif - - " If a:szNamespace starts with '::' we add '::' to the beginning - " of the result - if match(a:szNamespace, '^::')>=0 - let szResult = omni#cpp#utils#SimplifyScope('::' . szResult) - endif - endif - endif - return szResult -endfunc - -" Resolve namespace alias -function! s:ResolveAliasInNamespaceList(mapNamespaceAlias, listNamespaces) - call map(a:listNamespaces, 'omni#cpp#namespaces#ResolveAlias(a:mapNamespaceAlias, v:val)') -endfunc - -" Get namespaces used at the cursor postion in a vim buffer -" Note: The result depends on the current cursor position -" @return -" - List of namespace used in the reverse order -function! omni#cpp#namespaces#GetUsingNamespaces() - " We have to get local using namespace declarations - " We need the current cursor position and the position of the start of the - " current scope - - " We store the cursor position because searchpairpos() moves the cursor - let result = [] - let originalPos = getpos('.') - let origPos = originalPos[1:2] - - let stopPos = s:GetStopPositionForLocalSearch() - - let stopLine = stopPos[0] - let curPos = origPos - let lastLine = 0 - let nextStopLine = origPos[0] - while curPos !=[0,0] - let curPos = searchpos('\C}\|\(using\s\+namespace\)', 'bW',stopLine) - if curPos!=[0,0] && curPos[0]!=lastLine - let lastLine = curPos[0] - - let szLine = getline('.') - if origPos[0] == curPos[0] - " We get the line until cursor position - let szLine = szLine[:origPos[1]] - endif - - let szLine = omni#cpp#utils#GetCodeFromLine(szLine) - if match(szLine, '\Cusing\s\+namespace')<0 - " We found a '}' - let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) - else - " We get the namespace list from the line - let result = s:GetNamespaceListFromLine(szLine) + result - let nextStopLine = curPos[0] - endif - endif - endwhile - - " Setting the cursor to the original position - call setpos('.', originalPos) - - " 2) Now we can get all global using namespace declaration from the - " beginning of the file to nextStopLine - let result = omni#cpp#namespaces#GetListFromCurrentBuffer(nextStopLine) + result - - " Resolving alias in the namespace list - " TODO: For the next release - "let g:omni#cpp#namespaces#CacheAlias= s:GetNamespaceAliasMap() - "call s:ResolveAliasInNamespaceList(g:omni#cpp#namespaces#CacheAlias, result) - - return ['::'] + result -endfunc - -" Resolve a using namespace regarding the current context -" For each namespace used: -" - We get all possible contexts where the namespace -" can be define -" - We do a comparison test of each parent contexts with the current -" context list -" - If one and only one parent context is present in the -" current context list we add the namespace in the current -" context -" - If there is more than one of parent contexts in the -" current context the namespace is ambiguous -" @return -" - result item -" - kind = 0|1 -" - 0 = unresolved or error -" - 1 = resolved -" - value = resolved namespace -function! s:ResolveNamespace(namespace, mapCurrentContexts) - let result = {'kind':0, 'value': ''} - - " If the namespace is already resolved we add it in the list of - " current contexts - if match(a:namespace, '^::')>=0 - let result.kind = 1 - let result.value = a:namespace - return result - elseif match(a:namespace, '\w\+::\w\+')>=0 - let mapCurrentContextsTmp = copy(a:mapCurrentContexts) - let resolvedItem = {} - for nsTmp in split(a:namespace, '::') - let resolvedItem = s:ResolveNamespace(nsTmp, mapCurrentContextsTmp) - if resolvedItem.kind - " Note: We don't extend the map - let mapCurrentContextsTmp = {resolvedItem.value : 1} - else - break - endif - endfor - if resolvedItem!={} && resolvedItem.kind - let result.kind = 1 - let result.value = resolvedItem.value - endif - return result - endif - - " We get all possible parent contexts of this namespace - let listTagsOfNamespace = [] - if has_key(g:omni#cpp#namespaces#CacheResolve, a:namespace) - let listTagsOfNamespace = g:omni#cpp#namespaces#CacheResolve[a:namespace] - else - let listTagsOfNamespace = omni#common#utils#TagList('^'.a:namespace.'$') - let g:omni#cpp#namespaces#CacheResolve[a:namespace] = listTagsOfNamespace - endif - - if len(listTagsOfNamespace)==0 - return result - endif - call filter(listTagsOfNamespace, 'v:val.kind[0]=="n"') - - " We extract parent context from tags - " We use a map to avoid multiple entries - let mapContext = {} - for tagItem in listTagsOfNamespace - let szParentContext = omni#cpp#utils#ExtractScope(tagItem) - let mapContext[szParentContext] = 1 - endfor - let listParentContext = keys(mapContext) - - " Now for each parent context we test if the context is in the current - " contexts list - let listResolvedNamespace = [] - for szParentContext in listParentContext - if has_key(a:mapCurrentContexts, szParentContext) - call extend(listResolvedNamespace, [omni#cpp#utils#SimplifyScope(szParentContext.'::'.a:namespace)]) - endif - endfor - - " Now we know if the namespace is ambiguous or not - let len = len(listResolvedNamespace) - if len==1 - " Namespace resolved - let result.kind = 1 - let result.value = listResolvedNamespace[0] - elseif len > 1 - " Ambiguous namespace, possible matches are in listResolvedNamespace - else - " Other cases - endif - return result -endfunc - -" Resolve namespaces -"@return -" - List of resolved namespaces -function! omni#cpp#namespaces#ResolveAll(namespacesUsed) - - " We add the default context '::' - let contextOrder = 0 - let mapCurrentContexts = {} - - " For each namespace used: - " - We get all possible contexts where the namespace - " can be define - " - We do a comparison test of each parent contexts with the current - " context list - " - If one and only one parent context is present in the - " current context list we add the namespace in the current - " context - " - If there is more than one of parent contexts in the - " current context the namespace is ambiguous - for ns in a:namespacesUsed - let resolvedItem = s:ResolveNamespace(ns, mapCurrentContexts) - if resolvedItem.kind - let contextOrder+=1 - let mapCurrentContexts[resolvedItem.value] = contextOrder - endif - endfor - - " Build the list of current contexts from the map, we have to keep the - " order - let mapReorder = {} - for key in keys(mapCurrentContexts) - let mapReorder[ mapCurrentContexts[key] ] = key - endfor - let result = [] - for key in sort(keys(mapReorder)) - call extend(result, [mapReorder[key]]) - endfor - return result -endfunc - -" Build the context stack -function! s:BuildContextStack(namespaces, szCurrentScope) - let result = copy(a:namespaces) - if a:szCurrentScope != '::' - let tagItem = omni#cpp#utils#GetResolvedTagItem(a:namespaces, omni#cpp#utils#CreateTypeInfo(a:szCurrentScope)) - if has_key(tagItem, 'inherits') - let listBaseClass = omni#cpp#utils#GetClassInheritanceList(a:namespaces, omni#cpp#utils#CreateTypeInfo(a:szCurrentScope)) - let result = listBaseClass + result - elseif has_key(tagItem, 'kind') && index(['c', 's', 'u', 'n'], tagItem.kind[0])>=0 - call insert(result, omni#cpp#utils#ExtractTypeInfoFromTag(tagItem)) - endif - endif - return result -endfunc - -" Returns the class scope at the current position of the cursor -" @return a string that represents the class scope -" eg: ::NameSpace1::Class1 -" The returned string always starts with '::' -" Note: In term of performance it's the weak point of the script -function! s:GetClassScopeAtCursor() - " We store the cursor position because searchpairpos() moves the cursor - let originalPos = getpos('.') - let endPos = originalPos[1:2] - let listCode = [] - let result = {'namespaces': [], 'scope': ''} - - while endPos!=[0,0] - let endPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) - let szReStartPos = '[;{}]\|\%^' - let startPos = searchpairpos(szReStartPos, '', '{', 'bWn', g:omni#cpp#utils#expIgnoreComments) - - " If the file starts with a comment so the startPos can be [0,0] - " we change it to [1,1] - if startPos==[0,0] - let startPos = [1,1] - endif - - " Get lines backward from cursor position to last ; or { or } - " or when we are at the beginning of the file. - " We store lines in listCode - if endPos!=[0,0] - " We remove the last character which is a '{' - " We also remove starting { or } or ; if exits - let szCodeWithoutComments = substitute(omni#cpp#utils#GetCode(startPos, endPos)[:-2], '^[;{}]', '', 'g') - call insert(listCode, {'startLine' : startPos[0], 'code' : szCodeWithoutComments}) - endif - endwhile - " Setting the cursor to the original position - call setpos('.', originalPos) - - let listClassScope = [] - let bResolved = 0 - let startLine = 0 - " Now we can check in the list of code if there is a function - for code in listCode - " We get the name of the namespace, class, struct or union - " and we store it in listClassScope - let tokens = omni#cpp#tokenizer#Tokenize(code.code) - let bContinue=0 - let bAddNamespace = 0 - let state=0 - for token in tokens - if state==0 - if index(['namespace', 'class', 'struct', 'union'], token.value)>=0 - if token.value == 'namespace' - let bAddNamespace = 1 - endif - let state= 1 - " Maybe end of tokens - endif - elseif state==1 - if token.kind == 'cppWord' - " eg: namespace MyNs { class MyCl {}; } - " => listClassScope = [MyNs, MyCl] - call extend( listClassScope , [token.value] ) - - " Add the namespace in result - if bAddNamespace - call extend(result.namespaces, [token.value]) - let bAddNamespace = 0 - endif - - let bContinue=1 - break - endif - endif - endfor - if bContinue==1 - continue - endif - - " Simple test to check if we have a chance to find a - " class method - let aPos = matchend(code.code, '::\s*\~*\s*\w\+\s*(') - if aPos ==-1 - continue - endif - - let startLine = code.startLine - let listTmp = [] - " eg: 'void MyNamespace::MyClass::foo(' - " => tokens = ['MyClass', '::', 'MyNamespace', 'void'] - let tokens = reverse(omni#cpp#tokenizer#Tokenize(code.code[:aPos-1])[:-4]) - let state = 0 - " Reading tokens backward - for token in tokens - if state==0 - if token.kind=='cppWord' - call insert(listTmp, token.value) - let state=1 - endif - elseif state==1 - if token.value=='::' - let state=2 - else - break - endif - elseif state==2 - if token.kind=='cppWord' - call insert(listTmp, token.value) - let state=1 - else - break - endif - endif - endfor - - if len(listTmp) - if len(listClassScope) - let bResolved = 1 - " Merging class scopes - " eg: current class scope = 'MyNs::MyCl1' - " method class scope = 'MyCl1::MyCl2' - " If we add the method class scope to current class scope - " we'll have MyNs::MyCl1::MyCl1::MyCl2 => it's wrong - " we want MyNs::MyCl1::MyCl2 - let index = 0 - for methodClassScope in listTmp - if methodClassScope==listClassScope[-1] - let listTmp = listTmp[index+1:] - break - else - let index+=1 - endif - endfor - endif - call extend(listClassScope, listTmp) - break - endif - endfor - - let szClassScope = '::' - if len(listClassScope) - if bResolved - let szClassScope .= join(listClassScope, '::') - else - let szClassScope = join(listClassScope, '::') - - " The class scope is not resolved, we have to check using - " namespace declarations and search the class scope in each - " namespace - if startLine != 0 - let namespaces = ['::'] + omni#cpp#namespaces#GetListFromCurrentBuffer(startLine) - let namespaces = omni#cpp#namespaces#ResolveAll(namespaces) - let tagItem = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(szClassScope)) - if tagItem != {} - let szClassScope = omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) - endif - endif - endif - endif - - let result.scope = szClassScope - return result -endfunc - -" Get all contexts at the cursor position -function! omni#cpp#namespaces#GetContexts() - " Get the current class scope at the cursor, the result depends on the current cursor position - let scopeItem = s:GetClassScopeAtCursor() - let listUsingNamespace = copy(g:OmniCpp_DefaultNamespaces) - call extend(listUsingNamespace, scopeItem.namespaces) - if g:OmniCpp_NamespaceSearch && &filetype != 'c' - " Get namespaces used in the file until the cursor position - let listUsingNamespace = omni#cpp#namespaces#GetUsingNamespaces() + listUsingNamespace - " Resolving namespaces, removing ambiguous namespaces - let namespaces = omni#cpp#namespaces#ResolveAll(listUsingNamespace) - else - let namespaces = ['::'] + listUsingNamespace - endif - call reverse(namespaces) - - " Building context stack from namespaces and the current class scope - return s:BuildContextStack(namespaces, scopeItem.scope) -endfunc diff --git a/.vim/autoload/omni/cpp/settings.vim b/.vim/autoload/omni/cpp/settings.vim deleted file mode 100644 index 6683d3a..0000000 --- a/.vim/autoload/omni/cpp/settings.vim +++ /dev/null @@ -1,96 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -function! omni#cpp#settings#Init() - " Global scope search on/off - " 0 = disabled - " 1 = enabled - if !exists('g:OmniCpp_GlobalScopeSearch') - let g:OmniCpp_GlobalScopeSearch = 1 - endif - - " Sets the namespace search method - " 0 = disabled - " 1 = search namespaces in the current file - " 2 = search namespaces in the current file and included files - if !exists('g:OmniCpp_NamespaceSearch') - let g:OmniCpp_NamespaceSearch = 1 - endif - - " Set the class scope completion mode - " 0 = auto - " 1 = show all members (static, public, protected and private) - if !exists('g:OmniCpp_DisplayMode') - let g:OmniCpp_DisplayMode = 0 - endif - - " Set if the scope is displayed in the abbr column of the popup - " 0 = no - " 1 = yes - if !exists('g:OmniCpp_ShowScopeInAbbr') - let g:OmniCpp_ShowScopeInAbbr = 0 - endif - - " Set if the function prototype is displayed in the abbr column of the popup - " 0 = no - " 1 = yes - if !exists('g:OmniCpp_ShowPrototypeInAbbr') - let g:OmniCpp_ShowPrototypeInAbbr = 0 - endif - - " Set if the access (+,#,-) is displayed - " 0 = no - " 1 = yes - if !exists('g:OmniCpp_ShowAccess') - let g:OmniCpp_ShowAccess = 1 - endif - - " Set the list of default namespaces - " eg: ['std'] - if !exists('g:OmniCpp_DefaultNamespaces') - let g:OmniCpp_DefaultNamespaces = [] - endif - - " Set MayComplete to '.' - " 0 = disabled - " 1 = enabled - " default = 1 - if !exists('g:OmniCpp_MayCompleteDot') - let g:OmniCpp_MayCompleteDot = 1 - endif - - " Set MayComplete to '->' - " 0 = disabled - " 1 = enabled - " default = 1 - if !exists('g:OmniCpp_MayCompleteArrow') - let g:OmniCpp_MayCompleteArrow = 1 - endif - - " Set MayComplete to dot - " 0 = disabled - " 1 = enabled - " default = 0 - if !exists('g:OmniCpp_MayCompleteScope') - let g:OmniCpp_MayCompleteScope = 0 - endif - - " When completeopt does not contain longest option, this setting - " controls the behaviour of the popup menu selection when starting the completion - " 0 = don't select first item - " 1 = select first item (inserting it to the text) - " 2 = select first item (without inserting it to the text) - " default = 0 - if !exists('g:OmniCpp_SelectFirstItem') - let g:OmniCpp_SelectFirstItem= 0 - endif - - " Use local search function for variable definitions - " 0 = use standard vim search function - " 1 = use local search function - " default = 0 - if !exists('g:OmniCpp_LocalSearchDecl') - let g:OmniCpp_LocalSearchDecl= 0 - endif -endfunc diff --git a/.vim/autoload/omni/cpp/tokenizer.vim b/.vim/autoload/omni/cpp/tokenizer.vim deleted file mode 100644 index 16e0be2..0000000 --- a/.vim/autoload/omni/cpp/tokenizer.vim +++ /dev/null @@ -1,93 +0,0 @@ -" Description: Omni completion tokenizer -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 -" TODO: Generic behaviour for Tokenize() - -" From the C++ BNF -let s:cppKeyword = ['asm', 'auto', 'bool', 'break', 'case', 'catch', 'char', 'class', 'const', 'const_cast', 'continue', 'default', 'delete', 'do', 'double', 'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern', 'false', 'float', 'for', 'friend', 'goto', 'if', 'inline', 'int', 'long', 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', 'register', 'reinterpret_cast', 'return', 'short', 'signed', 'sizeof', 'static', 'static_cast', 'struct', 'switch', 'template', 'this', 'throw', 'true', 'try', 'typedef', 'typeid', 'typename', 'union', 'unsigned', 'using', 'virtual', 'void', 'volatile', 'wchar_t', 'while', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'] - -let s:reCppKeyword = '\C\<'.join(s:cppKeyword, '\>\|\<').'\>' - -" The order of items in this list is very important because we use this list to build a regular -" expression (see below) for tokenization -let s:cppOperatorPunctuator = ['->*', '->', '--', '-=', '-', '!=', '!', '##', '#', '%:%:', '%=', '%>', '%:', '%', '&&', '&=', '&', '(', ')', '*=', '*', ',', '...', '.*', '.', '/=', '/', '::', ':>', ':', ';', '?', '[', ']', '^=', '^', '{', '||', '|=', '|', '}', '~', '++', '+=', '+', '<<=', '<%', '<:', '<<', '<=', '<', '==', '=', '>>=', '>>', '>=', '>'] - -" We build the regexp for the tokenizer -let s:reCComment = '\/\*\|\*\/' -let s:reCppComment = '\/\/' -let s:reComment = s:reCComment.'\|'.s:reCppComment -let s:reCppOperatorOrPunctuator = escape(join(s:cppOperatorPunctuator, '\|'), '*./^~[]') - - -" Tokenize a c++ code -" a token is dictionary where keys are: -" - kind = cppKeyword|cppWord|cppOperatorPunctuator|unknown|cComment|cppComment|cppDigit -" - value = 'something' -" Note: a cppWord is any word that is not a cpp keyword -function! omni#cpp#tokenizer#Tokenize(szCode) - let result = [] - - " The regexp to find a token, a token is a keyword, word or - " c++ operator or punctuator. To work properly we have to put - " spaces and tabs to our regexp. - let reTokenSearch = '\(\w\+\)\|\s\+\|'.s:reComment.'\|'.s:reCppOperatorOrPunctuator - " eg: 'using namespace std;' - " ^ ^ - " start=0 end=5 - let startPos = 0 - let endPos = matchend(a:szCode, reTokenSearch) - let len = endPos-startPos - while endPos!=-1 - " eg: 'using namespace std;' - " ^ ^ - " start=0 end=5 - " token = 'using' - " We also remove space and tabs - let token = substitute(strpart(a:szCode, startPos, len), '\s', '', 'g') - - " eg: 'using namespace std;' - " ^ ^ - " start=5 end=15 - let startPos = endPos - let endPos = matchend(a:szCode, reTokenSearch, startPos) - let len = endPos-startPos - - " It the token is empty we continue - if token=='' - continue - endif - - " Building the token - let resultToken = {'kind' : 'unknown', 'value' : token} - - " Classify the token - if token =~ '^\d\+' - " It's a digit - let resultToken.kind = 'cppDigit' - elseif token=~'^\w\+$' - " It's a word - let resultToken.kind = 'cppWord' - - " But maybe it's a c++ keyword - if match(token, s:reCppKeyword)>=0 - let resultToken.kind = 'cppKeyword' - endif - else - if match(token, s:reComment)>=0 - if index(['/*','*/'],token)>=0 - let resultToken.kind = 'cComment' - else - let resultToken.kind = 'cppComment' - endif - else - " It's an operator - let resultToken.kind = 'cppOperatorPunctuator' - endif - endif - - " We have our token, let's add it to the result list - call extend(result, [resultToken]) - endwhile - - return result -endfunc diff --git a/.vim/autoload/omni/cpp/utils.vim b/.vim/autoload/omni/cpp/utils.vim deleted file mode 100644 index 5d74d34..0000000 --- a/.vim/autoload/omni/cpp/utils.vim +++ /dev/null @@ -1,587 +0,0 @@ -" Description: Omni completion script for cpp files -" Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 - -let g:omni#cpp#utils#CACHE_TAG_INHERITS = {} -let g:omni#cpp#utils#szFilterGlobalScope = "(!has_key(v:val, 'class') && !has_key(v:val, 'struct') && !has_key(v:val, 'union') && !has_key(v:val, 'namespace')" -let g:omni#cpp#utils#szFilterGlobalScope .= "&& (!has_key(v:val, 'enum') || (has_key(v:val, 'enum') && v:val.enum =~ '^\\w\\+$')))" - -" Expression used to ignore comments -" Note: this expression drop drastically the performance -"let omni#cpp#utils#expIgnoreComments = 'match(synIDattr(synID(line("."), col("."), 1), "name"), '\CcComment')!=-1' -" This one is faster but not really good for C comments -let omni#cpp#utils#reIgnoreComment = escape('\/\/\|\/\*\|\*\/', '*/\') -let omni#cpp#utils#expIgnoreComments = 'getline(".") =~ g:omni#cpp#utils#reIgnoreComment' - -" Characters to escape in a filename for vimgrep -"TODO: Find more characters to escape -let omni#cpp#utils#szEscapedCharacters = ' %#' - -" Resolve the path of the file -" TODO: absolute file path -function! omni#cpp#utils#ResolveFilePath(szFile) - let result = '' - let listPath = split(globpath(&path, a:szFile), "\n") - if len(listPath) - let result = listPath[0] - endif - return simplify(result) -endfunc - -" Get code without comments and with empty strings -" szSingleLine must not have carriage return -function! omni#cpp#utils#GetCodeFromLine(szSingleLine) - " We set all strings to empty strings, it's safer for - " the next of the process - let szResult = substitute(a:szSingleLine, '".*"', '""', 'g') - - " Removing c++ comments, we can use the pattern ".*" because - " we are modifying a line - let szResult = substitute(szResult, '\/\/.*', '', 'g') - - " Now we have the entire code in one line and we can remove C comments - return s:RemoveCComments(szResult) -endfunc - -" Remove C comments on a line -function! s:RemoveCComments(szLine) - let result = a:szLine - - " We have to match the first '/*' and first '*/' - let startCmt = match(result, '\/\*') - let endCmt = match(result, '\*\/') - while startCmt!=-1 && endCmt!=-1 && startCmt<endCmt - if startCmt>0 - let result = result[ : startCmt-1 ] . result[ endCmt+2 : ] - else - " Case where '/*' is at the start of the line - let result = result[ endCmt+2 : ] - endif - let startCmt = match(result, '\/\*') - let endCmt = match(result, '\*\/') - endwhile - return result -endfunc - -" Get a c++ code from current buffer from [lineStart, colStart] to -" [lineEnd, colEnd] without c++ and c comments, without end of line -" and with empty strings if any -" @return a string -function! omni#cpp#utils#GetCode(posStart, posEnd) - let posStart = a:posStart - let posEnd = a:posEnd - if a:posStart[0]>a:posEnd[0] - let posStart = a:posEnd - let posEnd = a:posStart - elseif a:posStart[0]==a:posEnd[0] && a:posStart[1]>a:posEnd[1] - let posStart = a:posEnd - let posEnd = a:posStart - endif - - " Getting the lines - let lines = getline(posStart[0], posEnd[0]) - let lenLines = len(lines) - - " Formatting the result - let result = '' - if lenLines==1 - let sStart = posStart[1]-1 - let sEnd = posEnd[1]-1 - let line = lines[0] - let lenLastLine = strlen(line) - let sEnd = (sEnd>lenLastLine)?lenLastLine : sEnd - if sStart >= 0 - let result = omni#cpp#utils#GetCodeFromLine(line[ sStart : sEnd ]) - endif - elseif lenLines>1 - let sStart = posStart[1]-1 - let sEnd = posEnd[1]-1 - let lenLastLine = strlen(lines[-1]) - let sEnd = (sEnd>lenLastLine)?lenLastLine : sEnd - if sStart >= 0 - let lines[0] = lines[0][ sStart : ] - let lines[-1] = lines[-1][ : sEnd ] - for aLine in lines - let result = result . omni#cpp#utils#GetCodeFromLine(aLine)." " - endfor - let result = result[:-2] - endif - endif - - " Now we have the entire code in one line and we can remove C comments - return s:RemoveCComments(result) -endfunc - -" Extract the scope (context) of a tag item -" eg: ::MyNamespace -" @return a string of the scope. a scope from tag always starts with '::' -function! omni#cpp#utils#ExtractScope(tagItem) - let listKindScope = ['class', 'struct', 'union', 'namespace', 'enum'] - let szResult = '::' - for scope in listKindScope - if has_key(a:tagItem, scope) - let szResult = szResult . a:tagItem[scope] - break - endif - endfor - return szResult -endfunc - -" Simplify scope string, remove consecutive '::' if any -function! omni#cpp#utils#SimplifyScope(szScope) - let szResult = substitute(a:szScope, '\(::\)\+', '::', 'g') - if szResult=='::' - return szResult - else - return substitute(szResult, '::$', '', 'g') - endif -endfunc - -" Check if the cursor is in comment -function! omni#cpp#utils#IsCursorInCommentOrString() - return match(synIDattr(synID(line("."), col(".")-1, 1), "name"), '\C\<cComment\|\<cCppString\|\<cIncluded')>=0 -endfunc - -" Tokenize the current instruction until the cursor position. -" @return list of tokens -function! omni#cpp#utils#TokenizeCurrentInstruction(...) - let szAppendText = '' - if a:0>0 - let szAppendText = a:1 - endif - - let startPos = searchpos('[;{}]\|\%^', 'bWn') - let curPos = getpos('.')[1:2] - " We don't want the character under the cursor - let column = curPos[1]-1 - let curPos[1] = (column<1)?1:column - return omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCode(startPos, curPos)[1:] . szAppendText) -endfunc - -" Tokenize the current instruction until the word under the cursor. -" @return list of tokens -function! omni#cpp#utils#TokenizeCurrentInstructionUntilWord() - let startPos = searchpos('[;{}]\|\%^', 'bWn') - - " Saving the current cursor pos - let originalPos = getpos('.') - - " We go at the end of the word - execute 'normal gee' - let curPos = getpos('.')[1:2] - - " Restoring the original cursor pos - call setpos('.', originalPos) - - let szCode = omni#cpp#utils#GetCode(startPos, curPos)[1:] - return omni#cpp#tokenizer#Tokenize(szCode) -endfunc - -" Build parenthesis groups -" add a new key 'group' in the token -" where value is the group number of the parenthesis -" eg: (void*)(MyClass*) -" group1 group0 -" if a parenthesis is unresolved the group id is -1 -" @return a copy of a:tokens with parenthesis group -function! omni#cpp#utils#BuildParenthesisGroups(tokens) - let tokens = copy(a:tokens) - let kinds = {'(': '()', ')' : '()', '[' : '[]', ']' : '[]', '<' : '<>', '>' : '<>', '{': '{}', '}': '{}'} - let unresolved = {'()' : [], '[]': [], '<>' : [], '{}' : []} - let groupId = 0 - - " Note: we build paren group in a backward way - " because we can often have parenthesis unbalanced - " instruction - " eg: doSomething(_member.get()-> - for token in reverse(tokens) - if index([')', ']', '>', '}'], token.value)>=0 - let token['group'] = groupId - call extend(unresolved[kinds[token.value]], [token]) - let groupId+=1 - elseif index(['(', '[', '<', '{'], token.value)>=0 - if len(unresolved[kinds[token.value]]) - let tokenResolved = remove(unresolved[kinds[token.value]], -1) - let token['group'] = tokenResolved.group - else - let token['group'] = -1 - endif - endif - endfor - - return reverse(tokens) -endfunc - -" Determine if tokens represent a C cast -" @return -" - itemCast -" - itemCppCast -" - itemVariable -" - itemThis -function! omni#cpp#utils#GetCastType(tokens) - " Note: a:tokens is not modified - let tokens = omni#cpp#utils#SimplifyParenthesis(omni#cpp#utils#BuildParenthesisGroups(a:tokens)) - - if tokens[0].value == '(' - return 'itemCast' - elseif index(['static_cast', 'dynamic_cast', 'reinterpret_cast', 'const_cast'], tokens[0].value)>=0 - return 'itemCppCast' - else - for token in tokens - if token.value=='this' - return 'itemThis' - endif - endfor - return 'itemVariable' - endif -endfunc - -" Remove useless parenthesis -function! omni#cpp#utils#SimplifyParenthesis(tokens) - "Note: a:tokens is not modified - let tokens = a:tokens - " We remove useless parenthesis eg: (((MyClass))) - if len(tokens)>2 - while tokens[0].value=='(' && tokens[-1].value==')' && tokens[0].group==tokens[-1].group - let tokens = tokens[1:-2] - endwhile - endif - return tokens -endfunc - -" Function create a type info -function! omni#cpp#utils#CreateTypeInfo(param) - let type = type(a:param) - return {'type': type, 'value':a:param} -endfunc - -" Extract type info from a tag item -" eg: ::MyNamespace::MyClass -function! omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) - let szTypeInfo = omni#cpp#utils#ExtractScope(a:tagItem) . '::' . substitute(a:tagItem.name, '.*::', '', 'g') - return omni#cpp#utils#SimplifyScope(szTypeInfo) -endfunc - -" Build a class inheritance list -function! omni#cpp#utils#GetClassInheritanceList(namespaces, typeInfo) - let result = [] - for tagItem in omni#cpp#utils#GetResolvedTags(a:namespaces, a:typeInfo) - call extend(result, [omni#cpp#utils#ExtractTypeInfoFromTag(tagItem)]) - endfor - return result -endfunc - -" Get class inheritance list where items in the list are tag items. -" TODO: Verify inheritance order -function! omni#cpp#utils#GetResolvedTags(namespaces, typeInfo) - let result = [] - let tagItem = omni#cpp#utils#GetResolvedTagItem(a:namespaces, a:typeInfo) - if tagItem!={} - let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) - if has_key(g:omni#cpp#utils#CACHE_TAG_INHERITS, szTypeInfo) - let result = g:omni#cpp#utils#CACHE_TAG_INHERITS[szTypeInfo] - else - call extend(result, [tagItem]) - if has_key(tagItem, 'inherits') - for baseClassTypeInfo in split(tagItem.inherits, ',') - let namespaces = [omni#cpp#utils#ExtractScope(tagItem), '::'] - call extend(result, omni#cpp#utils#GetResolvedTags(namespaces, omni#cpp#utils#CreateTypeInfo(baseClassTypeInfo))) - endfor - endif - let g:omni#cpp#utils#CACHE_TAG_INHERITS[szTypeInfo] = result - endif - endif - return result -endfunc - -" Get a tag item after a scope resolution and typedef resolution -function! omni#cpp#utils#GetResolvedTagItem(namespaces, typeInfo) - let typeInfo = {} - if type(a:typeInfo) == 1 - let typeInfo = omni#cpp#utils#CreateTypeInfo(a:typeInfo) - else - let typeInfo = a:typeInfo - endif - - let result = {} - if !omni#cpp#utils#IsTypeInfoValid(typeInfo) - return result - endif - - " Unnamed type case eg: '1::2' - if typeInfo.type == 4 - " Here there is no typedef or namespace to resolve, the tagInfo.value is a tag item - " representing a variable ('v') a member ('m') or a typedef ('t') and the typename is - " always in global scope - return typeInfo.value - endif - - " Named type case eg: 'MyNamespace::MyClass' - let szTypeInfo = omni#cpp#utils#GetTypeInfoString(typeInfo) - - " Resolving namespace alias - " TODO: For the next release - "let szTypeInfo = omni#cpp#namespaces#ResolveAlias(g:omni#cpp#namespaces#CacheAlias, szTypeInfo) - - if szTypeInfo=='::' - return result - endif - - " We can only get members of class, struct, union and namespace - let szTagFilter = "index(['c', 's', 'u', 'n', 't'], v:val.kind[0])>=0" - let szTagQuery = szTypeInfo - - if s:IsTypeInfoResolved(szTypeInfo) - " The type info is already resolved, we remove the starting '::' - let szTagQuery = substitute(szTypeInfo, '^::', '', 'g') - if len(split(szTagQuery, '::'))==1 - " eg: ::MyClass - " Here we have to get tags that have no parent scope - " That's why we change the szTagFilter - let szTagFilter .= '&& ' . g:omni#cpp#utils#szFilterGlobalScope - let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') - call filter(tagList, szTagFilter) - if len(tagList) - let result = tagList[0] - endif - else - " eg: ::MyNamespace::MyClass - let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') - call filter(tagList, szTagFilter) - - if len(tagList) - let result = tagList[0] - endif - endif - else - " The type is not resolved - let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') - call filter(tagList, szTagFilter) - - if len(tagList) - " Resolving scope (namespace, nested class etc...) - let szScopeOfTypeInfo = s:ExtractScopeFromTypeInfo(szTypeInfo) - if s:IsTypeInfoResolved(szTypeInfo) - let result = s:GetTagOfSameScope(tagList, szScopeOfTypeInfo) - else - " For each namespace of the namespace list we try to get a tag - " that can be in the same scope - if g:OmniCpp_NamespaceSearch && &filetype != 'c' - for scope in a:namespaces - let szTmpScope = omni#cpp#utils#SimplifyScope(scope.'::'.szScopeOfTypeInfo) - let result = s:GetTagOfSameScope(tagList, szTmpScope) - if result!={} - break - endif - endfor - else - let szTmpScope = omni#cpp#utils#SimplifyScope('::'.szScopeOfTypeInfo) - let result = s:GetTagOfSameScope(tagList, szTmpScope) - endif - endif - endif - endif - - if result!={} - " We have our tagItem but maybe it's a typedef or an unnamed type - if result.kind[0]=='t' - " Here we can have a typedef to another typedef, a class, struct, union etc - " but we can also have a typedef to an unnamed type, in that - " case the result contains a 'typeref' key - let namespaces = [omni#cpp#utils#ExtractScope(result), '::'] - if has_key(result, 'typeref') - let result = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(result)) - else - let szCmd = omni#cpp#utils#ExtractCmdFromTagItem(result) - let szCode = substitute(omni#cpp#utils#GetCodeFromLine(szCmd), '\C\<'.result.name.'\>.*', '', 'g') - let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTokens(omni#cpp#tokenizer#Tokenize(szCode)) - let result = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(szTypeInfo)) - " TODO: Namespace resolution for result - endif - endif - endif - - return result -endfunc - -" Returns if the type info is valid -" @return -" - 1 if valid -" - 0 otherwise -function! omni#cpp#utils#IsTypeInfoValid(typeInfo) - if a:typeInfo=={} - return 0 - else - if a:typeInfo.type == 1 && a:typeInfo.value=='' - " String case - return 0 - elseif a:typeInfo.type == 4 && a:typeInfo.value=={} - " Dictionary case - return 0 - endif - endif - return 1 -endfunc - -" Get the string of the type info -function! omni#cpp#utils#GetTypeInfoString(typeInfo) - if a:typeInfo.type == 1 - return a:typeInfo.value - else - return substitute(a:typeInfo.value.typeref, '^\w\+:', '', 'g') - endif -endfunc - -" A resolved type info starts with '::' -" @return -" - 1 if type info starts with '::' -" - 0 otherwise -function! s:IsTypeInfoResolved(szTypeInfo) - return match(a:szTypeInfo, '^::')!=-1 -endfunc - -" A returned type info's scope may not have the global namespace '::' -" eg: '::NameSpace1::NameSpace2::MyClass' => '::NameSpace1::NameSpace2' -" 'NameSpace1::NameSpace2::MyClass' => 'NameSpace1::NameSpace2' -function! s:ExtractScopeFromTypeInfo(szTypeInfo) - let szScope = substitute(a:szTypeInfo, '\w\+$', '', 'g') - if szScope =='::' - return szScope - else - return substitute(szScope, '::$', '', 'g') - endif -endfunc - -" @return -" - the tag with the same scope -" - {} otherwise -function! s:GetTagOfSameScope(listTags, szScopeToMatch) - for tagItem in a:listTags - let szScopeOfTag = omni#cpp#utils#ExtractScope(tagItem) - if szScopeOfTag == a:szScopeToMatch - return tagItem - endif - endfor - return {} -endfunc - -" Extract the cmd of a tag item without regexp -function! omni#cpp#utils#ExtractCmdFromTagItem(tagItem) - let line = a:tagItem.cmd - let re = '\(\/\^\)\|\(\$\/\)' - if match(line, re)!=-1 - let line = substitute(line, re, '', 'g') - return line - else - " TODO: the cmd is a line number - return '' - endif -endfunc - -" Extract type from tokens. -" eg: examples of tokens format -" 'const MyClass&' -" 'const map < int, int >&' -" 'MyNs::MyClass' -" '::MyClass**' -" 'MyClass a, *b = NULL, c[1] = {}; -" 'hello(MyClass a, MyClass* b' -" @return the type info string eg: ::std::map -" can be empty -function! omni#cpp#utils#ExtractTypeInfoFromTokens(tokens) - let szResult = '' - let state = 0 - - let tokens = omni#cpp#utils#BuildParenthesisGroups(a:tokens) - - " If there is an unbalanced parenthesis we are in a parameter list - let bParameterList = 0 - for token in tokens - if token.value == '(' && token.group==-1 - let bParameterList = 1 - break - endif - endfor - - if bParameterList - let tokens = reverse(tokens) - let state = 0 - let parenGroup = -1 - for token in tokens - if state==0 - if token.value=='>' - let parenGroup = token.group - let state=1 - elseif token.kind == 'cppWord' - let szResult = token.value.szResult - let state=2 - elseif index(['*', '&'], token.value)<0 - break - endif - elseif state==1 - if token.value=='<' && token.group==parenGroup - let state=0 - endif - elseif state==2 - if token.value=='::' - let szResult = token.value.szResult - let state=3 - else - break - endif - elseif state==3 - if token.kind == 'cppWord' - let szResult = token.value.szResult - let state=2 - else - break - endif - endif - endfor - return szResult - endif - - for token in tokens - if state==0 - if token.value == '::' - let szResult .= token.value - let state = 1 - elseif token.kind == 'cppWord' - let szResult .= token.value - let state = 2 - " Maybe end of token - endif - elseif state==1 - if token.kind == 'cppWord' - let szResult .= token.value - let state = 2 - " Maybe end of token - else - break - endif - elseif state==2 - if token.value == '::' - let szResult .= token.value - let state = 1 - else - break - endif - endif - endfor - return szResult -endfunc - -" Get the preview window string -function! omni#cpp#utils#GetPreviewWindowStringFromTagItem(tagItem) - let szResult = '' - - let szResult .= 'name: '.a:tagItem.name."\n" - for tagKey in keys(a:tagItem) - if index(['name', 'static'], tagKey)>=0 - continue - endif - let szResult .= tagKey.': '.a:tagItem[tagKey]."\n" - endfor - - return substitute(szResult, "\n$", '', 'g') -endfunc diff --git a/.vim/autoload/pathogen.vim b/.vim/autoload/pathogen.vim deleted file mode 100644 index ff7dba3..0000000 --- a/.vim/autoload/pathogen.vim +++ /dev/null @@ -1,139 +0,0 @@ -" pathogen.vim - path option manipulation -" Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Version: 1.2 - -" Install in ~/.vim/autoload (or ~\vimfiles\autoload). -" -" API is documented below. - -if exists("g:loaded_pathogen") || &cp - finish -endif -let g:loaded_pathogen = 1 - -" Split a path into a list. -function! pathogen#split(path) abort " {{{1 - if type(a:path) == type([]) | return a:path | endif - let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,') - return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")') -endfunction " }}}1 - -" Convert a list to a path. -function! pathogen#join(...) abort " {{{1 - if type(a:1) == type(1) && a:1 - let i = 1 - let space = ' ' - else - let i = 0 - let space = '' - endif - let path = "" - while i < a:0 - if type(a:000[i]) == type([]) - let list = a:000[i] - let j = 0 - while j < len(list) - let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g') - let path .= ',' . escaped - let j += 1 - endwhile - else - let path .= "," . a:000[i] - endif - let i += 1 - endwhile - return substitute(path,'^,','','') -endfunction " }}}1 - -" Convert a list to a path with escaped spaces for 'path', 'tag', etc. -function! pathogen#legacyjoin(...) abort " {{{1 - return call('pathogen#join',[1] + a:000) -endfunction " }}}1 - -" Remove duplicates from a list. -function! pathogen#uniq(list) abort " {{{1 - let i = 0 - let seen = {} - while i < len(a:list) - if has_key(seen,a:list[i]) - call remove(a:list,i) - else - let seen[a:list[i]] = 1 - let i += 1 - endif - endwhile - return a:list -endfunction " }}}1 - -" Returns a hash indicating which filetype features are enabled. -function! pathogen#filetype() abort " {{{1 - redir => output - silent filetype - redir END - let result = {} - let result.detection = match(output,'detection:ON') >= 0 - let result.indent = match(output,'indent:ON') >= 0 - let result.plugin = match(output,'plugin:ON') >= 0 - return result -endfunction " }}}1 - -" \ on Windows unless shellslash is set, / everywhere else. -function! pathogen#separator() abort " {{{1 - return !exists("+shellslash") || &shellslash ? '/' : '\' -endfunction " }}}1 - -" Convenience wrapper around glob() which returns a list. -function! pathogen#glob(pattern) abort " {{{1 - let files = split(glob(a:pattern),"\n") - return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")') -endfunction "}}}1 - -" Like pathogen#glob(), only limit the results to directories. -function! pathogen#glob_directories(pattern) abort " {{{1 - return filter(pathogen#glob(a:pattern),'isdirectory(v:val)') -endfunction "}}}1 - -" Prepend all subdirectories of path to the rtp, and append all after -" directories in those subdirectories. -function! pathogen#runtime_prepend_subdirectories(path) " {{{1 - let sep = pathogen#separator() - let before = pathogen#glob_directories(a:path.sep."*[^~]") - let after = pathogen#glob_directories(a:path.sep."*[^~]".sep."after") - let rtp = pathogen#split(&rtp) - let path = expand(a:path) - call filter(rtp,'v:val[0:strlen(path)-1] !=# path') - let &rtp = pathogen#join(pathogen#uniq(before + rtp + after)) - return &rtp -endfunction " }}}1 - -" For each directory in rtp, check for a subdirectory named dir. If it -" exists, add all subdirectories of that subdirectory to the rtp, immediately -" after the original directory. If no argument is given, 'bundle' is used. -" Repeated calls with the same arguments are ignored. -function! pathogen#runtime_append_all_bundles(...) " {{{1 - let sep = pathogen#separator() - let name = a:0 ? a:1 : 'bundle' - let list = [] - for dir in pathogen#split(&rtp) - if dir =~# '\<after$' - let list += pathogen#glob_directories(substitute(dir,'after$',name.sep.'*[^~]'.sep.'after','')) + [dir] - else - let list += [dir] + pathogen#glob_directories(dir.sep.name.sep.'*[^~]') - endif - endfor - let &rtp = pathogen#join(pathogen#uniq(list)) - return 1 -endfunction - -" }}}1 - -" Invoke :helptags on all non-$VIM doc directories in runtimepath. -function! pathogen#helptags() " {{{1 - for dir in pathogen#split(&rtp) - if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags')) - helptags `=dir.'/doc'` - endif - endfor -endfunction " }}}1 - -" vim:set ft=vim ts=8 sw=2 sts=2: diff --git a/.vim/bundle/gundo.vim/.hg/00changelog.i b/.vim/bundle/gundo.vim/.hg/00changelog.i Binary files differdeleted file mode 100644 index d3a8311..0000000 --- a/.vim/bundle/gundo.vim/.hg/00changelog.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/branch b/.vim/bundle/gundo.vim/.hg/branch deleted file mode 100644 index 4ad96d5..0000000 --- a/.vim/bundle/gundo.vim/.hg/branch +++ /dev/null @@ -1 +0,0 @@ -default diff --git a/.vim/bundle/gundo.vim/.hg/branchheads.cache b/.vim/bundle/gundo.vim/.hg/branchheads.cache deleted file mode 100644 index d2ce2b6..0000000 --- a/.vim/bundle/gundo.vim/.hg/branchheads.cache +++ /dev/null @@ -1,2 +0,0 @@ -40049e1b235d68d8d4e35d3f21bab89fd39fbc1a 36 -40049e1b235d68d8d4e35d3f21bab89fd39fbc1a default diff --git a/.vim/bundle/gundo.vim/.hg/dirstate b/.vim/bundle/gundo.vim/.hg/dirstate Binary files differdeleted file mode 100644 index 4cd2e90..0000000 --- a/.vim/bundle/gundo.vim/.hg/dirstate +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/hgrc b/.vim/bundle/gundo.vim/.hg/hgrc deleted file mode 100644 index 9e0829e..0000000 --- a/.vim/bundle/gundo.vim/.hg/hgrc +++ /dev/null @@ -1,2 +0,0 @@ -[paths] -default = http://bitbucket.org/sjl/gundo.vim diff --git a/.vim/bundle/gundo.vim/.hg/requires b/.vim/bundle/gundo.vim/.hg/requires deleted file mode 100644 index 5175383..0000000 --- a/.vim/bundle/gundo.vim/.hg/requires +++ /dev/null @@ -1,3 +0,0 @@ -revlogv1 -store -fncache diff --git a/.vim/bundle/gundo.vim/.hg/store/00changelog.i b/.vim/bundle/gundo.vim/.hg/store/00changelog.i Binary files differdeleted file mode 100644 index 2e446d0..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/00changelog.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/00manifest.i b/.vim/bundle/gundo.vim/.hg/store/00manifest.i Binary files differdeleted file mode 100644 index 444bbb1..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/00manifest.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/data/.hgignore.i b/.vim/bundle/gundo.vim/.hg/store/data/.hgignore.i Binary files differdeleted file mode 100644 index 0eb9036..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/data/.hgignore.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/data/.hgtags.i b/.vim/bundle/gundo.vim/.hg/store/data/.hgtags.i Binary files differdeleted file mode 100644 index 7b958a5..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/data/.hgtags.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/data/_r_e_a_d_m_e.markdown.i b/.vim/bundle/gundo.vim/.hg/store/data/_r_e_a_d_m_e.markdown.i Binary files differdeleted file mode 100644 index ef8a1d4..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/data/_r_e_a_d_m_e.markdown.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/data/doc/gundo.txt.i b/.vim/bundle/gundo.vim/.hg/store/data/doc/gundo.txt.i Binary files differdeleted file mode 100644 index 2ef255c..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/data/doc/gundo.txt.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/data/plugin/gundo.vim.i b/.vim/bundle/gundo.vim/.hg/store/data/plugin/gundo.vim.i Binary files differdeleted file mode 100644 index 9f8f1df..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/data/plugin/gundo.vim.i +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/store/fncache b/.vim/bundle/gundo.vim/.hg/store/fncache deleted file mode 100644 index 3aa89ae..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/fncache +++ /dev/null @@ -1,5 +0,0 @@ -data/.hgignore.i -data/.hgtags.i -data/README.markdown.i -data/doc/gundo.txt.i -data/plugin/gundo.vim.i diff --git a/.vim/bundle/gundo.vim/.hg/store/undo b/.vim/bundle/gundo.vim/.hg/store/undo Binary files differdeleted file mode 100644 index 20f94ae..0000000 --- a/.vim/bundle/gundo.vim/.hg/store/undo +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hg/tags.cache b/.vim/bundle/gundo.vim/.hg/tags.cache deleted file mode 100644 index 1f51c3d..0000000 --- a/.vim/bundle/gundo.vim/.hg/tags.cache +++ /dev/null @@ -1,4 +0,0 @@ -36 40049e1b235d68d8d4e35d3f21bab89fd39fbc1a e2c49b93bf7f235e769a8b5cfae330dc2edb8180 - -4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 semver -4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 v0.8.0 diff --git a/.vim/bundle/gundo.vim/.hg/undo.branch b/.vim/bundle/gundo.vim/.hg/undo.branch deleted file mode 100644 index 331d858..0000000 --- a/.vim/bundle/gundo.vim/.hg/undo.branch +++ /dev/null @@ -1 +0,0 @@ -default
\ No newline at end of file diff --git a/.vim/bundle/gundo.vim/.hg/undo.dirstate b/.vim/bundle/gundo.vim/.hg/undo.dirstate deleted file mode 100644 index e69de29..0000000 --- a/.vim/bundle/gundo.vim/.hg/undo.dirstate +++ /dev/null diff --git a/.vim/bundle/gundo.vim/.hgignore b/.vim/bundle/gundo.vim/.hgignore deleted file mode 100644 index 90c2787..0000000 --- a/.vim/bundle/gundo.vim/.hgignore +++ /dev/null @@ -1,5 +0,0 @@ -syntax:glob - -*.un~ -*.pyc -tags diff --git a/.vim/bundle/gundo.vim/.hgtags b/.vim/bundle/gundo.vim/.hgtags deleted file mode 100644 index 78bebd9..0000000 --- a/.vim/bundle/gundo.vim/.hgtags +++ /dev/null @@ -1,2 +0,0 @@ -4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 v0.8.0 -4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 semver diff --git a/.vim/bundle/gundo.vim/README.markdown b/.vim/bundle/gundo.vim/README.markdown deleted file mode 100644 index a27c8f1..0000000 --- a/.vim/bundle/gundo.vim/README.markdown +++ /dev/null @@ -1,50 +0,0 @@ -<a href="http://flattr.com/thing/74149/Gundo-vim" target="_blank"> -<img src="http://api.flattr.com/button/button-compact-static-100x17.png" alt="Flattr this" title="Flattr this" border="0" /></a> - -Gundo.vim is Vim plugin to visualize your Vim undo tree. - -Current status: Beta. It might eat your data. Be careful. -========================================================= - -Preview -------- - - -Screenshot: - -<a href="http://www.flickr.com/photos/sjl7678/5093114605/" title="gundo by stevelosh, on Flickr"><img src="http://farm5.static.flickr.com/4113/5093114605_ebc46d6494.jpg" width="487" height="500" alt="gundo" /></a> - -Screencast: [http://screenr.com/M9l](http://screenr.com/M9l) - - -Requirements ------------- - -* Vim 7.3+ -* Python support for Vim. -* Python 2.5+. - -Installation ------------- - -Use [Pathogen][]. Don't use pathogen? Start. - -Add a mapping to your `~/.vimrc` (change the key to suit your taste): - - nnoremap <F5> :GundoToggle<CR> - -[Pathogen]: http://www.vim.org/scripts/script.php?script_id=2332 - -Usage ------ - -When you're editing a file you can bring up the undo graph for that file with -`<F5>` (or whatever key you mapped it to). - -Press `<F5>` again to close the undo graph and return to your file. - -Use `j` and `k` to move up and down the graph. The preview pane will update with -a diff of the change made by the undo state you're currently on. - -Press return to revert the file's contents to that undo state and return to the -file. diff --git a/.vim/bundle/gundo.vim/doc/gundo.txt b/.vim/bundle/gundo.vim/doc/gundo.txt deleted file mode 100644 index c8498c1..0000000 --- a/.vim/bundle/gundo.vim/doc/gundo.txt +++ /dev/null @@ -1,128 +0,0 @@ -*gundo.txt* Graph your undo tree so you can actually USE it. - - - CURRENT STATUS: BETA - - IT MIGHT EAT YOUR DATA - - SERIOUSLY: IF YOU USE THIS PLUGIN, LOSE DATA AND COMPLAIN ABOUT IT - I AM GOING TO MAKE FUN OF YOU ON TWITTER - - -Making's Vim's undo tree usable by humans. - -============================================================================== -1. Intro *Gundo-plugin* *Gundo* - -You know that Vim lets you undo changes like any text editor. What you might -not know is that it doesn't just keep a list of your changes -- it keeps -a goddamed |:undo-tree| of them. - -Say you make a change (call it X), undo that change, and then make another -change (call it Y). With most editors, change X is now gone forever. With Vim -you can get it back. - -The problem is that trying to do this in the real world is painful. Vim gives -you an |:undolist| command that shows you the leaves of the tree. Good luck -finding the change you want in that list. - -Gundo is a plugin to make browsing this ridiculously powerful undo tree less -painful. - -============================================================================== -2. Usage *GundoUsage* - -We'll get to the technical details later, but if you're a human the first -thing you need to do is add a mapping to your |:vimrc| to toggle the undo -graph: > - - nnoremap <F5> :GundoToggle<CR> - -Change the mapped key to suit your taste. We'll stick with F5 because that's -what the author uses. - -Now you can press F5 to toggle the undo graph and preview pane, which will -look something like this: > - - Undo graph File - +-----------------------------------+------------------------------------+ - | " Gundo for something.txt [1] |one | - | " j/k - move between undo states |two | - | " <cr> - revert to that state |three | - | |five | - | @ [5] 3 hours ago | | - | | | | - | | o [4] 4 hours ago | | - | | | | | - | o | [3] 4 hours ago | | - | | | | | - | o | [2] 4 hours ago | | - | |/ | | - | o [1] 4 hours ago | | - | | | | - | o [0] Original | | - +-----------------------------------+ | - | --- 3 2010-10-12 06:27:35 PM | | - | +++ 5 2010-10-12 07:38:37 PM | | - | @@ -1,3 +1,4 | | - | one | | - | two | | - | three | | - | +five | | - +-----------------------------------+------------------------------------+ - Preview pane - -Your current position in the undo tree is marked with an '@' character. Other -nodes are marked with an 'o' character. - -When you toggle open the graph Gundo will put your cursor on your current -position in the tree. You can move up and down the graph with the j and -k keys. - -You can move to the top of the graph (the newest state) with gg and to the -bottom of the graph (the oldest state) with G. - -As you move between undo states the preview pane will show you a unified diff -of the change that state made. - -Pressing enter on a state will revert the contents of the file to match that -state. - -Pressing P while on a state will initiate "play to" mode targeted at that -state. This will replay all the changes between your current state and the -target, with a slight pause after each change. It's mostly useless, but can be -fun to watch and see where your editing lags -- that might be a good place to -define a new mapping to speed up your editing. - -Pressing q while in the undo graph will close it. You can also just press your -toggle mapping key. - -============================================================================== -3. License *GundoLicense* - -GPLv2+. Look it up. - -============================================================================== -4. Bugs *GundoBugs* - -If you find a bug please post it on the issue tracker: -http://bitbucket.org/sjl/gundo.vim/issues?status=new&status=open - -============================================================================== -5. Contributing *GundoContributing* - -Think you can make this plugin better? Awesome. Fork it on BitBucket or GitHub -and send a pull request. - -BitBucket: http://bitbucket.org/sjl/gundo.vim/ -GitHub: http://github.com/sjl/gundo.vim/ - -============================================================================== -6. Credits *GundoCredits* - -The graphing code was all taken from Mercurial, hence the GPLv2+ license. - -The plugin was heavily inspired by histwin.vim, and the code for scratch.vim -helped the author get started. - -============================================================================== diff --git a/.vim/bundle/gundo.vim/doc/tags b/.vim/bundle/gundo.vim/doc/tags deleted file mode 100644 index ba84bf9..0000000 --- a/.vim/bundle/gundo.vim/doc/tags +++ /dev/null @@ -1,8 +0,0 @@ -Gundo gundo.txt /*Gundo* -Gundo-plugin gundo.txt /*Gundo-plugin* -GundoBugs gundo.txt /*GundoBugs* -GundoContributing gundo.txt /*GundoContributing* -GundoCredits gundo.txt /*GundoCredits* -GundoLicense gundo.txt /*GundoLicense* -GundoUsage gundo.txt /*GundoUsage* -gundo.txt gundo.txt /*gundo.txt* diff --git a/.vim/bundle/gundo.vim/plugin/gundo.vim b/.vim/bundle/gundo.vim/plugin/gundo.vim deleted file mode 100644 index c6a7c37..0000000 --- a/.vim/bundle/gundo.vim/plugin/gundo.vim +++ /dev/null @@ -1,795 +0,0 @@ -" ============================================================================ -" File: gundo.vim -" Description: vim global plugin to visualize your undo tree -" Maintainer: Steve Losh <steve@stevelosh.com> -" License: GPLv2+ -- look it up. -" Notes: Much of this code was thiefed from Mercurial, and the rest was -" heavily inspired by scratch.vim and histwin.vim. -" -" ============================================================================ - - -"{{{ Init -"if exists('loaded_gundo') || &cp - "finish -"endif - -"let loaded_gundo = 1 - -if !exists('g:gundo_width') - let g:gundo_width = 45 -endif -"}}} - -"{{{ Movement Mappings -function! s:GundoMove(direction) - let start_line = getline('.') - - " If we're in between two nodes we move by one to get back on track. - if stridx(start_line, '[') == -1 - let distance = 1 - else - let distance = 2 - endif - - let target_n = line('.') + (distance * a:direction) - - " Bound the movement to the graph. - if target_n <= 4 - call cursor(5, 0) - else - call cursor(target_n, 0) - endif - - let line = getline('.') - - " Move to the node, whether it's an @ or an o - let idx1 = stridx(line, '@') - let idx2 = stridx(line, 'o') - if idx1 != -1 - call cursor(0, idx1 + 1) - else - call cursor(0, idx2 + 1) - endif - - let target_line = matchstr(getline("."), '\v\[[0-9]+\]') - let target_num = matchstr(target_line, '\v[0-9]+') - call s:GundoRenderPreview(target_num) -endfunction -"}}} - -"{{{ Buffer/Window Management -function! s:GundoResizeBuffers(backto) - " This sucks and doesn't work. TODO: Fix it. - exe bufwinnr(bufnr('__Gundo__')) . "wincmd w" - exe "vertical resize " . g:gundo_width - exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w" - exe "resize " . 15 - exe a:backto . "wincmd w" -endfunction - -function! s:GundoOpenBuffer() - let existing_gundo_buffer = bufnr("__Gundo__") - - if existing_gundo_buffer == -1 - exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w" - exe "new __Gundo__" - call s:GundoResizeBuffers(winnr()) - nnoremap <script> <silent> <buffer> <CR> :call <sid>GundoRevert()<CR> - nnoremap <script> <silent> <buffer> j :call <sid>GundoMove(1)<CR> - nnoremap <script> <silent> <buffer> k :call <sid>GundoMove(-1)<CR> - nnoremap <script> <silent> <buffer> gg gg:call <sid>GundoMove(1)<CR> - nnoremap <script> <silent> <buffer> P :call <sid>GundoPlayTo()<CR> - nnoremap <script> <silent> <buffer> q :call <sid>GundoToggle()<CR> - else - let existing_gundo_window = bufwinnr(existing_gundo_buffer) - - if existing_gundo_window != -1 - if winnr() != existing_gundo_window - exe existing_gundo_window . "wincmd w" - endif - else - exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w" - exe "split +buffer" . existing_gundo_buffer - call s:GundoResizeBuffers(winnr()) - endif - endif -endfunction - -function! s:GundoToggle() - if expand('%') == "__Gundo__" - quit - if bufwinnr(bufnr('__Gundo_Preview__')) != -1 - exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w" - quit - endif - exe bufwinnr(g:gundo_target_n) . "wincmd w" - else - if expand('%') != "__Gundo_Preview__" - " Record the previous buffer number. - " - " This sucks because we're not getting the window number, and there - " may be more than one window viewing the same buffer, so we might - " go back to the wrong one. - " - " Unfortunately window numbers change as we open more windows. - " - " TODO: Figure out how to fix this. - let g:gundo_target_n = bufnr('') - let g:gundo_target_f = @% - endif - - call s:GundoOpenPreview() - exe bufwinnr(g:gundo_target_n) . "wincmd w" - GundoRender - - " TODO: Move these lines into RenderPreview - let target_line = matchstr(getline("."), '\v\[[0-9]+\]') - let target_num = matchstr(target_line, '\v[0-9]+') - call s:GundoRenderPreview(target_num) - endif -endfunction - -function! s:GundoMarkPreviewBuffer() - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal noswapfile - setlocal buflisted - setlocal nomodifiable - setlocal filetype=diff - setlocal nonumber - setlocal norelativenumber - setlocal nowrap - setlocal foldlevel=20 - " TODO: Set foldmethod? -endfunction - -function! s:GundoMarkBuffer() - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal noswapfile - setlocal buflisted - setlocal nomodifiable - setlocal filetype=gundo - setlocal nolist - setlocal nonumber - setlocal norelativenumber - setlocal nowrap - call s:GundoSyntax() -endfunction - -function! s:GundoSyntax() - let b:current_syntax = 'gundo' - - syn match GundoCurrentLocation '@' - syn match GundoHelp '\v^".*$' - syn match GundoNumberField '\v\[[0-9]+\]' - syn match GundoNumber '\v[0-9]+' contained containedin=GundoNumberField - - hi def link GundoCurrentLocation Keyword - hi def link GundoHelp Comment - hi def link GundoNumberField Comment - hi def link GundoNumber Identifier -endfunction - -function! s:GundoOpenPreview() - let existing_preview_buffer = bufnr("__Gundo_Preview__") - - if existing_preview_buffer == -1 - exe "vnew __Gundo_Preview__" - wincmd H - else - let existing_preview_window = bufwinnr(existing_preview_buffer) - - if existing_preview_window != -1 - if winnr() != existing_preview_window - exe existing_preview_window . "wincmd w" - endif - else - exe "vsplit +buffer" . existing_preview_buffer - wincmd H - endif - endif -endfunction -"}}} - -"{{{ Mercurial's Graphlog Code -python << ENDPYTHON -def asciiedges(seen, rev, parents): - """adds edge info to changelog DAG walk suitable for ascii()""" - if rev not in seen: - seen.append(rev) - nodeidx = seen.index(rev) - - knownparents = [] - newparents = [] - for parent in parents: - if parent in seen: - knownparents.append(parent) - else: - newparents.append(parent) - - ncols = len(seen) - seen[nodeidx:nodeidx + 1] = newparents - edges = [(nodeidx, seen.index(p)) for p in knownparents] - - if len(newparents) > 0: - edges.append((nodeidx, nodeidx)) - if len(newparents) > 1: - edges.append((nodeidx, nodeidx + 1)) - - nmorecols = len(seen) - ncols - return nodeidx, edges, ncols, nmorecols - -def get_nodeline_edges_tail( - node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail): - if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0: - # Still going in the same non-vertical direction. - if n_columns_diff == -1: - start = max(node_index + 1, p_node_index) - tail = ["|", " "] * (start - node_index - 1) - tail.extend(["/", " "] * (n_columns - start)) - return tail - else: - return ["\\", " "] * (n_columns - node_index - 1) - else: - return ["|", " "] * (n_columns - node_index - 1) - -def draw_edges(edges, nodeline, interline): - for (start, end) in edges: - if start == end + 1: - interline[2 * end + 1] = "/" - elif start == end - 1: - interline[2 * start + 1] = "\\" - elif start == end: - interline[2 * start] = "|" - else: - nodeline[2 * end] = "+" - if start > end: - (start, end) = (end, start) - for i in range(2 * start + 1, 2 * end): - if nodeline[i] != "+": - nodeline[i] = "-" - -def ascii(buf, state, type, char, text, coldata): - """prints an ASCII graph of the DAG - - takes the following arguments (one call per node in the graph): - - - buffer to write to - - Somewhere to keep the needed state in (init to asciistate()) - - Column of the current node in the set of ongoing edges. - - Type indicator of node data == ASCIIDATA. - - Payload: (char, lines): - - Character to use as node's symbol. - - List of lines to display as the node's text. - - Edges; a list of (col, next_col) indicating the edges between - the current node and its parents. - - Number of columns (ongoing edges) in the current revision. - - The difference between the number of columns (ongoing edges) - in the next revision and the number of columns (ongoing edges) - in the current revision. That is: -1 means one column removed; - 0 means no columns added or removed; 1 means one column added. - """ - - idx, edges, ncols, coldiff = coldata - assert -2 < coldiff < 2 - if coldiff == -1: - # Transform - # - # | | | | | | - # o | | into o---+ - # |X / |/ / - # | | | | - fix_long_right_edges(edges) - - # add_padding_line says whether to rewrite - # - # | | | | | | | | - # | o---+ into | o---+ - # | / / | | | # <--- padding line - # o | | | / / - # o | | - add_padding_line = (len(text) > 2 and coldiff == -1 and - [x for (x, y) in edges if x + 1 < y]) - - # fix_nodeline_tail says whether to rewrite - # - # | | o | | | | o | | - # | | |/ / | | |/ / - # | o | | into | o / / # <--- fixed nodeline tail - # | |/ / | |/ / - # o | | o | | - fix_nodeline_tail = len(text) <= 2 and not add_padding_line - - # nodeline is the line containing the node character (typically o) - nodeline = ["|", " "] * idx - nodeline.extend([char, " "]) - - nodeline.extend( - get_nodeline_edges_tail(idx, state[1], ncols, coldiff, - state[0], fix_nodeline_tail)) - - # shift_interline is the line containing the non-vertical - # edges between this entry and the next - shift_interline = ["|", " "] * idx - if coldiff == -1: - n_spaces = 1 - edge_ch = "/" - elif coldiff == 0: - n_spaces = 2 - edge_ch = "|" - else: - n_spaces = 3 - edge_ch = "\\" - shift_interline.extend(n_spaces * [" "]) - shift_interline.extend([edge_ch, " "] * (ncols - idx - 1)) - - # draw edges from the current node to its parents - draw_edges(edges, nodeline, shift_interline) - - # lines is the list of all graph lines to print - lines = [nodeline] - if add_padding_line: - lines.append(get_padding_line(idx, ncols, edges)) - lines.append(shift_interline) - - # make sure that there are as many graph lines as there are - # log strings - while len(text) < len(lines): - text.append("") - if len(lines) < len(text): - extra_interline = ["|", " "] * (ncols + coldiff) - while len(lines) < len(text): - lines.append(extra_interline) - - # print lines - indentation_level = max(ncols, ncols + coldiff) - for (line, logstr) in zip(lines, text): - ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr) - buf.write(ln.rstrip() + '\n') - - # ... and start over - state[0] = coldiff - state[1] = idx - -def fix_long_right_edges(edges): - for (i, (start, end)) in enumerate(edges): - if end > start: - edges[i] = (start, end + 1) - -def ascii(buf, state, type, char, text, coldata): - """prints an ASCII graph of the DAG - - takes the following arguments (one call per node in the graph): - - - Somewhere to keep the needed state in (init to asciistate()) - - Column of the current node in the set of ongoing edges. - - Type indicator of node data == ASCIIDATA. - - Payload: (char, lines): - - Character to use as node's symbol. - - List of lines to display as the node's text. - - Edges; a list of (col, next_col) indicating the edges between - the current node and its parents. - - Number of columns (ongoing edges) in the current revision. - - The difference between the number of columns (ongoing edges) - in the next revision and the number of columns (ongoing edges) - in the current revision. That is: -1 means one column removed; - 0 means no columns added or removed; 1 means one column added. - """ - - idx, edges, ncols, coldiff = coldata - assert -2 < coldiff < 2 - if coldiff == -1: - # Transform - # - # | | | | | | - # o | | into o---+ - # |X / |/ / - # | | | | - fix_long_right_edges(edges) - - # add_padding_line says whether to rewrite - # - # | | | | | | | | - # | o---+ into | o---+ - # | / / | | | # <--- padding line - # o | | | / / - # o | | - add_padding_line = (len(text) > 2 and coldiff == -1 and - [x for (x, y) in edges if x + 1 < y]) - - # fix_nodeline_tail says whether to rewrite - # - # | | o | | | | o | | - # | | |/ / | | |/ / - # | o | | into | o / / # <--- fixed nodeline tail - # | |/ / | |/ / - # o | | o | | - fix_nodeline_tail = len(text) <= 2 and not add_padding_line - - # nodeline is the line containing the node character (typically o) - nodeline = ["|", " "] * idx - nodeline.extend([char, " "]) - - nodeline.extend( - get_nodeline_edges_tail(idx, state[1], ncols, coldiff, - state[0], fix_nodeline_tail)) - - # shift_interline is the line containing the non-vertical - # edges between this entry and the next - shift_interline = ["|", " "] * idx - if coldiff == -1: - n_spaces = 1 - edge_ch = "/" - elif coldiff == 0: - n_spaces = 2 - edge_ch = "|" - else: - n_spaces = 3 - edge_ch = "\\" - shift_interline.extend(n_spaces * [" "]) - shift_interline.extend([edge_ch, " "] * (ncols - idx - 1)) - - # draw edges from the current node to its parents - draw_edges(edges, nodeline, shift_interline) - - # lines is the list of all graph lines to print - lines = [nodeline] - if add_padding_line: - lines.append(get_padding_line(idx, ncols, edges)) - lines.append(shift_interline) - - # make sure that there are as many graph lines as there are - # log strings - while len(text) < len(lines): - text.append("") - if len(lines) < len(text): - extra_interline = ["|", " "] * (ncols + coldiff) - while len(lines) < len(text): - lines.append(extra_interline) - - # print lines - indentation_level = max(ncols, ncols + coldiff) - for (line, logstr) in zip(lines, text): - ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr) - buf.write(ln.rstrip() + '\n') - - # ... and start over - state[0] = coldiff - state[1] = idx - -def generate(dag, edgefn, current): - seen, state = [], [0, 0] - buf = Buffer() - for node, parents in list(dag): - age_label = age(int(node.time)) if node.time else 'Original' - line = '[%s] %s' % (node.n, age_label) - char = '@' if node.n == current else 'o' - ascii(buf, state, 'C', char, [line], edgefn(seen, node, parents)) - return buf.b -ENDPYTHON -"}}} - -"{{{ Mercurial age function -python << ENDPYTHON -import time - -agescales = [("year", 3600 * 24 * 365), - ("month", 3600 * 24 * 30), - ("week", 3600 * 24 * 7), - ("day", 3600 * 24), - ("hour", 3600), - ("minute", 60), - ("second", 1)] - -def age(ts): - '''turn a timestamp into an age string.''' - - def plural(t, c): - if c == 1: - return t - return t + "s" - def fmt(t, c): - return "%d %s" % (c, plural(t, c)) - - now = time.time() - then = ts - if then > now: - return 'in the future' - - delta = max(1, int(now - then)) - if delta > agescales[0][1] * 2: - return time.strftime('%Y-%m-%d', time.gmtime(float(ts))) - - for t, s in agescales: - n = delta // s - if n >= 2 or s == 1: - return '%s ago' % fmt(t, n) -ENDPYTHON -"}}} - -"{{{ Python Vim utility functions -python << ENDPYTHON -import vim - -normal = lambda s: vim.command('normal %s' % s) - -def _goto_window_for_buffer(b): - w = vim.eval('bufwinnr(%d)' % int(b)) - vim.command('%dwincmd w' % int(w)) - -def _goto_window_for_buffer_name(bn): - b = vim.eval('bufnr("%s")' % bn) - _goto_window_for_buffer(b) - -def _undo_to(n): - n = int(n) - if n == 0: - try: - vim.command('silent! undo 1') - except vim.error: - return - vim.command('silent undo') - else: - vim.command('silent undo %d' % n) - - -INLINE_HELP = '''\ -" Gundo for %s [%d] -" j/k - move between undo states -" <cr> - revert to that state - -''' -ENDPYTHON -"}}} - -"{{{ Python undo tree data structures and functions -python << ENDPYTHON -import itertools - -class Buffer(object): - def __init__(self): - self.b = '' - - def write(self, s): - self.b += s - -class Node(object): - def __init__(self, n, parent, time, curhead): - self.n = int(n) - self.parent = parent - self.children = [] - self.curhead = curhead - self.time = time - -def _make_nodes(alts, nodes, parent=None): - p = parent - - for alt in alts: - curhead = True if 'curhead' in alt else False - node = Node(n=alt['seq'], parent=p, time=alt['time'], curhead=curhead) - nodes.append(node) - if alt.get('alt'): - _make_nodes(alt['alt'], nodes, p) - p = node - -def make_nodes(): - ut = vim.eval('undotree()') - entries = ut['entries'] - - root = Node(0, None, False, 0) - nodes = [] - _make_nodes(entries, nodes, root) - nodes.append(root) - nmap = dict((node.n, node) for node in nodes) - return nodes, nmap - -def changenr(nodes): - # TODO: This seems to sometimes be wrong right after you open a file... - _curhead_l = list(itertools.dropwhile(lambda n: not n.curhead, nodes)) - if _curhead_l: - current = _curhead_l[0].parent.n - else: - current = int(vim.eval('changenr()')) - return current -ENDPYTHON -"}}} - -"{{{ Graph rendering -function! s:GundoRender() -python << ENDPYTHON -def GundoRender(): - nodes, nmap = make_nodes() - - for node in nodes: - node.children = [n for n in nodes if n.parent == node] - - def walk_nodes(nodes): - for node in nodes: - yield(node, [node.parent] if node.parent else []) - - dag = sorted(nodes, key=lambda n: int(n.n), reverse=True) - current = changenr(nodes) - - result = generate(walk_nodes(dag), asciiedges, current).rstrip().splitlines() - result = [' ' + l for l in result] - - target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n'))) - header = (INLINE_HELP % target).splitlines() - - vim.command('GundoOpenBuffer') - vim.command('setlocal modifiable') - vim.current.buffer[:] = (header + result) - vim.command('setlocal nomodifiable') - - i = 1 - for line in result: - try: - line.split('[')[0].index('@') - i += 1 - break - except ValueError: - pass - i += 1 - vim.command('%d' % (i+len(header)-1)) - -GundoRender() -ENDPYTHON -endfunction -"}}} - -"{{{ Preview Rendering -function! s:GundoRenderPreview(target) -python << ENDPYTHON -import difflib - -def _fmt_time(t): - return time.strftime('%Y-%m-%d %I:%M:%S %p', time.localtime(float(t))) - -def _output_preview_text(lines): - _goto_window_for_buffer_name('__Gundo_Preview__') - vim.command('setlocal modifiable') - vim.current.buffer[:] = lines - vim.command('setlocal nomodifiable') - -def _generate_preview_diff(current, node_before, node_after): - _goto_window_for_buffer(vim.eval('g:gundo_target_n')) - - if not node_after.n: # we're at the original file - before_lines = [] - - _undo_to(0) - after_lines = vim.current.buffer[:] - - before_name = 'n/a' - before_time = '' - after_name = 'Original' - after_time = '' - elif not node_before.n: # we're at a pseudo-root state - _undo_to(0) - before_lines = vim.current.buffer[:] - - _undo_to(node_after.n) - after_lines = vim.current.buffer[:] - - before_name = 'Original' - before_time = '' - after_name = node_after.n - after_time = _fmt_time(node_after.time) - else: - _undo_to(node_before.n) - before_lines = vim.current.buffer[:] - - _undo_to(node_after.n) - after_lines = vim.current.buffer[:] - - before_name = node_before.n - before_time = _fmt_time(node_before.time) - after_name = node_after.n - after_time = _fmt_time(node_after.time) - - _undo_to(current) - - return list(difflib.unified_diff(before_lines, after_lines, - before_name, after_name, - before_time, after_time)) - -def GundoRenderPreview(): - target_n = vim.eval('a:target') - - # Check that there's an undo state. There may not be if we're talking about - # a buffer with no changes yet. - if target_n == None: - _goto_window_for_buffer_name('__Gundo__') - return - else: - target_n = int(vim.eval('a:target')) - - _goto_window_for_buffer(vim.eval('g:gundo_target_n')) - - nodes, nmap = make_nodes() - current = changenr(nodes) - - node_after = nmap[target_n] - node_before = node_after.parent - - _output_preview_text(_generate_preview_diff(current, node_before, node_after)) - - _goto_window_for_buffer_name('__Gundo__') - -GundoRenderPreview() -ENDPYTHON -endfunction -"}}} - -"{{{ Undo/Redo Commands -function! s:GundoRevert() - let target_line = matchstr(getline("."), '\v\[[0-9]+\]') - let target_num = matchstr(target_line, '\v[0-9]+') - let back = bufwinnr(g:gundo_target_n) - exe back . "wincmd w" -python << ENDPYTHON -_undo_to(vim.eval('target_num')) -ENDPYTHON - GundoRender - exe back . "wincmd w" -endfunction - -function! s:GundoPlayTo() - let target_line = matchstr(getline("."), '\v\[[0-9]+\]') - let target_num = matchstr(target_line, '\v[0-9]+') - let back = bufwinnr(g:gundo_target_n) - exe back . "wincmd w" - -python << ENDPYTHON -def GundoPlayTo(): - nodes, nmap = make_nodes() - - start = nmap[changenr(nodes)] - end = nmap[int(vim.eval('target_num'))] - - def _walk_branch(origin, dest): - rev = origin.n < dest.n - - nodes = [] - current = origin if origin.n > dest.n else dest - final = dest if origin.n > dest.n else origin - - while current.n >= final.n: - if current.n == final.n: - break - nodes.append(current) - current = current.parent - else: - return None - nodes.append(current) - - return reversed(nodes) if rev else nodes - - branch = _walk_branch(start, end) - - if not branch: - vim.command('unsilent echo "No path to that node from here!"') - return - - for node in branch: - _undo_to(node.n) - vim.command('GundoRender') - normal('zz') - vim.command('%dwincmd w' % int(vim.eval('back'))) - vim.command('redraw') - vim.command('sleep 60m') - -GundoPlayTo() -ENDPYTHON -endfunction -"}}} - -"{{{ Misc -command! -nargs=0 GundoOpenBuffer call s:GundoOpenBuffer() -command! -nargs=0 GundoToggle call s:GundoToggle() -command! -nargs=0 GundoRender call s:GundoRender() -autocmd BufNewFile __Gundo__ call s:GundoMarkBuffer() -autocmd BufNewFile __Gundo_Preview__ call s:GundoMarkPreviewBuffer() -"}}} diff --git a/.vim/bundles.vim b/.vim/bundles.vim new file mode 100644 index 0000000..7234c0b --- /dev/null +++ b/.vim/bundles.vim @@ -0,0 +1,40 @@ +set nocompatible " be iMproved +filetype off " required! + +set rtp+=~/.vim/bundle/vundle/ +call vundle#rc() + +" vundle itself +" on a fresh install you need to do: +" > git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle +Bundle 'gmarik/vundle' + +" fugitive -- git handling +Bundle 'tpope/vim-fugitive' + +" GUndo +Bundle 'Gundo' + +" NERDTree +Bundle 'The-NERD-tree' + +" Taglist +Bundle 'taglist.vim' + +" surround.vim +Bundle 'surround.vim' + +" advanced matching +Bundle 'matchit.zip' + +" alternate files +Bundle 'a.vim' + +" toggle words +Bundle 'toggle_words.vim' + +" syntaxes +Bundle 'lighttpd-syntax' + + +filetype plugin indent on " required! diff --git a/.vim/colors/desert.vim b/.vim/colors/desert.vim deleted file mode 100644 index aa7c2d8..0000000 --- a/.vim/colors/desert.vim +++ /dev/null @@ -1,109 +0,0 @@ -" Vim color file -" Maintainer: Hans Fugal <hans@fugal.net> -" Last Change: $Date: 2004/06/13 19:30:30 $ -" Last Change: $Date: 2004/06/13 19:30:30 $ -" URL: http://hans.fugal.net/vim/colors/desert.vim -" Version: $Id: desert.vim,v 1.1 2004/06/13 19:30:30 vimboss Exp $ - -" cool help screens -" :he group-name -" :he highlight-groups -" :he cterm-colors - -set background=dark -if version > 580 - " no guarantees for version 5.8 and below, but this makes it stop - " complaining - hi clear - if exists("syntax_on") - syntax reset - endif -endif -let g:colors_name="desert" - -hi Normal guifg=White guibg=grey20 - -" highlight groups -hi Cursor guibg=khaki guifg=slategrey -"hi CursorIM -"hi Directory -"hi DiffAdd -"hi DiffChange -"hi DiffDelete -"hi DiffText -"hi ErrorMsg -hi VertSplit guibg=#c2bfa5 guifg=grey50 gui=none -hi Folded guibg=grey30 guifg=gold -hi FoldColumn guibg=grey30 guifg=tan -hi IncSearch guifg=slategrey guibg=khaki -"hi LineNr -hi ModeMsg guifg=goldenrod -hi MoreMsg guifg=SeaGreen -hi NonText guifg=LightBlue guibg=grey30 -hi Question guifg=springgreen -hi Search guibg=peru guifg=wheat -hi SpecialKey guifg=yellowgreen -hi StatusLine guibg=#c2bfa5 guifg=black gui=none -hi StatusLineNC guibg=#c2bfa5 guifg=grey50 gui=none -hi Title guifg=indianred -hi Visual gui=none guifg=khaki guibg=olivedrab -"hi VisualNOS -hi WarningMsg guifg=salmon -"hi WildMenu -"hi Menu -"hi Scrollbar -"hi Tooltip - -" syntax highlighting groups -hi Comment guifg=SkyBlue -hi Constant guifg=#ffa0a0 -hi Identifier guifg=LightSeaGreen -hi Function guifg=palegreen -hi Statement guifg=khaki -hi PreProc guifg=indianred -hi Type guifg=darkkhaki -hi Special guifg=navajowhite -"hi Underlined -hi Ignore guifg=grey40 -"hi Error -hi Todo guifg=orangered guibg=yellow2 - -" color terminal definitions -hi SpecialKey ctermfg=darkgreen -hi NonText cterm=bold ctermfg=darkblue -hi Directory ctermfg=darkcyan -hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1 -hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green -hi Search cterm=NONE ctermfg=grey ctermbg=blue -hi MoreMsg ctermfg=darkgreen -hi ModeMsg cterm=NONE ctermfg=brown -hi LineNr ctermfg=3 -hi Question ctermfg=green -hi StatusLine cterm=bold,reverse -hi StatusLineNC cterm=reverse -hi VertSplit cterm=reverse -hi Title ctermfg=5 -hi Visual cterm=reverse -hi VisualNOS cterm=bold,underline -hi WarningMsg ctermfg=1 -hi WildMenu ctermfg=0 ctermbg=3 -hi Folded ctermfg=darkgrey ctermbg=NONE -hi FoldColumn ctermfg=darkgrey ctermbg=NONE -hi DiffAdd ctermbg=4 -hi DiffChange ctermbg=5 -hi DiffDelete cterm=bold ctermfg=4 ctermbg=6 -hi DiffText cterm=bold ctermbg=1 -hi Comment ctermfg=darkcyan -hi Constant ctermfg=brown -hi Special ctermfg=5 -hi Identifier ctermfg=6 -hi Statement ctermfg=3 -hi PreProc ctermfg=5 -hi Type ctermfg=2 -hi Underlined cterm=underline ctermfg=5 -hi Ignore cterm=bold ctermfg=7 -hi Ignore ctermfg=darkgrey -hi Error cterm=bold ctermfg=7 ctermbg=1 - - -"vim: sw=4 diff --git a/.vim/compiler/ghc.vim b/.vim/compiler/ghc.vim deleted file mode 100644 index b50bc29..0000000 --- a/.vim/compiler/ghc.vim +++ /dev/null @@ -1,536 +0,0 @@ - -" Vim Compiler File -" Compiler: GHC -" Maintainer: Claus Reinke <claus.reinke@talk21.com> -" Last Change: 22/06/2010 -" -" part of haskell plugins: http://projects.haskell.org/haskellmode-vim - -" ------------------------------ paths & quickfix settings first -" - -if exists("current_compiler") && current_compiler == "ghc" - finish -endif -let current_compiler = "ghc" - -let s:scriptname = "ghc.vim" - -if !haskellmode#GHC() | finish | endif -if (!exists("b:ghc_staticoptions")) - let b:ghc_staticoptions = '' -endif - -" set makeprg (for quickfix mode) -execute 'setlocal makeprg=' . g:ghc . '\ ' . escape(b:ghc_staticoptions,' ') .'\ -e\ :q\ %' -"execute 'setlocal makeprg=' . g:ghc .'\ -e\ :q\ %' -"execute 'setlocal makeprg=' . g:ghc .'\ --make\ %' - -" quickfix mode: -" fetch file/line-info from error message -" TODO: how to distinguish multiline errors from warnings? -" (both have the same header, and errors have no common id-tag) -" how to get rid of first empty message in result list? -setlocal errorformat= - \%-Z\ %#, - \%W%f:%l:%c:\ Warning:\ %m, - \%E%f:%l:%c:\ %m, - \%E%>%f:%l:%c:, - \%+C\ \ %#%m, - \%W%>%f:%l:%c:, - \%+C\ \ %#%tarning:\ %m, - -" oh, wouldn't you guess it - ghc reports (partially) to stderr.. -setlocal shellpipe=2> - -" ------------------------- but ghc can do a lot more for us.. -" - -" allow map leader override -if !exists("maplocalleader") - let maplocalleader='_' -endif - -" initialize map of identifiers to their types -" associate type map updates to changedtick -if !exists("b:ghc_types") - let b:ghc_types = {} - let b:my_changedtick = b:changedtick -endif - -if exists("g:haskell_functions") - finish -endif -let g:haskell_functions = "ghc" - -" avoid hit-enter prompts -set cmdheight=3 - -" edit static GHC options -" TODO: add completion for options/packages? -command! GHCStaticOptions call GHC_StaticOptions() -function! GHC_StaticOptions() - let b:ghc_staticoptions = input('GHC static options: ',b:ghc_staticoptions) - execute 'setlocal makeprg=' . g:ghc . '\ ' . escape(b:ghc_staticoptions,' ') .'\ -e\ :q\ %' - let b:my_changedtick -=1 -endfunction - -map <LocalLeader>T :call GHC_ShowType(1)<cr> -map <LocalLeader>t :call GHC_ShowType(0)<cr> -function! GHC_ShowType(addTypeDecl) - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return 0 - endif - let [_,symb,qual,unqual] = namsym - let name = qual=='' ? unqual : qual.'.'.unqual - let pname = ( symb ? '('.name.')' : name ) - call GHC_HaveTypes() - if !has_key(b:ghc_types,name) - redraw - echo pname "type not known" - else - redraw - for type in split(b:ghc_types[name],' -- ') - echo pname "::" type - if a:addTypeDecl - call append( line(".")-1, pname . " :: " . type ) - endif - endfor - endif -endfunction - -" show type of identifier under mouse pointer in balloon -" TODO: it isn't a good idea to tie potentially time-consuming tasks -" (querying GHCi for the types) to cursor movements (#14). Currently, -" we ask the user to call :GHCReload explicitly. Should there be an -" option to reenable the old implicit querying? -if has("balloon_eval") - set ballooneval - set balloondelay=600 - set balloonexpr=GHC_TypeBalloon() - function! GHC_TypeBalloon() - if exists("b:current_compiler") && b:current_compiler=="ghc" - let [line] = getbufline(v:beval_bufnr,v:beval_lnum) - let namsym = haskellmode#GetNameSymbol(line,v:beval_col,0) - if namsym==[] - return '' - endif - let [start,symb,qual,unqual] = namsym - let name = qual=='' ? unqual : qual.'.'.unqual - let pname = name " ( symb ? '('.name.')' : name ) - if b:ghc_types == {} - redraw - echo "no type information (try :GHGReload)" - elseif (b:my_changedtick != b:changedtick) - redraw - echo "type information may be out of date (try :GHGReload)" - endif - " silent call GHC_HaveTypes() - if b:ghc_types!={} - if has("balloon_multiline") - return (has_key(b:ghc_types,pname) ? split(b:ghc_types[pname],' -- ') : '') - else - return (has_key(b:ghc_types,pname) ? b:ghc_types[pname] : '') - endif - else - return '' - endif - else - return '' - endif - endfunction -endif - -map <LocalLeader>si :call GHC_ShowInfo()<cr> -function! GHC_ShowInfo() - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return 0 - endif - let [_,symb,qual,unqual] = namsym - let name = qual=='' ? unqual : (qual.'.'.unqual) - let output = GHC_Info(name) - pclose | new - setlocal previewwindow - setlocal buftype=nofile - setlocal noswapfile - put =output - wincmd w - "redraw - "echo output -endfunction - -" fill the type map, unless nothing has changed since the last attempt -function! GHC_HaveTypes() - if b:ghc_types == {} && (b:my_changedtick != b:changedtick) - let b:my_changedtick = b:changedtick - return GHC_BrowseAll() - endif -endfunction - -" update b:ghc_types after successful make -au QuickFixCmdPost make if GHC_CountErrors()==0 | silent call GHC_BrowseAll() | endif - -" count only error entries in quickfix list, ignoring warnings -function! GHC_CountErrors() - let c=0 - for e in getqflist() | if e.type=='E' && e.text !~ "^[ \n]*Warning:" | let c+=1 | endif | endfor - return c -endfunction - -command! GHCReload call GHC_BrowseAll() -function! GHC_BrowseAll() - " let imports = haskellmode#GatherImports() - " let modules = keys(imports[0]) + keys(imports[1]) - let b:my_changedtick = b:changedtick - let imports = {} " no need for them at the moment - let current = GHC_NameCurrent() - let module = current==[] ? 'Main' : current[0] - if haskellmode#GHC_VersionGE([6,8,1]) - return GHC_BrowseBangStar(module) - else - return GHC_BrowseMultiple(imports,['*'.module]) - endif -endfunction - -function! GHC_NameCurrent() - let last = line("$") - let l = 1 - while l<last - let ml = matchlist( getline(l), '^module\s*\([^ (]*\)') - if ml != [] - let [_,module;x] = ml - return [module] - endif - let l += 1 - endwhile - redraw - echo "cannot find module header for file " . expand("%") - return [] -endfunction - -function! GHC_BrowseBangStar(module) - redraw - echo "browsing module " a:module - let command = ":browse! *" . a:module - let orig_shellredir = &shellredir - let &shellredir = ">" " ignore error/warning messages, only output or lack of it - let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -v0 --interactive ' . expand("%") , command ) - let &shellredir = orig_shellredir - return GHC_ProcessBang(a:module,output) -endfunction - -function! GHC_BrowseMultiple(imports,modules) - redraw - echo "browsing modules " a:modules - let command = ":browse " . join( a:modules, " \n :browse ") - let command = substitute(command,'\(:browse \(\S*\)\)','putStrLn "-- \2" \n \1','g') - let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -v0 --interactive ' . expand("%") , command ) - return GHC_Process(a:imports,output) -endfunction - -function! GHC_Info(what) - " call GHC_HaveTypes() - let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -v0 --interactive ' . expand("%"), ":info ". a:what) - return output -endfunction - -function! GHC_ProcessBang(module,output) - let module = a:module - let b = a:output - let linePat = '^\(.\{-}\)\n\(.*\)' - let contPat = '\s\+\(.\{-}\)\n\(.*\)' - let typePat = '^\(\)\(\S*\)\s*::\(.*\)' - let commentPat = '^-- \(\S*\)' - let definedPat = '^-- defined locally' - let importedPat = '^-- imported via \(.*\)' - if !(b=~commentPat) - echo s:scriptname.": GHCi reports errors (try :make?)" - return 0 - endif - let b:ghc_types = {} - let ml = matchlist( b , linePat ) - while ml != [] - let [_,l,rest;x] = ml - let mlDecl = matchlist( l, typePat ) - if mlDecl != [] - let [_,indent,id,type;x] = mlDecl - let ml2 = matchlist( rest , '^'.indent.contPat ) - while ml2 != [] - let [_,c,rest;x] = ml2 - let type .= c - let ml2 = matchlist( rest , '^'.indent.contPat ) - endwhile - let id = substitute( id, '^(\(.*\))$', '\1', '') - let type = substitute( type, '\s\+', " ", "g" ) - " using :browse! *<current>, we get both unqualified and qualified ids - let qualified = (id =~ '\.') && (id =~ '[A-Z]') - let b:ghc_types[id] = type - if !qualified - for qual in qualifiers - let b:ghc_types[qual.'.'.id] = type - endfor - endif - else - let mlImported = matchlist( l, importedPat ) - let mlDefined = matchlist( l, definedPat ) - if mlImported != [] - let [_,modules;x] = mlImported - let qualifiers = split( modules, ', ' ) - elseif mlDefined != [] - let qualifiers = [module] - endif - endif - let ml = matchlist( rest , linePat ) - endwhile - return 1 -endfunction - -function! GHC_Process(imports,output) - let b = a:output - let imports = a:imports - let linePat = '^\(.\{-}\)\n\(.*\)' - let contPat = '\s\+\(.\{-}\)\n\(.*\)' - let typePat = '^\(\s*\)\(\S*\)\s*::\(.*\)' - let modPat = '^-- \(\S*\)' - " add '-- defined locally' and '-- imported via ..' - if !(b=~modPat) - echo s:scriptname.": GHCi reports errors (try :make?)" - return 0 - endif - let b:ghc_types = {} - let ml = matchlist( b , linePat ) - while ml != [] - let [_,l,rest;x] = ml - let mlDecl = matchlist( l, typePat ) - if mlDecl != [] - let [_,indent,id,type;x] = mlDecl - let ml2 = matchlist( rest , '^'.indent.contPat ) - while ml2 != [] - let [_,c,rest;x] = ml2 - let type .= c - let ml2 = matchlist( rest , '^'.indent.contPat ) - endwhile - let id = substitute(id, '^(\(.*\))$', '\1', '') - let type = substitute( type, '\s\+', " ", "g" ) - " using :browse *<current>, we get both unqualified and qualified ids - if current_module " || has_key(imports[0],module) - if has_key(b:ghc_types,id) && !(matchstr(b:ghc_types[id],escape(type,'[].'))==type) - let b:ghc_types[id] .= ' -- '.type - else - let b:ghc_types[id] = type - endif - endif - if 0 " has_key(imports[1],module) - let qualid = module.'.'.id - let b:ghc_types[qualid] = type - endif - else - let mlMod = matchlist( l, modPat ) - if mlMod != [] - let [_,module;x] = mlMod - let current_module = module[0]=='*' - let module = current_module ? module[1:] : module - endif - endif - let ml = matchlist( rest , linePat ) - endwhile - return 1 -endfunction - -let s:ghc_templates = ["module _ () where","class _ where","class _ => _ where","instance _ where","instance _ => _ where","type family _","type instance _ = ","data _ = ","newtype _ = ","type _ = "] - -" use ghci :browse index for insert mode omnicompletion (CTRL-X CTRL-O) -function! GHC_CompleteImports(findstart, base) - if a:findstart - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),-1) " insert-mode: we're 1 beyond the text - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return -1 - endif - let [start,symb,qual,unqual] = namsym - return (start-1) - else " find keys matching with "a:base" - let res = [] - let l = len(a:base)-1 - call GHC_HaveTypes() - for key in keys(b:ghc_types) - if key[0 : l]==a:base - let res += [{"word":key,"menu":":: ".b:ghc_types[key],"dup":1}] - endif - endfor - return res - endif -endfunction -set omnifunc=GHC_CompleteImports -" -" Vim's default completeopt is menu,preview -" you probably want at least menu, or you won't see alternatives listed -" setlocal completeopt+=menu - -" menuone is useful, but other haskellmode menus will try to follow your choice here in future -" setlocal completeopt+=menuone - -" longest sounds useful, but doesn't seem to do what it says, and interferes with CTRL-E -" setlocal completeopt-=longest - -map <LocalLeader>ct :call GHC_CreateTagfile()<cr> -function! GHC_CreateTagfile() - redraw - echo "creating tags file" - let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -e ":ctags" ' . expand("%")) - " for ghcs older than 6.6, you would need to call another program - " here, such as hasktags - echo output -endfunction - -command! -nargs=1 GHCi redraw | echo system(g:ghc. ' ' . b:ghc_staticoptions .' '.expand("%").' -e "'.escape(<f-args>,'"').'"') - -" use :make 'not in scope' errors to explicitly list imported ids -" cursor needs to be on import line, in correctly loadable module -map <LocalLeader>ie :call GHC_MkImportsExplicit()<cr> -function! GHC_MkImportsExplicit() - let save_cursor = getpos(".") - let line = getline('.') - let lineno = line('.') - let ml = matchlist(line,'^import\(\s*qualified\)\?\s*\([^( ]\+\)') - if ml!=[] - let [_,q,mod;x] = ml - silent make - if getqflist()==[] - if line=~"import[^(]*Prelude" - call setline(lineno,substitute(line,"(.*","","").'()') - else - call setline(lineno,'-- '.line) - endif - silent write - silent make - let qflist = getqflist() - call setline(lineno,line) - silent write - let ids = {} - for d in qflist - let ml = matchlist(d.text,'Not in scope: \([^`]*\)`\([^'']*\)''') - if ml!=[] - let [_,what,qid;x] = ml - let id = ( qid =~ "^[A-Z]" ? substitute(qid,'.*\.\([^.]*\)$','\1','') : qid ) - let pid = ( id =~ "[a-zA-Z0-9_']\\+" ? id : '('.id.')' ) - if what =~ "data" - call GHC_HaveTypes() - if has_key(b:ghc_types,id) - let pid = substitute(b:ghc_types[id],'^.*->\s*\(\S*\).*$','\1','').'('.pid.')' - else - let pid = '???('.pid.')' - endif - endif - let ids[pid] = 1 - endif - endfor - call setline(lineno,'import'.q.' '.mod.'('.join(keys(ids),',').')') - else - copen - endif - endif - call setpos('.', save_cursor) -endfunction - -" no need to ask GHC about its supported languages and -" options with every editing session. cache the info in -" ~/.vim/haskellmode.config -" TODO: should we store more info (see haskell_doc.vim)? -" move to autoload? -" should we keep a history of GHC versions encountered? -function! GHC_SaveConfig() - let vimdir = expand('~').'/'.'.vim' - let config = vimdir.'/haskellmode.config' - if !isdirectory(vimdir) - call mkdir(vimdir) - endif - let entries = ['-- '.g:ghc_version] - for l in s:ghc_supported_languages - let entries += [l] - endfor - let entries += ['--'] - for l in s:opts - let entries += [l] - endfor - call writefile(entries,config) -endfunction - -" reuse cached GHC configuration info, if using the same -" GHC version. -function! GHC_LoadConfig() - let vimdir = expand('~').'/'.'.vim' - let config = vimdir.'/haskellmode.config' - if filereadable(config) - let lines = readfile(config) - if lines[0]=='-- '.g:ghc_version - let i=1 - let s:ghc_supported_languages = [] - while i<len(lines) && lines[i]!='--' - let s:ghc_supported_languages += [lines[i]] - let i+=1 - endwhile - let i+=1 - let s:opts = [] - while i<len(lines) - let s:opts += [lines[i]] - let i+=1 - endwhile - return 1 - else - return 0 - endif - else - return 0 - endif -endfunction - -let s:GHC_CachedConfig = haskellmode#GHC_VersionGE([6,8]) && GHC_LoadConfig() - -if haskellmode#GHC_VersionGE([6,8,2]) - if !s:GHC_CachedConfig - let s:opts = filter(split(substitute(system(g:ghc . ' -v0 --interactive', ':set'), ' ', '','g'), '\n'), 'v:val =~ "-f"') - endif -else - let s:opts = ["-fglasgow-exts","-fallow-undecidable-instances","-fallow-overlapping-instances","-fno-monomorphism-restriction","-fno-mono-pat-binds","-fno-cse","-fbang-patterns","-funbox-strict-fields"] -endif -let s:opts = sort(s:opts) - -amenu ]OPTIONS_GHC.- :echo '-'<cr> -aunmenu ]OPTIONS_GHC -for o in s:opts - exe 'amenu ]OPTIONS_GHC.'.o.' :call append(0,"{-# OPTIONS_GHC '.o.' #-}")<cr>' -endfor -if has("gui_running") - map <LocalLeader>opt :popup ]OPTIONS_GHC<cr> -else - map <LocalLeader>opt :emenu ]OPTIONS_GHC. -endif - -amenu ]LANGUAGES_GHC.- :echo '-'<cr> -aunmenu ]LANGUAGES_GHC -if haskellmode#GHC_VersionGE([6,8]) - if !s:GHC_CachedConfig - let s:ghc_supported_languages = sort(split(system(g:ghc . ' --supported-languages'),'\n')) - endif - for l in s:ghc_supported_languages - exe 'amenu ]LANGUAGES_GHC.'.l.' :call append(0,"{-# LANGUAGE '.l.' #-}")<cr>' - endfor - if has("gui_running") - map <LocalLeader>lang :popup ]LANGUAGES_GHC<cr> - else - map <LocalLeader>lang :emenu ]LANGUAGES_GHC. - endif -endif - -if !s:GHC_CachedConfig - call GHC_SaveConfig() -endif - diff --git a/.vim/doc/NERD_tree.txt b/.vim/doc/NERD_tree.txt deleted file mode 100644 index c9c94e9..0000000 --- a/.vim/doc/NERD_tree.txt +++ /dev/null @@ -1,961 +0,0 @@ -*NERD_tree.txt* A tree explorer plugin that owns your momma! v2.6.2 - - - - - - ________ ________ _ ____________ ____ __________ ____________~ - /_ __/ / / / ____/ / | / / ____/ __ \/ __ \ /_ __/ __ \/ ____/ ____/~ - / / / /_/ / __/ / |/ / __/ / /_/ / / / / / / / /_/ / __/ / __/ ~ - / / / __ / /___ / /| / /___/ _, _/ /_/ / / / / _, _/ /___/ /___ ~ - /_/ /_/ /_/_____/ /_/ |_/_____/_/ |_/_____/ /_/ /_/ |_/_____/_____/ ~ - - - Reference Manual~ - - - - -============================================================================== -CONTENTS *NERDTree-contents* - - 1.Intro...................................|NERDTree| - 2.Functionality provided..................|NERDTreeFunctionality| - 2.1 Commands..........................|NERDTreeCommands| - 2.2 NERD tree mappings................|NERDTreeMappings| - 2.3 The filesystem menu...............|NERDTreeFilesysMenu| - 3.Options.................................|NERDTreeOptions| - 3.1 Option summary....................|NERDTreeOptionSummary| - 3.2 Option details....................|NERDTreeOptionDetails| - 4.Public functions........................|NERDTreePublicFunctions| - 5.TODO list...............................|NERDTreeTodo| - 6.The Author..............................|NERDTreeAuthor| - 7.Changelog...............................|NERDTreeChangelog| - 8.Credits.................................|NERDTreeCredits| - -============================================================================== -1. Intro *NERDTree* - -What is this "NERD tree"?? - -The NERD tree allows you to explore your filesystem and to open files and -directories. It presents the filesystem to you in the form of a tree which you -manipulate with the keyboard and/or mouse. It also allows you to perform -simple filesystem operations so you can alter the tree dynamically. - -The following features and functionality are provided by the NERD tree: - * Files and directories are displayed in a hierarchical tree structure - * Different highlighting is provided for the following types of nodes: - * files - * directories - * sym-links - * windows .lnk files - * read-only files - * Many (customisable) mappings are provided to manipulate the tree: - * Mappings to open/close/explore directory nodes - * Mappings to open files in new/existing windows/tabs - * Mappings to change the current root of the tree - * Mappings to navigate around the tree - * ... - * Most NERD tree navigation can also be done with the mouse - * Dynamic customisation of tree content - * custom file filters to prevent e.g. vim backup files being displayed - * optional displaying of hidden files (. files) - * files can be "turned off" so that only directories are displayed - * A textual filesystem menu is provided which allows you to - create/delete/rename file and directory nodes - * The position and size of the NERD tree window can be customised - * The order in which the nodes in the tree are listed can be customised. - * A model of your filesystem is created/maintained as you explore it. This - has several advantages: - * All filesystem information is cached and is only re-read on demand - * If you revisit a part of the tree that you left earlier in your - session, the directory nodes will be opened/closed as you left them - * The script remembers the cursor position and window position in the NERD - tree so you can toggle it off (or just close the tree window) and then - reopen it (with NERDTreeToggle) the NERD tree window will appear EXACTLY - as you left it - * You can have a separate NERD tree for each tab - -============================================================================== -2. Functionality provided *NERDTreeFunctionality* - ------------------------------------------------------------------------------- -2.1. Commands *NERDTreeCommands* - -:NERDTree [start-directory] *:NERDTree* - Opens a fresh NERD tree in [start-directory] or the current - directory if [start-directory] isn't specified. - For example: > - :NERDTree /home/marty/vim7/src -< will open a NERD tree in /home/marty/vim7/src. - -:NERDTreeToggle [start-directory] *:NERDTreeToggle* - If a NERD tree already exists for this tab, it is reopened and - rendered again. If no NERD tree exists for this tab then this - command acts the same as the |:NERDTree| command. - ------------------------------------------------------------------------------- -2.2. NERD tree Mappings *NERDTreeMappings* - -Default Description~ help-tag~ -Key~ - -o.......Open selected file, or expand selected dir...............|NERDTree-o| -go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go| -t.......Open selected node in a new tab..........................|NERDTree-t| -T.......Same as 't' but keep the focus on the current tab........|NERDTree-T| -<tab>...Open selected file in a split window.....................|NERDTree-tab| -g<tab>..Same as <tab>, but leave the cursor on the NERDTree......|NERDTree-gtab| -!.......Execute the current file.................................|NERDTree-!| -O.......Recursively open the selected directory..................|NERDTree-O| -x.......Close the current nodes parent...........................|NERDTree-x| -X.......Recursively close all children of the current node.......|NERDTree-X| -e.......Open a netrw for the current dir.........................|NERDTree-e| - -double-click.......same as the |NERDTree-o| map. -middle-click.......same as |NERDTree-tab| for files, same as - |NERDTree-e| for dirs. - -P.......Jump to the root node....................................|NERDTree-P| -p.......Jump to current nodes parent.............................|NERDTree-p| -K.......Jump up inside directories at the current tree depth.....|NERDTree-K| -J.......Jump down inside directories at the current tree depth...|NERDTree-J| -<C-j>...Jump down to the next sibling of the current directory...|NERDTree-c-j| -<C-k>...Jump up to the previous sibling of the current directory.|NERDTree-c-k| - -C.......Change the tree root to the selected dir.................|NERDTree-C| -u.......Move the tree root up one directory......................|NERDTree-u| -U.......Same as 'u' except the old root node is left open........|NERDTree-U| -r.......Recursively refresh the current directory................|NERDTree-r| -R.......Recursively refresh the current root.....................|NERDTree-R| -m.......Display the filesystem menu..............................|NERDTree-m| -cd......Change the CWD to the dir of the selected node...........|NERDTree-cd| - -H.......Toggle whether hidden files displayed....................|NERDTree-H| -f.......Toggle whether the file filters are used.................|NERDTree-f| -F.......Toggle whether files are displayed.......................|NERDTree-F| - -q.......Close the NERDTree window................................|NERDTree-q| -?.......Toggle the display of the quick help.....................|NERDTree-?| - ------------------------------------------------------------------------------- - *NERDTree-o* -Default key: o -Map option: NERDTreeMapActivateNode -Applies to: files and directories. - -If a file node is selected, it is opened in the previous window. If a -directory is selected it is opened or closed depending on its current state. - ------------------------------------------------------------------------------- - *NERDTree-go* -Default key: go -Map option: None -Applies to: files. - -If a file node is selected, it is opened in the previous window, but the -cursor does not move. - -The key combo for this mapping is always "g" + NERDTreeMapActivateNode (see -|NERDTree-o|). - ------------------------------------------------------------------------------- - *NERDTree-t* -Default key: t -Map option: NERDTreeMapOpenInTab -Applies to: files and directories. - -Opens the selected file in a new tab. If a directory is selected, a netrw is -opened in a new tab. - ------------------------------------------------------------------------------- - *NERDTree-T* -Default key: T -Map option: NERDTreeMapOpenInTabSilent -Applies to: files and directories. - -The same as |NERDTree-t| except that the focus is kept in the current tab. - ------------------------------------------------------------------------------- - *NERDTree-tab* -Default key: <tab> -Map option: NERDTreeMapOpenSplit -Applies to: files. - -Opens the selected file in a new split window and puts the cursor in the new -window. - ------------------------------------------------------------------------------- - *NERDTree-gtab* -Default key: g<tab> -Map option: None -Applies to: files. - -The same as |NERDTree-tab| except that the cursor is not moved. - -The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see -|NERDTree-tab|). - ------------------------------------------------------------------------------- - *NERDTree-!* -Default key: ! -Map option: NERDTreeMapExecute -Applies to: files. - -Executes the selected file, prompting for arguments first. - ------------------------------------------------------------------------------- - *NERDTree-O* -Default key: O -Map option: NERDTreeMapOpenRecursively -Applies to: directories. - -Recursively opens the selelected directory. - -All files and directories are cached, but if a directory would not be -displayed due to file filters (see |NERDTreeIgnore| |NERDTree-f|) or the -hidden file filter (see |NERDTreeShowHidden|) then it is not opened. This is -handy, especially if you have .svn directories. - - ------------------------------------------------------------------------------- - *NERDTree-x* -Default key: x -Map option: NERDTreeMapCloseDir -Applies to: files and directories. - -Closes the parent of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-X* -Default key: X -Map option: NERDTreeMapCloseChildren -Applies to: directories. - -Recursively closes all children of the selected directory. - -Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. - ------------------------------------------------------------------------------- - *NERDTree-e* -Default key: e -Map option: NERDTreeMapOpenExpl -Applies to: files and directories. - -Opens a netrw on the selected directory, or the selected file's directory. - ------------------------------------------------------------------------------- - *NERDTree-P* -Default key: P -Map option: NERDTreeMapJumpRoot -Applies to: no restrictions. - -Jump to the tree root. - ------------------------------------------------------------------------------- - *NERDTree-p* -Default key: p -Map option: NERDTreeMapJumpParent -Applies to: files and directories. - -Jump to the parent node of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-K* -Default key: K -Map option: NERDTreeMapJumpFirstChild -Applies to: files and directories. - -Jump to the first child of the current nodes parent. - -If the cursor is already on the first node then do the following: - * loop back thru the siblings of the current nodes parent until we find an - open dir with children - * go to the first child of that node - ------------------------------------------------------------------------------- - *NERDTree-J* -Default key: J -Map option: NERDTreeMapJumpLastChild -Applies to: files and directories. - -Jump to the last child of the current nodes parent. - -If the cursor is already on the last node then do the following: - * loop forward thru the siblings of the current nodes parent until we find - an open dir with children - * go to the last child of that node - ------------------------------------------------------------------------------- - *NERDTree-c-j* -Default key: <C-j> -Map option: NERDTreeMapJumpNextSibling -Applies to: files and directories. - -If a dir node is selected, jump to the next sibling of that node. -If a file node is selected, jump to the next sibling of that nodes parent. - ------------------------------------------------------------------------------- - *NERDTree-c-k* -Default key: <C-k> -Map option: NERDTreeMapJumpPrevSibling -Applies to: files and directories. - -If a dir node is selected, jump to the previous sibling of that node. -If a file node is selected, jump to the previous sibling of that nodes parent. - ------------------------------------------------------------------------------- - *NERDTree-C* -Default key: C -Map option: NERDTreeMapChdir -Applies to: directories. - -Made the selected directory node the new tree root. - ------------------------------------------------------------------------------- - *NERDTree-u* -Default key: u -Map option: NERDTreeMapUpdir -Applies to: no restrictions. - -Move the tree root up a dir (like doing a "cd .."). - ------------------------------------------------------------------------------- - *NERDTree-U* -Default key: U -Map option: NERDTreeMapUpdirKeepOpen -Applies to: no restrictions. - -Like |NERDTree-u| except that the old tree root is kept open. - ------------------------------------------------------------------------------- - *NERDTree-r* -Default key: r -Map option: NERDTreeMapRefresh -Applies to: files and directories. - -If a dir is selected, recursively refresh that dir, i.e. scan the filesystem -for changes and represent them in the tree. - -If a file node is selected then the above is done on it's parent. - ------------------------------------------------------------------------------- - *NERDTree-R* -Default key: R -Map option: NERDTreeMapRefreshRoot -Applies to: no restrictions. - -Recursively refresh the tree root. - ------------------------------------------------------------------------------- - *NERDTree-m* -Default key: m -Map option: NERDTreeMapFilesystemMenu -Applies to: files and directories. - -Display the filesystem menu. See |NERDTreeFilesysMenu| for details. - ------------------------------------------------------------------------------- - *NERDTree-H* -Default key: H -Map option: NERDTreeMapToggleHidden -Applies to: no restrictions. - -Toggles whether hidden files are displayed. Hidden files are any -file/directory that starts with a "." - ------------------------------------------------------------------------------- - *NERDTree-f* -Default key: f -Map option: NERDTreeMapToggleFilters -Applies to: no restrictions. - -Toggles whether file filters are used. See |NERDTreeIgnore| for details. - ------------------------------------------------------------------------------- - *NERDTree-F* -Default key: F -Map option: NERDTreeMapToggleFiles -Applies to: no restrictions. - -Toggles whether file nodes are displayed. - ------------------------------------------------------------------------------- - *NERDTree-q* -Default key: q -Map option: NERDTreeMapQuit -Applies to: no restrictions. - -Closes the NERDtree window. - ------------------------------------------------------------------------------- - *NERDTree-?* -Default key: ? -Map option: NERDTreeMapHelp -Applies to: no restrictions. - -Toggles whether the quickhelp is displayed. - ------------------------------------------------------------------------------- -2.3. The filesystem menu *NERDTreeFilesysMenu* - -The purpose of the filesystem menu is to allow you to perform basic filesystem -operations quickly from the NERD tree rather than the console. - -The filesystem menu can be accessed with 'm' mapping and has three supported -operations: > - 1. Adding nodes. - 2. Renaming nodes. - 3. Deleting nodes. -< -1. Adding nodes: -To add a node move the cursor onto (or anywhere inside) the directory you wish -to create the new node inside. Select the 'add node' option from the -filesystem menu and type a filename. If the filename you type ends with a '/' -character then a directory will be created. Once the operation is completed, -the cursor is placed on the new node. - -2. Renaming nodes: -To rename a node, put the cursor on it and select the 'rename' option from the -filesystem menu. Enter the new name for the node and it will be renamed. If -the old file is open in a buffer, you will be asked if you wish to delete that -buffer. Once the operation is complete the cursor will be placed on the -renamed node. - -3. Deleting nodes: -To delete a node put the cursor on it and select the 'delete' option from the -filesystem menu. After confirmation the node will be deleted. If a file is -deleted but still exists as a buffer you will be given the option to delete -that buffer. - -============================================================================== -3. Customisation *NERDTreeOptions* - - ------------------------------------------------------------------------------- -3.1. Customisation summary *NERDTreeOptionSummary* - -The script provides the following options that can customise the behaviour the -NERD tree. These options should be set in your vimrc. - -|loaded_nerd_tree| Turns off the script. - -|NERDChristmasTree| Tells the NERD tree to make itself colourful - and pretty. - -|NERDTreeAutoCenter| Controls whether the NERD tree window centers - when the cursor moves within a specified - distance to the top/bottom of the window. -|NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. - -|NERDTreeCaseSensitiveSort| Tells the NERD tree whether to be case - sensitive or not when sorting nodes. - -|NERDTreeChDirMode| Tells the NERD tree if/when it should change - vim's current working directory. - -|NERDTreeHighlightCursorline| Tell the NERD tree whether to highlight the - current cursor line. - -|NERDTreeIgnore| Tells the NERD tree which files to ignore. - -|NERDTreeMouseMode| Tells the NERD tree how to handle mouse - clicks. - -|NERDTreeShowFiles| Tells the NERD tree whether to display files - in the tree on startup. - -|NERDTreeShowHidden| Tells the NERD tree whether to display hidden - files on startup. - -|NERDTreeSortOrder| Tell the NERD tree how to sort the nodes in - the tree. - -|NERDTreeSplitVertical| Tells the script whether the NERD tree should - be created by splitting the window vertically - or horizontally. - -|NERDTreeWinPos| Tells the script where to put the NERD tree - window. - - -|NERDTreeWinSize| Sets the window size when the NERD tree is - opened. - ------------------------------------------------------------------------------- -3.2. Customisation details *NERDTreeOptionDetails* - -To enable any of the below options you should put the given line in your -~/.vimrc - - *loaded_nerd_tree* -If this plugin is making you feel homicidal, it may be a good idea to turn it -off with this line in your vimrc: > - let loaded_nerd_tree=1 -< ------------------------------------------------------------------------------- - *NERDChristmasTree* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then some extra syntax highlighting elements are -added to the nerd tree to make it more colourful. - -Set it to 0 for a more vanilla looking tree. - ------------------------------------------------------------------------------- - *NERDTreeAutoCenter* -Values: 0 or 1. -Default: 1 - -If set to 1, the NERD tree window will center around the cursor if it moves to -within |NERDTreeAutoCenterThreshold| lines of the top/bottom of the window. - -This is ONLY done in response to tree navigation mappings, -i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-c-K| |NERDTree-p| -|NERDTree-P| - -The centering is done with a |zz| operation. - ------------------------------------------------------------------------------- - *NERDTreeAutoCenterThreshold* -Values: Any natural number. -Default: 3 - -This option controls the "sensitivity" of the NERD tree auto centering. See -|NERDTreeAutoCenter| for details. - ------------------------------------------------------------------------------- - *NERDTreeCaseSensitiveSort* -Values: 0 or 1. -Default: 0. - -By default the NERD tree does not sort nodes case sensitively, i.e. nodes -could appear like this: > - bar.c - Baz.c - blarg.c - boner.c - Foo.c -< -But, if you set this option to 1 then the case of the nodes will be taken into -account. The above nodes would then be sorted like this: > - Baz.c - Foo.c - bar.c - blarg.c - boner.c -< ------------------------------------------------------------------------------- - *NERDTreeChDirMode* - -Values: 0, 1 or 2. -Default: 1. - -Use this option to tell the script when (if at all) to change the current -working directory (CWD) for vim. - -If it is set to 0 then the CWD is never changed by the NERD tree. - -If set to 1 then the CWD is changed when the NERD tree is first loaded to the -directory it is initialized in. For example, if you start the NERD tree with > - :NERDTree /home/marty/foobar -< -then the CWD will be changed to /home/marty/foobar and will not be changed -again unless you init another NERD tree with a similar command. - -If the option is set to 2 then it behaves the same as if set to 1 except that -the CWD is changed whenever the tree root is changed. For example, if the CWD -is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new -root then the CWD will become /home/marty/foobar/baz. - -Note to windows users: it is highly recommended that you have this option set -to either 1 or 2 or else the script wont function properly if you attempt to -open a NERD tree on a different drive to the one vim is currently in. - -Authors note: at work i have this option set to 1 because i have a giant ctags -file in the root dir of my project. This way i can initialise the NERD tree -with the root dir of my project and always have ctags available to me --- no -matter where i go with the NERD tree. - ------------------------------------------------------------------------------- - *NERDTreeHighlightCursorline* -Values: 0 or 1. -Default: 1. - -If set to 1, the current cursor line in the NERD tree buffer will be -highlighted. This is done using the |cursorline| option. - ------------------------------------------------------------------------------- - *NERDTreeIgnore* -Values: a list of regular expressions. -Default: ['\~$']. - -This option is used to specify which files the NERD tree should ignore. It -must be a list of regular expressions. When the NERD tree is rendered, any -files/dirs that match any of the regex's in NERDTreeIgnore wont be displayed. - -For example if you put the following line in your vimrc: > - let NERDTreeIgnore=['\.vim$', '\~$'] -< -then all files ending in .vim or ~ will be ignored. - -Note: to tell the NERD tree not to ignore any files you must use the following -line: > - let NERDTreeIgnore=[] -< - -The file filters can be turned on and off dynamically with the |NERDTree-f| -mapping. - ------------------------------------------------------------------------------- - *NERDTreeMouseMode* -Values: 1, 2 or 3. -Default: 1. - -If set to 1 then a double click on a node is required to open it. -If set to 2 then a single click will open directory nodes, while a double -click will still be required for file nodes. -If set to 3 then a single click will open any node. - -Note: a double click anywhere on a line that a tree node is on will -activate it, but all single-click activations must be done on name of the node -itself. For example, if you have the following node: > - | | |-application.rb -< -then (to single click activate it) you must click somewhere in -'application.rb'. - ------------------------------------------------------------------------------- - *NERDTreeShowFiles* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then files are displayed in the NERD tree. If it is -set to 0 then only directories are displayed. - -This option can be toggled dynamically with the |NERDTree-F| mapping and is -useful for drastically shrinking the tree when you are navigating to a -different part of the tree. - ------------------------------------------------------------------------------- - *NERDTreeShowHidden* -Values: 0 or 1. -Default: 0. - -This option tells vim whether to display hidden files by default. This option -can be dynamically toggled with the |NERDTree-H| mapping. -Use one of the follow lines to set this option: > - let NERDTreeShowHidden=0 - let NERDTreeShowHidden=1 -< - ------------------------------------------------------------------------------- - *NERDTreeSortOrder* -Values: a list of regular expressions. -Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] - -This option is set to a list of regular expressions which are used to -specify the order of nodes under their parent. - -For example, if the option is set to: > - ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] -< -then all .vim files will be placed at the top, followed by all .c files then -all .h files. All files containing the string 'foobar' will be placed at the -end. The star is a special flag: it tells the script that every node that -doesnt match any of the other regexps should be placed here. - -If no star is present in NERDTreeSortOrder then one is automatically appended -to the array. - -The regex '\/$' should be used to match directory nodes. - -After this sorting is done, the files in each group are sorted alphabetically. - -Other examples: > - (1) ['*', '\/$'] - (2) [] - (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] -< -1. Directories will appear last, everything else will appear above. -2. Every will simply appear in alphabetical order. -3. Dirs will appear first, then ruby and php. Swap files, bak files and vim - backup files will appear last with everything else preceding them. - ------------------------------------------------------------------------------- - *NERDTreeSplitVertical* -Values: 0 or 1. -Default: 1. - -This option, along with |NERDTreeWinPos|, is used to determine where the NERD -tree window appears. - -If it is set to 1 then the NERD tree window will appear on either the left or -right side of the screen (depending on the |NERDTreeWinPos| option). - -If it set to 0 then the NERD tree window will appear at the top of the screen. - ------------------------------------------------------------------------------- - *NERDTreeWinPos* -Values: 0 or 1. -Default: 1. - -This option works in conjunction with the |NERDTreeSplitVertical| option to -determine where NERD tree window is placed on the screen. - -If the option is set to 1 then the NERD tree will appear on the left or top of -the screen (depending on the value of |NERDTreeSplitVertical|). If set to 0, -the window will appear on the right or bottom of the screen. - -This option is makes it possible to use two different explorer type -plugins simultaneously. For example, you could have the taglist plugin on the -left of the window and the NERD tree on the right. - ------------------------------------------------------------------------------- - *NERDTreeWinSize* -Values: a positive integer. -Default: 31. - -This option is used to change the size of the NERD tree when it is loaded. - -============================================================================== - *NERDTreePublicFunctions* -5. Public functions ~ - -The script provides 2 public functions for your hacking pleasure. Their -signatures are: > - function! NERDTreeGetCurrentNode() - function! NERDTreeGetCurrentPath() -< -The first returns the node object that the cursor is currently on, while the -second returns the corresponding path object. - -This is probably a good time to mention that the script implements prototype -style OO. To see the functions that each class provides you can read look at -the code. - -Use the node objects to manipulate the structure of the tree. Use the path -objects to access the data the tree represents and to make changes to the -filesystem. - -============================================================================== -5. TODO list *NERDTreeTodo* - -Window manager integration? - -============================================================================== -6. The Author *NERDTreeAuthor* - -The author of the NERD tree is a terrible terrible monster called Martyzilla -who gobbles up small children with milk and sugar for breakfast. He has an odd -love/hate relationship with computers (but monsters hate everything by nature -you know...) which can be awkward for him since he is a pro computer nerd for -a living. - -He can be reached at martin_grenfell at msn.com. He would love to hear from -you, so feel free to send him suggestions and/or comments about this plugin. -Don't be shy --- the worst he can do is slaughter you and stuff you in the -fridge for later ;) - -============================================================================== -7. Changelog *NERDTreeChangelog* - -2.6.2 - - Now when you try to open a file node into a window that is modified, the - window is not split if the &hidden option is set. Thanks to Niels Aan - de Brugh for this suggestion. - -2.6.1 - - Fixed a major bug with the <tab> mapping. Thanks to Zhang Weiwu for - emailing me. - -2.6.0 - - Extended the behaviour of <c-j/k>. Now if the cursor is on a file node - and you use <c-j/k> the cursor will jump to its PARENTS next/previous - sibling. Go :help NERDTree-c-j and :help NERDTree-c-k for info. - - Extended the behaviour of the J/K mappings. Now if the cursor is on the - last child of a node and you push J/K it will jump down to the last child - of the next/prev of its parents siblings that is open and has children. - Go :help NERDTree-J and :help NERDTree-K for info. - - The goal of these changes is to make tree navigation faster. - - Reorganised the help page a bit. - - Removed the E mapping. - - bugfixes - -2.5.0 - - Added an option to enforce case sensitivity when sorting tree nodes. - Read :help NERDTreeCaseSensitiveSort for details. (thanks to Michael - Madsen for emailing me about this). Case sensitivity defaults to off. - - Made the script echo a "please wait" style message when opening large - directories. Thanks to AOYAMA Shotaro for this suggestion. - - Added 2 public functions that can be used to retrieve the treenode and - path that the cursor is on. Read :help NERDTreePublicFunctions for - details (thanks again to AOYAMA Shotaro for the idea :). - - added 2 new mappings for file nodes: "g<tab>" and "go". These are the - same as the "<tab>" and "o" maps except that the cursor stays in the - NERDTree. Note: these maps are slaved to the o and <tab> mappings, so if - eg you remap "<tab>" to "i" then the "g<tab>" map will also be changed - to "gi". - - Renamed many of the help tags to be simpler. - - Simplified the ascii "graphics" for the filesystem menu - - Fixed bugs. - - Probably created bugs. - - Refactoring. - -2.4.0 - - Added the P mapping to jump to the tree root. - - Added window centering functionality that can be triggered when doing - using any of the tree nav mappings. Essentially, if the cursor comes - within a certain distance of the top/bottom of the window then a zz is - done in the window. Two related options were added: NERDTreeAutoCenter - to turn this functionality on/off, and NERDTreeAutoCenterThreshold to - control how close the cursor has to be to the window edge to trigger the - centering. - -2.3.0 - - Tree navigation changes: - - Added J and K mappings to jump to last/first child of the current dir. - Options to customise these mappings have also been added. - - Remapped the jump to next/prev sibling commands to be <C-j> and <C-k> by - default. - These changes should hopefully make tree navigation mappings easier to - remember and use as the j and k keys are simply reused 3 times (twice - with modifier keys). - - - Made it so that, when any of the tree filters are toggled, the cursor - stays with the selected node (or goes to its parent/grandparent/... if - that node is no longer visible) - - Fixed an error in the doc for the mouse mode option. - - Made the quickhelp correctly display the current single/double click - mappings for opening nodes as specified by the NERDTreeMouseMode option. - - Fixed a bug where the script was spazzing after prompting you to delete - a modified buffer when using the filesystem menu. - - Refactoring -2.2.3 - - Refactored the :echo output from the script. - - Fixed some minor typos in the doc. - - Made some minor changes to the output of the 'Tree filtering mappings' - part of the quickhelp - -2.2.2 - - More bugfixes... doh. - -2.2.1 - - Bug fix that was causing an exception when closing the nerd tree. Thanks - to Tim carey-smith and Yu Jun for pointing this out. - -2.2.0 - - Now 'cursorline' is set in the NERD tree buffer by default. See :help - NERDTreeHighlightCursorline for how to disable it. - -2.1.2 - - Stopped the script from clobbering the 1,2,3 .. 9 registers. - - Made it "silent!"ly delete buffers when renaming/deleting file nodes. - - Minor correction to the doc - - Fixed a bug when refreshing that was occurring when the node you - refreshed had been deleted externally. - - Fixed a bug that was occurring when you open a file that is already open - and modified. - -2.1.1 - - Added a bit more info about the buffers you are prompted to delete when - renaming/deleting nodes from the filesystem menu that are already loaded - into buffers. - - Refactoring and bugfixes - -2.1.0 - - Finally removed the blank line that always appears at the top of the - NERDTree buffer - - Added NERDTreeMouseMode option. If set to 1, then a double click is - required to activate all nodes, if set to 2 then a single click will - activate directory nodes, if set to 3 then a single click will activate - all nodes. - - Now if you delete a file node and have it open in a buffer you are given - the option to delete that buffer as well. Similarly if you rename a file - you are given the option to delete any buffers containing the old file - (if any exist) - - When you rename or create a node, the cursor is now put on the new node, - this makes it easy immediately edit the new file. - - Fixed a bug with the ! mapping that was occurring on windows with paths - containing spaces. - - Made all the mappings customisable. See |NERD_tree-mappings| for - details. A side effect is that a lot of the "double mappings" have - disappeared. E.g 'o' is now the key that is used to activate a node, - <CR> is no longer mapped to the same. - - Made the script echo warnings in some places rather than standard echos - - Insane amounts of refactoring all over the place. - -2.0.0 - - Added two new NERDChristmasTree decorations. First person to spot them - and email me gets a free copy of the NERDTree. - - Made it so that when you jump around the tree (with the p, s and S - mappings) it is counted as a jump by vim. This means if you, eg, push - 'p' one too many times then you can go `` or ctrl-o. - - Added a new option called NERDTreeSortOrder which takes an array of - regexs and is used to determine the order that the treenodes are listed - in. Go :help NERDTreeSortOrder for details. - - Removed the NERDTreeSortDirs option because it is consumed by - NERDTreeSortOrder - - Added the 'i' mapping which is the same as <tab> but requires less - effort to reach. - - Added the ! mapping which is used to execute file in the tree (after it - prompts you for arguments etc) - - -============================================================================== -8. Credits *NERDTreeCredits* - -Thanks to Tim Carey-Smith for testing/using the NERD tree from the first -pre-beta version, for his many suggestions and for his constant stream of bug -complaints. - -Thanks to Vigil for trying it out before the first release :) and suggesting -that mappings to open files in new tabs should be implemented. - -Thanks to Nick Brettell for testing, fixing my spelling and suggesting i put a - .. (up a directory) -line in the gui. - -Thanks to Thomas Scott Urban - the author of the vtreeexplorer plugin - whose -gui code i borrowed from. - -Thanks to Terrance Cohen for pointing out a bug where the script was changing -vims CWD all over the show. - -Thanks to Yegappan Lakshmanan (author of Taglist and other orgasmically -wonderful plugins) for telling me how to fix a bug that was causing vim to go -into visual mode everytime you double clicked a node :) - -Thanks to Jason Mills for sending me a fix that allows windows paths to use -forward slashes as well as backward. - -Thanks to Michael Geddes (frogonwheels on #vim at freenode) for giving me some -tips about syntax highlighting when i was doing highlighting for the -quickhelp. - -Thanks to Yu Jun for emailing me about a bug that was occurring when closing -the tree. - -Thanks to Michael Madsen for emailing me about making case sensitivity -optional when sorting nodes. - -Thanks to AOYAMA Shotaro for suggesting that i echo a "please wait" message -when opening large directories. - -Thanks to Michael Madsen for requesting the NERDTreeCaseSensitiveSort option. - -Thanks to AOYAMA Shotaro for suggesting that a "please wait" style message be -echoed when opening large directories. Also, thanks for the suggestion of -having public functions in the script to access the internal data :D - -Thanks to Zhang Weiwu for emailing me about a bug with the the <tab> mapping -in 2.6.0 - -Thanks to Niels Aan de Brugh for the suggestion that the script now split the -window if you try to open a file in a window containing a modified buffer when -the &hidden option is set. - - - vim:tw=78:ts=8:ft=help:norl: diff --git a/.vim/doc/haskellmode.txt b/.vim/doc/haskellmode.txt deleted file mode 100644 index 27c224d..0000000 --- a/.vim/doc/haskellmode.txt +++ /dev/null @@ -1,465 +0,0 @@ -*haskellmode.txt* Haskell Mode Plugins 02/05/2009 - -Authors: - Claus Reinke <claus.reinke@talk21.com> ~ - -Homepage: - http://projects.haskell.org/haskellmode-vim - -CONTENTS *haskellmode* - - 1. Overview |haskellmode-overview| - 1.1 Runtime Requirements |haskellmode-requirements| - 1.2 Quick Reference |haskellmode-quickref| - 2. Settings |haskellmode-settings| - 2.1 GHC and web browser |haskellmode-settings-main| - 2.2 Fine tuning - more configuration options |haskellmode-settings-fine| - 3. GHC Compiler Integration |haskellmode-compiler| - 4. Haddock Integration |haskellmode-haddock| - 4.1 Indexing |haskellmode-indexing| - 4.2 Lookup |haskellmode-lookup| - 4.3 Editing |haskellmode-editing| - 5. Hpaste Integration |haskellmode-hpaste| - 6. Additional Resources |haskellmode-resources| - -============================================================================== - *haskellmode-overview* -1. Overview ~ - - The Haskell mode plugins provide advanced support for Haskell development - using GHC/GHCi on Windows and Unix-like systems. The functionality is - based on Haddock-generated library indices, on GHCi's interactive - commands, or on simply activating (some of) Vim's built-in program editing - support in Haskell-relevant fashion. These plugins live side-by-side with - the pre-defined |syntax-highlighting| support for |haskell| sources, and - any other Haskell-related plugins you might want to install (see - |haskellmode-resources|). - - The Haskell mode plugins consist of three filetype plugins (haskell.vim, - haskell_doc.vim, haskell_hpaste.vim), which by Vim's |filetype| detection - mechanism will be auto-loaded whenever files with the extension '.hs' are - opened, and one compiler plugin (ghc.vim) which you will need to load from - your vimrc file (see |haskellmode-settings|). - - - *haskellmode-requirements* -1.1 Runtime Requirements ~ - - The plugins require a recent installation of GHC/GHCi. The functionality - derived from Haddock-generated library indices also requires a local - installation of the Haddock documentation for GHC's libraries (if there is - no documentation package for your system, you can download a tar-ball from - haskell.org), as well as an HTML browser (see |haddock_browser|). If you - want to use the experimental hpaste interface, you will also need Wget. - - * GHC/GHCi ~ - Provides core functionality. http://www.haskell.org/ghc - - * HTML library documentation files and indices generated by Haddock ~ - These usually come with your GHC installation, possibly as a separate - package. If you cannot get them this way, you can download a tar-ball - matching your GHC version from http://www.haskell.org/ghc/docs/ - - * HTML browser with basic CSS support ~ - For browsing Haddock docs. - - * Wget ~ - For interfacing with http://hpaste.org. - - Wget is widely available for modern Unix-like operating systems. Several - ports also exist for Windows, including: - - - Official GNU Wget (natively compiled for Win32) - http://www.gnu.org/software/wget/#downloading - - - UnxUtils Wget (natively compiled for Win32, bundled with other ported - Unix utilities) - http://sourceforge.net/projects/unxutils/ - - - Cygwin Wget (emulated POSIX in Win32, must be run under Cygwin) - http://cygwin.com/packages/wget/ - - *haskellmode-quickref* -1.2 Quick Reference ~ - -|:make| load into GHCi, show errors (|quickfix| |:copen|) -|_ct| create |tags| file -|_si| show info for id under cursor -|_t| show type for id under cursor -|_T| insert type declaration for id under cursor -|balloon| show type for id under mouse pointer -|_?| browse Haddock entry for id under cursor -|_?1| search Hoogle for id under cursor -|_?2| search Hayoo! for id under cursor -|:IDoc| {identifier} browse Haddock entry for unqualified {identifier} -|:MDoc| {module} browse Haddock entry for {module} -|:FlagReference| {s} browse Users Guide Flag Reference for section {s} -|_.| qualify unqualified id under cursor -|_i| add 'import <module>(<identifier>)' for id under cursor -|_im| add 'import <module>' for id under cursor -|_iq| add 'import qualified <module>(<identifier>)' for id under cursor -|_iqm| add 'import qualified <module>' for id under cursor -|_ie| make imports explit for import statement under cursor -|_opt| add OPTIONS_GHC pragma -|_lang| add LANGUAGE pragma -|i_CTRL-X_CTRL-O| insert-mode completion based on imported ids (|haskellmode-XO|) -|i_CTRL-X_CTRL-U| insert-mode completion based on documented ids (|haskellmode-XU|) -|i_CTRL-N| insert-mode completion based on imported sources -|:GHCi|{command/expr} run GHCi command/expr in current module - -|:GHCStaticOptions| edit static GHC options for this buffer -|:DocSettings| show current Haddock-files-related plugin settings -|:DocIndex| populate Haddock index -|:ExportDocIndex| cache current Haddock index to a file -|:HpasteIndex| Read index of most recent entries from hpaste.org -|:HpastePostNew| Submit current buffer as a new hpaste - - -============================================================================== - *haskellmode-settings* -2. Settings ~ - - The plugins try to find their dependencies in standard locations, so if - you're lucky, you will only need to set |compiler| to ghc, and configure - the location of your favourite web browser. You will also want to make - sure that |filetype| detection and |syntax| highlighting are on. Given the - variety of things to guess, however, some dependencies might not be found - correctly, or the defaults might not be to your liking, in which case you - can do some more fine tuning. All of this configuration should happen in - your |vimrc|. -> - " enable syntax highlighting - syntax on - - " enable filetype detection and plugin loading - filetype plugin on -< - - *haskellmode-settings-main* -2.1 GHC and web browser ~ - - *compiler-ghc* *ghc-compiler* - To use the features provided by the GHC |compiler| plugin, use the - following |autocommand| in your vimrc: -> - au BufEnter *.hs compiler ghc -< - *g:ghc* - If the compiler plugin can't locate your GHC binary, or if you have - several versions of GHC installed and have a preference as to which binary - is used, set |g:ghc|: -> - :let g:ghc="/usr/bin/ghc-6.6.1" -< - *g:haddock_browser* - The preferred HTML browser for viewing Haddock documentation can be set as - follows: -> - :let g:haddock_browser="/usr/bin/firefox" -< - - *haskellmode-settings-fine* -2.2 Fine tuning - more configuration options ~ - - Most of the fine tuning is likely to happen for the haskellmode_doc.vim - plugin, so you can check the current settings for this plugin via the - command |:DocSettings|. If all the settings reported there are to your - liking, you probably won't need to do any fine tuning. - - *g:haddock_browser_callformat* - By default, the web browser|g:haddock_browser| will be started - asynchronously (in the background) on Windows or when vim is running in a - GUI, and synchronously (in the foreground) otherwise. These settings seem - to work fine if you are using a console mode browser (eg, when editing in - a remote session), or if you are starting a GUI browser that will launch - itself in the background. But if these settings do not work for you, you - can change the default browser launching behavior. - - This is controlled by |g:haddock_browser_callformat|. It specifies a - format string which uses two '%s' parameters, the first representing the - path of the browser to launch, and the second is the documentation URL - (minus the protocol specifier, i.e. file://) passed to it by the Haddock - plugin. For instance, to launch a GUI browser on Unix-like systems and - force it to the background (see also |shellredir|): -> - :let g:haddock_browser_callformat = '%s file://%s '.printf(&shellredir,'/dev/null').' &' -< - *g:haddock_docdir* - Your system's installed Haddock documentation for GHC and its libraries - should be automatically detected. If the plugin can't locate them, you - must point |g:haddock_docdir| to the path containing the master index.html - file for the subdirectories 'libraries', 'Cabal', 'users_guide', etc.: -> - :let g:haddock_docdir="/usr/local/share/doc/ghc/html/" -< - *g:haddock_indexfiledir* - The information gathered from Haddock's index files will be stored in a - file called 'haddock_index.vim' in a directory derived from the Haddock - location, or in $HOME. To configure another directory for the index file, - use: -> - :let g:haddock_indexfiledir="~/.vim/" -< - *g:wget* - If you also want to try the experimental hpaste functionality, you might - you need to set |g:wget| before the |hpaste| plugin is loaded (unless wget - is in your PATH): -> - :let g:wget="C:\Program Files\wget\wget.exe" -< - - Finally, the mappings actually use|<LocalLeader>|behind the scenes, so if - you have to, you can redefine|maplocalleader|to something other than '_'. - Just remember that the docs still refer to mappings starting with '_', to - avoid confusing the majority of users!-) - -============================================================================== - *haskellmode-compiler* *ghc* -3. GHC Compiler Integration ~ - - The GHC |compiler| plugin sets the basic |errorformat| and |makeprg| to - enable |quickfix| mode using GHCi, and provides functionality for show - info (|_si|), show type (|_t| or mouse |balloon|), add type declaration - (|_T|), create tag file (|_ct|), and insert-mode completion - (|i_CTRL-X_CTRL-O|) based on GHCi browsing of the current and imported - modules. - - To avoid frequent calls to GHCi, type information is cached in Vim. The - cache will be populated the first time a command depends on it, and will - be refreshed every time a |:make| goes through without generating errors - (if the |:make| does not succeed, the old types will remain available in - Vim). You can also unconditionally force reloading of type info using - |:GHCReload| (if GHCi cannot load your file, the type info will be empty). - - - In addition to the standard|quickfix| commands, the GHC compiler plugin - provides: - - *:GHCReload* -:GHCReload Reload modules and unconditionally refresh cache of - type info. Usually, |:make| is prefered, as that will - refresh the cache only if GHCi reports no errors, and - show the errors otherwise. - - *:GHCStaticOptions* -:GHCStaticOptions Edit the static GHC options (more generally, options - that cannot be set by in-file OPTIONS_GHC pragmas) - for the current buffer. Useful for adding hidden - packages (-package ghc), or additional import paths - (-isrc; you will then also want to augment |path|). - If you have static options you want to set as - defaults, you could use b:ghc_staticoptions, eg: -> - au FileType haskell let b:ghc_staticoptions = '-isrc' - au FileType haskell setlocal path += src -< - - *:GHCi* -:GHCi {command/expr} Run GHCi commands/expressions in the current module. - - *_ct* -_ct Create |tags| file for the current Haskell source - file. This uses GHCi's :ctags command, so it will work - recursively, but will only list tags for exported - entities. - - *_opt* -_opt Shows a menu of frequently used GHC compiler options - (selecting an entry adds the option as a pragma to the - start of the file). Uses popup menu (GUI) or :emenu - and command-line completion (CLI). - - *_lang* -_lang Shows a menu of the LANGUAGE options supported by GHC - (selecting an entry adds the language as a pragma to - the start of the file). Uses popup menu (GUI) or - :emenu and command-line completion (CLI). - - *_si* -_si Show extended information for the name under the - cursor. Uses GHCi's :info command. Output appears in - |preview-window| (when done, close with |:pclose|). - - *_t* -_t Show type for the name under the cursor. Uses cached - info from GHCi's :browse command. - - *_T* -_T Insert type declaration for the name under the cursor. - Uses cached info from GHCi's :browse command. - - *haskellmode-XO* *haskellmode-omni-completion* -CTRL-X CTRL-O Standard insert-mode omni-completion based on the - cached type info from GHCi browsing current and - imported modules. Only names from the current and from - imported modules are included (the completion menu - also show the type of each identifier). - -============================================================================== - *haskellmode-haddock* *haddock* -4. Haddock Integration ~ - - Haskell mode integrates with Haddock-generated HTML documentation, - providing features such as navigating to the Haddock entry for the - identifier under the cursor (|_?|), completion for the identifier under - the cursor (|i_CTRL-X_CTRL-U|), and adding import statements (|_i| |_im| - |_iq| |_iqm|) or module qualifier (|_.|) for the identifier under the - cursor. - - These commands operate on an internal Haddock index built from the - platform's installed Haddock documentation for GHC's libraries. Since - populating this index takes several seconds, it should be stored as a - file called 'haddock_index.vim' in the directory specified by - |g:haddock_indexfiledir|. - - Some commands present a different interface (popup menu or command-line - completion) according to whether the current Vim instance is graphical or - console-based (actually: whether or not the GUI is running). Such - differences are marked below with the annotations (GUI) and (CLI), - respectively. - - |:DocSettings| shows the settings for this plugin. If you are happy with - them, you can call |:ExportDocIndex| to populate and write out the - documentation index (should be called once for every new version of GHC). - - *:DocSettings* -:DocSettings Show current Haddock-files-related plugin settings. - - - *haskellmode-indexing* -4.1 Indexing ~ - - *:DocIndex* -:DocIndex Populate the Haddock index from the GHC library - documentation. - - *:ExportDocIndex* -:ExportDocIndex Cache the current Haddock index to a file (populate - index first, if empty). - - - *haskellmode-lookup* -4.2 Lookup ~ - - *_?* -_? Open the Haddock entry (in |haddock_browser|) for an - identifier under the cursor, selecting full - qualifications from a popup menu (GUI) or via - command-line completion (CLI), if the identifier is - not qualified. - - *_?1* -_?1 Search Hoogle (using |haddock_browser|) for an - identifier under the cursor. - - - *_?2* -_?2 Search Hayoo! (using |haddock_browser|) for an - identifier under the cursor. - - *:IDoc* -:IDoc {identifier} Open the Haddock entry for the unqualified - {identifier} in |haddock_browser|, suggesting possible - full qualifications. - - *:MDoc* -:MDoc {module} Open the Haddock entry for {module} in - |haddock_browser| (with command-line completion for - the fully qualified module name). - - *:FlagReference* -:FlagReference {s} Browse Users Guide Flag Reference for section {s} - (with command-line completion for section headers). - - - *haskellmode-editing* -4.3 Editing ~ - - *_.* -_. Fully qualify the unqualified name under the cursor - selecting full qualifications from a popup menu (GUI) - or via command-line completion (CLI). - - *_iq* *_i* -_i _iq Add 'import [qualified] <module>(<identifier>)' - statement for the identifier under the cursor, - selecting fully qualified modules from a popup menu - (GUI) or via command-line completion (CLI), if the - identifier is not qualified. This currently adds one - import statement per call instead of merging into - existing import statements. - - *_iqm* *_im* -_im Add 'import [qualified] <module>' statement for the - identifier under the cursor, selecting fully qualified - modules from a popup menu (GUI) or via command-line - completion (CLI), if the identifier is not qualified. - This currently adds one import statement per call - instead of merging into existing import statements. - - *_ie* -_ie On an 'import <module>' line, in a correctly loadable - module, temporarily comment out import and use :make - 'not in scope' errors to explicitly list imported - identifiers. - - *haskellmode-XU* *haskellmode-user-completion* -CTRL-X CTRL-U User-defined insert mode name completion based on all - names known to the Haddock index, including package - names. Completions are presented in a popup menu which - also displays the fully qualified module from which - each entry may be imported. - - CamelCode shortcuts are supported, meaning that - lower-case letters can be elided, using only - upper-case letters and module qualifier separators (.) - for disambiguation: - - pSL -> putStrLn - C.E.t -> Control.Exception.t - C.M.MP -> Control.Monad.MonadPlus - - To reduce unwanted matches, the first letter of such - shortcuts and the first letter after each '.' have to - match directly. - -============================================================================== - *haskellmode-hpaste* *hpaste* -5. Hpaste Integration ~ - - This experimental feature allows browsing and posting to - http://hpaste.org, a Web-based pastebin tailored for Haskell code. - - - *:HpasteIndex* -:HpasteIndex Read the most recent entries from hpaste.org. Show an - index of the entries in a new buffer, where ',r' will - open the current highlighted entry [and ',p' will - annotate it with the current buffer]. - - *:HpastePostNew* -:HpastePostNew Submit current buffer as a new hpaste entry. - [This, and ',p' above, are temporarily disabled, - needs update to new hpaste.org layout] - -============================================================================== - *haskellmode-resources* -6. Additional Resources ~ - - An quick screencast tour through of these plugins is available at: - - http://projects.haskell.org/haskellmode-vim/screencasts.html - - Other Haskell-related Vim plugins can be found here: - - http://www.haskell.org/haskellwiki/Libraries_and_tools/Program_development#Vim - - Make sure to read about Vim's other program-editing features in its online - |user-manual|. Also have a look at Vim tips and plugins at www.vim.org - - two other plugins I tend to use when editing Haskell are AlignPlugin.vim - (to line up regexps for definitions, keywords, comments, etc. in - consecutive lines) and surround.vim (to surround text with quotes, - brackets, parentheses, comments, etc.). - -============================================================================== - vim:tw=78:ts=8:ft=help: diff --git a/.vim/doc/omnicppcomplete.txt b/.vim/doc/omnicppcomplete.txt deleted file mode 100644 index b11e006..0000000 --- a/.vim/doc/omnicppcomplete.txt +++ /dev/null @@ -1,1078 +0,0 @@ -*omnicppcomplete.txt* Plugin for C/C++ omnicompletion -*omnicppcomplete* - -Author: Vissale NEANG (fromtonrouge AT gmail DOT com) -Last Change: 26 sept. 2007 - -OmniCppComplete version 0.41 - -For Vim version 7.0 and above - -============================================================================== - -1. Overview |omnicpp-overview| -2. Downloads |omnicpp-download| -3. Installation |omnicpp-installation| -4. Options |omnicpp-options| -5. Features |omnicpp-features| -6. Limitations |omnicpp-limitations| -7. FAQ & TIPS |omnicpp-faq| -8. History |omnicpp-history| -9. Thanks |omnicpp-thanks| - -============================================================================== -1. Overview~ - *omnicpp-overview* -The purpose of this script is to provide an 'omnifunc' function for C and C++ -language. In a C++ file, while in insert mode, you can use CTRL-X CTRL-O to: - - * Complete namespaces, classes, structs and unions - * Complete attribute members and return type of functions - * Complete the "this" pointer - * Complete an object after a cast (C and C++ cast) - * Complete typedefs and anonymous types - -You can set a "may complete" behaviour to start a completion automatically -after a '.', '->' or '::'. Please see |omnicpp-may-complete| for more details. - -The script needs an |Exuberant_ctags| database to work properly. - -============================================================================== -2. Downloads~ - *omnicpp-download* -You can download the latest release of the script from this url : - - http://www.vim.org/scripts/script.php?script_id=1520 - -You can download |Exuberant_ctags| from : - - http://ctags.sourceforge.net - -============================================================================== -3. Installation~ - *omnicpp-installation* -3.1. Script installation~ - -Unzip the downloaded file in your personal |vimfiles| directory (~/.vim under -unix or %HOMEPATH%\vimfiles under windows). The 'omnifunc' will be -automatically set for C and C++ files. - -You also have to enable plugins by adding these two lines in your|.vimrc|file: > - - set nocp - filetype plugin on -< -Please see |cp| and |filetype-plugin-on| sections for more details. - -3.1.1. Files~ - -After installation you should find these files : - - after\ftplugin\cpp.vim - after\ftplugin\c.vim - - autoload\omni\common\debug.vim - \utils.vim - - autoload\omni\cpp\complete.vim - \includes.vim - \items.vim - \maycomplete.vim - \namespaces.vim - \settings.vim - \tokenizer.vim - \utils.vim - - doc\omnicppcomplete.txt - -3.2. Building the Exuberant Ctags database~ - -To extract C/C++ symbols information, the script needs an |Exuberant_ctags| -database. - -You have to build your database with at least the following options: - --c++-kinds=+p : Adds prototypes in the database for C/C++ files. - --fields=+iaS : Adds inheritance (i), access (a) and function - signatures (S) information. - --extra=+q : Adds context to the tag name. Note: Without this - option, the script cannot get class members. - -Thus to build recursively a ctags database from the current directory, the -command looks like this: -> - ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . -< -You can add a map in your |.vimrc| file, eg: > - - map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> -< -Or you can add these options in your ctags config file (~/.ctags under unix or -%HOMEPATH%\ctags.cnf under windows) and execute the command : > - - :!ctags -R . -< -If your project contains files of other languages you may add the following -options: - --languages=c++ : Builds only the tags for C++ files. - -If your project contains macros you may also use the -I option. - -Please read the ctags help or ctags man page for more details. - -3.3. Setting the 'tags' option~ - -The default value of the option 'tags' is "./tags,tags" ("./tags,./TAGS,tags,TAGS" -when |+emacs_tags| is enabled), if you build your tag database with the cmd above, -you normally don't have to change this setting (The cmd used above generates a -file with the name "tags"). In this case your current working directory must be -the directory where the tags file reside. - -Note: When |+emacs_tags| is enabled, the script may display members twice, it's - recommended to set tags to "./tags,tags' or "./TAGS,TAGS". - -If your tags file is not named "tags" you have to add it in the 'tags' -option eg: > - - set tags+=/usr/tagsdir/mytagfile -< -You can ensure that the 'tags' option is set properly by executing the following -command: > - - :tselect MyClass -< -Where MyClass is a class of your project. This command should display all -possible tags for the type MyClass. - -3.4. Simple test~ - -Now you can do a simple test. Edit a C++ file and write the simplest case : > - - MyClass myObject; - myObject.<C-X><C-O> -< -You should see class members of MyClass. - -============================================================================== -4. Options~ - *omnicpp-options* - -You can change completion behaviour by setting script options in your |.vimrc| -configuration file. - -4.1. Global scope search toggle~ - *OmniCpp_GlobalScopeSearch* - -You can enable/disable the global scope search by setting the -OmniCpp_GlobalScopeSearch option. - -Possible values are : - 0 = disabled - 1 = enabled - [default=1] > - - let OmniCpp_GlobalScopeSearch = 1 -< -4.2. Namespace search method~ - *OmniCpp_NamespaceSearch* - -You can change the 'using namespace' search behaviour by setting the -OmniCpp_NamespaceSearch option. - -Possible values are : - 0 = namespaces disabled - 1 = search namespaces in the current buffer - 2 = search namespaces in the current buffer and in included files - [default=1] > - - let OmniCpp_NamespaceSearch = 1 -< -When OmniCpp_NamespaceSearch is 2, "using namespace" declarations are parsed -in the current buffer and also in included files. To find included files, the -script use the vim env 'path', so you have to set it properly. - -Note: included files are searched with lvimgrep, thus the location list of the -current window is changed. - -Note: When the 'filetype' is "c", namespace search is always disabled even if -OmniCpp_NamespaceSearch != 0 - -4.3. Class scope completion mode~ - *OmniCpp_DisplayMode* - -When you are completing a class scope (eg: MyClass::<C-X><C-O>), depending on -the current scope, you may see sometimes static, public, protected or private -members and sometimes you may see all members. By default the choice is done -automatically by the script but you can override it with the -OmniCpp_DisplayMode option. - -Note: This option can be use when you have friend classes in your project (the -script does not support friend classes). - -Possible values are : - 0 = auto - 1 = always show all members - [default=0] > - - let OmniCpp_DisplayMode = 0 -< -4.4. Show scope in abbreviation~ - *OmniCpp_ShowScopeInAbbr* - -By default, in the |omnicpp-popup| menu, you will see the scope of a match in -the last column. You can remove this column and add the scope at the beginning -of match abbreviation. -eg: - -OmniCpp_ShowScopeInAbbr = 0 - +-------------------------------------+ - |method1( f + MyNamespace::MyClass| - |_member1 m + MyNamespace::MyClass| - |_member2 m # MyNamespace::MyClass| - |_member3 m - MyNamespace::MyClass| - +-------------------------------------+ - -OmniCpp_ShowScopeInAbbr = 1 - +-------------------------------------+ - |MyNamespace::MyClass::method1( f + | - |MyNamespace::MyClass::_member1 m + | - |MyNamespace::MyClass::_member2 m # | - |MyNamespace::MyClass::_member3 m - | - +-------------------------------------+ - -Possible values are : - 0 = don't show scope in abbreviation - 1 = show scope in abbreviation and remove the last column - [default=0] > - - let OmniCpp_ShowScopeInAbbr = 0 -< -4.5. Show prototype in abbreviation~ - *OmniCpp_ShowPrototypeInAbbr* - -This option allows to display the prototype of a function in the abbreviation -part of the popup menu. - -Possible values are: - 0 = don't display prototype in abbreviation - 1 = display prototype in abbreviation - [default=0] > - - let OmniCpp_ShowPrototypeInAbbr = 0 -< -4.6. Show access~ - *OmniCpp_ShowAccess* - -This option allows to show/hide the access information ('+', '#', '-') in the -popup menu. - -Possible values are: - 0 = hide access - 1 = show access - [default=1] > - - let OmniCpp_ShowAccess = 1 - -4.7. Default using namespace list~ - *OmniCpp_DefaultNamespaces* - -When |OmniCpp_NamespaceSearch| is not 0, the script will parse using namespace -declarations in the current buffer and maybe in included files. -You can specify manually a default namespace list if you want with the -OmniCpp_DefaultNamespaces option. Each item in the list is a namespace name. -eg: If you have - - let OmniCpp_DefaultNamespaces = ["std", "MyNamespace"] - - It will be the same as inserting this declarations at the top of the - current buffer : - - using namespace std; - using namespace MyNamespace; - -This option can be use if you don't want to parse using namespace declarations -in included files and want to add namespaces that are always used in your -project. - -Possible values are : - List of String - [default=[]] > - - let OmniCpp_DefaultNamespaces = [] -< -4.8. May complete behaviour~ - *omnicpp-may-complete* - -This feature allows you to run automatically a completion after a '.', '->' -or '::'. By default, the "may complete" feature is set automatically for '.' -and '->'. The reason to not set this feature for the scope operator '::' is -sometimes you don't want to complete a namespace that contains many members. - -To enable/disable the "may complete" behaviour for dot, arrow and scope -operator, you can change the option OmniCpp_MayCompleteDot, -OmniCpp_MayCompleteArrow and OmniCpp_MayCompleteScope respectively. - - *OmniCpp_MayCompleteDot* -Possible values are : - 0 = May complete disabled for dot - 1 = May complete enabled for dot - [default=1] > - - let OmniCpp_MayCompleteDot = 1 -< - *OmniCpp_MayCompleteArrow* -Possible values are : - 0 = May complete disabled for arrow - 1 = May complete enabled for arrow - [default=1] > - - let OmniCpp_MayCompleteArrow = 1 -< - *OmniCpp_MayCompleteScope* -Possible values are : - 0 = May complete disabled for scope - 1 = May complete enabled for scope - [default=0] > - - let OmniCpp_MayCompleteScope = 0 -< - -Note: You can obviously continue to use <C-X><C-O> - -4.9. Select/Don't select first popup item~ - *OmniCpp_SelectFirstItem* - -Note: This option is only used when 'completeopt' does not contain "longest". - -When 'completeopt' does not contain "longest", Vim automatically select the -first entry of the popup menu. You can change this behaviour with the -OmniCpp_SelectFirstItem option. - -Possible values are: - 0 = don't select first popup item - 1 = select first popup item (inserting it to the text) - 2 = select first popup item (without inserting it to the text) - [default=0] > - - let OmniCpp_SelectFirstItem = 0 - -4.10 Use local search function for variable definitions~ - *OmniCpp_LocalSearchDecl* - -The internal search function for variable definitions of vim requires that the -enclosing braces of the function are located in the first column. You can -change this behaviour with the OmniCpp_LocalSearchDecl option. The local -version works irrespective the position of braces. - -Possible values are: - 0 = use standard vim search function - 1 = use local search function - [default=0] > - -============================================================================== -5. Features~ - *omnicpp-features* -5.1. Popup menu~ - *omnicpp-popup* -Popup menu format: - +-------------------------------------+ - |method1( f + MyNamespace::MyClass| - |_member1 m + MyNamespace::MyClass| - |_member2 m # MyNamespace::MyClass| - |_member3 m - MyNamespace::MyClass| - +-------------------------------------+ - ^ ^ ^ ^ - (1) (2)(3) (4) - -(1) name of the symbol, when a match ends with '(' it's a function. - -(2) kind of the symbol, possible kinds are : - * c = classes - * d = macro definitions - * e = enumerators (values inside an enumeration) - * f = function definitions - * g = enumeration names - * m = class, struct, and union members - * n = namespaces - * p = function prototypes - * s = structure names - * t = typedefs - * u = union names - * v = variable definitions - -(3) access, possible values are : - * + = public - * # = protected - * - = private -Note: enumerators have no access information - -(4) scope where the symbol is defined. -Note: If the scope is empty it's a global symbol -Note: anonymous scope may end with __anon[number] -eg: If you have an anonymous enum in MyNamespace::MyClass : > - - namespace MyNamespace - { - class MyClass - { - private: - - enum - { - E_ENUM0, - E_ENUM1, - E_ENUM2 - }; - }; - } -< - -You should see : - - +----------------------------------------------+ - |E_ENUM0 e MyNamespace::MyClass::__anon1| - |E_ENUM1 e MyNamespace::MyClass::__anon1| - |E_ENUM2 e MyNamespace::MyClass::__anon1| - +----------------------------------------------+ - ^ - __anon[number] - -5.2. Global scope completion~ - -The global scope completion allows you to complete global symbols for the base -you are currently typing. The base can start with '::' or not. -Note: Global scope completion only works with a non empty base, if you run a -completion just after a '::' the completion will fail. The reason is that if -there is no base to complete the script will try to display all the tags in -the database. For small project it could be not a problem but for others you -may wait 5 minutes or more for a result. - -eg1 : > - - pthread_cr<C-X><C-O> => pthread_create -< -Where pthread_create is a global function. -eg2: > - ::globa<C-X><C-O> => ::global_func( - +----------------+ - |global_func( f| - |global_var1 v| - |global_var2 v| - +----------------+ -< -Where global_var1, global_var2 and global_func are global symbols -eg3: > - ::<C-X><C-O> => [NO MATCH] -< -No match because a global completion from an empty base is not allowed. - -5.3. Namespace scope completion~ - -You can complete namespace members after a 'MyNamespace::'. Contrary to global -scope completion you can run a completion from an empty base. -Possible members are: - * Namespaces - * Classes - * Structs - * Unions - * Enums - * Functions - * Variables - * Typedefs - -eg: > - MyNamespace::<C-X><C-O> - +--------------------------------+ - |E_ENUM0 e MyNamespace| - |E_ENUM1 e MyNamespace| - |E_ENUM2 e MyNamespace| - |MyClass c MyNamespace| - |MyEnum g MyNamespace| - |MyStruct s MyNamespace| - |MyUnion u MyNamespace| - |SubNamespace n MyNamespace| - |doSomething( f MyNamespace| - |myVar v MyNamespace| - |something_t t MyNamespace| - +--------------------------------+ - -5.4. Class scope completion~ - -You can complete class members after a 'MyClass::'. Contrary to global scope -completion you can run a completion from an empty base. -By default, there is two behaviours for class scope completion. - - a) Completion of a base class of the current class scope - - When you are completing a base class of the current class scope, you - will see all members of this class in the popup menu. - eg: > - - class A - { - public: - enum - { - E_ENUM0, - E_ENUM1, - E_ENUM2, - }; - - void func1(); - static int _staticMember; - - private: - int _member; - }; - - class B : public A - { - public: - void doSomething(); - }; - - - void MyClassB::doSomething() - { - MyClassA::<C-X><C-O> - +---------------------------+ - |E_ENUM0 e MyClassA| - |E_ENUM1 e MyClassA| - |E_ENUM2 e MyClassA| - |func1( f + MyClassA| - |_member m - MyClassA| - |_staticMember m + MyClassA| - +---------------------------+ - } -< - - b) Completion of a non base class of the current class scope - - When you are completing a class that is not a base class of the - current class you will see only enumerators and static members. - eg: > - - class C - { - public: - void doSomething(); - }; - - void MyClassC::doSomething() - { - MyClassA::<C-X><C-O> - +---------------------------+ - |E_ENUM0 e MyClassA| - |E_ENUM1 e MyClassA| - |E_ENUM2 e MyClassA| - |_staticMember m + MyClassA| - +---------------------------+ - } -< -You can override the default behaviour by setting the -|OmniCpp_DisplayMode| option. - -5.5. Current scope completion~ - -When you start a completion from an empty instruction you are in "Current -scope completion" mode. You will see possible members of each context in -the context stack. -eg: > - void MyClass::doSomething() - { - using namespace MyNamespace; - using namespace SubNamespace; - - // You will see members of each context in the context stack - // 1) MyClass members - // 2) MyNamespace::SubNamespace members - // 3) MyNamespace members - - <C-X><C-O> - +------------------------------------------+ - |_member1 m + MyClass | - |_member2 m # MyClass | - |func1( f MyNamespace::SubNamespace| - |var v MyNamespace::SubNamespace| - |func1( f MyNamespace | - |var v MyNamespace | - +------------------------------------------+ - } -< - -5.6. Class, Struct and Union members completion~ - -You can complete members of class, struct and union instances after a '->' or -'.'. -eg: > - MyClass myObject; - myObject.<C-X><C-O> - +-----------------------+ - |_member1 m + MyClass | - |_member2 m # MyClass | - +-----------------------+ -< - -5.7. Attribute members and returned type completion~ - -You can complete a class member or a return type of a function. -eg: > - MyClass myObject; - - // Completion of the member _member1 - myObject._member1-><C-X><C-O> - +------------------------+ - |get( m + AnotherClass1| - +------------------------+ - - // Completion of the return type of the function get() - myObject._member1->get()-><C-X><C-O> - +--------------------------+ - |_member1 m + AnotherClass2| - |_member2 m # AnotherClass2| - |_member3 m - AnotherClass2| - +--------------------------+ - -5.8. Anonymous type completion~ - -Note: To use this feature you need at least|Exuberant_ctags| version 5.6 - -You can complete an anonymous type like this : > - struct - { - int a; - int b; - int c; - }globalVar; - - void func() - { - globalVar.<C-X><C-O> - +---------------+ - |a m + __anon1| - |b m + __anon1| - |c m + __anon1| - +---------------+ - } -< -Where globalVar is a global variable of an anonymous type - -5.9. Typedef completion~ - -You can complete a typedef. The typedef is resolved recursively, thus typedef -of typedef of... may not be a problem. - -You can also complete a typedef of an anonymous type, eg : > - typedef struct - { - int a; - int b; - int c; - }something_t; - - something_t globalVar; - - void func() - { - globalVar.<C-X><C-O> - +---------------+ - |a m + __anon1| - |b m + __anon1| - |c m + __anon1| - +---------------+ - } -< -Where globalVar is a global variable of typedef of an anonymous type. - -5.10. Completion of the "this" pointer~ - -You can complete the "this" pointer. -eg: > - this-><C-X><C-O> - +-----------------------+ - |_member1 m + MyClass | - |_member2 m # MyClass | - +-----------------------+ - - (*this).<C-X><C-O> - +-----------------------+ - |_member1 m + MyClass | - |_member2 m # MyClass | - +-----------------------+ -< - -5.11. Completion after a cast~ - -You can complete an object after a C or C++ cast. -eg: > - // C cast style - ((AnotherStruct*)pStruct)-><C-X><C-O> - - // C++ cast style - static_cast<AnotherStruct*>(pStruct)-><C-X><C-O> -< - -5.12. Preview window~ - -If the 'completeopt' option contains the setting "preview" (this is the -default value), you will see a preview window during the completion. -This window shows useful information like function signature, filename where -the symbol is define etc... - -The preview window contains tag information, the list below is non exhaustive. - - * name : name of the tag - * cmd : regexp or line number that helps to find the tag - * signature : signature for prototypes and functions - * kind : kind of the tag (eg: namespace, class etc...) - * access : access information (eg: public, protected, private) - * inherits : list of base classes - * filename : filename where the tag is define - -5.13. Code tokenization~ - -When you start a completion, the current instruction is tokenized ignoring -spaces, tabs, carriage returns and comments. Thus you can complete a symbol -even if the current instruction is on multiple lines, has comments between -words etc... : -eg: this case is unrealistic but it's just for illustration > - - myObject [ 0 ]/* Why is there a comment here ?*/ - ->_member - -> <C-X><C-O> -< - -============================================================================== -6. Limitations~ - *omnicpp-limitations* -Some C++ features are not supported by the script, some implemented features -may not work properly in some conditions. They are multiple reasons like a -lack of information in the database, performance issues and so on... - -6.1. Attribute members and returned type completion~ - -To work properly, the completion of attribute members and returned type of -functions depends on how you write your code in the class declaration. -Because the tags database does not contain information like return type or -type of a member, the script use the cmd information of the tag to determine -the type of an attribute member or the return type of a function. - -Thus, because the cmd is a regular expression (or line number for #define) if -you write your code like this : > - - class MyClass - { - public: - - MyOtherClass - _member; - }; -< -The type of _member will not be recognized, because the cmd will be -/^ _member;$/ and does not contain the type MyOtherClass. -The correct case should be : > - - class MyClass - { - public: - - MyOtherClass _member; - }; -< -It's the same problem for return type of function : > - - class MyClass - { - public: - - MyOtherClass - getOtherClass(); - }; -< -Here the cmd will be /^ getOtherClass();$/ and the script won't find the -return type. -The correct case should be : > - class MyClass - { - public: - - MyOtherClass getOtherClass(); - }; -< - -6.2. Static members~ - -It's the same problem as above, tags database does not contain information -about static members. The only fast way to get this information is to use the -cmd. - -6.3. Typedef~ - -It's the same problem as above, tags database does not contain information -about the type of a typedef. The script use the cmd information to resolve the -typedef. - -6.4. Restricted inheritance access~ - -Tags database contains inheritance information but unfortunately inheritance -access are not available. We could use the cmd but we often find code -indentation like this : > - - class A : - public B, - protected C, - private D - { - }; -< -Here the cmd will be /^class A :$/, we can't extract inheritance access. - -6.5. Using namespace parsing~ - -When you start a completion, using namespace declarations are parsed from the -cursor position to the first scope to detect local using namespace -declarations. After that, global using namespace declarations are parsed in the -file and included files. - -There is a limitation for global using namespace detection, for performance -issues only using namespace that starts a line will be detected. - -6.6. Friend classes~ - -Tags database does not contain information about friend classes. The script -does not support friend classes. - -6.7. Templates~ - -At the moment, |Exuberant_ctags| does not provide additional information for -templates. That's why the script does not handle templates. - -============================================================================== -7. FAQ & TIPS~ - *omnicpp-faq* - -* How to complete STL objects ? - If you have some troubles to generate a good ctags database for STL you - can try this solution : - - 1) Download SGI's STL from SGI's site - (http://www.sgi.com/tech/stl/download.html) - 2) Replace all __STL_BEGIN_NAMESPACE by "namespace std {" and - __STL_END_NAMESPACE by "}" from header and source files. (with Vim, - or with tar and sed or another tool) - 3) Run ctags and put the generated tags file in a directory eg: - ~/MyTags/stl.tags - 4) set tags+=~/MyTags/stl.tags - - The main problem is that you can't tell to ctags that - __STL_BEGIN_NAMESPACE = "namespace std {" even with the option -I. - That's why you need the step 2). - - Here is another solution if you have STL sources using _GLIBCXX_STD macro - (Tip by Nicola Bonelli) : > - - let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] -< -* How to close automatically the preview window after a completion ? - (Tip by Kamil Renczewski) - - You can add to your |vimrc| the following lines : > - - autocmd CursorMovedI * if pumvisible() == 0|pclose|endif - autocmd InsertLeave * if pumvisible() == 0|pclose|endif -< -============================================================================== -8. History~ - *omnicpp-history* -Version O.41 - - It's recommended to update ctags to version 5.7 or higher - - The plugin is now activated for C files - - New value for OmniCpp_SelectFirstItem when the option is equal to - 2 the first item is selected without inserting it to - the text (patch from Marek Olszewski) - - Bug when completing union members fixed with ctags 5.7 - (reported by Willem-Jan de Hoog) - - New option OmniCpp_LocalSearchDecl (patch from Roland Kuck) - - Bug when tags=something,,somethingelse (reported by Tobias Pflug) - - Bug with nested structure (reported by Mikhail Daen) - - Bug where the script fails to detect the type of a variable when - the ignorecase option is on (reported by Alexey Vakhov) - - Error message when trying to use completion on a not yet saved - Vim buffer (reported by Neil Bird) - - Error message when trying to use completion on an file opened from - a tselect command (reported by Henrique Andrade) - -Version 0.4 - - The script is renamed to OmniCppComplete according to the library - script directory structure. - - OmniCpp_ClassScopeCompletionMethod renamed to OmniCpp_DisplayMode - - Fixed a bug where the quickfix list is modified after a completion. - - OmniCpp_ShowPrototypeInAbbr option added. It allows to show the - function signature in the abbreviation. - - OmniCpp_ShowAccess option added. It allows to hide the access - information in the popup menu. - - The tags database format must be a ctags 5.6 database if you want to - complete anonymous types. - - Fixed current scope detection not working properly in destructors. - - Don't show protected and private members according to the current scope. - - Overloaded functions are now filtered properly. - - New cache system using less memory. - - The class scope of a method is now resolved properly with "using - namespace" declarations. - - OmniCpp_SelectFirstItem option added. It allows to not select the first - item in the popup menu when 'completeopt' does not contain "longest". - - Fixed the bug where a "random" item in the popup menu is selected - by default when 'completeopt' does not contain "longest" option. - - The script is now split in library scripts. - - Cache added for 'using namespace' search in included files - - Default value for OmniCpp_NamespaceSearch is now 1 (search only in the - current buffer). - - Namespace search automatically disabled for C files even if - OmniCpp_NamespaceSearch != 0. - - To avoid linear search in tags files, the ignorecase option is now - disabled when getting tags datas (the user setting is restored after). - - Fixed a bug where friend functions may crash the script and also crash vim. - -Version 0.32 - - Optimizations in search members methods. - - 'May complete' behaviour is now set to default for dot '.' and arrow - '->' (mappings are set in after/ftplugin/cpp.vim) - - Fixed the option CppOmni_ShowScopeInAbbr not detected after the first - completion. - - Exceptions catched from taglist() when a tag file is corrupted. - - Fixed a bug where enumerators in global scope didn't appear in the - popup menu. - -Version 0.31 - WARNING: For this release and future releases you have to build your tags - database with this cmd : - "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." - Please read installation instructions in the documentation for details - - - May complete added, please see installation notes for details. - - Fixed a bug where the completion works while in a comment or in a string. - -Version 0.3 - WARNING: For this release and future releases you have to build your tags - database with this cmd : - "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." - Please read installation instructions in the documentation for details - - - Documentation added. - - Fixed a bug where typedefs were not correctly resolved in namespaces - in some cases. - - Fixed a bug where the type can not be detected when we have a decl - like this: class A {}globalVar; - - Fixed a bug in type detection where searchdecl() (gd) find - incorrect declaration instruction. - - Global scope completion now only works with non-empty base. - - Using namespace list is now parsed in the current buffer and in - included files. - - Fixed a bug where the completion fails in some cases when the user - sets the ignorecase to on - - Preview window information added - - Some improvements in type detection, the type can be properly detected - with a declaration like this: - 'Class1 *class1A = NULL, **class1B = NULL, class1C[9], class1D[1] = {};' - - Fixed a bug where parent scopes were not displayed in the popup menu - in the current scope completion mode. - - Fixed a bug where an error message was displayed when the last - instruction was not finished. - - Fixed a bug where the completion fails if a punctuator or operator was - immediately after the cursor. - - The script can now detect parent contexts at the cursor position - thanks to 'using namespace' declarations. - It can also detect ambiguous namespaces. They are not included in - the context list. - - Fixed a bug where the current scope is not properly detected when - a file starts with a comment - - Fixed a bug where the type is not detected when we have myObject[0] - - Removed the system() call in SearchMembers(), no more calls to the - ctags binary. The user have to build correctly his database with the cmd: - "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." - - File time cache removed, the user have to rebuild his data base after a - modification. - -Version 0.22 - - Completion of unnamed type (eg: You can complete g_Var defined like - this 'struct {int a; int b;}g_Var;'). It also works for a typedef of - an unnamed type (eg: 'typedef struct {int a; int b;}t_mytype; t_mytype - g_Var;'). - - Tag file's time cache added, if a tag file has changed the global - scope result cache is cleared. - - Fixed a bug where the tokenization process enter in an infinite loop - when a file starts with '/*'. - -Version 0.21 - - Improvements on the global scope completion. - The user can now see the progression of the search and complete - matches are stored in a cache for optimization. The cache is cleared - when the tag env is modified. - - Within a class scope when the user complete an empty word, the popup - menu displays the members of the class then members of the global - scope. - - Fixed a bug where a current scope completion failed after a punctuator - or operator (eg: after a '=' or '!='). - -Version 0.2 - - Improvements in type detection (eg: when a variable is declared in a - parameter list, a catch clause, etc...) - - Code tokenization => ignoring spaces, tabs, carriage returns and comments - You can complete a code even if the instruction has bad - indentation, spaces or carriage returns between words - - Completion of class members added - - Detection of the current scope at the cursor position. - If you run a completion from en empty line, members of the current - scope are displayed. It works on the global namespace and the current - class scope (but there is not the combination of the 2 for the moment) - - Basic completion on the global namespace (very slow) - - Completion of returned type added - - this pointer completion added - - Completion after a cast added (C and C++ cast) - - Fixed a bug where the matches of the complete menu are not filtered - according to what the user typed - - Change the output of the popup menu. The type of the member - (function, member, enum etc...) is now display as a single letter. - The access information is display like this : '+' for a public member - '#' for a protected member and '-' for a private member. - The last information is the class, namespace or enum where the member is define. - -Version 0.12: - - Complete check added to the search process, you can now cancel - the search during a complete search. - -Version 0.1: - - First release - -============================================================================== -9. Thanks~ - *omnicpp-thanks* - * For advices, bug report, documentation, help, ideas : - Alexey Vakhov (bug report) - Arthur Axel "fREW" Schmidt (documentation) - Dennis Lubert (bug report) - Henrique Andrade (bug report) - Kamil Renczewski (tips) - Marek Olszewski (patch) - Markus Trenkwalder (bug report) - Martin Stubenschrott (bug report) - Mikhail Daen (bug report) - Neil Bird (bug report) - Nicola Bonelli (tips) - Robert Webb (bug report) - Roland Kuck (patch) - Tobias Pflug (bug report) - Willem-Jan de Hoog (bug report) - Yegappan Lakshmanan (advices) - - - * Darren Hiebert for Exuberant Ctags - - * All Vim devs for Vim - - * Bram Moolenaar for Vim - - * You for using this script :) - -============================================================================== - - vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: diff --git a/.vim/doc/surround.txt b/.vim/doc/surround.txt deleted file mode 100644 index 1f3ba3d..0000000 --- a/.vim/doc/surround.txt +++ /dev/null @@ -1,184 +0,0 @@ -*surround.txt* Plugin for deleting, changing, and adding "surroundings" - -Author: Tim Pope <vimNOSPAM@tpope.info> *surround-author* -License: Same terms as Vim itself (see |license|) - -This plugin is only available if 'compatible' is not set. - -INTRODUCTION *surround* - -This plugin is a tool for dealing with pairs of "surroundings." Examples -of surroundings include parentheses, quotes, and HTML tags. They are -closely related to what Vim refers to as |text-objects|. Provided -are mappings to allow for removing, changing, and adding surroundings. - -Details follow on the exact semantics, but first, consider the following -examples. An asterisk (*) is used to denote the cursor position. - - Old text Command New text ~ - "Hello *world!" ds" Hello world! - [123+4*56]/2 cs]) (123+456)/2 - "Look ma, I'm *HTML!" cs"<q> <q>Look ma, I'm HTML!</q> - if *x>3 { ysW( if ( x>3 ) { - my $str = *whee!; vlllls' my $str = 'whee!'; - -While a few features of this plugin will work in older versions of Vim, -Vim 7 is recommended for full functionality. - -MAPPINGS *surround-mappings* - -Delete surroundings is *ds*. The next character given determines the target -to delete. The exact nature of the target are explained in -|surround-targets| but essentially it is the last character of a -|text-object|. This mapping deletes the difference between the "inner" -object and "an" object. This is easiest to understand with some examples: - - Old text Command New text ~ - "Hello *world!" ds" Hello world! - (123+4*56)/2 ds) 123+456/2 - <div>Yo!*</div> dst Yo! - -Change surroundings is *cs*. It takes two arguments, a target like with -|ds|, and a replacement. Details about the second argument can be found -below in |surround-replacements|. Once again, examples are in order. - - Old text Command New text ~ - "Hello *world!" cs"' 'Hello world!' - "Hello *world!" cs"<q> <q>Hello world!</q> - (123+4*56)/2 cs)] [123+456]/2 - (123+4*56)/2 cs)[ [ 123+456 ]/2 - <div>Yo!*</div> cst<p> <p>Yo!</p> - -*ys* takes an valid Vim motion or text object as the first object, and wraps -it using the second argument as with |cs|. (Unfortunately there's no good -mnemonic for "ys"). - - Old text Command New text ~ - Hello w*orld! ysiw) Hello (world)! - -As a special case, *yss* operates on the current line, ignoring leading -whitespace. - - Old text Command New text ~ - Hello w*orld! yssB {Hello world!} - -There is also *yS* and *ySS* which indent the surrounded text and place it -on a line of its own. - -In visual mode, a simple "s" with an argument wraps the selection. This is -referred to as the *vs* mapping, although ordinarily there will be -additional keystrokes between the v and s. In linewise visual mode, the -surroundings are placed on separate lines. In blockwise visual mode, each -line is surrounded. - -An "S" in visual mode (*vS*) behaves similarly but always places the -surroundings on separate lines. Additionally, the surrounded text is -indented. In blockwise visual mode, using "S" instead of "s" instead skips -trailing whitespace. - -Note that "s" and "S" already have valid meaning in visual mode, but it is -identical to "c". If you have muscle memory for "s" and would like to use a -different key, add your own mapping and the existing one will be disabled. -> - vmap <Leader>s <Plug>Vsurround - vmap <Leader>S <Plug>VSurround -< -Finally, there is an experimental insert mode mapping on <C-S>. Beware that -this won't work on terminals with flow control (if you accidentally freeze -your terminal, use <C-Q> to unfreeze it). The mapping inserts the specified -surroundings and puts the cursor between them. If, immediately after <C-S> -and before the replacement, a second <C-S> or carriage return is pressed, -the prefix, cursor, and suffix will be placed on three separate lines. If -this is a common use case you can add a mapping for it as well. -> - imap <C-Z> <Plug>Isurround<CR> -< -TARGETS *surround-targets* - -The |ds| and |cs| commands both take a target as their first argument. The -possible targets are based closely on the |text-objects| provided by Vim. -In order for a target to work, the corresponding text object must be -supported in the version of Vim used (Vim 7 adds several text objects, and -thus is highly recommended). All targets are currently just one character. - -Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves -and their counterpart. If the opening mark is used, contained whitespace is -also trimmed. The targets b, B, r, and a are aliases for ), }, ], and > -(the first two mirror Vim; the second two are completely arbitrary and -subject to change). - -Three quote marks, ', ", `, represent themselves, in pairs. They are only -searched for on the current line. - -A t is a pair of HTML or XML tags. See |tag-blocks| for details. Remember -that you can specify a numerical argument if you want to get to a tag other -than the innermost one. - -The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|, -respectively. These are special in that they have nothing do delete, and -used with |ds| they are a no-op. With |cs|, one could consider them a -slight shortcut for ysi (cswb == ysiwb, more or less). - -A p represents a |paragraph|. This behaves similarly to w, W, and s above; -however, newlines are sometimes added and/or removed. - -REPLACEMENTS *surround-replacements* - -A replacement argument is a single character, and is required by |cs|, |ys|, -and |vs|. Undefined replacement characters (with the exception of -alphabetic characters) default to placing themselves at the beginning and -end of the destination, which can be useful for characters like / and |. - -If either ), }, ], or > is used, the text is wrapped in the appropriate -pair of characters. Similar behavior can be found with (, {, and [ (but not -<), which append an additional space to the inside. Like with the targets -above, b, B, r, and a are aliases for ), }, ], and >. - -If t or < is used, Vim prompts for an HTML/XML tag to insert. You may -specify attributes here and they will be stripped from the closing tag. -End your input by pressing <CR> or >. As an experimental feature, if , or -<C-T> is used, the tags will appear on lines by themselves. - -An experimental replacement of a LaTeX environment is provided on \ and l. -The name of the environment and any arguments will be input from a prompt. -The following shows the resulting environment from csp\tabular}{lc<CR> -> - \begin{tabular}{lc} - \end{tabular} -< -CUSTOMIZING *surround-customizing* - -The following adds a potential replacement on "-" (ASCII 45) in PHP files. -(To determine the ASCII code to use, :echo char2nr("-")). The carriage -return will be replaced by the original text. -> - autocmd FileType php let b:surround_45 = "<?php \r ?>" -< -This can be used in a PHP file as in the following example. - - Old text Command New text ~ - print "Hello *world!" yss- <?php print "Hello world!" ?> - -Additionally, one can use a global variable for globally available -replacements. -> - let g:surround_45 = "<% \r %>" - let g:surround_61 = "<%= \r %>" -< -ISSUES *surround-issues* - -Vim could potentially get confused when deleting/changing occurs at the very -end of the line. Please report any repeatable instances of this. - -Do we need to use |inputsave()|/|inputrestore()| with the tag replacement? - -Customization isn't very flexible. Need a system that allows for prompting, -like with HTML tags and LaTeX environments. - -Indenting is handled haphazardly. Need to decide the most appropriate -behavior and implement it. Right now one can do :let b:surround_indent = 1 -(or the global equivalent) to enable automatic re-indenting by Vim via |=|; -should this be the default? - -It would be nice if |.| would work to repeat an operation. - vim:tw=78:ts=8:ft=help:norl: diff --git a/.vim/doc/taglist.txt b/.vim/doc/taglist.txt deleted file mode 100755 index 6a62b39..0000000 --- a/.vim/doc/taglist.txt +++ /dev/null @@ -1,1501 +0,0 @@ -*taglist.txt* Plugin for browsing source code - -Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) -For Vim version 6.0 and above -Last change: 2007 May 24 - -1. Overview |taglist-intro| -2. Taglist on the internet |taglist-internet| -3. Requirements |taglist-requirements| -4. Installation |taglist-install| -5. Usage |taglist-using| -6. Options |taglist-options| -7. Commands |taglist-commands| -8. Global functions |taglist-functions| -9. Extending |taglist-extend| -10. FAQ |taglist-faq| -11. License |taglist-license| -12. Todo |taglist-todo| - -============================================================================== - *taglist-intro* -1. Overview~ - -The "Tag List" plugin is a source code browser plugin for Vim. This plugin -allows you to efficiently browse through source code files for different -programming languages. The "Tag List" plugin provides the following features: - - * Displays the tags (functions, classes, structures, variables, etc.) - defined in a file in a vertically or horizontally split Vim window. - * In GUI Vim, optionally displays the tags in the Tags drop-down menu and - in the popup menu. - * Automatically updates the taglist window as you switch between - files/buffers. As you open new files, the tags defined in the new files - are added to the existing file list and the tags defined in all the - files are displayed grouped by the filename. - * When a tag name is selected from the taglist window, positions the - cursor at the definition of the tag in the source file. - * Automatically highlights the current tag name. - * Groups the tags by their type and displays them in a foldable tree. - * Can display the prototype and scope of a tag. - * Can optionally display the tag prototype instead of the tag name in the - taglist window. - * The tag list can be sorted either by name or by chronological order. - * Supports the following language files: Assembly, ASP, Awk, Beta, C, - C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, - Lua, Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang, - SML, Sql, TCL, Verilog, Vim and Yacc. - * Can be easily extended to support new languages. Support for - existing languages can be modified easily. - * Provides functions to display the current tag name in the Vim status - line or the window title bar. - * The list of tags and files in the taglist can be saved and - restored across Vim sessions. - * Provides commands to get the name and prototype of the current tag. - * Runs in both console/terminal and GUI versions of Vim. - * Works with the winmanager plugin. Using the winmanager plugin, you - can use Vim plugins like the file explorer, buffer explorer and the - taglist plugin at the same time like an IDE. - * Can be used in both Unix and MS-Windows systems. - -============================================================================== - *taglist-internet* -2. Taglist on the internet~ - -The home page of the taglist plugin is at: -> - http://vim-taglist.sourceforge.net/ -< -You can subscribe to the taglist mailing list to post your questions or -suggestions for improvement or to send bug reports. Visit the following page -for subscribing to the mailing list: -> - http://groups.yahoo.com/group/taglist -< -============================================================================== - *taglist-requirements* -3. Requirements~ - -The taglist plugin requires the following: - - * Vim version 6.0 and above - * Exuberant ctags 5.0 and above - -The taglist plugin will work on all the platforms where the exuberant ctags -utility and Vim are supported (this includes MS-Windows and Unix based -systems). - -The taglist plugin relies on the exuberant ctags utility to dynamically -generate the tag listing. The exuberant ctags utility must be installed in -your system to use this plugin. The exuberant ctags utility is shipped with -most of the Linux distributions. You can download the exuberant ctags utility -from -> - http://ctags.sourceforge.net -< -The taglist plugin doesn't use or create a tags file and there is no need to -create a tags file to use this plugin. The taglist plugin will not work with -the GNU ctags or the Unix ctags utility. - -This plugin relies on the Vim "filetype" detection mechanism to determine the -type of the current file. You have to turn on the Vim filetype detection by -adding the following line to your .vimrc file: -> - filetype on -< -The taglist plugin will not work if you run Vim in the restricted mode (using -the -Z command-line argument). - -The taglist plugin uses the Vim system() function to invoke the exuberant -ctags utility. If Vim is compiled without the system() function then you -cannot use the taglist plugin. Some of the Linux distributions (Suse) compile -Vim without the system() function for security reasons. - -============================================================================== - *taglist-install* -4. Installation~ - -1. Download the taglist.zip file and unzip the files to the $HOME/.vim or the - $HOME/vimfiles or the $VIM/vimfiles directory. After this step, you should - have the following two files (the directory structure should be preserved): - - plugin/taglist.vim - main taglist plugin file - doc/taglist.txt - documentation (help) file - - Refer to the |add-plugin|and |'runtimepath'| Vim help pages for more - details about installing Vim plugins. -2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or $VIM/vimfiles/doc - directory, start Vim and run the ":helptags ." command to process the - taglist help file. Without this step, you cannot jump to the taglist help - topics. -3. If the exuberant ctags utility is not present in one of the directories in - the PATH environment variable, then set the 'Tlist_Ctags_Cmd' variable to - point to the location of the exuberant ctags utility (not to the directory) - in the .vimrc file. -4. If you are running a terminal/console version of Vim and the terminal - doesn't support changing the window width then set the - 'Tlist_Inc_Winwidth' variable to 0 in the .vimrc file. -5. Restart Vim. -6. You can now use the ":TlistToggle" command to open/close the taglist - window. You can use the ":help taglist" command to get more information - about using the taglist plugin. - -To uninstall the taglist plugin, remove the plugin/taglist.vim and -doc/taglist.txt files from the $HOME/.vim or $HOME/vimfiles directory. - -============================================================================== - *taglist-using* -5. Usage~ - -The taglist plugin can be used in several different ways. - -1. You can keep the taglist window open during the entire editing session. On - opening the taglist window, the tags defined in all the files in the Vim - buffer list will be displayed in the taglist window. As you edit files, the - tags defined in them will be added to the taglist window. You can select a - tag from the taglist window and jump to it. The current tag will be - highlighted in the taglist window. You can close the taglist window when - you no longer need the window. -2. You can configure the taglist plugin to process the tags defined in all the - edited files always. In this configuration, even if the taglist window is - closed and the taglist menu is not displayed, the taglist plugin will - processes the tags defined in newly edited files. You can then open the - taglist window only when you need to select a tag and then automatically - close the taglist window after selecting the tag. -3. You can configure the taglist plugin to display only the tags defined in - the current file in the taglist window. By default, the taglist plugin - displays the tags defined in all the files in the Vim buffer list. As you - switch between files, the taglist window will be refreshed to display only - the tags defined in the current file. -4. In GUI Vim, you can use the Tags pull-down and popup menu created by the - taglist plugin to display the tags defined in the current file and select a - tag to jump to it. You can use the menu without opening the taglist window. - By default, the Tags menu is disabled. -5. You can configure the taglist plugin to display the name of the current tag - in the Vim window status line or in the Vim window title bar. For this to - work without the taglist window or menu, you need to configure the taglist - plugin to process the tags defined in a file always. -6. You can save the tags defined in multiple files to a taglist session file - and load it when needed. You can also configure the taglist plugin to not - update the taglist window when editing new files. You can then manually add - files to the taglist window. - -Opening the taglist window~ -You can open the taglist window using the ":TlistOpen" or the ":TlistToggle" -commands. The ":TlistOpen" command opens the taglist window and jumps to it. -The ":TlistToggle" command opens or closes (toggle) the taglist window and the -cursor remains in the current window. If the 'Tlist_GainFocus_On_ToggleOpen' -variable is set to 1, then the ":TlistToggle" command opens the taglist window -and moves the cursor to the taglist window. - -You can map a key to invoke these commands. For example, the following command -creates a normal mode mapping for the <F8> key to toggle the taglist window. -> - nnoremap <silent> <F8> :TlistToggle<CR> -< -Add the above mapping to your ~/.vimrc or $HOME/_vimrc file. - -To automatically open the taglist window on Vim startup, set the -'Tlist_Auto_Open' variable to 1. - -You can also open the taglist window on startup using the following command -line: -> - $ vim +TlistOpen -< -Closing the taglist window~ -You can close the taglist window from the taglist window by pressing 'q' or -using the Vim ":q" command. You can also use any of the Vim window commands to -close the taglist window. Invoking the ":TlistToggle" command when the taglist -window is opened, closes the taglist window. You can also use the -":TlistClose" command to close the taglist window. - -To automatically close the taglist window when a tag or file is selected, you -can set the 'Tlist_Close_On_Select' variable to 1. To exit Vim when only the -taglist window is present, set the 'Tlist_Exit_OnlyWindow' variable to 1. - -Jumping to a tag or a file~ -You can select a tag in the taglist window either by pressing the <Enter> key -or by double clicking the tag name using the mouse. To jump to a tag on a -single mouse click set the 'Tlist_Use_SingleClick' variable to 1. - -If the selected file is already opened in a window, then the cursor is moved -to that window. If the file is not currently opened in a window then the file -is opened in the window used by the taglist plugin to show the previously -selected file. If there are no usable windows, then the file is opened in a -new window. The file is not opened in special windows like the quickfix -window, preview window and windows containing buffer with the 'buftype' option -set. - -To jump to the tag in a new window, press the 'o' key. To open the file in the -previous window (Ctrl-W_p) use the 'P' key. You can press the 'p' key to jump -to the tag but still keep the cursor in the taglist window (preview). - -To open the selected file in a tab, use the 't' key. If the file is already -present in a tab then the cursor is moved to that tab otherwise the file is -opened in a new tab. To jump to a tag in a new tab press Ctrl-t. The taglist -window is automatically opened in the newly created tab. - -Instead of jumping to a tag, you can open a file by pressing the <Enter> key -or by double clicking the file name using the mouse. - -In the taglist window, you can use the [[ or <Backspace> key to jump to the -beginning of the previous file. You can use the ]] or <Tab> key to jump to the -beginning of the next file. When you reach the first or last file, the search -wraps around and the jumps to the next/previous file. - -Highlighting the current tag~ -The taglist plugin automatically highlights the name of the current tag in the -taglist window. The Vim |CursorHold| autocmd event is used for this. If the -current tag name is not visible in the taglist window, then the taglist window -contents are scrolled to make that tag name visible. You can also use the -":TlistHighlightTag" command to force the highlighting of the current tag. - -The tag name is highlighted if no activity is performed for |'updatetime'| -milliseconds. The default value for this Vim option is 4 seconds. To avoid -unexpected problems, you should not set the |'updatetime'| option to a very -low value. - -To disable the automatic highlighting of the current tag name in the taglist -window, set the 'Tlist_Auto_Highlight_Tag' variable to zero. - -When entering a Vim buffer/window, the taglist plugin automatically highlights -the current tag in that buffer/window. If you like to disable the automatic -highlighting of the current tag when entering a buffer, set the -'Tlist_Highlight_Tag_On_BufEnter' variable to zero. - -Adding files to the taglist~ -When the taglist window is opened, all the files in the Vim buffer list are -processed and the supported files are added to the taglist. When you edit a -file in Vim, the taglist plugin automatically processes this file and adds it -to the taglist. If you close the taglist window, the tag information in the -taglist is retained. - -To process files even when the taglist window is not open, set the -'Tlist_Process_File_Always' variable to 1. - -You can manually add multiple files to the taglist without opening them using -the ":TlistAddFiles" and the ":TlistAddFilesRecursive" commands. - -For example, to add all the C files in the /my/project/dir directory to the -taglist, you can use the following command: -> - :TlistAddFiles /my/project/dir/*.c -< -Note that when adding several files with a large number of tags or a large -number of files, it will take several seconds to several minutes for the -taglist plugin to process all the files. You should not interrupt the taglist -plugin by pressing <CTRL-C>. - -You can recursively add multiple files from a directory tree using the -":TlistAddFilesRecursive" command: -> - :TlistAddFilesRecursive /my/project/dir *.c -< -This command takes two arguments. The first argument specifies the directory -from which to recursively add the files. The second optional argument -specifies the wildcard matching pattern for selecting the files to add. The -default pattern is * and all the files are added. - -Displaying tags for only one file~ -The taglist window displays the tags for all the files in the Vim buffer list -and all the manually added files. To display the tags for only the current -active buffer, set the 'Tlist_Show_One_File' variable to 1. - -Removing files from the taglist~ -You can remove a file from the taglist window, by pressing the 'd' key when the -cursor is on one of the tags listed for the file in the taglist window. The -removed file will no longer be displayed in the taglist window in the current -Vim session. To again display the tags for the file, open the file in a Vim -window and then use the ":TlistUpdate" command or use ":TlistAddFiles" command -to add the file to the taglist. - -When a buffer is removed from the Vim buffer list using the ":bdelete" or the -":bwipeout" command, the taglist is updated to remove the stored information -for this buffer. - -Updating the tags displayed for a file~ -The taglist plugin keeps track of the modification time of a file. When the -modification time changes (the file is modified), the taglist plugin -automatically updates the tags listed for that file. The modification time of -a file is checked when you enter a window containing that file or when you -load that file. - -You can also update or refresh the tags displayed for a file by pressing the -"u" key in the taglist window. If an existing file is modified, after the file -is saved, the taglist plugin automatically updates the tags displayed for the -file. - -You can also use the ":TlistUpdate" command to update the tags for the current -buffer after you made some changes to it. You should save the modified buffer -before you update the taglist window. Otherwise the listed tags will not -include the new tags created in the buffer. - -If you have deleted the tags displayed for a file in the taglist window using -the 'd' key, you can again display the tags for that file using the -":TlistUpdate" command. - -Controlling the taglist updates~ -To disable the automatic processing of new files or modified files, you can -set the 'Tlist_Auto_Update' variable to zero. When this variable is set to -zero, the taglist is updated only when you use the ":TlistUpdate" command or -the ":TlistAddFiles" or the ":TlistAddFilesRecursive" commands. You can use -this option to control which files are added to the taglist. - -You can use the ":TlistLock" command to lock the taglist contents. After this -command is executed, new files are not automatically added to the taglist. -When the taglist is locked, you can use the ":TlistUpdate" command to add the -current file or the ":TlistAddFiles" or ":TlistAddFilesRecursive" commands to -add new files to the taglist. To unlock the taglist, use the ":TlistUnlock" -command. - -Displaying the tag prototype~ -To display the prototype of the tag under the cursor in the taglist window, -press the space bar. If you place the cursor on a tag name in the taglist -window, then the tag prototype is displayed at the Vim status line after -|'updatetime'| milliseconds. The default value for the |'updatetime'| Vim -option is 4 seconds. - -You can get the name and prototype of a tag without opening the taglist window -and the taglist menu using the ":TlistShowTag" and the ":TlistShowPrototype" -commands. These commands will work only if the current file is already present -in the taglist. To use these commands without opening the taglist window, set -the 'Tlist_Process_File_Always' variable to 1. - -You can use the ":TlistShowTag" command to display the name of the tag at or -before the specified line number in the specified file. If the file name and -line number are not supplied, then this command will display the name of the -current tag. For example, -> - :TlistShowTag - :TlistShowTag myfile.java 100 -< -You can use the ":TlistShowPrototype" command to display the prototype of the -tag at or before the specified line number in the specified file. If the file -name and the line number are not supplied, then this command will display the -prototype of the current tag. For example, -> - :TlistShowPrototype - :TlistShowPrototype myfile.c 50 -< -In the taglist window, when the mouse is moved over a tag name, the tag -prototype is displayed in a balloon. This works only in GUI versions where -balloon evaluation is supported. - -Taglist window contents~ -The taglist window contains the tags defined in various files in the taglist -grouped by the filename and by the tag type (variable, function, class, etc.). -For tags with scope information (like class members, structures inside -structures, etc.), the scope information is displayed in square brackets "[]" -after the tag name. - -The contents of the taglist buffer/window are managed by the taglist plugin. -The |'filetype'| for the taglist buffer is set to 'taglist'. The Vim -|'modifiable'| option is turned off for the taglist buffer. You should not -manually edit the taglist buffer, by setting the |'modifiable'| flag. If you -manually edit the taglist buffer contents, then the taglist plugin will be out -of sync with the taglist buffer contents and the plugin will no longer work -correctly. To redisplay the taglist buffer contents again, close the taglist -window and reopen it. - -Opening and closing the tag and file tree~ -In the taglist window, the tag names are displayed as a foldable tree using -the Vim folding support. You can collapse the tree using the '-' key or using -the Vim |zc| fold command. You can open the tree using the '+' key or using -the Vim |zo| fold command. You can open all the folds using the '*' key or -using the Vim |zR| fold command. You can also use the mouse to open/close the -folds. You can close all the folds using the '=' key. You should not manually -create or delete the folds in the taglist window. - -To automatically close the fold for the inactive files/buffers and open only -the fold for the current buffer in the taglist window, set the -'Tlist_File_Fold_Auto_Close' variable to 1. - -Sorting the tags for a file~ -The tags displayed in the taglist window can be sorted either by their name or -by their chronological order. The default sorting method is by the order in -which the tags appear in a file. You can change the default sort method by -setting the 'Tlist_Sort_Type' variable to either "name" or "order". You can -sort the tags by their name by pressing the "s" key in the taglist window. You -can again sort the tags by their chronological order using the "s" key. Each -file in the taglist window can be sorted using different order. - -Zooming in and out of the taglist window~ -You can press the 'x' key in the taglist window to maximize the taglist -window width/height. The window will be maximized to the maximum possible -width/height without closing the other existing windows. You can again press -'x' to restore the taglist window to the default width/height. - - *taglist-session* -Taglist Session~ -A taglist session refers to the group of files and their tags stored in the -taglist in a Vim session. - -You can save and restore a taglist session (and all the displayed tags) using -the ":TlistSessionSave" and ":TlistSessionLoad" commands. - -To save the information about the tags and files in the taglist to a file, use -the ":TlistSessionSave" command and specify the filename: -> - :TlistSessionSave <file name> -< -To load a saved taglist session, use the ":TlistSessionLoad" command: > - - :TlistSessionLoad <file name> -< -When you load a taglist session file, the tags stored in the file will be -added to the tags already stored in the taglist. - -The taglist session feature can be used to save the tags for large files or a -group of frequently used files (like a project). By using the taglist session -file, you can minimize the amount to time it takes to load/refresh the taglist -for multiple files. - -You can create more than one taglist session file for multiple groups of -files. - -Displaying the tag name in the Vim status line or the window title bar~ -You can use the Tlist_Get_Tagname_By_Line() function provided by the taglist -plugin to display the current tag name in the Vim status line or the window -title bar. Similarly, you can use the Tlist_Get_Tag_Prototype_By_Line() -function to display the current tag prototype in the Vim status line or the -window title bar. - -For example, the following command can be used to display the current tag name -in the status line: -> - :set statusline=%<%f%=%([%{Tlist_Get_Tagname_By_Line()}]%) -< -The following command can be used to display the current tag name in the -window title bar: -> - :set title titlestring=%<%f\ %([%{Tlist_Get_Tagname_By_Line()}]%) -< -Note that the current tag name can be displayed only after the file is -processed by the taglist plugin. For this, you have to either set the -'Tlist_Process_File_Always' variable to 1 or open the taglist window or use -the taglist menu. For more information about configuring the Vim status line, -refer to the documentation for the Vim |'statusline'| option. - -Changing the taglist window highlighting~ -The following Vim highlight groups are defined and used to highlight the -various entities in the taglist window: - - TagListTagName - Used for tag names - TagListTagScope - Used for tag scope - TagListTitle - Used for tag titles - TagListComment - Used for comments - TagListFileName - Used for filenames - -By default, these highlight groups are linked to the standard Vim highlight -groups. If you want to change the colors used for these highlight groups, -prefix the highlight group name with 'My' and define it in your .vimrc or -.gvimrc file: MyTagListTagName, MyTagListTagScope, MyTagListTitle, -MyTagListComment and MyTagListFileName. For example, to change the colors -used for tag names, you can use the following command: -> - :highlight MyTagListTagName guifg=blue ctermfg=blue -< -Controlling the taglist window~ -To use a horizontally split taglist window, instead of a vertically split -window, set the 'Tlist_Use_Horiz_Window' variable to 1. - -To use a vertically split taglist window on the rightmost side of the Vim -window, set the 'Tlist_Use_Right_Window' variable to 1. - -You can specify the width of the vertically split taglist window, by setting -the 'Tlist_WinWidth' variable. You can specify the height of the horizontally -split taglist window, by setting the 'Tlist_WinHeight' variable. - -When opening a vertically split taglist window, the Vim window width is -increased to accommodate the new taglist window. When the taglist window is -closed, the Vim window is reduced. To disable this, set the -'Tlist_Inc_Winwidth' variable to zero. - -To reduce the number of empty lines in the taglist window, set the -'Tlist_Compact_Format' variable to 1. - -To not display the Vim fold column in the taglist window, set the -'Tlist_Enable_Fold_Column' variable to zero. - -To display the tag prototypes instead of the tag names in the taglist window, -set the 'Tlist_Display_Prototype' variable to 1. - -To not display the scope of the tags next to the tag names, set the -'Tlist_Display_Tag_Scope' variable to zero. - - *taglist-keys* -Taglist window key list~ -The following table lists the description of the keys that can be used -in the taglist window. - - Key Description~ - - <CR> Jump to the location where the tag under cursor is - defined. - o Jump to the location where the tag under cursor is - defined in a new window. - P Jump to the tag in the previous (Ctrl-W_p) window. - p Display the tag definition in the file window and - keep the cursor in the taglist window itself. - t Jump to the tag in a new tab. If the file is already - opened in a tab, move to that tab. - Ctrl-t Jump to the tag in a new tab. - <Space> Display the prototype of the tag under the cursor. - For file names, display the full path to the file, - file type and the number of tags. For tag types, display the - tag type and the number of tags. - u Update the tags listed in the taglist window - s Change the sort order of the tags (by name or by order) - d Remove the tags for the file under the cursor - x Zoom-in or Zoom-out the taglist window - + Open a fold - - Close a fold - * Open all folds - = Close all folds - [[ Jump to the beginning of the previous file - <Backspace> Jump to the beginning of the previous file - ]] Jump to the beginning of the next file - <Tab> Jump to the beginning of the next file - q Close the taglist window - <F1> Display help - -The above keys will work in both the normal mode and the insert mode. - - *taglist-menu* -Taglist menu~ -When using GUI Vim, the taglist plugin can display the tags defined in the -current file in the drop-down menu and the popup menu. By default, this -feature is turned off. To turn on this feature, set the 'Tlist_Show_Menu' -variable to 1. - -You can jump to a tag by selecting the tag name from the menu. You can use the -taglist menu independent of the taglist window i.e. you don't need to open the -taglist window to get the taglist menu. - -When you switch between files/buffers, the taglist menu is automatically -updated to display the tags defined in the current file/buffer. - -The tags are grouped by their type (variables, functions, classes, methods, -etc.) and displayed as a separate sub-menu for each type. If all the tags -defined in a file are of the same type (e.g. functions), then the sub-menu is -not used. - -If the number of items in a tag type submenu exceeds the value specified by -the 'Tlist_Max_Submenu_Items' variable, then the submenu will be split into -multiple submenus. The default setting for 'Tlist_Max_Submenu_Items' is 25. -The first and last tag names in the submenu are used to form the submenu name. -The menu items are prefixed by alpha-numeric characters for easy selection by -keyboard. - -If the popup menu support is enabled (the |'mousemodel'| option contains -"popup"), then the tags menu is added to the popup menu. You can access -the popup menu by right clicking on the GUI window. - -You can regenerate the tags menu by selecting the 'Tags->Refresh menu' entry. -You can sort the tags listed in the menu either by name or by order by -selecting the 'Tags->Sort menu by->Name/Order' menu entry. - -You can tear-off the Tags menu and keep it on the side of the Vim window -for quickly locating the tags. - -Using the taglist plugin with the winmanager plugin~ -You can use the taglist plugin with the winmanager plugin. This will allow you -to use the file explorer, buffer explorer and the taglist plugin at the same -time in different windows. To use the taglist plugin with the winmanager -plugin, set 'TagList' in the 'winManagerWindowLayout' variable. For example, -to use the file explorer plugin and the taglist plugin at the same time, use -the following setting: > - - let winManagerWindowLayout = 'FileExplorer|TagList' -< -Getting help~ -If you have installed the taglist help file (this file), then you can use the -Vim ":help taglist-<keyword>" command to get help on the various taglist -topics. - -You can press the <F1> key in the taglist window to display the help -information about using the taglist window. If you again press the <F1> key, -the help information is removed from the taglist window. - - *taglist-debug* -Debugging the taglist plugin~ -You can use the ":TlistDebug" command to enable logging of the debug messages -from the taglist plugin. To display the logged debug messages, you can use the -":TlistMessages" command. To disable the logging of the debug messages, use -the ":TlistUndebug" command. - -You can specify a file name to the ":TlistDebug" command to log the debug -messages to a file. Otherwise, the debug messages are stored in a script-local -variable. In the later case, to minimize memory usage, only the last 3000 -characters from the debug messages are stored. - -============================================================================== - *taglist-options* -6. Options~ - -A number of Vim variables control the behavior of the taglist plugin. These -variables are initialized to a default value. By changing these variables you -can change the behavior of the taglist plugin. You need to change these -settings only if you want to change the behavior of the taglist plugin. You -should use the |:let| command in your .vimrc file to change the setting of any -of these variables. - -The configurable taglist variables are listed below. For a detailed -description of these variables refer to the text below this table. - -|'Tlist_Auto_Highlight_Tag'| Automatically highlight the current tag in the - taglist. -|'Tlist_Auto_Open'| Open the taglist window when Vim starts. -|'Tlist_Auto_Update'| Automatically update the taglist to include - newly edited files. -|'Tlist_Close_On_Select'| Close the taglist window when a file or tag is - selected. -|'Tlist_Compact_Format'| Remove extra information and blank lines from - the taglist window. -|'Tlist_Ctags_Cmd'| Specifies the path to the ctags utility. -|'Tlist_Display_Prototype'| Show prototypes and not tags in the taglist - window. -|'Tlist_Display_Tag_Scope'| Show tag scope next to the tag name. -|'Tlist_Enable_Fold_Column'| Show the fold indicator column in the taglist - window. -|'Tlist_Exit_OnlyWindow'| Close Vim if the taglist is the only window. -|'Tlist_File_Fold_Auto_Close'| Close tag folds for inactive buffers. -|'Tlist_GainFocus_On_ToggleOpen'| - Jump to taglist window on open. -|'Tlist_Highlight_Tag_On_BufEnter'| - On entering a buffer, automatically highlight - the current tag. -|'Tlist_Inc_Winwidth'| Increase the Vim window width to accommodate - the taglist window. -|'Tlist_Max_Submenu_Items'| Maximum number of items in a tags sub-menu. -|'Tlist_Max_Tag_Length'| Maximum tag length used in a tag menu entry. -|'Tlist_Process_File_Always'| Process files even when the taglist window is - closed. -|'Tlist_Show_Menu'| Display the tags menu. -|'Tlist_Show_One_File'| Show tags for the current buffer only. -|'Tlist_Sort_Type'| Sort method used for arranging the tags. -|'Tlist_Use_Horiz_Window'| Use a horizontally split window for the - taglist window. -|'Tlist_Use_Right_Window'| Place the taglist window on the right side. -|'Tlist_Use_SingleClick'| Single click on a tag jumps to it. -|'Tlist_WinHeight'| Horizontally split taglist window height. -|'Tlist_WinWidth'| Vertically split taglist window width. - - *'Tlist_Auto_Highlight_Tag'* -Tlist_Auto_Highlight_Tag~ -The taglist plugin will automatically highlight the current tag in the taglist -window. If you want to disable this, then you can set the -'Tlist_Auto_Highlight_Tag' variable to zero. Note that even though the current -tag highlighting is disabled, the tags for a new file will still be added to -the taglist window. -> - let Tlist_Auto_Highlight_Tag = 0 -< -With the above variable set to 1, you can use the ":TlistHighlightTag" command -to highlight the current tag. - - *'Tlist_Auto_Open'* -Tlist_Auto_Open~ -To automatically open the taglist window, when you start Vim, you can set the -'Tlist_Auto_Open' variable to 1. By default, this variable is set to zero and -the taglist window will not be opened automatically on Vim startup. -> - let Tlist_Auto_Open = 1 -< -The taglist window is opened only when a supported type of file is opened on -Vim startup. For example, if you open text files, then the taglist window will -not be opened. - - *'Tlist_Auto_Update'* -Tlist_Auto_Update~ -When a new file is edited, the tags defined in the file are automatically -processed and added to the taglist. To stop adding new files to the taglist, -set the 'Tlist_Auto_Update' variable to zero. By default, this variable is set -to 1. -> - let Tlist_Auto_Update = 0 -< -With the above variable set to 1, you can use the ":TlistUpdate" command to -add the tags defined in the current file to the taglist. - - *'Tlist_Close_On_Select'* -Tlist_Close_On_Select~ -If you want to close the taglist window when a file or tag is selected, then -set the 'Tlist_Close_On_Select' variable to 1. By default, this variable is -set zero and when you select a tag or file from the taglist window, the window -is not closed. -> - let Tlist_Close_On_Select = 1 -< - *'Tlist_Compact_Format'* -Tlist_Compact_Format~ -By default, empty lines are used to separate different tag types displayed for -a file and the tags displayed for different files in the taglist window. If -you want to display as many tags as possible in the taglist window, you can -set the 'Tlist_Compact_Format' variable to 1 to get a compact display. -> - let Tlist_Compact_Format = 1 -< - *'Tlist_Ctags_Cmd'* -Tlist_Ctags_Cmd~ -The 'Tlist_Ctags_Cmd' variable specifies the location (path) of the exuberant -ctags utility. If exuberant ctags is present in any one of the directories in -the PATH environment variable, then there is no need to set this variable. - -The exuberant ctags tool can be installed under different names. When the -taglist plugin starts up, if the 'Tlist_Ctags_Cmd' variable is not set, it -checks for the names exuberant-ctags, exctags, ctags, ctags.exe and tags in -the PATH environment variable. If any one of the named executable is found, -then the Tlist_Ctags_Cmd variable is set to that name. - -If exuberant ctags is not present in one of the directories specified in the -PATH environment variable, then set this variable to point to the location of -the ctags utility in your system. Note that this variable should point to the -fully qualified exuberant ctags location and NOT to the directory in which -exuberant ctags is installed. If the exuberant ctags tool is not found in -either PATH or in the specified location, then the taglist plugin will not be -loaded. Examples: -> - let Tlist_Ctags_Cmd = 'd:\tools\ctags.exe' - let Tlist_Ctags_Cmd = '/usr/local/bin/ctags' -< - *'Tlist_Display_Prototype'* -Tlist_Display_Prototype~ -By default, only the tag name will be displayed in the taglist window. If you -like to see tag prototypes instead of names, set the 'Tlist_Display_Prototype' -variable to 1. By default, this variable is set to zero and only tag names -will be displayed. -> - let Tlist_Display_Prototype = 1 -< - *'Tlist_Display_Tag_Scope'* -Tlist_Display_Tag_Scope~ -By default, the scope of a tag (like a C++ class) will be displayed in -square brackets next to the tag name. If you don't want the tag scopes -to be displayed, then set the 'Tlist_Display_Tag_Scope' to zero. By default, -this variable is set to 1 and the tag scopes will be displayed. -> - let Tlist_Display_Tag_Scope = 0 -< - *'Tlist_Enable_Fold_Column'* -Tlist_Enable_Fold_Column~ -By default, the Vim fold column is enabled and displayed in the taglist -window. If you wish to disable this (for example, when you are working with a -narrow Vim window or terminal), you can set the 'Tlist_Enable_Fold_Column' -variable to zero. -> - let Tlist_Enable_Fold_Column = 1 -< - *'Tlist_Exit_OnlyWindow'* -Tlist_Exit_OnlyWindow~ -If you want to exit Vim if only the taglist window is currently opened, then -set the 'Tlist_Exit_OnlyWindow' variable to 1. By default, this variable is -set to zero and the Vim instance will not be closed if only the taglist window -is present. -> - let Tlist_Exit_OnlyWindow = 1 -< - *'Tlist_File_Fold_Auto_Close'* -Tlist_File_Fold_Auto_Close~ -By default, the tags tree displayed in the taglist window for all the files is -opened. You can close/fold the tags tree for the files manually. To -automatically close the tags tree for inactive files, you can set the -'Tlist_File_Fold_Auto_Close' variable to 1. When this variable is set to 1, -the tags tree for the current buffer is automatically opened and for all the -other buffers is closed. -> - let Tlist_File_Fold_Auto_Close = 1 -< - *'Tlist_GainFocus_On_ToggleOpen'* -Tlist_GainFocus_On_ToggleOpen~ -When the taglist window is opened using the ':TlistToggle' command, this -option controls whether the cursor is moved to the taglist window or remains -in the current window. By default, this option is set to 0 and the cursor -remains in the current window. When this variable is set to 1, the cursor -moves to the taglist window after opening the taglist window. -> - let Tlist_GainFocus_On_ToggleOpen = 1 -< - *'Tlist_Highlight_Tag_On_BufEnter'* -Tlist_Highlight_Tag_On_BufEnter~ -When you enter a Vim buffer/window, the current tag in that buffer/window is -automatically highlighted in the taglist window. If the current tag name is -not visible in the taglist window, then the taglist window contents are -scrolled to make that tag name visible. If you like to disable the automatic -highlighting of the current tag when entering a buffer, you can set the -'Tlist_Highlight_Tag_On_BufEnter' variable to zero. The default setting for -this variable is 1. -> - let Tlist_Highlight_Tag_On_BufEnter = 0 -< - *'Tlist_Inc_Winwidth'* -Tlist_Inc_Winwidth~ -By default, when the width of the window is less than 100 and a new taglist -window is opened vertically, then the window width is increased by the value -set in the 'Tlist_WinWidth' variable to accommodate the new window. The value -of this variable is used only if you are using a vertically split taglist -window. - -If your terminal doesn't support changing the window width from Vim (older -version of xterm running in a Unix system) or if you see any weird problems in -the screen due to the change in the window width or if you prefer not to -adjust the window width then set the 'Tlist_Inc_Winwidth' variable to zero. -CAUTION: If you are using the MS-Windows version of Vim in a MS-DOS command -window then you must set this variable to zero, otherwise the system may hang -due to a Vim limitation (explained in :help win32-problems) -> - let Tlist_Inc_Winwidth = 0 -< - *'Tlist_Max_Submenu_Items'* -Tlist_Max_Submenu_Items~ -If a file contains too many tags of a particular type (function, variable, -class, etc.), greater than that specified by the 'Tlist_Max_Submenu_Items' -variable, then the menu for that tag type will be split into multiple -sub-menus. The default setting for the 'Tlist_Max_Submenu_Items' variable is -25. This can be changed by setting the 'Tlist_Max_Submenu_Items' variable: -> - let Tlist_Max_Submenu_Items = 20 -< -The name of the submenu is formed using the names of the first and the last -tag entries in that submenu. - - *'Tlist_Max_Tag_Length'* -Tlist_Max_Tag_Length~ -Only the first 'Tlist_Max_Tag_Length' characters from the tag names will be -used to form the tag type submenu name. The default value for this variable is -10. Change the 'Tlist_Max_Tag_Length' setting if you want to include more or -less characters: -> - let Tlist_Max_Tag_Length = 10 -< - *'Tlist_Process_File_Always'* -Tlist_Process_File_Always~ -By default, the taglist plugin will generate and process the tags defined in -the newly opened files only when the taglist window is opened or when the -taglist menu is enabled. When the taglist window is closed, the taglist plugin -will stop processing the tags for newly opened files. - -You can set the 'Tlist_Process_File_Always' variable to 1 to generate the list -of tags for new files even when the taglist window is closed and the taglist -menu is disabled. -> - let Tlist_Process_File_Always = 1 -< -To use the ":TlistShowTag" and the ":TlistShowPrototype" commands without the -taglist window and the taglist menu, you should set this variable to 1. - - *'Tlist_Show_Menu'* -Tlist_Show_Menu~ -When using GUI Vim, you can display the tags defined in the current file in a -menu named "Tags". By default, this feature is turned off. To turn on this -feature, set the 'Tlist_Show_Menu' variable to 1: -> - let Tlist_Show_Menu = 1 -< - *'Tlist_Show_One_File'* -Tlist_Show_One_File~ -By default, the taglist plugin will display the tags defined in all the loaded -buffers in the taglist window. If you prefer to display the tags defined only -in the current buffer, then you can set the 'Tlist_Show_One_File' to 1. When -this variable is set to 1, as you switch between buffers, the taglist window -will be refreshed to display the tags for the current buffer and the tags for -the previous buffer will be removed. -> - let Tlist_Show_One_File = 1 -< - *'Tlist_Sort_Type'* -Tlist_Sort_Type~ -The 'Tlist_Sort_Type' variable specifies the sort order for the tags in the -taglist window. The tags can be sorted either alphabetically by their name or -by the order of their appearance in the file (chronological order). By -default, the tag names will be listed by the order in which they are defined -in the file. You can change the sort type (from name to order or from order to -name) by pressing the "s" key in the taglist window. You can also change the -default sort order by setting 'Tlist_Sort_Type' to "name" or "order": -> - let Tlist_Sort_Type = "name" -< - *'Tlist_Use_Horiz_Window'* -Tlist_Use_Horiz_Window~ -Be default, the tag names are displayed in a vertically split window. If you -prefer a horizontally split window, then set the 'Tlist_Use_Horiz_Window' -variable to 1. If you are running MS-Windows version of Vim in a MS-DOS -command window, then you should use a horizontally split window instead of a -vertically split window. Also, if you are using an older version of xterm in a -Unix system that doesn't support changing the xterm window width, you should -use a horizontally split window. -> - let Tlist_Use_Horiz_Window = 1 -< - *'Tlist_Use_Right_Window'* -Tlist_Use_Right_Window~ -By default, the vertically split taglist window will appear on the left hand -side. If you prefer to open the window on the right hand side, you can set the -'Tlist_Use_Right_Window' variable to 1: -> - let Tlist_Use_Right_Window = 1 -< - *'Tlist_Use_SingleClick'* -Tlist_Use_SingleClick~ -By default, when you double click on the tag name using the left mouse -button, the cursor will be positioned at the definition of the tag. You -can set the 'Tlist_Use_SingleClick' variable to 1 to jump to a tag when -you single click on the tag name using the mouse. By default this variable -is set to zero. -> - let Tlist_Use_SingleClick = 1 -< -Due to a bug in Vim, if you set 'Tlist_Use_SingleClick' to 1 and try to resize -the taglist window using the mouse, then Vim will crash. This problem is fixed -in Vim 6.3 and above. In the meantime, instead of resizing the taglist window -using the mouse, you can use normal Vim window resizing commands to resize the -taglist window. - - *'Tlist_WinHeight'* -Tlist_WinHeight~ -The default height of the horizontally split taglist window is 10. This can be -changed by modifying the 'Tlist_WinHeight' variable: -> - let Tlist_WinHeight = 20 -< -The |'winfixheight'| option is set for the taglist window, to maintain the -height of the taglist window, when new Vim windows are opened and existing -windows are closed. - - *'Tlist_WinWidth'* -Tlist_WinWidth~ -The default width of the vertically split taglist window is 30. This can be -changed by modifying the 'Tlist_WinWidth' variable: -> - let Tlist_WinWidth = 20 -< -Note that the value of the |'winwidth'| option setting determines the minimum -width of the current window. If you set the 'Tlist_WinWidth' variable to a -value less than that of the |'winwidth'| option setting, then Vim will use the -value of the |'winwidth'| option. - -When new Vim windows are opened and existing windows are closed, the taglist -plugin will try to maintain the width of the taglist window to the size -specified by the 'Tlist_WinWidth' variable. - -============================================================================== - *taglist-commands* -7. Commands~ - -The taglist plugin provides the following ex-mode commands: - -|:TlistAddFiles| Add multiple files to the taglist. -|:TlistAddFilesRecursive| - Add files recursively to the taglist. -|:TlistClose| Close the taglist window. -|:TlistDebug| Start logging of taglist debug messages. -|:TlistLock| Stop adding new files to the taglist. -|:TlistMessages| Display the logged taglist plugin debug messages. -|:TlistOpen| Open and jump to the taglist window. -|:TlistSessionSave| Save the information about files and tags in the - taglist to a session file. -|:TlistSessionLoad| Load the information about files and tags stored - in a session file to taglist. -|:TlistShowPrototype| Display the prototype of the tag at or before the - specified line number. -|:TlistShowTag| Display the name of the tag defined at or before the - specified line number. -|:TlistHighlightTag| Highlight the current tag in the taglist window. -|:TlistToggle| Open or close (toggle) the taglist window. -|:TlistUndebug| Stop logging of taglist debug messages. -|:TlistUnlock| Start adding new files to the taglist. -|:TlistUpdate| Update the tags for the current buffer. - - *:TlistAddFiles* -:TlistAddFiles {file(s)} [file(s) ...] - Add one or more specified files to the taglist. You can - specify multiple filenames using wildcards. To specify a - file name with space character, you should escape the space - character with a backslash. - Examples: -> - :TlistAddFiles *.c *.cpp - :TlistAddFiles file1.html file2.html -< - If you specify a large number of files, then it will take some - time for the taglist plugin to process all of them. The - specified files will not be edited in a Vim window and will - not be added to the Vim buffer list. - - *:TlistAddFilesRecursive* -:TlistAddFilesRecursive {directory} [ {pattern} ] - Add files matching {pattern} recursively from the specified - {directory} to the taglist. If {pattern} is not specified, - then '*' is assumed. To specify the current directory, use "." - for {directory}. To specify a directory name with space - character, you should escape the space character with a - backslash. - Examples: -> - :TlistAddFilesRecursive myproject *.java - :TlistAddFilesRecursive smallproject -< - If large number of files are present in the specified - directory tree, then it will take some time for the taglist - plugin to process all of them. - - *:TlistClose* -:TlistClose Close the taglist window. This command can be used from any - one of the Vim windows. - - *:TlistDebug* -:TlistDebug [filename] - Start logging of debug messages from the taglist plugin. - If {filename} is specified, then the debug messages are stored - in the specified file. Otherwise, the debug messages are - stored in a script local variable. If the file {filename} is - already present, then it is overwritten. - - *:TlistLock* -:TlistLock - Lock the taglist and don't process new files. After this - command is executed, newly edited files will not be added to - the taglist. - - *:TlistMessages* -:TlistMessages - Display the logged debug messages from the taglist plugin - in a window. This command works only when logging to a - script-local variable. - - *:TlistOpen* -:TlistOpen Open and jump to the taglist window. Creates the taglist - window, if the window is not opened currently. After executing - this command, the cursor is moved to the taglist window. When - the taglist window is opened for the first time, all the files - in the buffer list are processed and the tags defined in them - are displayed in the taglist window. - - *:TlistSessionSave* -:TlistSessionSave {filename} - Saves the information about files and tags in the taglist to - the specified file. This command can be used to save and - restore the taglist contents across Vim sessions. - - *:TlistSessionLoad* -:TlistSessionLoad {filename} - Load the information about files and tags stored in the - specified session file to the taglist. - - *:TlistShowPrototype* -:TlistShowPrototype [filename] [linenumber] - Display the prototype of the tag at or before the specified - line number. If the file name and the line number are not - specified, then the current file name and line number are - used. A tag spans multiple lines starting from the line where - it is defined to the line before the next tag. This command - displays the prototype for the tag for any line number in this - range. - - *:TlistShowTag* -:TlistShowTag [filename] [linenumber] - Display the name of the tag defined at or before the specified - line number. If the file name and the line number are not - specified, then the current file name and line number are - used. A tag spans multiple lines starting from the line where - it is defined to the line before the next tag. This command - displays the tag name for any line number in this range. - - *:TlistHighlightTag* -:TlistHighlightTag - Highlight the current tag in the taglist window. By default, - the taglist plugin periodically updates the taglist window to - highlight the current tag. This command can be used to force - the taglist plugin to highlight the current tag. - - *:TlistToggle* -:TlistToggle Open or close (toggle) the taglist window. Opens the taglist - window, if the window is not opened currently. Closes the - taglist window, if the taglist window is already opened. When - the taglist window is opened for the first time, all the files - in the buffer list are processed and the tags are displayed in - the taglist window. After executing this command, the cursor - is not moved from the current window to the taglist window. - - *:TlistUndebug* -:TlistUndebug - Stop logging of debug messages from the taglist plugin. - - *:TlistUnlock* -:TlistUnlock - Unlock the taglist and start processing newly edited files. - - *:TlistUpdate* -:TlistUpdate Update the tags information for the current buffer. This - command can be used to re-process the current file/buffer and - get the tags information. As the taglist plugin uses the file - saved in the disk (instead of the file displayed in a Vim - buffer), you should save a modified buffer before you update - the taglist. Otherwise the listed tags will not include the - new tags created in the buffer. You can use this command even - when the taglist window is not opened. - -============================================================================== - *taglist-functions* -8. Global functions~ - -The taglist plugin provides several global functions that can be used from -other Vim plugins to interact with the taglist plugin. These functions are -described below. - -|Tlist_Update_File_Tags()| Update the tags for the specified file -|Tlist_Get_Tag_Prototype_By_Line()| Return the prototype of the tag at or - before the specified line number in the - specified file. -|Tlist_Get_Tagname_By_Line()| Return the name of the tag at or - before the specified line number in - the specified file. -|Tlist_Set_App()| Set the name of the application - controlling the taglist window. - - *Tlist_Update_File_Tags()* -Tlist_Update_File_Tags({filename}, {filetype}) - Update the tags for the file {filename}. The second argument - specifies the Vim filetype for the file. If the taglist plugin - has not processed the file previously, then the exuberant - ctags tool is invoked to generate the tags for the file. - - *Tlist_Get_Tag_Prototype_By_Line()* -Tlist_Get_Tag_Prototype_By_Line([{filename}, {linenumber}]) - Return the prototype of the tag at or before the specified - line number in the specified file. If the filename and line - number are not specified, then the current buffer name and the - current line number are used. - - *Tlist_Get_Tagname_By_Line()* -Tlist_Get_Tagname_By_Line([{filename}, {linenumber}]) - Return the name of the tag at or before the specified line - number in the specified file. If the filename and line number - are not specified, then the current buffer name and the - current line number are used. - - *Tlist_Set_App()* -Tlist_Set_App({appname}) - Set the name of the plugin that controls the taglist plugin - window and buffer. This can be used to integrate the taglist - plugin with other Vim plugins. - - For example, the winmanager plugin and the Cream package use - this function and specify the appname as "winmanager" and - "cream" respectively. - - By default, the taglist plugin is a stand-alone plugin and - controls the taglist window and buffer. If the taglist window - is controlled by an external plugin, then the appname should - be set appropriately. - -============================================================================== - *taglist-extend* -9. Extending~ - -The taglist plugin supports all the languages supported by the exuberant ctags -tool, which includes the following languages: Assembly, ASP, Awk, Beta, C, -C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, Lua, -Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang, SML, Sql, -TCL, Verilog, Vim and Yacc. - -You can extend the taglist plugin to add support for new languages and also -modify the support for the above listed languages. - -You should NOT make modifications to the taglist plugin script file to add -support for new languages. You will lose these changes when you upgrade to the -next version of the taglist plugin. Instead you should follow the below -described instructions to extend the taglist plugin. - -You can extend the taglist plugin by setting variables in the .vimrc or _vimrc -file. The name of these variables depends on the language name and is -described below. - -Modifying support for an existing language~ -To modify the support for an already supported language, you have to set the -tlist_xxx_settings variable in the ~/.vimrc or $HOME/_vimrc file. Replace xxx -with the Vim filetype name for the language file. For example, to modify the -support for the perl language files, you have to set the tlist_perl_settings -variable. To modify the support for java files, you have to set the -tlist_java_settings variable. - -To determine the filetype name used by Vim for a file, use the following -command in the buffer containing the file: - - :set filetype - -The above command will display the Vim filetype for the current buffer. - -The format of the value set in the tlist_xxx_settings variable is - - <language_name>;flag1:name1;flag2:name2;flag3:name3 - -The different fields in the value are separated by the ';' character. - -The first field 'language_name' is the name used by exuberant ctags to refer -to this language file. This name can be different from the file type name used -by Vim. For example, for C++, the language name used by ctags is 'c++' but the -filetype name used by Vim is 'cpp'. To get the list of language names -supported by exuberant ctags, use the following command: - - $ ctags --list-maps=all - -The remaining fields follow the format "flag:name". The sub-field 'flag' is -the language specific flag used by exuberant ctags to generate the -corresponding tags. For example, for the C language, to list only the -functions, the 'f' flag is used. To get the list of flags supported by -exuberant ctags for the various languages use the following command: - - $ ctags --list-kinds=all - -The sub-field 'name' specifies the title text to use for displaying the tags -of a particular type. For example, 'name' can be set to 'functions'. This -field can be set to any text string name. - -For example, to list only the classes and functions defined in a C++ language -file, add the following line to your .vimrc file: - - let tlist_cpp_settings = 'c++;c:class;f:function' - -In the above setting, 'cpp' is the Vim filetype name and 'c++' is the name -used by the exuberant ctags tool. 'c' and 'f' are the flags passed to -exuberant ctags to list C++ classes and functions and 'class' is the title -used for the class tags and 'function' is the title used for the function tags -in the taglist window. - -For example, to display only functions defined in a C file and to use "My -Functions" as the title for the function tags, use - - let tlist_c_settings = 'c;f:My Functions' - -When you set the tlist_xxx_settings variable, you will override the default -setting used by the taglist plugin for the 'xxx' language. You cannot add to -the default options used by the taglist plugin for a particular file type. To -add to the options used by the taglist plugin for a language, copy the option -values from the taglist plugin file to your .vimrc file and modify it. - -Adding support for a new language~ -If you want to add support for a new language to the taglist plugin, you need -to first extend the exuberant ctags tool. For more information about extending -exuberant ctags, visit the following page: - - http://ctags.sourceforge.net/EXTENDING.html - -To add support for a new language, set the tlist_xxx_settings variable in the -~/.vimrc file appropriately as described above. Replace 'xxx' in the variable -name with the Vim filetype name for the new language. - -For example, to extend the taglist plugin to support the latex language, you -can use the following line (assuming, you have already extended exuberant -ctags to support the latex language): - - let tlist_tex_settings='latex;b:bibitem;c:command;l:label' - -With the above line, when you edit files of filetype "tex" in Vim, the taglist -plugin will invoke the exuberant ctags tool passing the "latex" filetype and -the flags b, c and l to generate the tags. The text heading 'bibitem', -'command' and 'label' will be used in the taglist window for the tags which -are generated for the flags b, c and l respectively. - -============================================================================== - *taglist-faq* -10. Frequently Asked Questions~ - -Q. The taglist plugin doesn't work. The taglist window is empty and the tags - defined in a file are not displayed. -A. Are you using Vim version 6.0 and above? The taglist plugin relies on the - features supported by Vim version 6.0 and above. You can use the following - command to get the Vim version: -> - $ vim --version -< - Are you using exuberant ctags version 5.0 and above? The taglist plugin - relies on the features supported by exuberant ctags and will not work with - GNU ctags or the Unix ctags utility. You can use the following command to - determine whether the ctags installed in your system is exuberant ctags: -> - $ ctags --version -< - Is exuberant ctags present in one of the directories in your PATH? If not, - you need to set the Tlist_Ctags_Cmd variable to point to the location of - exuberant ctags. Use the following Vim command to verify that this is setup - correctly: -> - :echo system(Tlist_Ctags_Cmd . ' --version') -< - The above command should display the version information for exuberant - ctags. - - Did you turn on the Vim filetype detection? The taglist plugin relies on - the filetype detected by Vim and passes the filetype to the exuberant ctags - utility to parse the tags. Check the output of the following Vim command: -> - :filetype -< - The output of the above command should contain "filetype detection:ON". - To turn on the filetype detection, add the following line to the .vimrc or - _vimrc file: -> - filetype on -< - Is your version of Vim compiled with the support for the system() function? - The following Vim command should display 1: -> - :echo exists('*system') -< - In some Linux distributions (particularly Suse Linux), the default Vim - installation is built without the support for the system() function. The - taglist plugin uses the system() function to invoke the exuberant ctags - utility. You need to rebuild Vim after enabling the support for the - system() function. If you use the default build options, the system() - function will be supported. - - Do you have the |'shellslash'| option set? You can try disabling the - |'shellslash'| option. When the taglist plugin invokes the exuberant ctags - utility with the path to the file, if the incorrect slashes are used, then - you will see errors. - - Check the shell related Vim options values using the following command: -> - :set shell? shellcmdflag? shellpipe? - :set shellquote? shellredir? shellxquote? -< - If these options are set in your .vimrc or _vimrc file, try removing those - lines. - - Are you using a Unix shell in a MS-Windows environment? For example, - the Unix shell from the MKS-toolkit. Do you have the SHELL environment - set to point to this shell? You can try resetting the SHELL environment - variable. - - If you are using a Unix shell on MS-Windows, you should try to use - exuberant ctags that is compiled for Unix-like environments so that - exuberant ctags will understand path names with forward slash characters. - - Is your filetype supported by the exuberant ctags utility? The file types - supported by the exuberant ctags utility are listed in the ctags help. If a - file type is not supported, you have to extend exuberant ctags. You can use - the following command to list the filetypes supported by exuberant ctags: -> - ctags --list-languages -< - Run the following command from the shell prompt and check whether the tags - defined in your file are listed in the output from exuberant ctags: -> - ctags -f - --format=2 --excmd=pattern --fields=nks <filename> -< - If you see your tags in the output from the above command, then the - exuberant ctags utility is properly parsing your file. - - Do you have the .ctags or _ctags or the ctags.cnf file in your home - directory for specifying default options or for extending exuberant ctags? - If you do have this file, check the options in this file and make sure - these options are not interfering with the operation of the taglist plugin. - - If you are using MS-Windows, check the value of the TEMP and TMP - environment variables. If these environment variables are set to a path - with space characters in the name, then try using the DOS 8.3 short name - for the path or set them to a path without the space characters in the - name. For example, if the temporary directory name is "C:\Documents and - Settings\xyz\Local Settings\Temp", then try setting the TEMP variable to - the following: -> - set TEMP=C:\DOCUMEN~1\xyz\LOCALS~1\Temp -< - If exuberant ctags is installed in a directory with space characters in the - name, then try adding the directory to the PATH environment variable or try - setting the 'Tlist_Ctags_Cmd' variable to the shortest path name to ctags - or try copying the exuberant ctags to a path without space characters in - the name. For example, if exuberant ctags is installed in the directory - "C:\Program Files\Ctags", then try setting the 'Tlist_Ctags_Cmd' variable - as below: -> - let Tlist_Ctags_Cmd='C:\Progra~1\Ctags\ctags.exe' -< - If you are using a cygwin compiled version of exuberant ctags on MS-Windows, - make sure that either you have the cygwin compiled sort utility installed - and available in your PATH or compile exuberant ctags with internal sort - support. Otherwise, when exuberant ctags sorts the tags output by invoking - the sort utility, it may end up invoking the MS-Windows version of - sort.exe, thereby resulting in failure. - -Q. When I try to open the taglist window, I am seeing the following error - message. How do I fix this problem? - - Taglist: Failed to generate tags for /my/path/to/file - ctags: illegal option -- -^@usage: ctags [-BFadtuwvx] [-f tagsfile] file ... - -A. The taglist plugin will work only with the exuberant ctags tool. You - cannot use the GNU ctags or the Unix ctags program with the taglist plugin. - You will see an error message similar to the one shown above, if you try - use a non-exuberant ctags program with Vim. To fix this problem, either add - the exuberant ctags tool location to the PATH environment variable or set - the 'Tlist_Ctags_Cmd' variable. - -Q. A file has more than one tag with the same name. When I select a tag name - from the taglist window, the cursor is positioned at the incorrect tag - location. -A. The taglist plugin uses the search pattern generated by the exuberant ctags - utility to position the cursor at the location of a tag definition. If a - file has more than one tag with the same name and same prototype, then the - search pattern will be the same. In this case, when searching for the tag - pattern, the cursor may be positioned at the incorrect location. - -Q. I have made some modifications to my file and introduced new - functions/classes/variables. I have not yet saved my file. The taglist - plugin is not displaying the new tags when I update the taglist window. -A. The exuberant ctags utility will process only files that are present in the - disk. To list the tags defined in a file, you have to save the file and - then update the taglist window. - -Q. I have created a ctags file using the exuberant ctags utility for my source - tree. How do I configure the taglist plugin to use this tags file? -A. The taglist plugin doesn't use a tags file stored in disk. For every opened - file, the taglist plugin invokes the exuberant ctags utility to get the - list of tags dynamically. The Vim system() function is used to invoke - exuberant ctags and get the ctags output. This function internally uses a - temporary file to store the output. This file is deleted after the output - from the command is read. So you will never see the file that contains the - output of exuberant ctags. - -Q. When I set the |'updatetime'| option to a low value (less than 1000) and if - I keep pressing a key with the taglist window open, the current buffer - contents are changed. Why is this? -A. The taglist plugin uses the |CursorHold| autocmd to highlight the current - tag. The CursorHold autocmd triggers for every |'updatetime'| milliseconds. - If the |'updatetime'| option is set to a low value, then the CursorHold - autocmd will be triggered frequently. As the taglist plugin changes - the focus to the taglist window to highlight the current tag, this could - interfere with the key movement resulting in changing the contents of - the current buffer. The workaround for this problem is to not set the - |'updatetime'| option to a low value. - -============================================================================== - *taglist-license* -11. License~ -Permission is hereby granted to use and distribute the taglist plugin, with or -without modifications, provided that this copyright notice is copied with it. -Like anything else that's free, taglist.vim is provided *as is* and comes with -no warranty of any kind, either expressed or implied. In no event will the -copyright holder be liable for any damamges resulting from the use of this -software. - -============================================================================== - *taglist-todo* -12. Todo~ - -1. Group tags according to the scope and display them. For example, - group all the tags belonging to a C++/Java class -2. Support for displaying tags in a modified (not-yet-saved) file. -3. Automatically open the taglist window only for selected filetypes. - For other filetypes, close the taglist window. -4. When using the shell from the MKS toolkit, the taglist plugin - doesn't work. -5. The taglist plugin doesn't work with files edited remotely using the - netrw plugin. The exuberant ctags utility cannot process files over - scp/rcp/ftp, etc. - -============================================================================== - -vim:tw=78:ts=8:noet:ft=help: diff --git a/.vim/doc/tags b/.vim/doc/tags deleted file mode 100644 index d4f773b..0000000 --- a/.vim/doc/tags +++ /dev/null @@ -1,290 +0,0 @@ -'Tlist_Auto_Highlight_Tag' taglist.txt /*'Tlist_Auto_Highlight_Tag'* -'Tlist_Auto_Open' taglist.txt /*'Tlist_Auto_Open'* -'Tlist_Auto_Update' taglist.txt /*'Tlist_Auto_Update'* -'Tlist_Close_On_Select' taglist.txt /*'Tlist_Close_On_Select'* -'Tlist_Compact_Format' taglist.txt /*'Tlist_Compact_Format'* -'Tlist_Ctags_Cmd' taglist.txt /*'Tlist_Ctags_Cmd'* -'Tlist_Display_Prototype' taglist.txt /*'Tlist_Display_Prototype'* -'Tlist_Display_Tag_Scope' taglist.txt /*'Tlist_Display_Tag_Scope'* -'Tlist_Enable_Fold_Column' taglist.txt /*'Tlist_Enable_Fold_Column'* -'Tlist_Exit_OnlyWindow' taglist.txt /*'Tlist_Exit_OnlyWindow'* -'Tlist_File_Fold_Auto_Close' taglist.txt /*'Tlist_File_Fold_Auto_Close'* -'Tlist_GainFocus_On_ToggleOpen' taglist.txt /*'Tlist_GainFocus_On_ToggleOpen'* -'Tlist_Highlight_Tag_On_BufEnter' taglist.txt /*'Tlist_Highlight_Tag_On_BufEnter'* -'Tlist_Inc_Winwidth' taglist.txt /*'Tlist_Inc_Winwidth'* -'Tlist_Max_Submenu_Items' taglist.txt /*'Tlist_Max_Submenu_Items'* -'Tlist_Max_Tag_Length' taglist.txt /*'Tlist_Max_Tag_Length'* -'Tlist_Process_File_Always' taglist.txt /*'Tlist_Process_File_Always'* -'Tlist_Show_Menu' taglist.txt /*'Tlist_Show_Menu'* -'Tlist_Show_One_File' taglist.txt /*'Tlist_Show_One_File'* -'Tlist_Sort_Type' taglist.txt /*'Tlist_Sort_Type'* -'Tlist_Use_Horiz_Window' taglist.txt /*'Tlist_Use_Horiz_Window'* -'Tlist_Use_Right_Window' taglist.txt /*'Tlist_Use_Right_Window'* -'Tlist_Use_SingleClick' taglist.txt /*'Tlist_Use_SingleClick'* -'Tlist_WinHeight' taglist.txt /*'Tlist_WinHeight'* -'Tlist_WinWidth' taglist.txt /*'Tlist_WinWidth'* -:CVSEdit vcscommand.txt /*:CVSEdit* -:CVSEditors vcscommand.txt /*:CVSEditors* -:CVSUnedit vcscommand.txt /*:CVSUnedit* -:CVSWatch vcscommand.txt /*:CVSWatch* -:CVSWatchAdd vcscommand.txt /*:CVSWatchAdd* -:CVSWatchOff vcscommand.txt /*:CVSWatchOff* -:CVSWatchOn vcscommand.txt /*:CVSWatchOn* -:CVSWatchRemove vcscommand.txt /*:CVSWatchRemove* -:CVSWatchers vcscommand.txt /*:CVSWatchers* -:DocIndex haskellmode.txt /*:DocIndex* -:DocSettings haskellmode.txt /*:DocSettings* -:ExportDocIndex haskellmode.txt /*:ExportDocIndex* -:FlagReference haskellmode.txt /*:FlagReference* -:GHCReload haskellmode.txt /*:GHCReload* -:GHCStaticOptions haskellmode.txt /*:GHCStaticOptions* -:GHCi haskellmode.txt /*:GHCi* -:HpasteIndex haskellmode.txt /*:HpasteIndex* -:HpastePostNew haskellmode.txt /*:HpastePostNew* -:IDoc haskellmode.txt /*:IDoc* -:MDoc haskellmode.txt /*:MDoc* -:NERDTree NERD_tree.txt /*:NERDTree* -:NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle* -:TlistAddFiles taglist.txt /*:TlistAddFiles* -:TlistAddFilesRecursive taglist.txt /*:TlistAddFilesRecursive* -:TlistClose taglist.txt /*:TlistClose* -:TlistDebug taglist.txt /*:TlistDebug* -:TlistHighlightTag taglist.txt /*:TlistHighlightTag* -:TlistLock taglist.txt /*:TlistLock* -:TlistMessages taglist.txt /*:TlistMessages* -:TlistOpen taglist.txt /*:TlistOpen* -:TlistSessionLoad taglist.txt /*:TlistSessionLoad* -:TlistSessionSave taglist.txt /*:TlistSessionSave* -:TlistShowPrototype taglist.txt /*:TlistShowPrototype* -:TlistShowTag taglist.txt /*:TlistShowTag* -:TlistToggle taglist.txt /*:TlistToggle* -:TlistUndebug taglist.txt /*:TlistUndebug* -:TlistUnlock taglist.txt /*:TlistUnlock* -:TlistUpdate taglist.txt /*:TlistUpdate* -:VCSAdd vcscommand.txt /*:VCSAdd* -:VCSAnnotate vcscommand.txt /*:VCSAnnotate* -:VCSBlame vcscommand.txt /*:VCSBlame* -:VCSCommit vcscommand.txt /*:VCSCommit* -:VCSDelete vcscommand.txt /*:VCSDelete* -:VCSDiff vcscommand.txt /*:VCSDiff* -:VCSGotoOriginal vcscommand.txt /*:VCSGotoOriginal* -:VCSInfo vcscommand.txt /*:VCSInfo* -:VCSLock vcscommand.txt /*:VCSLock* -:VCSLog vcscommand.txt /*:VCSLog* -:VCSRemove vcscommand.txt /*:VCSRemove* -:VCSRevert vcscommand.txt /*:VCSRevert* -:VCSReview vcscommand.txt /*:VCSReview* -:VCSStatus vcscommand.txt /*:VCSStatus* -:VCSUnlock vcscommand.txt /*:VCSUnlock* -:VCSUpdate vcscommand.txt /*:VCSUpdate* -:VCSVimDiff vcscommand.txt /*:VCSVimDiff* -NERDChristmasTree NERD_tree.txt /*NERDChristmasTree* -NERDTree NERD_tree.txt /*NERDTree* -NERDTree-! NERD_tree.txt /*NERDTree-!* -NERDTree-? NERD_tree.txt /*NERDTree-?* -NERDTree-C NERD_tree.txt /*NERDTree-C* -NERDTree-F NERD_tree.txt /*NERDTree-F* -NERDTree-H NERD_tree.txt /*NERDTree-H* -NERDTree-J NERD_tree.txt /*NERDTree-J* -NERDTree-K NERD_tree.txt /*NERDTree-K* -NERDTree-O NERD_tree.txt /*NERDTree-O* -NERDTree-P NERD_tree.txt /*NERDTree-P* -NERDTree-R NERD_tree.txt /*NERDTree-R* -NERDTree-T NERD_tree.txt /*NERDTree-T* -NERDTree-U NERD_tree.txt /*NERDTree-U* -NERDTree-X NERD_tree.txt /*NERDTree-X* -NERDTree-c-j NERD_tree.txt /*NERDTree-c-j* -NERDTree-c-k NERD_tree.txt /*NERDTree-c-k* -NERDTree-contents NERD_tree.txt /*NERDTree-contents* -NERDTree-e NERD_tree.txt /*NERDTree-e* -NERDTree-f NERD_tree.txt /*NERDTree-f* -NERDTree-go NERD_tree.txt /*NERDTree-go* -NERDTree-gtab NERD_tree.txt /*NERDTree-gtab* -NERDTree-m NERD_tree.txt /*NERDTree-m* -NERDTree-o NERD_tree.txt /*NERDTree-o* -NERDTree-p NERD_tree.txt /*NERDTree-p* -NERDTree-q NERD_tree.txt /*NERDTree-q* -NERDTree-r NERD_tree.txt /*NERDTree-r* -NERDTree-t NERD_tree.txt /*NERDTree-t* -NERDTree-tab NERD_tree.txt /*NERDTree-tab* -NERDTree-u NERD_tree.txt /*NERDTree-u* -NERDTree-x NERD_tree.txt /*NERDTree-x* -NERDTreeAuthor NERD_tree.txt /*NERDTreeAuthor* -NERDTreeAutoCenter NERD_tree.txt /*NERDTreeAutoCenter* -NERDTreeAutoCenterThreshold NERD_tree.txt /*NERDTreeAutoCenterThreshold* -NERDTreeCaseSensitiveSort NERD_tree.txt /*NERDTreeCaseSensitiveSort* -NERDTreeChDirMode NERD_tree.txt /*NERDTreeChDirMode* -NERDTreeChangelog NERD_tree.txt /*NERDTreeChangelog* -NERDTreeCommands NERD_tree.txt /*NERDTreeCommands* -NERDTreeCredits NERD_tree.txt /*NERDTreeCredits* -NERDTreeFilesysMenu NERD_tree.txt /*NERDTreeFilesysMenu* -NERDTreeFunctionality NERD_tree.txt /*NERDTreeFunctionality* -NERDTreeHighlightCursorline NERD_tree.txt /*NERDTreeHighlightCursorline* -NERDTreeIgnore NERD_tree.txt /*NERDTreeIgnore* -NERDTreeMappings NERD_tree.txt /*NERDTreeMappings* -NERDTreeMouseMode NERD_tree.txt /*NERDTreeMouseMode* -NERDTreeOptionDetails NERD_tree.txt /*NERDTreeOptionDetails* -NERDTreeOptionSummary NERD_tree.txt /*NERDTreeOptionSummary* -NERDTreeOptions NERD_tree.txt /*NERDTreeOptions* -NERDTreePublicFunctions NERD_tree.txt /*NERDTreePublicFunctions* -NERDTreeShowFiles NERD_tree.txt /*NERDTreeShowFiles* -NERDTreeShowHidden NERD_tree.txt /*NERDTreeShowHidden* -NERDTreeSortOrder NERD_tree.txt /*NERDTreeSortOrder* -NERDTreeSplitVertical NERD_tree.txt /*NERDTreeSplitVertical* -NERDTreeTodo NERD_tree.txt /*NERDTreeTodo* -NERDTreeWinPos NERD_tree.txt /*NERDTreeWinPos* -NERDTreeWinSize NERD_tree.txt /*NERDTreeWinSize* -NERD_tree.txt NERD_tree.txt /*NERD_tree.txt* -OmniCpp_DefaultNamespaces omnicppcomplete.txt /*OmniCpp_DefaultNamespaces* -OmniCpp_DisplayMode omnicppcomplete.txt /*OmniCpp_DisplayMode* -OmniCpp_GlobalScopeSearch omnicppcomplete.txt /*OmniCpp_GlobalScopeSearch* -OmniCpp_LocalSearchDecl omnicppcomplete.txt /*OmniCpp_LocalSearchDecl* -OmniCpp_MayCompleteArrow omnicppcomplete.txt /*OmniCpp_MayCompleteArrow* -OmniCpp_MayCompleteDot omnicppcomplete.txt /*OmniCpp_MayCompleteDot* -OmniCpp_MayCompleteScope omnicppcomplete.txt /*OmniCpp_MayCompleteScope* -OmniCpp_NamespaceSearch omnicppcomplete.txt /*OmniCpp_NamespaceSearch* -OmniCpp_SelectFirstItem omnicppcomplete.txt /*OmniCpp_SelectFirstItem* -OmniCpp_ShowAccess omnicppcomplete.txt /*OmniCpp_ShowAccess* -OmniCpp_ShowPrototypeInAbbr omnicppcomplete.txt /*OmniCpp_ShowPrototypeInAbbr* -OmniCpp_ShowScopeInAbbr omnicppcomplete.txt /*OmniCpp_ShowScopeInAbbr* -Tlist_Get_Tag_Prototype_By_Line() taglist.txt /*Tlist_Get_Tag_Prototype_By_Line()* -Tlist_Get_Tagname_By_Line() taglist.txt /*Tlist_Get_Tagname_By_Line()* -Tlist_Set_App() taglist.txt /*Tlist_Set_App()* -Tlist_Update_File_Tags() taglist.txt /*Tlist_Update_File_Tags()* -VCSCommandCVSDiffOpt vcscommand.txt /*VCSCommandCVSDiffOpt* -VCSCommandCVSExec vcscommand.txt /*VCSCommandCVSExec* -VCSCommandCommitOnWrite vcscommand.txt /*VCSCommandCommitOnWrite* -VCSCommandDeleteOnHide vcscommand.txt /*VCSCommandDeleteOnHide* -VCSCommandDiffSplit vcscommand.txt /*VCSCommandDiffSplit* -VCSCommandDisableAll vcscommand.txt /*VCSCommandDisableAll* -VCSCommandDisableExtensionMappings vcscommand.txt /*VCSCommandDisableExtensionMappings* -VCSCommandDisableMappings vcscommand.txt /*VCSCommandDisableMappings* -VCSCommandEdit vcscommand.txt /*VCSCommandEdit* -VCSCommandEnableBufferSetup vcscommand.txt /*VCSCommandEnableBufferSetup* -VCSCommandMapPrefix vcscommand.txt /*VCSCommandMapPrefix* -VCSCommandMappings vcscommand.txt /*VCSCommandMappings* -VCSCommandResultBufferNameExtension vcscommand.txt /*VCSCommandResultBufferNameExtension* -VCSCommandResultBufferNameFunction vcscommand.txt /*VCSCommandResultBufferNameFunction* -VCSCommandSVKExec vcscommand.txt /*VCSCommandSVKExec* -VCSCommandSVNDiffExt vcscommand.txt /*VCSCommandSVNDiffExt* -VCSCommandSVNDiffOpt vcscommand.txt /*VCSCommandSVNDiffOpt* -VCSCommandSVNExec vcscommand.txt /*VCSCommandSVNExec* -VCSCommandSplit vcscommand.txt /*VCSCommandSplit* -VCSCommandVCSTypeOverride vcscommand.txt /*VCSCommandVCSTypeOverride* -_. haskellmode.txt /*_.* -_? haskellmode.txt /*_?* -_?1 haskellmode.txt /*_?1* -_?2 haskellmode.txt /*_?2* -_T haskellmode.txt /*_T* -_ct haskellmode.txt /*_ct* -_i haskellmode.txt /*_i* -_ie haskellmode.txt /*_ie* -_im haskellmode.txt /*_im* -_iq haskellmode.txt /*_iq* -_iqm haskellmode.txt /*_iqm* -_lang haskellmode.txt /*_lang* -_opt haskellmode.txt /*_opt* -_si haskellmode.txt /*_si* -_t haskellmode.txt /*_t* -b:VCSCommandCommand vcscommand.txt /*b:VCSCommandCommand* -b:VCSCommandOriginalBuffer vcscommand.txt /*b:VCSCommandOriginalBuffer* -b:VCSCommandSourceFile vcscommand.txt /*b:VCSCommandSourceFile* -b:VCSCommandVCSType vcscommand.txt /*b:VCSCommandVCSType* -compiler-ghc haskellmode.txt /*compiler-ghc* -cvscommand-changes vcscommand.txt /*cvscommand-changes* -g:ghc haskellmode.txt /*g:ghc* -g:haddock_browser haskellmode.txt /*g:haddock_browser* -g:haddock_browser_callformat haskellmode.txt /*g:haddock_browser_callformat* -g:haddock_docdir haskellmode.txt /*g:haddock_docdir* -g:haddock_indexfiledir haskellmode.txt /*g:haddock_indexfiledir* -g:wget haskellmode.txt /*g:wget* -ghc haskellmode.txt /*ghc* -ghc-compiler haskellmode.txt /*ghc-compiler* -haddock haskellmode.txt /*haddock* -haskellmode haskellmode.txt /*haskellmode* -haskellmode-XO haskellmode.txt /*haskellmode-XO* -haskellmode-XU haskellmode.txt /*haskellmode-XU* -haskellmode-compiler haskellmode.txt /*haskellmode-compiler* -haskellmode-editing haskellmode.txt /*haskellmode-editing* -haskellmode-haddock haskellmode.txt /*haskellmode-haddock* -haskellmode-hpaste haskellmode.txt /*haskellmode-hpaste* -haskellmode-indexing haskellmode.txt /*haskellmode-indexing* -haskellmode-lookup haskellmode.txt /*haskellmode-lookup* -haskellmode-omni-completion haskellmode.txt /*haskellmode-omni-completion* -haskellmode-overview haskellmode.txt /*haskellmode-overview* -haskellmode-quickref haskellmode.txt /*haskellmode-quickref* -haskellmode-requirements haskellmode.txt /*haskellmode-requirements* -haskellmode-resources haskellmode.txt /*haskellmode-resources* -haskellmode-settings haskellmode.txt /*haskellmode-settings* -haskellmode-settings-fine haskellmode.txt /*haskellmode-settings-fine* -haskellmode-settings-main haskellmode.txt /*haskellmode-settings-main* -haskellmode-user-completion haskellmode.txt /*haskellmode-user-completion* -haskellmode.txt haskellmode.txt /*haskellmode.txt* -hpaste haskellmode.txt /*hpaste* -loaded_nerd_tree NERD_tree.txt /*loaded_nerd_tree* -omnicpp-download omnicppcomplete.txt /*omnicpp-download* -omnicpp-faq omnicppcomplete.txt /*omnicpp-faq* -omnicpp-features omnicppcomplete.txt /*omnicpp-features* -omnicpp-history omnicppcomplete.txt /*omnicpp-history* -omnicpp-installation omnicppcomplete.txt /*omnicpp-installation* -omnicpp-limitations omnicppcomplete.txt /*omnicpp-limitations* -omnicpp-may-complete omnicppcomplete.txt /*omnicpp-may-complete* -omnicpp-options omnicppcomplete.txt /*omnicpp-options* -omnicpp-overview omnicppcomplete.txt /*omnicpp-overview* -omnicpp-popup omnicppcomplete.txt /*omnicpp-popup* -omnicpp-thanks omnicppcomplete.txt /*omnicpp-thanks* -omnicppcomplete omnicppcomplete.txt /*omnicppcomplete* -omnicppcomplete.txt omnicppcomplete.txt /*omnicppcomplete.txt* -surround surround.txt /*surround* -surround-author surround.txt /*surround-author* -surround-customizing surround.txt /*surround-customizing* -surround-issues surround.txt /*surround-issues* -surround-mappings surround.txt /*surround-mappings* -surround-replacements surround.txt /*surround-replacements* -surround-targets surround.txt /*surround-targets* -surround.txt surround.txt /*surround.txt* -taglist-commands taglist.txt /*taglist-commands* -taglist-debug taglist.txt /*taglist-debug* -taglist-extend taglist.txt /*taglist-extend* -taglist-faq taglist.txt /*taglist-faq* -taglist-functions taglist.txt /*taglist-functions* -taglist-install taglist.txt /*taglist-install* -taglist-internet taglist.txt /*taglist-internet* -taglist-intro taglist.txt /*taglist-intro* -taglist-keys taglist.txt /*taglist-keys* -taglist-license taglist.txt /*taglist-license* -taglist-menu taglist.txt /*taglist-menu* -taglist-options taglist.txt /*taglist-options* -taglist-requirements taglist.txt /*taglist-requirements* -taglist-session taglist.txt /*taglist-session* -taglist-todo taglist.txt /*taglist-todo* -taglist-using taglist.txt /*taglist-using* -taglist.txt taglist.txt /*taglist.txt* -vcscommand vcscommand.txt /*vcscommand* -vcscommand-buffer-management vcscommand.txt /*vcscommand-buffer-management* -vcscommand-buffer-variables vcscommand.txt /*vcscommand-buffer-variables* -vcscommand-bugs vcscommand.txt /*vcscommand-bugs* -vcscommand-commands vcscommand.txt /*vcscommand-commands* -vcscommand-config vcscommand.txt /*vcscommand-config* -vcscommand-contents vcscommand.txt /*vcscommand-contents* -vcscommand-customize vcscommand.txt /*vcscommand-customize* -vcscommand-events vcscommand.txt /*vcscommand-events* -vcscommand-install vcscommand.txt /*vcscommand-install* -vcscommand-intro vcscommand.txt /*vcscommand-intro* -vcscommand-manual vcscommand.txt /*vcscommand-manual* -vcscommand-mappings vcscommand.txt /*vcscommand-mappings* -vcscommand-mappings-override vcscommand.txt /*vcscommand-mappings-override* -vcscommand-naming vcscommand.txt /*vcscommand-naming* -vcscommand-options vcscommand.txt /*vcscommand-options* -vcscommand-ssh vcscommand.txt /*vcscommand-ssh* -vcscommand-ssh-config vcscommand.txt /*vcscommand-ssh-config* -vcscommand-ssh-env vcscommand.txt /*vcscommand-ssh-env* -vcscommand-ssh-other vcscommand.txt /*vcscommand-ssh-other* -vcscommand-ssh-wrapper vcscommand.txt /*vcscommand-ssh-wrapper* -vcscommand-statusline vcscommand.txt /*vcscommand-statusline* -vcscommand.txt vcscommand.txt /*vcscommand.txt* -vs surround.txt /*vs* -yS surround.txt /*yS* -ySS surround.txt /*ySS* -ys surround.txt /*ys* -yss surround.txt /*yss* diff --git a/.vim/doc/vcscommand.txt b/.vim/doc/vcscommand.txt deleted file mode 100644 index cf6bd97..0000000 --- a/.vim/doc/vcscommand.txt +++ /dev/null @@ -1,819 +0,0 @@ -*vcscommand.txt* vcscommand -Copyright (c) 2007 Bob Hiestand - -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. - -For instructions on installing this file, type - :help add-local-help -inside Vim. - -Author: Bob Hiestand <bob.hiestand@gmail.com> -Credits: Benji Fisher's excellent MatchIt documentation - -============================================================================== -1. Contents *vcscommand-contents* - - Installation : |vcscommand-install| - vcscommand Intro : |vcscommand| - vcscommand Manual : |vcscommand-manual| - Customization : |vcscommand-customize| - SSH "integration" : |vcscommand-ssh| - Changes from cvscommand : |cvscommand-changes| - Bugs : |vcscommand-bugs| - -============================================================================== - -2. vcscommand Installation *vcscommand-install* - -The vcscommand plugin comprises five files: vcscommand.vim, vcssvn.vim, -vcscvs.vim, vcssvk.vim and vcscommand.txt (this file). In order to install -the plugin, place the vcscommand.vim, vcssvn.vim, vcssvk.vim, and vcscvs.vim -files into a plugin directory in your runtime path (please see -|add-global-plugin| and |'runtimepath'|. - -This help file can be included in the VIM help system by copying it into a -'doc' directory in your runtime path and then executing the |:helptags| -command, specifying the full path of the 'doc' directory. Please see -|add-local-help| for more details. - -vcscommand may be customized by setting variables, creating maps, and -specifying event handlers. Please see |vcscommand-customize| for more -details. - -============================================================================== - -3. vcscommand Intro *vcscommand* - *vcscommand-intro* - -The vcscommand plugin provides global ex commands for manipulating -version-controlled source files, currently those controlled either by CVS or -Subversion. In general, each command operates on the current buffer and -accomplishes a separate source control function, such as update, commit, log, -and others (please see |vcscommand-commands| for a list of all available -commands). The results of each operation are displayed in a scratch buffer. -Several buffer variables are defined for those scratch buffers (please see -|vcscommand-buffer-variables|). - -The notion of "current file" means either the current buffer, or, in the case -of a directory buffer (such as Explorer or netrw buffers), the directory (and -all subdirectories) represented by the the buffer. - -For convenience, any vcscommand invoked on a vcscommand scratch buffer acts as -though it was invoked on the original file and splits the screen so that the -output appears in a new window. - -Many of the commands accept revisions as arguments. By default, most operate -on the most recent revision on the current branch if no revision is specified. - -Each vcscommand is mapped to a key sequence starting with the <Leader> -keystroke. The default mappings may be overridden by supplying different -mappings before the plugin is loaded, such as in the vimrc, in the standard -fashion for plugin mappings. For examples, please see -|vcscommand-mappings-override|. - -The vcscommand plugin may be configured in several ways. For more details, -please see |vcscommand-customize|. - -============================================================================== - -4. vcscommand Manual *vcscommand-manual* - -4.1 vcscommand commands *vcscommand-commands* - -vcscommand defines the following commands: - -|:VCSAdd| -|:VCSAnnotate| -|:VCSBlame| -|:VCSCommit| -|:VCSDelete| -|:VCSDiff| -|:VCSGotoOriginal| -|:VCSLog| -|:VCSRemove| -|:VCSRevert| -|:VCSReview| -|:VCSStatus| -|:VCSUpdate| -|:VCSVimDiff| - -The following commands are specific to CVS files: - -|:CVSEdit| -|:CVSEditors| -|:CVSUnedit| -|:CVSWatch| -|:CVSWatchAdd| -|:CVSWatchOn| -|:CVSWatchOff| -|:CVSWatchRemove| -|:CVSWatchers| - -:VCSAdd *:VCSAdd* - -This command adds the current file to source control. Please note, this does -not commit the newly-added file. All parameters to the command are passed to -the underlying VCS. - -:VCSAnnotate[!] *:VCSAnnotate* - -This command displays the current file with each line annotated with the -version in which it was most recently changed. If an argument is given, the -argument is used as a revision number to display. If not given an argument, -it uses the most recent version of the file (on the current branch, if under -CVS control). Additionally, if the current buffer is a VCSAnnotate buffer -already, the version number on the current line is used. - -If '!' is used, the view of the annotated buffer is split so that the -annotation is in a separate window from the content, and each is highlighted -separately. - -For CVS buffers, the 'VCSCommandCVSAnnotateParent' option, if set to non-zero, -will cause the above behavior to change. Instead of annotating the version on -the current line, the parent revision is used instead, crossing branches if -necessary. - -The filetype of the vcscommand scratch buffer is set to one of 'CVSAnnotate', -'SVNAnnotate', 'SVKAnnotate' or 'gitAnnotate' as appropriate, to take advantage of the -bundled syntax files. - -:VCSBlame[!] *:VCSBlame* - -Alias for |:VCSAnnotate|. - -:VCSCommit[!] *:VCSCommit* - -This command commits changes to the current file to source control. - -If called with arguments, the arguments are the log message. - -If '!' is used, an empty log message is committed. - -If called with no arguments, this is a two-step command. The first step opens -a buffer to accept a log message. When that buffer is written, it is -automatically closed and the file is committed using the information from that -log message. The commit can be abandoned if the log message buffer is deleted -or wiped before being written. - -Alternatively, the mapping that is used to invoke :VCSCommit (by default -<Leader>cc) can be used in the log message buffer to immediately commit. This -is useful if the |VCSCommandCommitOnWrite| variable is set to 0 to disable the -normal commit-on-write behavior. - -:VCSDelete *:VCSDelete* - -Deletes the current file and removes it from source control. All parameters -to the command are passed to the underlying VCS. - -:VCSDiff *:VCSDiff* - -With no arguments, this displays the differences between the current file and -its parent version under source control in a new scratch buffer. - -With one argument, the diff is performed on the current file against the -specified revision. - -With two arguments, the diff is performed between the specified revisions of -the current file. - -For CVS, this command uses the |VCSCommandCVSDiffOpt| variable to specify diff -options. If that variable does not exist, a plugin-specific default is used. -If you wish to have no options, then set it to the empty string. - -For SVN, this command uses the |VCSCommandSVNDiffOpt| variable to specify diff -options. If that variable does not exist, the SVN default is used. -Additionally, |VCSCommandSVNDiffExt| can be used to select an external diff -application. - -:VCSGotoOriginal *:VCSGotoOriginal* - -This command jumps to the source buffer if the current buffer is a VCS scratch -buffer. - -:VCSGotoOriginal! - -Like ":VCSGotoOriginal" but also executes :bufwipeout on all VCS scrach -buffers associated with the original file. - -:VCSInfo *:VCSInfo* - -This command displays extended information about the current file in a new -scratch buffer. - -:VCSLock *:VCSLock* - -This command locks the current file in order to prevent other users from -concurrently modifying it. The exact semantics of this command depend on the -underlying VCS. This does nothing in CVS. All parameters are passed to the -underlying VCS. - -:VCSLog *:VCSLog* - -Displays the version history of the current file in a new scratch buffer. If -there is one parameter supplied, it is taken as as a revision parameters to be -passed through to the underlying VCS. Otherwise, all parameters are passed to -the underlying VCS. - -:VCSRemove *:VCSRemove* - -Alias for |:VCSDelete|. - -:VCSRevert *:VCSRevert* - -This command replaces the current file with the most recent version from the -repository in order to wipe out any undesired changes. - -:VCSReview *:VCSReview* - -Displays a particular version of the current file in a new scratch buffer. If -no argument is given, the most recent version of the file on the current -branch is retrieved. - -:VCSStatus *:VCSStatus* - -Displays versioning information about the current file in a new scratch -buffer. All parameters are passed to the underlying VCS. - - -:VCSUnlock *:VCSUnlock* - -Unlocks the current file in order to allow other users from concurrently -modifying it. The exact semantics of this command depend on the underlying -VCS. All parameters are passed to the underlying VCS. - -:VCSUpdate *:VCSUpdate* - -Updates the current file with any relevant changes from the repository. This -intentionally does not automatically reload the current buffer, though vim -should prompt the user to do so if the underlying file is altered by this -command. - -:VCSVimDiff *:VCSVimDiff* - -Uses vimdiff to display differences between versions of the current file. - -If no revision is specified, the most recent version of the file on the -current branch is used. With one argument, that argument is used as the -revision as above. With two arguments, the differences between the two -revisions is displayed using vimdiff. - -With either zero or one argument, the original buffer is used to perform the -vimdiff. When the scratch buffer is closed, the original buffer will be -returned to normal mode. - -Once vimdiff mode is started using the above methods, additional vimdiff -buffers may be added by passing a single version argument to the command. -There may be up to 4 vimdiff buffers total. - -Using the 2-argument form of the command resets the vimdiff to only those 2 -versions. Additionally, invoking the command on a different file will close -the previous vimdiff buffers. - -:CVSEdit *:CVSEdit* - -This command performs "cvs edit" on the current file. Yes, the output buffer -in this case is almost completely useless. - -:CVSEditors *:CVSEditors* - -This command performs "cvs edit" on the current file. - -:CVSUnedit *:CVSUnedit* - -Performs "cvs unedit" on the current file. Again, yes, the output buffer here -is basically useless. - -:CVSWatch *:CVSWatch* - -This command takes an argument which must be one of [on|off|add|remove]. The -command performs "cvs watch" with the given argument on the current file. - -:CVSWatchAdd *:CVSWatchAdd* - -This command is an alias for ":CVSWatch add" - -:CVSWatchOn *:CVSWatchOn* - -This command is an alias for ":CVSWatch on" - -:CVSWatchOff *:CVSWatchOff* - -This command is an alias for ":CVSWatch off" - -:CVSWatchRemove *:CVSWatchRemove* - -This command is an alias for ":CVSWatch remove" - -:CVSWatchers *:CVSWatchers* - -This command performs "cvs watchers" on the current file. - -4.2 Mappings *vcscommand-mappings* - -By default, a mapping is defined for each command. These mappings execute the -default (no-argument) form of each command. - -<Leader>ca VCSAdd -<Leader>cn VCSAnnotate -<Leader>cN VCSAnnotate! -<Leader>cc VCSCommit -<Leader>cD VCSDelete -<Leader>cd VCSDiff -<Leader>cg VCSGotoOriginal -<Leader>cG VCSGotoOriginal! -<Leader>ci VCSInfo -<Leader>cl VCSLog -<Leader>cL VCSLock -<Leader>cr VCSReview -<Leader>cs VCSStatus -<Leader>cu VCSUpdate -<Leader>cU VCSUnlock -<Leader>cv VCSVimDiff - -Only for CVS buffers: - -<Leader>ce CVSEdit -<Leader>cE CVSEditors -<Leader>ct CVSUnedit -<Leader>cwv CVSWatchers -<Leader>cwa CVSWatchAdd -<Leader>cwn CVSWatchOn -<Leader>cwf CVSWatchOff -<Leader>cwf CVSWatchRemove - - *vcscommand-mappings-override* - -The default mappings can be overridden by user-provided instead by mapping to -<Plug>CommandName. This is especially useful when these mappings collide with -other existing mappings (vim will warn of this during plugin initialization, -but will not clobber the existing mappings). - -There are three methods for controlling mapping: - -First, maps can be overriden for individual commands. For instance, to -override the default mapping for :VCSAdd to set it to '\add', add the -following to the vimrc: - -nmap \add <Plug>VCSAdd - -Second, the default map prefix ('<Leader>c') can be overridden by defining the -|VCSCommandMapPrefix| variable. - -Third, the entire set of default maps can be overridden by defining the -|VCSCommandMappings| variable. - - -4.3 Automatic buffer variables *vcscommand-buffer-variables* - -Several buffer variables are defined in each vcscommand result buffer. These -may be useful for additional customization in callbacks defined in the event -handlers (please see |vcscommand-events|). - -The following variables are automatically defined: - -b:VCSCommandOriginalBuffer *b:VCSCommandOriginalBuffer* - -This variable is set to the buffer number of the source file. - -b:VCSCommandCommand *b:VCSCommandCommand* - -This variable is set to the name of the vcscommand that created the result -buffer. - -b:VCSCommandSourceFile *b:VCSCommandSourceFile* - -This variable is set to the name of the original file under source control. - -b:VCSCommandVCSType *b:VCSCommandVCSType* - -This variable is set to the type of the source control. This variable is also -set on the original file itself. -============================================================================== - -5. Configuration and customization *vcscommand-customize* - *vcscommand-config* - -The vcscommand plugin can be configured in several ways: by setting -configuration variables (see |vcscommand-options|) or by defining vcscommand -event handlers (see |vcscommand-events|). Additionally, the vcscommand plugin -supports a customized status line (see |vcscommand-statusline| and -|vcscommand-buffer-management|). - -5.1 vcscommand configuration variables *vcscommand-options* - -Several variables affect the plugin's behavior. These variables are checked -at time of execution, and may be defined at the window, buffer, or global -level and are checked in that order of precedence. - - -The following variables are available: - -|VCSCommandCommitOnWrite| -|VCSCommandCVSDiffOpt| -|VCSCommandCVSExec| -|VCSCommandDeleteOnHide| -|VCSCommandDiffSplit| -|VCSCommandDisableAll| -|VCSCommandDisableMappings| -|VCSCommandDisableExtensionMappings| -|VCSCommandEdit| -|VCSCommandEnableBufferSetup| -|VCSCommandMappings| -|VCSCommandMapPrefix| -|VCSCommandResultBufferNameExtension| -|VCSCommandResultBufferNameFunction| -|VCSCommandSplit| -|VCSCommandSVKExec| -|VCSCommandSVNDiffExt| -|VCSCommandSVNDiffOpt| -|VCSCommandSVNExec| -|VCSCommandVCSTypeOverride| - -VCSCommandCommitOnWrite *VCSCommandCommitOnWrite* - -This variable, if set to a non-zero value, causes the pending commit -to take place immediately as soon as the log message buffer is written. -If set to zero, only the VCSCommit mapping will cause the pending commit to -occur. If not set, it defaults to 1. - -VCSCommandCVSExec *VCSCommandCVSExec* - -This variable controls the executable used for all CVS commands If not set, -it defaults to "cvs". - -VCSCommandDeleteOnHide *VCSCommandDeleteOnHide* - -This variable, if set to a non-zero value, causes the temporary result buffers -to automatically delete themselves when hidden. - -VCSCommandCVSDiffOpt *VCSCommandCVSDiffOpt* - -This variable, if set, determines the options passed to the diff command of -CVS. If not set, it defaults to 'u'. - -VCSCommandDiffSplit *VCSCommandDiffSplit* - -This variable overrides the |VCSCommandSplit| variable, but only for buffers -created with |:VCSVimDiff|. - -VCSCommandDisableAll *VCSCommandDisableAll* - -This variable, if set, prevents the plugin or any extensions from loading at -all. This is useful when a single runtime distribution is used on multiple -systems with varying versions. - -VCSCommandDisableMappings *VCSCommandDisableMappings* - -This variable, if set to a non-zero value, prevents the default command -mappings from being set. This supercedes -|VCSCommandDisableExtensionMappings|. - -VCSCommandDisableExtensionMappings *VCSCommandDisableExtensionMappings* - -This variable, if set to a non-zero value, prevents the default command -mappings from being set for commands specific to an individual VCS. - -VCSCommandEdit *VCSCommandEdit* - -This variable controls whether the original buffer is replaced ('edit') or -split ('split'). If not set, it defaults to 'split'. - -VCSCommandEnableBufferSetup *VCSCommandEnableBufferSetup* - -This variable, if set to a non-zero value, activates VCS buffer management -mode see (|vcscommand-buffer-management|). This mode means that the -'VCSCommandBufferInfo' variable is filled with version information if the file -is VCS-controlled. This is useful for displaying version information in the -status bar. - -VCSCommandMappings *VCSCommandMappings* - -This variable, if set, overrides the default mappings used for shortcuts. It -should be a List of 2-element Lists, each containing a shortcut and function -name pair. The value of the '|VCSCommandMapPrefix|' variable will be added to -each shortcut. - -VCSCommandMapPrefix *VCSCommandMapPrefix* - -This variable, if set, overrides the default mapping prefix ('<Leader>c'). -This allows customization of the mapping space used by the vcscommand -shortcuts. - -VCSCommandResultBufferNameExtension *VCSCommandResultBufferNameExtension* - -This variable, if set to a non-blank value, is appended to the name of the VCS -command output buffers. For example, '.vcs'. Using this option may help -avoid problems caused by autocommands dependent on file extension. - -VCSCommandResultBufferNameFunction *VCSCommandResultBufferNameFunction* - -This variable, if set, specifies a custom function for naming VCS command -output buffers. This function is expected to return the new buffer name, and -will be passed the following arguments: - - command - name of the VCS command being executed (such as 'Log' or - 'Diff'). - - originalBuffer - buffer number of the source file. - - vcsType - type of VCS controlling this file (such as 'CVS' or 'SVN'). - - statusText - extra text associated with the VCS action (such as version - numbers). - -VCSCommandSplit *VCSCommandSplit* - -This variable controls the orientation of the various window splits that -may occur. - -If set to 'horizontal', the resulting windows will be on stacked on top of -one another. If set to 'vertical', the resulting windows will be -side-by-side. If not set, it defaults to 'horizontal' for all but -VCSVimDiff windows. VCSVimDiff windows default to the user's 'diffopt' -setting, if set, otherwise 'vertical'. - -VCSCommandSVKExec *VCSCommandSVKExec* - -This variable controls the executable used for all SVK commands If not set, -it defaults to "svk". - -VCSCommandSVNDiffExt *VCSCommandSVNDiffExt* - -This variable, if set, is passed to SVN via the --diff-cmd command to select -an external application for performing the diff. - -VCSCommandSVNDiffOpt *VCSCommandSVNDiffOpt* - -This variable, if set, determines the options passed with the '-x' parameter -to the SVN diff command. If not set, no options are passed. - -VCSCommandSVNExec *VCSCommandSVNExec* - -This variable controls the executable used for all SVN commands If not set, -it defaults to "svn". - -VCSCommandVCSTypeOverride *VCSCommandVCSTypeOverride* - -This variable allows the VCS type detection to be overridden on a path-by-path -basis. The value of this variable is expected to be a List of Lists. Each -item in the high-level List is a List containing two elements. The first -element is a regular expression that will be matched against the full file -name of a given buffer. If it matches, the second element will be used as the -VCS type. - -5.2 VCSCommand events *vcscommand-events* - -For additional customization, vcscommand can trigger user-defined events. -Event handlers are provided by defining User event autocommands (see -|autocommand|, |User|) in the vcscommand group with patterns matching the -event name. - -For instance, the following could be added to the vimrc to provide a 'q' -mapping to quit a vcscommand scratch buffer: - -augroup VCSCommand - au User VCSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr> -augroup END - -The following hooks are available: - -VCSBufferCreated This event is fired just after a vcscommand - result buffer is created and populated. It is - executed within the context of the vcscommand - buffer. The vcscommand buffer variables may - be useful for handlers of this event (please - see |vcscommand-buffer-variables|). - -VCSBufferSetup This event is fired just after vcscommand buffer - setup occurs, if enabled. - -VCSPluginInit This event is fired when the vcscommand plugin - first loads. - -VCSPluginFinish This event is fired just after the vcscommand - plugin loads. - -VCSVimDiffFinish This event is fired just after the VCSVimDiff - command executes to allow customization of, - for instance, window placement and focus. - -Additionally, there is another hook which is used internally to handle loading -the multiple scripts in order. This hook should probably not be used by an -end user without a good idea of how it works. Among other things, any events -associated with this hook are cleared after they are executed (during -vcscommand.vim script initialization). - -VCSLoadExtensions This event is fired just before the - VCSPluginFinish. It is used internally to - execute any commands from the VCS - implementation plugins that needs to be - deferred until the primary plugin is - initialized. - -5.3 vcscommand buffer naming *vcscommand-naming* - -vcscommand result buffers use the following naming convention: -[{VCS type} {VCS command} {Source file name}] - -If additional buffers are created that would otherwise conflict, a -distinguishing number is added: - -[{VCS type} {VCS command} {Source file name}] (1,2, etc) - -5.4 vcscommand status line support *vcscommand-statusline* - -It is intended that the user will customize the |'statusline'| option to -include vcscommand result buffer attributes. A sample function that may be -used in the |'statusline'| option is provided by the plugin, -VCSCommandGetStatusLine(). In order to use that function in the status line, do -something like the following: - -set statusline=%<%f\ %{VCSCommandGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P - -of which %{VCSCommandGetStatusLine()} is the relevant portion. - -The sample VCSCommandGetStatusLine() function handles both vcscommand result -buffers and VCS-managed files if vcscommand buffer management is enabled -(please see |vcscommand-buffer-management|). - -5.5 vcscommand buffer management *vcscommand-buffer-management* - -The vcscommand plugin can operate in buffer management mode, which means that -it attempts to set a buffer variable ('VCSCommandBufferInfo') upon entry into -a buffer. This is rather slow because it means that the VCS will be invoked -at each entry into a buffer (during the |BufEnter| autocommand). - -This mode is disabled by default. In order to enable it, set the -|VCSCommandEnableBufferSetup| variable to a true (non-zero) value. Enabling -this mode simply provides the buffer variable mentioned above. The user must -explicitly include information from the variable in the |'statusline'| option -if they are to appear in the status line (but see |vcscommand-statusline| for -a simple way to do that). - -The 'VCSCommandBufferInfo' variable is a list which contains, in order, the -revision of the current file, the latest revision of the file in the -repository, and (for CVS) the name of the branch. If those values cannot be -determined, the list is a single element: 'Unknown'. - -============================================================================== - -6. SSH "integration" *vcscommand-ssh* - -The following instructions are intended for use in integrating the -vcscommand.vim plugin with an SSH-based CVS environment. - -Familiarity with SSH and CVS are assumed. - -These instructions assume that the intent is to have a message box pop up in -order to allow the user to enter a passphrase. If, instead, the user is -comfortable using certificate-based authentication, then only instructions -6.1.1 and 6.1.2 (and optionally 6.1.4) need to be followed; ssh should then -work transparently. - -6.1 Environment settings *vcscommand-ssh-env* - -6.1.1 CVSROOT should be set to something like: - - :ext:user@host:/path_to_repository - -6.1.2 CVS_RSH should be set to: - - ssh - - Together, those settings tell CVS to use ssh as the transport when - performing CVS calls. - -6.1.3 SSH_ASKPASS should be set to the password-dialog program. In my case, - running gnome, it's set to: - - /usr/libexec/openssh/gnome-ssh-askpass - - This tells SSH how to get passwords if no input is available. - -6.1.4 OPTIONAL. You may need to set SSH_SERVER to the location of the cvs - executable on the remote (server) machine. - -6.2 CVS wrapper program *vcscommand-ssh-wrapper* - -Now you need to convince SSH to use the password-dialog program. This means -you need to execute SSH (and therefore CVS) without standard input. The -following script is a simple perl wrapper that dissasociates the CVS command -from the current terminal. Specific steps to do this may vary from system to -system; the following example works for me on linux. - -#!/usr/bin/perl -w -use strict; -use POSIX qw(setsid); -open STDIN, '/dev/null'; -fork and do {wait; exit;}; -setsid; -exec('cvs', @ARGV); - -6.3 Configuring vcscommand.vim *vcscommand-ssh-config* - -At this point, you should be able to use your wrapper script to invoke CVS with -various commands, and get the password dialog. All that's left is to make CVS -use your newly-created wrapper script. - -6.3.1 Tell vcscommand.vim what CVS executable to use. The easiest way to do this - is globally, by putting the following in your .vimrc: - - let VCSCommandCVSExec=/path/to/cvs/wrapper/script - -6.4 Where to go from here *vcscommand-ssh-other* - -The script given above works even when non-SSH CVS connections are used, -except possibly when interactively entering the message for CVS commit log -(depending on the editor you use... VIM works fine). Since the vcscommand.vim -plugin handles that message without a terminal, the wrapper script can be used -all the time. - -This allows mixed-mode operation, where some work is done with SSH-based CVS -repositories, and others with pserver or local access. - -It is possible, though beyond the scope of the plugin, to dynamically set the -CVS executable based on the CVSROOT for the file being edited. The user -events provided (such as VCSBufferCreated and VCSBufferSetup) can be used to -set a buffer-local value (b:VCSCommandCVSExec) to override the CVS executable -on a file-by-file basis. Alternatively, much the same can be done (less -automatically) by the various project-oriented plugins out there. - -It is highly recommended for ease-of-use that certificates with no passphrase -or ssh-agent are employed so that the user is not given the password prompt -too often. - -============================================================================== - -7. Changes from cvscommand *cvscommand-changes* - -1. Require Vim 7 in order to leverage several convenient features; also -because I wanted to play with Vim 7. - -2. Renamed commands to start with 'VCS' instead of 'CVS'. The exceptions are -the 'CVSEdit' and 'CVSWatch' family of commands, which are specific to CVS. - -3. Renamed options, events to start with 'VCSCommand'. - -4. Removed option to jump to the parent version of the current line in an -annotated buffer, as opposed to the version on the current line. This made -little sense in the branching scheme used by subversion, where jumping to a -parent branch required finding a different location in the repository. It -didn't work consistently in CVS anyway. - -5. Removed option to have nameless scratch buffers. - -6. Changed default behavior of scratch buffers to split the window instead of -displaying in the current window. This may still be overridden using the -'VCSCommandEdit' option. - -7. Split plugin into multiple plugins. - -8. Added 'VCSLock' and 'VCSUnlock' commands. These are implemented for -subversion but not for CVS. These were not kept specific to subversion as they -seemed more general in nature and more likely to be supported by any future VCS -supported by this plugin. - -9. Changed name of buffer variables set by commands. - -'b:cvsOrigBuffNR' became 'b:VCSCommandOriginalBuffer' -'b:cvscmd' became 'b:VCSCommandCommand' - -10. Added new automatic variables to command result buffers. - -'b:VCSCommandSourceFile' -'b:VCSCommandVCSType' - -============================================================================== - -8. Known bugs *vcscommand-bugs* - -Please let me know if you run across any. - -CVSUnedit may, if a file is changed from the repository, provide prompt text -to determine whether the changes should be thrown away. Currently, that text -shows up in the CVS result buffer as information; there is no way for the user -to actually respond to the prompt and the CVS unedit command does nothing. If -this really bothers anyone, please let me know. - -VCSVimDiff, when using the original (real) source buffer as one of the diff -buffers, uses some hacks to try to restore the state of the original buffer -when the scratch buffer containing the other version is destroyed. There may -still be bugs in here, depending on many configuration details. - -vim:tw=78:ts=8:ft=help diff --git a/.vim/filetype.vim b/.vim/filetype.vim index c4c3ffb..5c74eb9 100644 --- a/.vim/filetype.vim +++ b/.vim/filetype.vim @@ -2,9 +2,6 @@ if exists("did_load_filetypes") finish endif augroup filetypedetect - au! BufRead,BufNewFile *.cobra setfiletype cobra - au! BufRead,BufNewFile *.vala setfiletype vala - au! BufRead,BufNewFile *.tpl setfiletype npt au! BufRead,BufNewFile *.mako setfiletype mako au! BufRead,BufNewFile *.ML setfiletype sml au! BufRead,BufNewFile /etc/lighttpd/*.conf,lighttpd.conf setfiletype lighttpd diff --git a/.vim/ftplugin/haskell.vim b/.vim/ftplugin/haskell.vim deleted file mode 100644 index 968741e..0000000 --- a/.vim/ftplugin/haskell.vim +++ /dev/null @@ -1,14 +0,0 @@ -" -" general Haskell source settings -" (shared functions are in autoload/haskellmode.vim) -" -" (Claus Reinke, last modified: 28/04/2009) -" -" part of haskell plugins: http://projects.haskell.org/haskellmode-vim -" please send patches to <claus.reinke@talk21.com> - -" try gf on import line, or ctrl-x ctrl-i, or [I, [i, .. -setlocal include=^import\\s*\\(qualified\\)\\?\\s* -setlocal includeexpr=substitute(v:fname,'\\.','/','g').'.' -setlocal suffixesadd=hs,lhs,hsc - diff --git a/.vim/ftplugin/haskell_doc.vim b/.vim/ftplugin/haskell_doc.vim deleted file mode 100644 index 482ea69..0000000 --- a/.vim/ftplugin/haskell_doc.vim +++ /dev/null @@ -1,881 +0,0 @@ -" -" use haddock docs and index files -" show documentation, complete & qualify identifiers -" -" (Claus Reinke; last modified: 17/06/2009) -" -" part of haskell plugins: http://projects.haskell.org/haskellmode-vim -" please send patches to <claus.reinke@talk21.com> - -" :Doc <name> and :IDoc <name> open haddocks for <name> in opera -" -" :Doc needs qualified name (default Prelude) and package (default base) -" :IDoc needs unqualified name, looks up possible links in g:haddock_index -" -" :DocIndex populates g:haddock_index from haddock's index files -" :ExportDocIndex saves g:haddock_index to cache file -" :ImportDocIndex reloads g:haddock_index from cache file -" -" all the following use the haddock index (g:haddock_index) -" -" _? opens haddocks for unqualified name under cursor, -" suggesting alternative full qualifications in popup menu -" -" _. fully qualifies unqualified name under cursor, -" suggesting alternative full qualifications in popup menu -" -" _i add import <module>(<name>) statement for unqualified <name> under cursor, -" _im add import <module> statement for unqualified <name> under cursor, -" suggesting alternative full qualifications in popup menu -" (this currently adds one statement per call, instead of -" merging into existing import statements, but it's a start;-) -" -" CTRL-X CTRL-U (user-defined insert mode completion) -" suggests completions of unqualified names in popup menu - -let s:scriptname = "haskell_doc.vim" - -" script parameters -" g:haddock_browser *mandatory* which browser to call -" g:haddock_browser_callformat [optional] how to call browser -" g:haddock_indexfiledir [optional] where to put 'haddock_index.vim' -" g:haddock_docdir [optional] where to find html docs -" g:ghc [optional] which ghc to call -" g:ghc_pkg [optional] which ghc_pkg to call - -" been here before? -if exists("g:haddock_index") - finish -endif - -" initialise nested dictionary, to be populated -" - from haddock index files via :DocIndex -" - from previous cached version via :ImportDocIndex -let g:haddock_index = {} - -" initialise dictionary, mapping modules with haddocks to their packages, -" populated via MkHaddockModuleIndex() or HaveModuleIndex() -let g:haddock_moduleindex = {} - -" program to open urls, please set this in your vimrc - "examples (for windows): - "let g:haddock_browser = "C:/Program Files/Opera/Opera.exe" - "let g:haddock_browser = "C:/Program Files/Mozilla Firefox/firefox.exe" - "let g:haddock_browser = "C:/Program Files/Internet Explorer/IEXPLORE.exe" -if !exists("g:haddock_browser") - echoerr s:scriptname." WARNING: please set g:haddock_browser!" -endif - -if !haskellmode#GHC() | finish | endif - -if (!exists("g:ghc_pkg") || !executable(g:ghc_pkg)) - let g:ghc_pkg = substitute(g:ghc,'\(.*\)ghc','\1ghc-pkg','') -endif - -if exists("g:haddock_docdir") && isdirectory(g:haddock_docdir) - let s:docdir = g:haddock_docdir -elseif executable(g:ghc_pkg) -" try to figure out location of html docs -" first choice: where the base docs are (from the first base listed) - let [field;x] = split(system(g:ghc_pkg . ' field base haddock-html'),'\n') - " path changes in ghc-6.12.* - " let field = substitute(field,'haddock-html: \(.*\)libraries.base','\1','') - let field = substitute(field,'haddock-html: \(.*\)lib\(raries\)\?.base.*$','\1','') - let field = substitute(field,'\\','/','g') - " let alternate = substitute(field,'html','doc/html','') - " changes for ghc-6.12.*: check for doc/html/ first - let alternate = field.'doc/html/' - if isdirectory(alternate) - let s:docdir = alternate - elseif isdirectory(field) - let s:docdir = field - endif -else - echoerr s:scriptname." can't find ghc-pkg (set g:ghc_pkg ?)." -endif - -" second choice: try some known suspects for windows/unix -if !exists('s:docdir') || !isdirectory(s:docdir) - let s:ghc_libdir = substitute(system(g:ghc . ' --print-libdir'),'\n','','') - let location1a = s:ghc_libdir . '/doc/html/' - let location1b = s:ghc_libdir . '/doc/' - let location2 = '/usr/share/doc/ghc-' . haskellmode#GHC_Version() . '/html/' - if isdirectory(location1a) - let s:docdir = location1a - elseif isdirectory(location1b) - let s:docdir = location1b - elseif isdirectory(location2) - let s:docdir = location2 - else " give up - echoerr s:scriptname." can't find locaton of html documentation (set g:haddock_docdir)." - finish - endif -endif - -" todo: can we turn s:docdir into a list of paths, and -" include docs for third-party libs as well? - -let s:libraries = s:docdir . 'libraries/' -let s:guide = s:docdir . 'users_guide/' -let s:index = 'index.html' -if exists("g:haddock_indexfiledir") && filewritable(g:haddock_indexfiledir) - let s:haddock_indexfiledir = g:haddock_indexfiledir -elseif filewritable(s:libraries) - let s:haddock_indexfiledir = s:libraries -elseif filewritable($HOME) - let s:haddock_indexfiledir = $HOME.'/' -else "give up - echoerr s:scriptname." can't locate index file. please set g:haddock_indexfiledir" - finish -endif -let s:haddock_indexfile = s:haddock_indexfiledir . 'haddock_index.vim' - -" different browser setups require different call formats; -" you might want to call the browser synchronously or -" asynchronously, and the latter is os-dependent; -" -" by default, the browser is started in the background when on -" windows or if running in a gui, and in the foreground otherwise -" (eg, console-mode for remote sessions, with text-mode browsers). -" -" you can override these defaults in your vimrc, via a format -" string including 2 %s parameters (the first being the browser -" to call, the second being the url). -if !exists("g:haddock_browser_callformat") - if has("win32") || has("win64") - let g:haddock_browser_callformat = 'start %s "%s"' - else - if has("gui_running") - let g:haddock_browser_callformat = '%s %s '.printf(&shellredir,'/dev/null').' &' - else - let g:haddock_browser_callformat = '%s %s' - endif - endif -endif - -" allow map leader override -if !exists("maplocalleader") - let maplocalleader='_' -endif - -command! DocSettings call DocSettings() -function! DocSettings() - for v in ["g:haddock_browser","g:haddock_browser_callformat","g:haddock_docdir","g:haddock_indexfiledir","s:ghc_libdir","g:ghc_version","s:docdir","s:libraries","s:guide","s:haddock_indexfile"] - if exists(v) - echo v '=' eval(v) - else - echo v '=' - endif - endfor -endfunction - -function! DocBrowser(url) - "echomsg "DocBrowser(".url.")" - if (!exists("g:haddock_browser") || !executable(g:haddock_browser)) - echoerr s:scriptname." can't find documentation browser. please set g:haddock_browser" - return - endif - " start browser to open url, according to specified format - let url = a:url=~'^\(file://\|http://\)' ? a:url : 'file://'.a:url - silent exe '!'.printf(g:haddock_browser_callformat,g:haddock_browser,escape(url,'#%')) -endfunction - -"Doc/Doct are an old interface for documentation lookup -"(that is the reason they are not documented!-) -" -"These uses are still fine at the moment, and are the reason -"that this command still exists at all -" -" :Doc -top -" :Doc -libs -" :Doc -guide -" -"These uses may or may not work, and shouldn't be relied on anymore -"(usually, you want _?/_?1/_?2 or :MDoc; there is also :IDoc) -" -" :Doc length -" :Doc Control.Monad.when -" :Doc Data.List. -" :Doc Control.Monad.State.runState mtl -command! -nargs=+ Doc call Doc('v',<f-args>) -command! -nargs=+ Doct call Doc('t',<f-args>) - -function! Doc(kind,qualname,...) - let suffix = '.html' - let relative = '#'.a:kind.'%3A' - - if a:qualname=="-top" - call DocBrowser(s:docdir . s:index) - return - elseif a:qualname=="-libs" - call DocBrowser(s:libraries . s:index) - return - elseif a:qualname=="-guide" - call DocBrowser(s:guide . s:index) - return - endif - - if a:0==0 " no package specified - let package = 'base/' - else - let package = a:1 . '/' - endif - - if match(a:qualname,'\.')==-1 " unqualified name - let [qual,name] = [['Prelude'],a:qualname] - let file = join(qual,'-') . suffix . relative . name - elseif a:qualname[-1:]=='.' " module qualifier only - let parts = split(a:qualname,'\.') - let quallen = len(parts)-1 - let [qual,name] = [parts[0:quallen],parts[-1]] - let file = join(qual,'-') . suffix - else " qualified name - let parts = split(a:qualname,'\.') - let quallen = len(parts)-2 - let [qual,name] = [parts[0:quallen],parts[-1]] - let file = join(qual,'-') . suffix . relative . name - endif - - let path = s:libraries . package . file - call DocBrowser(path) -endfunction - -" TODO: add commandline completion for :IDoc -" switch to :emenu instead of inputlist? -" indexed variant of Doc, looking up links in g:haddock_index -" usage: -" 1. :IDoc length -" 2. click on one of the choices, or select by number (starting from 0) -command! -nargs=+ IDoc call IDoc(<f-args>) -function! IDoc(name,...) - let choices = HaddockIndexLookup(a:name) - if choices=={} | return | endif - if a:0==0 - let keylist = map(deepcopy(keys(choices)),'substitute(v:val,"\\[.\\]","","")') - let choice = inputlist(keylist) - else - let choice = a:1 - endif - let path = values(choices)[choice] " assumes same order for keys/values.. - call DocBrowser(path) -endfunction - -let s:flagref = s:guide . 'flag-reference.html' -if filereadable(s:flagref) - " extract the generated fragment ids for the - " flag reference sections - let s:headerPat = '.\{-}<h3 class="title"><a name="\([^"]*\)"><\/a>\([^<]*\)<\/h3>\(.*\)' - let s:flagheaders = [] - let s:flagheaderids = {} - let s:contents = join(readfile(s:flagref)) - let s:ml = matchlist(s:contents,s:headerPat) - while s:ml!=[] - let [_,s:id,s:title,s:r;s:x] = s:ml - let s:flagheaders = add(s:flagheaders, s:title) - let s:flagheaderids[s:title] = s:id - let s:ml = matchlist(s:r,s:headerPat) - endwhile - command! -nargs=1 -complete=customlist,CompleteFlagHeaders FlagReference call FlagReference(<f-args>) - function! FlagReference(section) - let relativeUrl = a:section==""||!exists("s:flagheaderids['".a:section."']") ? - \ "" : "#".s:flagheaderids[a:section] - call DocBrowser(s:flagref.relativeUrl) - endfunction - function! CompleteFlagHeaders(al,cl,cp) - let s:choices = s:flagheaders - return CompleteAux(a:al,a:cl,a:cp) - endfunction -endif - -command! -nargs=1 -complete=customlist,CompleteHaddockModules MDoc call MDoc(<f-args>) -function! MDoc(module) - let suffix = '.html' - call HaveModuleIndex() - if !has_key(g:haddock_moduleindex,a:module) - echoerr a:module 'not found in haddock module index' - return - endif - let package = g:haddock_moduleindex[a:module]['package'] - let file = substitute(a:module,'\.','-','g') . suffix -" let path = s:libraries . package . '/' . file - let path = g:haddock_moduleindex[a:module]['html'] - call DocBrowser(path) -endfunction - -function! CompleteHaddockModules(al,cl,cp) - call HaveModuleIndex() - let s:choices = keys(g:haddock_moduleindex) - return CompleteAux(a:al,a:cl,a:cp) -endfunction - -" create a dictionary g:haddock_index, containing the haddoc index -command! DocIndex call DocIndex() -function! DocIndex() - let files = split(globpath(s:libraries,'doc-index*.html'),'\n') - let g:haddock_index = {} - if haskellmode#GHC_VersionGE([7,0,0]) - call ProcessHaddockIndexes3(s:libraries,files) - else - call ProcessHaddockIndexes2(s:libraries,files) - endif - if haskellmode#GHC_VersionGE([6,8,2]) - if &shell =~ 'sh' " unix-type shell - let s:addon_libraries = split(system(g:ghc_pkg . ' field \* haddock-html'),'\n') - else " windows cmd.exe and the like - let s:addon_libraries = split(system(g:ghc_pkg . ' field * haddock-html'),'\n') - endif - for addon in s:addon_libraries - let ml = matchlist(addon,'haddock-html: \("\)\?\(file:///\)\?\([^"]*\)\("\)\?') - if ml!=[] - let [_,quote,file,addon_path;x] = ml - let addon_path = substitute(addon_path,'\(\\\\\|\\\)','/','g') - let addon_files = split(globpath(addon_path,'doc-index*.html'),'\n') - if haskellmode#GHC_VersionGE([7,0,0]) - call ProcessHaddockIndexes3(addon_path,addon_files) - else - call ProcessHaddockIndexes2(addon_path,addon_files) - endif - endif - endfor - endif - return 1 -endfunction - -function! ProcessHaddockIndexes(location,files) - let entryPat= '.\{-}"indexentry"[^>]*>\([^<]*\)<\(\%([^=]\{-}TD CLASS="\%(indexentry\)\@!.\{-}</TD\)*\)[^=]\{-}\(\%(="indexentry\|TABLE\).*\)' - let linkPat = '.\{-}HREF="\([^"]*\)".>\([^<]*\)<\(.*\)' - - redraw - echo 'populating g:haddock_index from haddock index files in ' a:location - for f in a:files - echo f[len(a:location):] - let contents = join(readfile(f)) - let ml = matchlist(contents,entryPat) - while ml!=[] - let [_,entry,links,r;x] = ml - "echo entry links - let ml2 = matchlist(links,linkPat) - let link = {} - while ml2!=[] - let [_,l,m,links;x] = ml2 - "echo l m - let link[m] = a:location . '/' . l - let ml2 = matchlist(links,linkPat) - endwhile - let g:haddock_index[DeHTML(entry)] = deepcopy(link) - "echo entry g:haddock_index[entry] - let ml = matchlist(r,entryPat) - endwhile - endfor -endfunction - -" concatenating all lines is too slow for a big file, process lines directly -function! ProcessHaddockIndexes2(location,files) - let entryPat= '^>\([^<]*\)</' - let linkPat = '.\{-}A HREF="\([^"]*\)"' - let kindPat = '#\(.\)' - - " redraw - echo 'populating g:haddock_index from haddock index files in ' a:location - for f in a:files - echo f[len(a:location):] - let isEntry = 0 - let isLink = '' - let link = {} - let entry = '' - for line in readfile(f) - if line=~'CLASS="indexentry' - if (link!={}) && (entry!='') - if has_key(g:haddock_index,DeHTML(entry)) - let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link)) - else - let dict = deepcopy(link) - endif - let g:haddock_index[DeHTML(entry)] = dict - let link = {} - let entry = '' - endif - let isEntry=1 - continue - endif - if isEntry==1 - let ml = matchlist(line,entryPat) - if ml!=[] | let [_,entry;x] = ml | let isEntry=0 | continue | endif - endif - if entry!='' - let ml = matchlist(line,linkPat) - if ml!=[] | let [_,isLink;x]=ml | continue | endif - endif - if isLink!='' - let ml = matchlist(line,entryPat) - if ml!=[] - let [_,module;x] = ml - let [_,kind;x] = matchlist(isLink,kindPat) - let last = a:location[strlen(a:location)-1] - let link[module."[".kind."]"] = a:location . (last=='/'?'':'/') . isLink - let isLink='' - continue - endif - endif - endfor - if link!={} - if has_key(g:haddock_index,DeHTML(entry)) - let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link)) - else - let dict = deepcopy(link) - endif - let g:haddock_index[DeHTML(entry)] = dict - endif - endfor -endfunction - -function! ProcessHaddockIndexes3(location,files) - let entryPat= '>\(.*\)$' - let linkPat = '<a href="\([^"]*\)"' - let kindPat = '#\(.\)' - - " redraw - echo 'populating g:haddock_index from haddock index files in ' a:location - for f in a:files - echo f[len(a:location):] - let isLink = '' - let link = {} - let entry = '' - let lines = split(join(readfile(f,'b')),'\ze<') - for line in lines - if (line=~'class="src') || (line=~'/table') - if (link!={}) && (entry!='') - if has_key(g:haddock_index,DeHTML(entry)) - let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link)) - else - let dict = deepcopy(link) - endif - let g:haddock_index[DeHTML(entry)] = dict - let link = {} - let entry = '' - endif - let ml = matchlist(line,entryPat) - if ml!=[] | let [_,entry;x] = ml | continue | endif - continue - endif - if entry!='' - let ml = matchlist(line,linkPat) - if ml!=[] - let [_,isLink;x]=ml - let ml = matchlist(line,entryPat) - if ml!=[] - let [_,module;x] = ml - let [_,kind;x] = matchlist(isLink,kindPat) - let last = a:location[strlen(a:location)-1] - let link[module."[".kind."]"] = a:location . (last=='/'?'':'/') . isLink - let isLink='' - endif - continue - endif - endif - endfor - if link!={} - if has_key(g:haddock_index,DeHTML(entry)) - let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link)) - else - let dict = deepcopy(link) - endif - let g:haddock_index[DeHTML(entry)] = dict - endif - endfor -endfunction - - -command! ExportDocIndex call ExportDocIndex() -function! ExportDocIndex() - call HaveIndex() - let entries = [] - for key in keys(g:haddock_index) - let entries += [key,string(g:haddock_index[key])] - endfor - call writefile(entries,s:haddock_indexfile) - redir end -endfunction - -command! ImportDocIndex call ImportDocIndex() -function! ImportDocIndex() - if filereadable(s:haddock_indexfile) - let lines = readfile(s:haddock_indexfile) - let i=0 - while i<len(lines) - let [key,dict] = [lines[i],lines[i+1]] - sandbox let g:haddock_index[key] = eval(dict) - let i+=2 - endwhile - return 1 - else - return 0 - endif -endfunction - -function! HaveIndex() - return (g:haddock_index!={} || ImportDocIndex() || DocIndex() ) -endfunction - -function! MkHaddockModuleIndex() - let g:haddock_moduleindex = {} - call HaveIndex() - for key in keys(g:haddock_index) - let dict = g:haddock_index[key] - for module in keys(dict) - let html = dict[module] - let html = substitute(html ,'#.*$','','') - let module = substitute(module,'\[.\]','','') - let ml = matchlist(html,'libraries/\([^\/]*\)[\/]') - if ml!=[] - let [_,package;x] = ml - let g:haddock_moduleindex[module] = {'package':package,'html':html} - endif - let ml = matchlist(html,'/\([^\/]*\)\/html/[A-Z]') - if ml!=[] - let [_,package;x] = ml - let g:haddock_moduleindex[module] = {'package':package,'html':html} - endif - endfor - endfor -endfunction - -function! HaveModuleIndex() - return (g:haddock_moduleindex!={} || MkHaddockModuleIndex() ) -endfunction - -" decode HTML symbol encodings (are these all we need?) -function! DeHTML(entry) - let res = a:entry - let decode = { '<': '<', '>': '>', '&': '\\&' } - for enc in keys(decode) - exe 'let res = substitute(res,"'.enc.'","'.decode[enc].'","g")' - endfor - return res -endfunction - -" find haddocks for word under cursor -" also lists possible definition sites -" - needs to work for both qualified and unqualified items -" - for 'import qualified M as A', consider M.item as source of A.item -" - offer sources from both type [t] and value [v] namespaces -" - for unqualified items, list all possible sites -" - for qualified items, list imported sites only -" keep track of keys with and without namespace tags: -" the former are needed for lookup, the latter for matching against source -map <LocalLeader>? :call Haddock()<cr> -function! Haddock() - amenu ]Popup.- :echo '-'<cr> - aunmenu ]Popup - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return 0 - endif - let [start,symb,qual,unqual] = namsym - let imports = haskellmode#GatherImports() - let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : [] - let name = unqual - let dict = HaddockIndexLookup(name) - if dict=={} | return | endif - " for qualified items, narrow results to possible imports that provide qualifier - let filteredKeys = filter(copy(keys(dict)) - \ ,'match(asm,substitute(v:val,''\[.\]'','''',''''))!=-1') - let keys = (qual!='') ? filteredKeys : keys(dict) - if (keys==[]) && (qual!='') - echoerr qual.'.'.unqual.' not found in imports' - return 0 - endif - " use 'setlocal completeopt+=menuone' if you always want to see menus before - " anything happens (I do, but many users don't..) - if len(keys)==1 && (&completeopt!~'menuone') - call DocBrowser(dict[keys[0]]) - elseif has("gui_running") - for key in keys - exe 'amenu ]Popup.'.escape(key,'\.').' :call DocBrowser('''.dict[key].''')<cr>' - endfor - popup ]Popup - else - let s:choices = keys - let key = input('browse docs for '.name.' in: ','','customlist,CompleteAux') - if key!='' - call DocBrowser(dict[key]) - endif - endif -endfunction - -if !exists("g:haskell_search_engines") - let g:haskell_search_engines = - \ {'hoogle':'http://www.haskell.org/hoogle/?hoogle=%s' - \ ,'hayoo!':'http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=%s' - \ } -endif - -map <LocalLeader>?? :let es=g:haskell_search_engines - \ \|echo "g:haskell_search_engines" - \ \|for e in keys(es) - \ \|echo e.' : '.es[e] - \ \|endfor<cr> -map <LocalLeader>?1 :call HaskellSearchEngine('hoogle')<cr> -map <LocalLeader>?2 :call HaskellSearchEngine('hayoo!')<cr> - -" query one of the Haskell search engines for the thing under cursor -" - unqualified symbols need to be url-escaped -" - qualified ids need to be fed as separate qualifier and id for -" both hoogle (doesn't handle qualified symbols) and hayoo! (no qualified -" ids at all) -" - qualified ids referring to import-qualified-as qualifiers need to be -" translated to the multi-module searches over the list of original modules -function! HaskellSearchEngine(engine) - amenu ]Popup.- :echo '-'<cr> - aunmenu ]Popup - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return 0 - endif - let [start,symb,qual,unqual] = namsym - let imports = haskellmode#GatherImports() - let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : [] - let unqual = haskellmode#UrlEncode(unqual) - if a:engine=='hoogle' - let name = asm!=[] ? unqual.'+'.join(map(copy(asm),'"%2B".v:val'),'+') - \ : qual!='' ? unqual.'+'.haskellmode#UrlEncode('+').qual - \ : unqual - elseif a:engine=='hayoo!' - let name = asm!=[] ? unqual.'+module:('.join(copy(asm),' OR ').')' - \ : qual!='' ? unqual.'+module:'.qual - \ : unqual - else - let name = qual=="" ? unqual : qual.".".unqual - endif - if has_key(g:haskell_search_engines,a:engine) - call DocBrowser(printf(g:haskell_search_engines[a:engine],name)) - else - echoerr "unknown search engine: ".a:engine - endif -endfunction - -" used to pass on choices to CompleteAux -let s:choices=[] - -" if there's no gui, use commandline completion instead of :popup -" completion function CompleteAux suggests completions for a:al, wrt to s:choices -function! CompleteAux(al,cl,cp) - "echomsg '|'.a:al.'|'.a:cl.'|'.a:cp.'|' - let res = [] - let l = len(a:al)-1 - for r in s:choices - if l==-1 || r[0 : l]==a:al - let res += [r] - endif - endfor - return res -endfunction - -" CamelCase shorthand matching: -" favour upper-case letters and module qualifier separators (.) for disambiguation -function! CamelCase(shorthand,string) - let s1 = a:shorthand - let s2 = a:string - let notFirst = 0 " don't elide before first pattern letter - while ((s1!="")&&(s2!="")) - let head1 = s1[0] - let head2 = s2[0] - let elide = notFirst && ( ((head1=~'[A-Z]') && (head2!~'[A-Z.]')) - \ ||((head1=='.') && (head2!='.')) ) - if elide - let s2=s2[1:] - elseif (head1==head2) - let s1=s1[1:] - let s2=s2[1:] - else - return 0 - endif - let notFirst = (head1!='.')||(head2!='.') " treat separators as new beginnings - endwhile - return (s1=="") -endfunction - -" use haddock name index for insert mode completion (CTRL-X CTRL-U) -function! CompleteHaddock(findstart, base) - if a:findstart - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),-1) " insert-mode: we're 1 beyond the text - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return -1 - endif - let [start,symb,qual,unqual] = namsym - return (start-1) - else " find keys matching with "a:base" - let res = [] - let l = len(a:base)-1 - let qual = a:base =~ '^[A-Z][a-zA-Z0-9_'']*\(\.[A-Z][a-zA-Z0-9_'']*\)*\(\.[a-zA-Z0-9_'']*\)\?$' - call HaveIndex() - for key in keys(g:haddock_index) - let keylist = map(deepcopy(keys(g:haddock_index[key])),'substitute(v:val,"\\[.\\]","","")') - if (key[0 : l]==a:base) - for m in keylist - let res += [{"word":key,"menu":m,"dup":1}] - endfor - elseif qual " this tends to be slower - for m in keylist - let word = m . '.' . key - if word[0 : l]==a:base - let res += [{"word":word,"menu":m,"dup":1}] - endif - endfor - endif - endfor - if res==[] " no prefix matches, try CamelCase shortcuts - for key in keys(g:haddock_index) - let keylist = map(deepcopy(keys(g:haddock_index[key])),'substitute(v:val,"\\[.\\]","","")') - if CamelCase(a:base,key) - for m in keylist - let res += [{"word":key,"menu":m,"dup":1}] - endfor - elseif qual " this tends to be slower - for m in keylist - let word = m . '.' . key - if CamelCase(a:base,word) - let res += [{"word":word,"menu":m,"dup":1}] - endif - endfor - endif - endfor - endif - return res - endif -endfunction -setlocal completefunc=CompleteHaddock -" -" Vim's default completeopt is menu,preview -" you probably want at least menu, or you won't see alternatives listed -" setlocal completeopt+=menu - -" menuone is useful, but other haskellmode menus will try to follow your choice here in future -" setlocal completeopt+=menuone - -" longest sounds useful, but doesn't seem to do what it says, and interferes with CTRL-E -" setlocal completeopt-=longest - -" fully qualify an unqualified name -" TODO: - standardise commandline versions of menus -map <LocalLeader>. :call Qualify()<cr> -function! Qualify() - amenu ]Popup.- :echo '-'<cr> - aunmenu ]Popup - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return 0 - endif - let [start,symb,qual,unqual] = namsym - if qual!='' " TODO: should we support re-qualification? - redraw - echo 'already qualified' - return 0 - endif - let name = unqual - let line = line('.') - let prefix = (start<=1 ? '' : getline(line)[0:start-2] ) - let dict = HaddockIndexLookup(name) - if dict=={} | return | endif - let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")') - let imports = haskellmode#GatherImports() - let qualifiedImports = [] - for qualifiedImport in keys(imports[1]) - let c=0 - for module in imports[1][qualifiedImport]['modules'] - if haskellmode#ListElem(keylist,module) | let c+=1 | endif - endfor - if c>0 | let qualifiedImports=[qualifiedImport]+qualifiedImports | endif - endfor - "let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : [] - let keylist = filter(copy(keylist),'index(qualifiedImports,v:val)==-1') - if has("gui_running") - " amenu ]Popup.-imported- : - for key in qualifiedImports - let lhs=escape(prefix.name,'/.|\') - let rhs=escape(prefix.key.'.'.name,'/&|\') - exe 'amenu ]Popup.'.escape(key,'\.').' :'.line.'s/'.lhs.'/'.rhs.'/<cr>:noh<cr>' - endfor - amenu ]Popup.-not\ imported- : - for key in keylist - let lhs=escape(prefix.name,'/.|\') - let rhs=escape(prefix.key.'.'.name,'/&|\') - exe 'amenu ]Popup.'.escape(key,'\.').' :'.line.'s/'.lhs.'/'.rhs.'/<cr>:noh<cr>' - endfor - popup ]Popup - else - let s:choices = qualifiedImports+keylist - let key = input('qualify '.name.' with: ','','customlist,CompleteAux') - if key!='' - let lhs=escape(prefix.name,'/.\') - let rhs=escape(prefix.key.'.'.name,'/&\') - exe line.'s/'.lhs.'/'.rhs.'/' - noh - endif - endif -endfunction - -" create (qualified) import for a (qualified) name -" TODO: refine search patterns, to avoid misinterpretation of -" oddities like import'Neither or not'module -map <LocalLeader>i :call Import(0,0)<cr> -map <LocalLeader>im :call Import(1,0)<cr> -map <LocalLeader>iq :call Import(0,1)<cr> -map <LocalLeader>iqm :call Import(1,1)<cr> -function! Import(module,qualified) - amenu ]Popup.- :echo '-'<cr> - aunmenu ]Popup - let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0) - if namsym==[] - redraw - echo 'no name/symbol under cursor!' - return 0 - endif - let [start,symb,qual,unqual] = namsym - let name = unqual - let pname = ( symb ? '('.name.')' : name ) - let importlist = a:module ? '' : '('.pname.')' - let qualified = a:qualified ? 'qualified ' : '' - - if qual!='' - exe 'call append(search(''\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.qual.importlist.''')' - return - endif - - let line = line('.') - let prefix = getline(line)[0:start-1] - let dict = HaddockIndexLookup(name) - if dict=={} | return | endif - let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")') - if has("gui_running") - for key in keylist - " exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search("\\%1c\\(import\\\\|module\\\\|{-# OPTIONS\\)","nb"),"import '.key.importlist.'")<cr>' - exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search(''\%1c\(\<import\>\\|\<module\>\\|{-# OPTIONS\\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.escape(importlist,'|').''')<cr>' - endfor - popup ]Popup - else - let s:choices = keylist - let key = input('import '.name.' from: ','','customlist,CompleteAux') - if key!='' - exe 'call append(search(''\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.importlist.''')' - endif - endif -endfunction - -function! HaddockIndexLookup(name) - call HaveIndex() - if !has_key(g:haddock_index,a:name) - echoerr a:name 'not found in haddock index' - return {} - endif - return g:haddock_index[a:name] -endfunction - diff --git a/.vim/ftplugin/haskell_hpaste.vim b/.vim/ftplugin/haskell_hpaste.vim deleted file mode 100644 index 33ea0bd..0000000 --- a/.vim/ftplugin/haskell_hpaste.vim +++ /dev/null @@ -1,79 +0,0 @@ -" rudimentary hpaste support for vim -" (using netrw for reading, wget for posting/annotating) -" -" claus reinke, last modified: 07/04/2009 -" -" part of haskell plugins: http://projects.haskell.org/haskellmode-vim - -" unless wget is in your PATH, you need to set g:wget -" before loading this script. windows users are out of -" luck, unless they have wget installed (such as the -" cygwin one looked for here), or adapt this script to -" whatever alternative they have at hand (perhaps using -" vim's perl/python bindings?) -if !exists("g:wget") - if executable("wget") - let g:wget = "!wget -q" - else - let g:wget = "!c:\\cygwin\\bin\\wget -q" - endif -endif - -" read (recent) hpaste files -" show index in new buffer, where ,r will open current entry -" and ,p will annotate current entry with current buffer -command! HpasteIndex call HpasteIndex() -function! HpasteIndex() - new - read http://hpaste.org - %s/\_$\_.//g - %s/<tr[^>]*>//g - %s/<\/tr>/
/g - g/<\/table>/d - g/DOCTYPE/d - %s/<td>\([^<]*\)<\/td><td><a href="\/fastcgi\/hpaste\.fcgi\/view?id=\([0-9]*\)">\([^<]*\)<\/a><\/td><td>\([^<]*\)<\/td><td>\([^<]*\)<\/td><td>\([^<]*\)<\/td>/\2 [\1] "\3" \4 \5 \6/ - map <buffer> ,r 0yE:noh<cr>:call HpasteEditEntry('"')<cr> -endfunction - -" load an existing entry for editing -command! -nargs=1 HpasteEditEntry call HpasteEditEntry(<f-args>) -function! HpasteEditEntry(entry) - new - exe 'Nread http://hpaste.org/fastcgi/hpaste.fcgi/raw?id='.a:entry - "exe 'map <buffer> ,p :call HpasteAnnotate('''.a:entry.''')<cr>' -endfunction - -" " posting temporarily disabled -- needs someone to look into new -" " hpaste.org structure - -" " annotate existing entry (only to be called via ,p in HpasteIndex) -" function! HpasteAnnotate(entry) -" let nick = input("nick? ") -" let title = input("title? ") -" if nick=='' || title=='' -" echo "nick or title missing. aborting annotation" -" return -" endif -" call HpastePost('annotate/'.a:entry,nick,title) -" endfunction -" -" " post new hpaste entry -" " using 'wget --post-data' and url-encoded content -" command! HpastePostNew call HpastePost('new',<args>) -" function! HpastePost(mode,nick,title,...) -" let lines = getbufline("%",1,"$") -" let pat = '\([^[:alnum:]]\)' -" let code = '\=printf("%%%02X",char2nr(submatch(1)))' -" let lines = map(lines,'substitute(v:val."\r\n",'''.pat.''','''.code.''',''g'')') -" -" let url = 'http://hpaste.org/' . a:mode -" let nick = substitute(a:nick,pat,code,'g') -" let title = substitute(a:title,pat,code,'g') -" if a:0==0 -" let announce = 'false' -" else -" let announce = a:1 -" endif -" let cmd = g:wget.' --post-data="content='.join(lines,'').'&nick='.nick.'&title='.title.'&announce='.announce.'" '.url -" exe escape(cmd,'%') -" endfunction diff --git a/.vim/ftplugin/java/CTree.vim b/.vim/ftplugin/java/CTree.vim deleted file mode 100644 index a67fdbc..0000000 --- a/.vim/ftplugin/java/CTree.vim +++ /dev/null @@ -1,240 +0,0 @@ -" ------------------------------------------------------------------- -" CTree.vim -- Display Class/Interface Hierarchy "{{{ -" -" Author: Yanbiao Zhao (yanbiao_zhao at yahoo.com) -" Requires: Vim 7 -" Version: 1.1.2 -" -" Command: -" CTree -- Display a tree of Class/Interface hierarchy -" CTag -- Jump to the class/interface definition of the tag -" }}} - -if v:version < 700 - echomsg "Vim 7 or higher is required for CTree.vim" - finish -endif - -command! -nargs=1 -complete=tag CTree call s:CTree_GetTypeTree(<f-args>) -command! -nargs=1 -complete=tag CTag call s:CT_Jump_To_ClassName(<f-args>) - -"Short cut to use the commands -"nmap <silent> <M-F9> :exec "CTree ".expand("<cword>")<CR> -"nmap <silent> <M-]> :exec "CTag ".expand("<cword>")<CR> - -function! s:CT_Jump_To_ClassName(className) - let tagEntry = {} - let tagEntry["name"] = a:className - if s:CT_Jump_To_Class(tagEntry)== 0 - echohl WarningMsg | echo 'tag not found: '.a:className | echohl None - endif -endfunction - -let s:CTree_AllTypeEntries = [] -let s:CTree_TagEnvCache = '' -let s:CTree_tagFilesCache = {} - -function! s:CTree_GetTypeTree(typeName) - call s:CTree_LoadAllTypeEntries() - - let rootEntry = s:CTree_GetRootType(a:typeName, '') - - if empty(rootEntry) - let rootEntry["name"] = a:typeName - let rootEntry["namespace"] = "" - let rootEntry["kind"] = 'c' - let rootEntry["inherits"] = "" - endif - - echohl Title | echo ' # tag' | echohl None - - let allEntries = [] - call s:CTree_GetChildren(allEntries, rootEntry, 0) - - let i = input('Choice number (<Enter> cancels):') - let i = str2nr(i) - if i > 0 && i <= len(allEntries) - call s:CT_Jump_To_Class(allEntries[i-1]) - endif -endfunction - -function! s:CTree_GetChildren(allEntries, rootEntry, depth) - call add(a:allEntries, a:rootEntry) - call s:CTree_DisplayTagEntry(len(a:allEntries), a:rootEntry, a:depth) - - let children = [] - let rootTypeName = a:rootEntry["name"] - for tagEntry in s:CTree_AllTypeEntries - if index(split(tagEntry["inherits"], ","), rootTypeName) >= 0 - call add(children, tagEntry) - endif - endfor - - let rootKind = a:rootEntry["kind"] - for child in children - "We only want to display class that implement an interface directly - if child["kind"] == 'c' && rootKind == 'i' - call add(a:allEntries, child) - call s:CTree_DisplayTagEntry(len(a:allEntries), child, a:depth+1) - else - call s:CTree_GetChildren(a:allEntries, child, a:depth+1) - endif - endfor - -endfunction - -" Return if a tag file has changed in tagfiles() -function! s:HasTagFileChanged() - let result = 0 - let tagFiles = map(tagfiles(), 'escape(v:val, " ")') - let newTagFilesCache = {} - - if len(tagFiles) != len(s:CTree_tagFilesCache) - let result = 1 - endif - - for tagFile in tagFiles - let currentFiletime = getftime(tagFile) - let newTagFilesCache[tagFile] = currentFiletime - - if !has_key(s:CTree_tagFilesCache, tagFile) - let result = 1 - elseif currentFiletime != s:CTree_tagFilesCache[tagFile] - let result = 1 - endif - endfor - - let s:CTree_tagFilesCache = newTagFilesCache - return result -endfunc - -function! s:CTree_LoadAllTypeEntries() - if s:HasTagFileChanged() - let s:CTree_AllTypeEntries = [] - else - return - endif - - echo 'Loading tag information. It may take a while...' - let ch = 'A' - while ch <= 'Z' - call s:CTree_GetTypeEntryWithCh(ch) - let ch = nr2char(char2nr(ch)+1) - endwhile - - call s:CTree_GetTypeEntryWithCh('_') - - let ch = 'a' - while ch <= 'z' - call s:CTree_GetTypeEntryWithCh(ch) - let ch = nr2char(char2nr(ch)+1) - endwhile - - echo "Count of type tag entries loaded: ".len(s:CTree_AllTypeEntries) -endfunction - -function! s:CTree_GetTypeEntryWithCh(ch) - for tagEntry in taglist('^'.a:ch) - let kind = tagEntry["kind"] - if (kind == 'i' || kind == 'c') && has_key(tagEntry, "inherits") - call add(s:CTree_AllTypeEntries, tagEntry) - endif - endfor -endfunction - -function! s:CTree_GetRootType(typeName, originalKind) - for tagEntry in taglist("^".a:typeName."$") - - let kind = tagEntry["kind"] - if kind != 'c' && kind != 'i' - continue - endif - - let originalKind = a:originalKind - if originalKind == '' - let originalKind = kind - elseif originalKind != tagEntry["kind"] - "We will not accept interface as a parent of class - return {} - endif - - if !has_key(tagEntry, "inherits") - return tagEntry - endif - - "interface support multiple inheritance, so we will not try to get its - "parent if it has more than one parent - let parents = split(tagEntry["inherits"], ",") - if originalKind == 'i' && len(parents) > 1 - return tagEntry - endif - - for parent in parents - let rootEntry = s:CTree_GetRootType(parent, originalKind) - - if !empty(rootEntry) - return rootEntry - endif - endfor - - return tagEntry - endfor - - return {} -endfunction - -function! s:CTree_DisplayTagEntry(index, typeEntry, depth) - let s = string(a:index) - while strlen(s) < 4 - let s = ' '.s - endwhile - - let s = s." " - let i = 0 - while i < a:depth - let s = s." " - let i = i + 1 - endwhile - - let s = s.a:typeEntry["name"] - - if has_key(a:typeEntry, "namespace") - let s = s.' ['.a:typeEntry["namespace"].']' - elseif has_key(a:typeEntry, "class") - let s = s.' <'.a:typeEntry["class"].'>' - endif - - echo s -endfunction - -function! s:CT_Jump_To_Class(tagEntry) - let className = a:tagEntry["name"] - - if has_key(a:tagEntry, "namespace") - let keyName = "namespace" - elseif has_key(a:tagEntry, "class") - let keyName = "class" - else - let keyName = "" - endif - - if keyName == "" - let namespace = "" - else - let namespace = a:tagEntry[keyName] - endif - - let i = 1 - let entries = taglist('^'.className.'$') - for entry in entries - let kind = entry["kind"] - if kind == 'c' || kind == 'i' || kind == 'g' - if namespace == "" || namespace == entry[keyName] - exec "silent ".i."tag ".className - return 1 - endif - endif - let i += 1 - endfor - return 0 -endfunction diff --git a/.vim/ftplugin/java/java.vim b/.vim/ftplugin/java/java.vim deleted file mode 100644 index e442356..0000000 --- a/.vim/ftplugin/java/java.vim +++ /dev/null @@ -1,84 +0,0 @@ - -" Editing settings -"set tabstop=4 shiftwidth=4 expandtab textwidth=90 - -" Syntax highlighting settings. -"let g:java_allow_cpp_keywords=1 -"syntax on - -" Comma (,) prefixes a KEYWORD abbreviation -inoremap <buffer> ,c class -inoremap <buffer> ,i interface -inoremap <buffer> ,I implements -inoremap <buffer> ,m import -inoremap <buffer> ,f final -inoremap <buffer> ,s static -inoremap <buffer> ,y synchronized -inoremap <buffer> ,e extends -inoremap <buffer> ,p public -inoremap <buffer> ,P private -inoremap <buffer> ,o protected -inoremap <buffer> ,f final -inoremap <buffer> ,s static -inoremap <buffer> ,y synchronized -inoremap <buffer> ,a package - -" Colon (:) prefixes a FLOW abbreviation - -inoremap <buffer> :f for -inoremap <buffer> :w while -inoremap <buffer> :s switch -inoremap <buffer> :C case -inoremap <buffer> :b break -inoremap <buffer> :d default -inoremap <buffer> :i if -inoremap <buffer> :r return -inoremap <buffer> :t try -inoremap <buffer> :c catch -inoremap <buffer> :f finally -inoremap <buffer> :T throws -inoremap <buffer> :R throw - -" CTRL + T (^T) prefixes a TYPE abbreviation - -inoremap <buffer> <C-T>i int -inoremap <buffer> <C-T>I Integer -inoremap <buffer> <C-T>l long -inoremap <buffer> <C-T>L Long -inoremap <buffer> <C-T>b boolean -inoremap <buffer> <C-T>B Boolean -inoremap <buffer> <C-T>c char -inoremap <buffer> <C-T>C Char -inoremap <buffer> <C-T>d Double -inoremap <buffer> <C-T>D Double -inoremap <buffer> <C-T>v void -inoremap <buffer> <C-T>V Void -inoremap <buffer> <C-T>s String -inoremap <buffer> <C-T>S String -inoremap <buffer> <C-T>e Exception -inoremap <buffer> <C-T>E Exception - -" CTRL + Underscore (_) prefixes a GENERAL abbreviation - -inoremap <buffer> <C-_>m public static void main(String args[]) -inoremap <buffer> <C-_>o System.out.println(X);<Esc>FXs -inoremap <buffer> <C-_>e System.err.println(X);<Esc>FXs -inoremap <buffer> <C-_>t true -inoremap <buffer> <C-_>f false -inoremap <buffer> <C-_>E e.printStackTrace(); -inoremap <buffer> <C-_>C <C-V><code> -inoremap <buffer> <C-_>c <C-V></code> - -" Helpful mappings when creating a new object -" Type: Object o<F2> -" Get: Object o = new Object(); -" F3 leaves the cursor between the parentheses. -inoremap <buffer> <F2> <C-O>A = new <Esc>^yE<End>pA();<CR> -inoremap <buffer> <F3> <C-O>A = new <Esc>^yE<End>pA();<Left><Left> - -" To create a javadoc comment above the current line -nnoremap Zc O/**<CR><BS>*<CR>*/<Up><Space> - -" Useful when editing javadoc comments -nnoremap ZR :se formatoptions+=ro<CR> -nnoremap Zr :se formatoptions-=ro<CR> diff --git a/.vim/ftplugin/java/java_getset.vim b/.vim/ftplugin/java/java_getset.vim deleted file mode 100644 index 6a906e9..0000000 --- a/.vim/ftplugin/java/java_getset.vim +++ /dev/null @@ -1,871 +0,0 @@ -" Vim filetype plugin file for adding getter/setter methods -" Language: Java -" Maintainer: Pete Kazmier (pete-vim AT kazmier DOT com) -" Last Change: 2002 Nov 21 -" Revision: $Id: java_getset.vim,v 1.10 2002/12/02 15:14:31 kaz Exp $ -" Credit: -" - Based on jcommenter.vim by Kalle Björklid <bjorklid@st.jyu.fi. -" - Thanks to Dan Sharp for his feedback, suggestions and help. -" - Thanks to Steven Op de beeck for his feedback and help. -" -" ======================================================================= -" -" Copyright 2002 by Peter Kazmier -" -" Redistribution and use in source and binary forms, with or without -" modification, are permitted provided that the following conditions -" are met: -" -" 1. Redistributions of source code must retain the above copyright -" notice, this list of conditions and the following disclaimer. -" -" 2. 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. -" -" 3. The name of the author may not be used to endorse or promote -" products derived from this software without specific prior -" written permission. -" -" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. -" -" ======================================================================= -" -" DESCRIPTION -" This filetype plugin enables a user to automatically add getter/setter -" methods for Java properties. The script will insert a getter, setter, -" or both depending on the command/mapping invoked. Users can select -" properties one at a time, or in bulk (via a visual block or specifying a -" range). In either case, the selected block may include comments as they -" will be ignored during the parsing. For example, you could select all -" of these properties with a single visual block. -" -" public class Test -" { -" // The global count -" private static int count; -" -" /** The name */ -" private String name; -" -" /** The array of addresses */ -" private String[] address; -" } -" -" The script will also add the 'static' modifier to the method if the -" property was declared as 'static'. Array-based properties will get -" additional methods added to support indexing. In addition, if a -" property is declared 'final', it will not generate a setter for it. -" If a previous getter OR setter exists for a property, the script will -" not add any methods (under the assumption that you've manually added -" your own). -" -" The getters/setters that are inserted can be configured by the user. -" First, the insertion point can be selected. It can be one of the -" following: before the current line / block, after the current line / -" block, or at the end of the class (default). Finally, the text that is -" inserted can be configured by defining your own templates. This allows -" the user to format for his/her coding style. For example, the default -" value for s:javagetset_getterTemplate is: -" -" /** -" * Get %varname%. -" * -" * @return %varname% as %type%. -" */ -" %modifiers% %type% %funcname%() -" { -" return %varname%; -" } -" -" Where the items surrounded by % are parameters that are substituted when -" the script is invoked on a particular property. For more information on -" configuration, please see the section below on the INTERFACE. -" -" INTERFACE (commands, mappings, and variables) -" The following section documents the commands, mappings, and variables -" used to customize the behavior of this script. -" -" Commands: -" :InsertGetterSetter -" Inserts a getter/setter for the property on the current line, or -" the range of properties specified via a visual block or x,y range -" notation. The user is prompted to determine what type of method -" to insert. -" -" :InsertGetterOnly -" Inserts a getter for the property on the current line, or the -" range of properties specified via a visual block or x,y range -" notation. The user is not prompted. -" -" :InsertSetterOnly -" Inserts a setter for the property on the current line, or the -" range of properties specified via a visual block or x,y range -" notation. The user is not prompted. -" -" :InsertBothGetterSetter -" Inserts a getter and setter for the property on the current line, -" or the range of properties specified via a visual block or x,y -" range notation. The user is not prompted. -" -" -" Mappings: -" The following mappings are pre-defined. You can disable the mappings -" by setting a variable (see the Variables section below). The default -" key mappings use the <LocalLeader> which is the backslash key by -" default '\'. This can also be configured via a variable (see below). -" -" <LocalLeader>p (or <Plug>JavagetsetInsertGetterSetter) -" Inserts a getter/setter for the property on the current line, or -" the range of properties specified via a visual block. User is -" prompted for choice. -" -" <LocalLeader>g (or <Plug>JavagetsetInsertGetterOnly) -" Inserts a getter for the property on the current line, or the -" range of properties specified via a visual block. User is not -" prompted. -" -" <LocalLeader>s (or <Plug>JavagetsetInsertSetterOnly) -" Inserts a getter for the property on the current line, or the -" range of properties specified via a visual block. User is not -" prompted. -" -" <LocalLeader>b (or <Plug>JavagetsetInsertBothGetterSetter) -" Inserts both a getter and setter for the property on the current -" line, or the range of properties specified via a visual block. -" User is not prompted. -" -" If you want to define your own mapping, you can map whatever you want -" to <Plug>JavagetsetInsertGetterSetter (or any of the other <Plug>s -" defined above). For example, -" -" map <buffer> <C-p> <Plug>JavagetsetInsertGetterSetter -" -" When you define your own mapping, the default mapping does not get -" set, only the mapping you specify. -" -" Variables: -" The following variables allow you to customize the behavior of this -" script so that you do not need to make changes directly to the script. -" These variables can be set in your vimrc. -" -" no_plugin_maps -" Setting this variable will disable all key mappings defined by any -" of your plugins (if the plugin writer adhered to the standard -" convention documented in the scripting section of the VIM manual) -" including this one. -" -" no_java_maps -" Setting this variable will disable all key mappings defined by any -" java specific plugin including this one. -" -" maplocalleader -" By default, the key mappings defined by this script use -" <LocalLeader> which is the backslash character by default. You can -" change this by setting this variable to a different key. For -" example, if you want to use the comma-key, you can add this line to -" your vimrc: -" -" let maplocalleader = ',' -" -" b:javagetset_insertPosition -" This variable determines the location where the getter and/or setter -" will be inserted. Currently, three positions have been defined: -" -" 0 - insert at the end of the class (default) -" 1 - insert before the current line / block -" 2 - insert after the current line / block -" -" b:javagetset_getterTemplate -" b:javagetset_setterTemplate -" b:javagetset_getterArrayTemplate -" b:javagetset_setterArrayTemplate -" These variables determine the text that will be inserted for a -" getter, setter, array-based getter, and array-based setter -" respectively. The templates may contain the following placeholders -" which will be substituted by their appropriate values at insertion -" time: -" -" %type% Java type of the property -" %varname% The name of the property -" %funcname% The method name ("getXzy" or "setXzy") -" %modifiers% "public" followed by "static" if the property is static -" -" For example, if you wanted to set the default getter template so -" that it would produce the following block of code for a property -" defined as "public static String name": -" -" /** -" * Get name. -" * @return name as String -" */ -" public static String getName() { return name; } -" -" This block of code can be produced by adding the following variable -" definition to your vimrc file. -" -" let b:javagetset_getterTemplate = -" \ "\n" . -" \ "/**\n" . -" \ " * Get %varname%.\n" . -" \ " * @return %varname% as %type%.\n" . -" \ " */\n" . -" \ "%modifiers% %type% %funcname%() { return %varname%; }" -" -" The defaults for these variables are defined in the script. For -" both the getterTemplate and setterTemplate, there is a corresponding -" array-baded template that is invoked if a property is array-based. -" This allows you to set indexed-based getters/setters if you desire. -" This is the default behavior. -" -" -" INSTALLATION -" 1. Copy the script to your ${HOME}/.vim/ftplugins directory and make -" sure its named "java_getset.vim" or "java_something.vim" where -" "something" can be anything you want. -" -" 2. (Optional) Customize the mapping and/or templates. You can create -" your own filetype plugin (just make sure its loaded before this one) -" and set the variables in there (i.e. ${HOME}/.vim/ftplugin/java.vim) -" -" ======================================================================= -" -" NOTE: -" This is my very first VIM script. I read all of the documentation, and -" have tried to follow the conventions outlined there; however, I may have -" missed some so please bear with me. - -" Only do this when not done yet for this buffer -if exists("b:did_javagetset_ftplugin") - finish -endif -let b:did_javagetset_ftplugin = 1 - -" Make sure we are in vim mode -let s:save_cpo = &cpo -set cpo&vim - -" TEMPLATE SECTION: -" The templates can use the following placeholders which will be replaced -" with appropriate values when the template is invoked: -" -" %type% Java type of the property -" %varname% The name of the property -" %funcname% The method name ("getXzy" or "setXzy") -" %modifiers% "public" followed by "static" if the property is static -" -" The templates consist of a getter and setter template. In addition, -" there are also templates for array-based properties. These are defined -" below. -" -" Getter Templates (non-array and array-based) -if exists("b:javagetset_getterTemplate") - let s:javagetset_getterTemplate = b:javagetset_getterTemplate -else - let s:javagetset_getterTemplate = - \ "\n" . - \ "/**\n" . - \ " * Get %varname%.\n" . - \ " *\n" . - \ " * @return %varname% as %type%.\n" . - \ " */\n" . - \ "%modifiers% %type% %funcname%()\n" . - \ "{\n" . - \ " return %varname%;\n" . - \ "}" -endif - -if exists("b:javagetset_getterArrayTemplate") - let s:javagetset_getterArrayTemplate = b:javagetset_getterArrayTemplate -else - let s:javagetset_getterArrayTemplate = - \ "\n" . - \ "/**\n" . - \ " * Get %varname%.\n" . - \ " *\n" . - \ " * @return %varname% as %type%[].\n" . - \ " */\n" . - \ "%modifiers% %type%[] %funcname%()\n" . - \ "{\n" . - \ " return %varname%;\n" . - \ "}\n" . - \ "\n" . - \ "/**\n" . - \ " * Get %varname% element at specified index.\n" . - \ " *\n" . - \ " * @param index the index.\n" . - \ " * @return %varname% at index as %type%.\n" . - \ " */\n" . - \ "%modifiers% %type% %funcname%(int index)\n" . - \ "{\n" . - \ " return %varname%[index];\n" . - \ "}" -endif - -" Setter Templates (non-array and array-based) -if exists("b:javagetset_setterTemplate") - let s:javagetset_setterTemplate = b:javagetset_setterTemplate -else - let s:javagetset_setterTemplate = - \ "\n" . - \ "/**\n" . - \ " * Set %varname%.\n" . - \ " *\n" . - \ " * @param %varname% the value to set.\n" . - \ " */\n" . - \ "%modifiers% void %funcname%(%type% %varname%)\n" . - \ "{\n" . - \ " this.%varname% = %varname%;\n" . - \ "}" -endif - -if exists("b:javagetset_setterArrayTemplate") - let s:javagetset_setterArrayTemplate = b:javagetset_setterArrayTemplate -else - let s:javagetset_setterArrayTemplate = - \ "\n" . - \ "/**\n" . - \ " * Set %varname%.\n" . - \ " *\n" . - \ " * @param %varname% the value to set.\n" . - \ " */\n" . - \ "%modifiers% void %funcname%(%type%[] %varname%)\n" . - \ "{\n" . - \ " this.%varname% = %varname%;\n" . - \ "}\n" . - \ "\n" . - \ "/**\n" . - \ " * Set %varname% at the specified index.\n" . - \ " *\n" . - \ " * @param %varname% the value to set.\n" . - \ " * @param index the index.\n" . - \ " */\n" . - \ "%modifiers% void %funcname%(%type% %varname%, int index)\n" . - \ "{\n" . - \ " this.%varname%[index] = %varname%;\n" . - \ "}" -endif - -" Position where methods are inserted. The possible values are: -" 0 - end of class -" 1 = above block / line -" 2 = below block / line -if exists("b:javagetset_insertPosition") - let s:javagetset_insertPosition = b:javagetset_insertPosition -else - let s:javagetset_insertPosition = 0 -endif - -" Script local variables that are used like globals. -" -" If set to 1, the user has requested that getters be inserted -let s:getter = 0 - -" If set to 1, the user has requested that setters be inserted -let s:setter = 0 - -" If set to 1, the property was a static property (i.e. static methods) -let s:static = 0 - -" If set to 1, the property was declared final (i.e. doesn't need a setter) -let s:final = 0 - -" If set to 1, use the array based templates -let s:isarray = 0 - -" The current indentation level of the property (i.e. used for the methods) -let s:indent = '' - -" The list of property modifiers -let s:modifiers = '' - -" The type of the property -let s:vartype = '' - -" If the property is an array, the []'s will be stored here -let s:vararray = '' - -" The name of the property -let s:varname = '' - -" The function name of the property (capitalized varname) -let s:funcname = '' - -" The first line of the block selected -let s:firstline = 0 - -" The last line of the block selected -let s:lastline = 0 - -" Regular expressions used to match property statements -let s:javaname = '[a-zA-Z_$][a-zA-Z0-9_$]*' -let s:brackets = '\(\s*\(\[\s*\]\)\)\=' -let s:modifier = '\(private\|protected\|public\|volatile\|static\|final\)' -let s:variable = '\(\s*\)\(\(' . s:modifier . '\s\+\)*\)\(' . s:javaname . '\)' . s:brackets . '\s\+\(' . s:javaname . '\)\s*\(;\|=[^;]\+;\)' - -" The main entry point. This function saves the current position of the -" cursor without the use of a mark (see note below) Then the selected -" region is processed for properties. -" -" FIXME: I wanted to avoid clobbering any marks in use by the user, so I -" manually try to save the current position and restore it. The only drag -" is that the position isn't restored correctly if the user opts to insert -" the methods ABOVE the current position. Using a mark would solve this -" problem as they are automatically adjusted. Perhaps I just haven't -" found it yet, but I wish that VIM would let a scripter save a mark and -" then restore it later. Why? In this case, I'd be able to use a mark -" safely without clobbering any user marks already set. First, I'd save -" the contents of the mark, then set the mark, do my stuff, jump back to -" the mark, and finally restore the mark to what the user may have had -" previously set. Seems weird to me that you can't save/restore marks. -" -if !exists("*s:InsertGetterSetter") - function s:InsertGetterSetter(flag) range - let restorepos = line(".") . "normal!" . virtcol(".") . "|" - let s:firstline = a:firstline - let s:lastline = a:lastline - - if s:DetermineAction(a:flag) - call s:ProcessRegion(s:GetRangeAsString(a:firstline, a:lastline)) - endif - - execute restorepos - - " Not sure why I need this but if I don't have it, the drawing on the - " screen is messed up from my insert. Perhaps I'm doing something - " wrong, but it seems to me that I probably shouldn't be calling - " redraw. - redraw! - - endfunction -endif - -" Set the appropriate script variables (s:getter and s:setter) to -" appropriate values based on the flag that was selected. The current -" valid values for flag are: 'g' for getter, 's' for setter, 'b' for both -" getter/setter, and 'a' for ask/prompt user. -if !exists("*s:DetermineAction") - function s:DetermineAction(flag) - - if a:flag == 'g' - let s:getter = 1 - let s:setter = 0 - - elseif a:flag == 's' - let s:getter = 0 - let s:setter = 1 - - elseif a:flag == 'b' - let s:getter = 1 - let s:setter = 1 - - elseif a:flag == 'a' - return s:DetermineAction(s:AskUser()) - - else - return 0 - endif - - return 1 - endfunction -endif - -" Ask the user what they want to insert, getter, setter, or both. Return -" an appropriate flag for use with s:DetermineAction, or return 0 if the -" user cancelled out. -if !exists("*s:AskUser") - function s:AskUser() - let choice = - \ confirm("What do you want to insert?", - \ "&Getter\n&Setter\n&Both", 3) - - if choice == 0 - return 0 - - elseif choice == 1 - return 'g' - - elseif choice == 2 - return 's' - - elseif choice == 3 - return 'b' - - else - return 0 - - endif - endfunction -endif - -" Gets a range specified by a first and last line and returns it as a -" single string that will eventually be parsed using regular expresssions. -" For example, if the following lines were selected: -" -" // Age -" private int age; -" -" // Name -" private static String name; -" -" Then, the following string would be returned: -" -" // Age private int age; // Name priavte static String name; -" -if !exists("*s:GetRangeAsString") - function s:GetRangeAsString(first, last) - let line = a:first - let string = s:TrimRight(getline(line)) - - while line < a:last - let line = line + 1 - let string = string . s:TrimRight(getline(line)) - endwhile - - return string - endfunction -endif - -" Trim whitespace from right of string. -if !exists("*s:TrimRight") - function s:TrimRight(text) - return substitute(a:text, '\(\.\{-}\)\s*$', '\1', '') - endfunction -endif - -" Process the specified region indicated by the user. The region is -" simply a concatenated string of the lines that were selected by the -" user. This string is searched for properties (that match the s:variable -" regexp). Each property is then processed. For example, if the region -" was: -" -" // Age private int age; // Name priavte static String name; -" -" Then, the following strings would be processed one at a time: -" -" private int age; -" private static String name; -" -if !exists("*s:ProcessRegion") - function s:ProcessRegion(region) - let startPosition = match(a:region, s:variable, 0) - let endPosition = matchend(a:region, s:variable, 0) - - while startPosition != -1 - let result = strpart(a:region, startPosition, endPosition - startPosition) - - "call s:DebugParsing(result) - call s:ProcessVariable(result) - - let startPosition = match(a:region, s:variable, endPosition) - let endPosition = matchend(a:region, s:variable, endPosition) - endwhile - - endfunction -endif - -" Process a single property. The first thing this function does is -" break apart the property into the following components: indentation, -" modifiers ,type, array, and name. In addition, the following other -" components are then derived from the previous: funcname, static, -" final, and isarray. For example, if the specified variable was: -" -" private static String name; -" -" Then the following would be set for the global variables: -" -" indent = ' ' -" modifiers = 'private static' -" vartype = 'String' -" vararray = '' -" varname = 'name' -" funcname = 'Name' -" static = 1 -" final = 0 -" isarray = 0 -" -if !exists("*s:ProcessVariable") - function s:ProcessVariable(variable) - let s:static = 0 - let s:isarray = 0 - let s:final = 0 - let s:indent = substitute(a:variable, s:variable, '\1', '') - let s:modifiers = substitute(a:variable, s:variable, '\2', '') - let s:vartype = substitute(a:variable, s:variable, '\5', '') - let s:vararray = substitute(a:variable, s:variable, '\7', '') - let s:varname = substitute(a:variable, s:variable, '\8', '') - let s:funcname = toupper(s:varname[0]) . strpart(s:varname, 1) - - " If any getter or setter already exists, then just return as there - " is nothing to be done. The assumption is that the user already - " made his choice. - if s:AlreadyExists() - return - endif - - if s:modifiers =~ 'static' - let s:static = 1 - endif - - if s:modifiers =~ 'final' - let s:final = 1 - endif - - if s:vararray =~ '[' - let s:isarray = 1 - endif - - if s:getter - call s:InsertGetter() - endif - - if s:setter && !s:final - call s:InsertSetter() - endif - - endfunction -endif - -" Checks to see if any getter/setter exists. -if !exists("*s:AlreadyExists") - function s:AlreadyExists() - return search('\(get\|set\)' . s:funcname . '\_s*([^)]*)\_s*{', 'w') - endfunction -endif - -" Inserts a getter by selecting the appropriate template to use and then -" populating the template parameters with actual values. -if !exists("*s:InsertGetter") - function s:InsertGetter() - - if s:isarray - let method = s:javagetset_getterArrayTemplate - else - let method = s:javagetset_getterTemplate - endif - - let mods = "public" - if s:static - let mods = mods . " static" - endif - - let method = substitute(method, '%type%', s:vartype, 'g') - let method = substitute(method, '%varname%', s:varname, 'g') - let method = substitute(method, '%funcname%', 'get' . s:funcname, 'g') - let method = substitute(method, '%modifiers%', mods, 'g') - - call s:InsertMethodBody(method) - - endfunction -endif - -" Inserts a setter by selecting the appropriate template to use and then -" populating the template parameters with actual values. -if !exists("*s:InsertSetter") - function s:InsertSetter() - - if s:isarray - let method = s:javagetset_setterArrayTemplate - else - let method = s:javagetset_setterTemplate - endif - - let mods = "public" - if s:static - let mods = mods . " static" - endif - - let method = substitute(method, '%type%', s:vartype, 'g') - let method = substitute(method, '%varname%', s:varname, 'g') - let method = substitute(method, '%funcname%', 'set' . s:funcname, 'g') - let method = substitute(method, '%modifiers%', mods, 'g') - - call s:InsertMethodBody(method) - - endfunction -endif - -" Inserts a body of text using the indentation level. The passed string -" may have embedded newlines so we need to search for each "line" and then -" call append separately. I couldn't figure out how to get a string with -" newlines to be added in one single call to append (it kept inserting the -" newlines as ^@ characters which is not what I wanted). -if !exists("*s:InsertMethodBody") - function s:InsertMethodBody(text) - call s:MoveToInsertPosition() - - let pos = line('.') - let string = a:text - - while 1 - let len = stridx(string, "\n") - - if len == -1 - call append(pos, s:indent . string) - break - endif - - call append(pos, s:indent . strpart(string, 0, len)) - - let pos = pos + 1 - let string = strpart(string, len + 1) - - endwhile - endfunction -endif - -" Move the cursor to the insertion point. This insertion point can be -" defined by the user by setting the b:javagetset_insertPosition variable. -if !exists("*s:MoveToInsertPosition") - function s:MoveToInsertPosition() - - " 1 indicates above the current block / line - if s:javagetset_insertPosition == 1 - execute "normal! " . (s:firstline - 1) . "G0" - - " 2 indicates below the current block / line - elseif s:javagetset_insertPosition == 2 - execute "normal! " . s:lastline . "G0" - - " 0 indicates end of class (and is default) - else - execute "normal! ?{\<CR>w99[{%k" | nohls - - endif - - endfunction -endif - -" Debug code to decode the properties. -if !exists("*s:DebugParsing") - function s:DebugParsing(variable) - echo 'DEBUG: ====================================================' - echo 'DEBUG:' a:variable - echo 'DEBUG: ----------------------------------------------------' - echo 'DEBUG: indent:' substitute(a:variable, s:variable, '\1', '') - echo 'DEBUG: modifiers:' substitute(a:variable, s:variable, '\2', '') - echo 'DEBUG: type:' substitute(a:variable, s:variable, '\5', '') - echo 'DEBUG: array:' substitute(a:variable, s:variable, '\7', '') - echo 'DEBUG: name:' substitute(a:variable, s:variable, '\8', '') - echo '' - endfunction -endif - -" Add mappings, unless the user didn't want this. I'm still not clear why -" I need to have two (2) noremap statements for each, but that is what the -" example shows in the documentation so I've stuck with that convention. -" Ideally, I'd prefer to use only one noremap line and map the <Plug> -" directly to the ':call <SID>function()<CR>'. -if !exists("no_plugin_maps") && !exists("no_java_maps") - if !hasmapto('<Plug>JavagetsetInsertGetterSetter') - map <unique> <buffer> <LocalLeader>p <Plug>JavagetsetInsertGetterSetter - endif - noremap <buffer> <script> - \ <Plug>JavagetsetInsertGetterSetter - \ <SID>InsertGetterSetter - noremap <buffer> - \ <SID>InsertGetterSetter - \ :call <SID>InsertGetterSetter('a')<CR> - - if !hasmapto('<Plug>JavagetsetInsertGetterOnly') - map <unique> <buffer> <LocalLeader>g <Plug>JavagetsetInsertGetterOnly - endif - noremap <buffer> <script> - \ <Plug>JavagetsetInsertGetterOnly - \ <SID>InsertGetterOnly - noremap <buffer> - \ <SID>InsertGetterOnly - \ :call <SID>InsertGetterSetter('g')<CR> - - if !hasmapto('<Plug>JavagetsetInsertSetterOnly') - map <unique> <buffer> <LocalLeader>s <Plug>JavagetsetInsertSetterOnly - endif - noremap <buffer> <script> - \ <Plug>JavagetsetInsertSetterOnly - \ <SID>InsertSetterOnly - noremap <buffer> - \ <SID>InsertSetterOnly - \ :call <SID>InsertGetterSetter('s')<CR> - - if !hasmapto('<Plug>JavagetsetInsertBothGetterSetter') - map <unique> <buffer> <LocalLeader>b <Plug>JavagetsetInsertBothGetterSetter - endif - noremap <buffer> <script> - \ <Plug>JavagetsetInsertBothGetterSetter - \ <SID>InsertBothGetterSetter - noremap <buffer> - \ <SID>InsertBothGetterSetter - \ :call <SID>InsertGetterSetter('b')<CR> -endif - -" Add commands, unless already set. -if !exists(":InsertGetterSetter") - command -range -buffer - \ InsertGetterSetter - \ :<line1>,<line2>call s:InsertGetterSetter('a') -endif -if !exists(":InsertGetterOnly") - command -range -buffer - \ InsertGetterOnly - \ :<line1>,<line2>call s:InsertGetterSetter('g') -endif -if !exists(":InsertSetterOnly") - command -range -buffer - \ InsertSetterOnly - \ :<line1>,<line2>call s:InsertGetterSetter('s') -endif -if !exists(":InsertBothGetterSetter") - command -range -buffer - \ InsertBothGetterSetter - \ :<line1>,<line2>call s:InsertGetterSetter('b') -endif - -let &cpo = s:save_cpo - -"if !exists("*s:InsertText") -" function s:InsertText(text) -" let pos = line('.') -" let beg = 0 -" let len = stridx(a:text, "\n") -" -" while beg < strlen(a:text) -" if len == -1 -" call append(pos, s:indent . strpart(a:text, beg)) -" break -" endif -" -" call append(pos, s:indent . strpart(a:text, beg, len)) -" let pos = pos + 1 -" let beg = beg + len + 1 -" let len = stridx(strpart(a:text, beg), "\n") -" endwhile -" -" " Not too sure why I have to call redraw, but weirdo things appear -" " on the screen if I don't. -" redraw! -" -" endfunction -"endif -" -"if !exists("*s:InsertAccessor") -" function s:InsertAccessor() -" echo "InsertAccessor was called" -" endfunction -"endif -" -"if !exists("*s:SqueezeWhitespace") -" function s:SqueezeWhitespace(string) -" return substitute(a:string, '\_s\+', ' ', 'g') -" endfunction -"endif diff --git a/.vim/indent/haskell.vim b/.vim/indent/haskell.vim deleted file mode 100644 index dc7c649..0000000 --- a/.vim/indent/haskell.vim +++ /dev/null @@ -1,85 +0,0 @@ -" Vim indent file -" Language: Haskell -" Author: motemen <motemen@gmail.com> -" Version: 0.1 -" Last Change: 2007-07-25 -" -" Modify g:haskell_indent_if and g:haskell_indent_case to -" change indentation for `if'(default 3) and `case'(default 5). -" Example (in .vimrc): -" > let g:haskell_indent_if = 2 - -if exists('b:did_indent') - finish -endif - -let b:did_indent = 1 - -if !exists('g:haskell_indent_if') - " if bool - " >>>then ... - " >>>else ... - let g:haskell_indent_if = 3 -endif - -if !exists('g:haskell_indent_case') - " case xs of - " >>>>>[] -> ... - " >>>>>(y:ys) -> ... - let g:haskell_indent_case = 5 -endif - -setlocal indentexpr=GetHaskellIndent() -setlocal indentkeys=!^F,o,O - -function! GetHaskellIndent() - let line = substitute(getline(getpos('.')[1] - 1), '\t', repeat(' ', &tabstop), 'g') - - if line =~ '[!#$%&*+./<=>?@\\^|~-]$\|\<do$' - return match(line, '\s*where \zs\|\S') + &shiftwidth - endif - - if line =~ '{$' - return match(line, '\s*where \zs\|\S') + &shiftwidth - endif - - if line =~ '^\(instance\|class\).*\&.*where$' - return &shiftwidth - endif - - if line =~ ')$' - let pos = getpos('.') - normal k$ - let paren_end = getpos('.') - normal % - let paren_begin = getpos('.') - call setpos('.', pos) - if paren_begin[1] != paren_end[1] - return paren_begin[2] - 1 - endif - endif - - if line !~ '\<else\>' - let s = match(line, '\<if\>.*\&.*\zs\<then\>') - if s > 0 - return s - endif - - let s = match(line, '\<if\>') - if s > 0 - return s + g:haskell_indent_if - endif - endif - - let s = match(line, '\<do\s\+\zs[^{]\|\<where\s\+\zs\w\|\<let\s\+\zs\S\|^\s*\zs|\s') - if s > 0 - return s - endif - - let s = match(line, '\<case\>') - if s > 0 - return s + g:haskell_indent_case - endif - - return match(line, '\S') -endfunction diff --git a/.vim/plugin/NERD_tree.vim b/.vim/plugin/NERD_tree.vim deleted file mode 100644 index cb2d422..0000000 --- a/.vim/plugin/NERD_tree.vim +++ /dev/null @@ -1,3917 +0,0 @@ -" vim global plugin that provides a nice tree explorer -" Last Change: 26 august 2007 -" Maintainer: Martin Grenfell <martin_grenfell at msn dot com> -let s:NERD_tree_version = '2.6.2' - -"A help file is installed when the script is run for the first time. -"Go :help NERD_tree.txt to see it. - -" SECTION: Script init stuff {{{1 -"============================================================ -if exists("loaded_nerd_tree") - finish -endif -if v:version < 700 - echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!" - finish -endif -let loaded_nerd_tree = 1 -"Function: s:InitVariable() function {{{2 -"This function is used to initialise a given variable to a given value. The -"variable is only initialised if it does not exist prior -" -"Args: -"var: the name of the var to be initialised -"value: the value to initialise var to -" -"Returns: -"1 if the var is set, 0 otherwise -function! s:InitVariable(var, value) - if !exists(a:var) - exec 'let ' . a:var . ' = ' . "'" . a:value . "'" - return 1 - endif - return 0 -endfunction - -"SECTION: Init variable calls and other random constants {{{2 -call s:InitVariable("g:NERDChristmasTree", 1) -call s:InitVariable("g:NERDTreeAutoCenter", 1) -call s:InitVariable("g:NERDTreeAutoCenterThreshold", 3) -call s:InitVariable("g:NERDTreeCaseSensitiveSort", 0) -call s:InitVariable("g:NERDTreeChDirMode", 1) -if !exists("g:NERDTreeIgnore") - let g:NERDTreeIgnore = ['\~$'] -endif -call s:InitVariable("g:NERDTreeHighlightCursorline", 1) -call s:InitVariable("g:NERDTreeMouseMode", 1) -call s:InitVariable("g:NERDTreeNotificationThreshold", 100) -call s:InitVariable("g:NERDTreeShowHidden", 0) -call s:InitVariable("g:NERDTreeShowFiles", 1) -call s:InitVariable("g:NERDTreeSortDirs", 1) - -if !exists("g:NERDTreeSortOrder") - let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -else - "if there isnt a * in the sort sequence then add one - if count(g:NERDTreeSortOrder, '*') < 1 - call add(g:NERDTreeSortOrder, '*') - endif -endif - -"we need to use this number many times for sorting... so we calculate it only -"once here -let g:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') - -call s:InitVariable("g:NERDTreeSplitVertical", 1) -call s:InitVariable("g:NERDTreeWinPos", 1) -call s:InitVariable("g:NERDTreeWinSize", 31) - -let s:running_windows = has("win16") || has("win32") || has("win64") - -"init the shell command that will be used to remove dir trees -" -"Note: the space after the command is important -if s:running_windows - call s:InitVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') -else - call s:InitVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') -endif - - -"SECTION: Init variable calls for key mappings {{{2 -call s:InitVariable("g:NERDTreeMapActivateNode", "o") -call s:InitVariable("g:NERDTreeMapChangeRoot", "C") -call s:InitVariable("g:NERDTreeMapChdir", "cd") -call s:InitVariable("g:NERDTreeMapCloseChildren", "X") -call s:InitVariable("g:NERDTreeMapCloseDir", "x") -call s:InitVariable("g:NERDTreeMapExecute", "!") -call s:InitVariable("g:NERDTreeMapFilesystemMenu", "m") -call s:InitVariable("g:NERDTreeMapHelp", "?") -call s:InitVariable("g:NERDTreeMapJumpFirstChild", "K") -call s:InitVariable("g:NERDTreeMapJumpLastChild", "J") -call s:InitVariable("g:NERDTreeMapJumpNextSibling", "<C-j>") -call s:InitVariable("g:NERDTreeMapJumpParent", "p") -call s:InitVariable("g:NERDTreeMapJumpPrevSibling", "<C-k>") -call s:InitVariable("g:NERDTreeMapJumpRoot", "P") -call s:InitVariable("g:NERDTreeMapOpenExpl", "e") -call s:InitVariable("g:NERDTreeMapOpenInTab", "t") -call s:InitVariable("g:NERDTreeMapOpenInTabSilent", "T") -call s:InitVariable("g:NERDTreeMapOpenRecursively", "O") -call s:InitVariable("g:NERDTreeMapOpenSplit", "<tab>") -call s:InitVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode) -call s:InitVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit) -call s:InitVariable("g:NERDTreeMapQuit", "q") -call s:InitVariable("g:NERDTreeMapRefresh", "r") -call s:InitVariable("g:NERDTreeMapRefreshRoot", "R") -call s:InitVariable("g:NERDTreeMapToggleFiles", "F") -call s:InitVariable("g:NERDTreeMapToggleFilters", "f") -call s:InitVariable("g:NERDTreeMapToggleHidden", "H") -call s:InitVariable("g:NERDTreeMapUpdir", "u") -call s:InitVariable("g:NERDTreeMapUpdirKeepOpen", "U") - -"SECTION: Script level variable declaration{{{2 -let s:escape_chars = " `|\"~'#" -let s:NERDTreeWinName = '_NERD_tree_' - -"init all the nerd tree markup -let s:tree_vert = '|' -let s:tree_vert_last = '`' -let s:tree_wid = 2 -let s:tree_wid_str = ' ' -let s:tree_wid_strM1 = ' ' -let s:tree_dir_open = '~' -let s:tree_dir_closed = '+' -let s:tree_file = '-' -let s:tree_markup_reg = '[ \-+~`|]' -let s:tree_markup_reg_neg = '[^ \-+~`|]' -let s:tree_up_dir_line = '.. (up a dir)' -let s:tree_RO_str = ' [RO]' -let s:tree_RO_str_reg = ' \[RO\]' - -let s:os_slash = '/' -if s:running_windows - let s:os_slash = '\' -endif - - -" SECTION: Commands {{{1 -"============================================================ -"init the command that users start the nerd tree with -command! -n=? -complete=dir NERDTree :call s:InitNerdTree('<args>') -command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>') -" SECTION: Auto commands {{{1 -"============================================================ -"Save the cursor position whenever we close the nerd tree -exec "autocmd BufWinLeave *". s:NERDTreeWinName ."* :call <SID>SaveScreenState()" - -"SECTION: Classes {{{1 -"============================================================ -"CLASS: oTreeFileNode {{{2 -"This class is the parent of the oTreeDirNode class and constitures the -"'Component' part of the composite design pattern between the treenode -"classes. -"============================================================ -let s:oTreeFileNode = {} -"FUNCTION: oTreeFileNode.CompareNodes {{{3 -"This is supposed to be a class level method but i cant figure out how to -"get func refs to work from a dict.. -" -"A class level method that compares two nodes -" -"Args: -"n1, n2: the 2 nodes to compare -function! s:CompareNodes(n1, n2) - return a:n1.path.CompareTo(a:n2.path) -endfunction - -"FUNCTION: oTreeFileNode.Delete {{{3 -"Removes this node from the tree and calls the Delete method for its path obj -function! s:oTreeFileNode.Delete() dict - call self.path.Delete() - call self.parent.RemoveChild(self) -endfunction - -"FUNCTION: oTreeFileNode.Equals(treenode) {{{3 -" -"Compares this treenode to the input treenode and returns 1 if they are the -"same node. -" -"Use this method instead of == because sometimes when the treenodes contain -"many children, vim seg faults when doing == -" -"Args: -"treenode: the other treenode to compare to -function! s:oTreeFileNode.Equals(treenode) dict - return self.path.Str(1) == a:treenode.path.Str(1) -endfunction - -"FUNCTION: oTreeFileNode.FindNode(path) {{{3 -"Returns self if this node.path.Equals the given path. -"Returns {} if not equal. -" -"Args: -"path: the path object to compare against -function! s:oTreeFileNode.FindNode(path) dict - if a:path.Equals(self.path) - return self - endif - return {} -endfunction -"FUNCTION: oTreeFileNode.FindOpenDirSiblingWithChildren(direction) {{{3 -" -"Finds the next sibling for this node in the indicated direction. This sibling -"must be a directory and may/may not have children as specified. -" -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -"Return: -"a treenode object or {} if no appropriate sibling could be found -function! s:oTreeFileNode.FindOpenDirSiblingWithChildren(direction) dict - "if we have no parent then we can have no siblings - if self.parent != {} - let nextSibling = self.FindSibling(a:direction) - - while nextSibling != {} - if nextSibling.path.isDirectory && nextSibling.HasVisibleChildren() && nextSibling.isOpen - return nextSibling - endif - let nextSibling = nextSibling.FindSibling(a:direction) - endwhile - endif - - return {} -endfunction -"FUNCTION: oTreeFileNode.FindSibling(direction) {{{3 -" -"Finds the next sibling for this node in the indicated direction -" -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -"Return: -"a treenode object or {} if no sibling could be found -function! s:oTreeFileNode.FindSibling(direction) dict - "if we have no parent then we can have no siblings - if self.parent != {} - - "get the index of this node in its parents children - let siblingIndx = self.parent.GetChildIndex(self.path) - - if siblingIndx != -1 - "move a long to the next potential sibling node - let siblingIndx = a:direction == 1 ? siblingIndx+1 : siblingIndx-1 - - "keep moving along to the next sibling till we find one that is valid - let numSiblings = self.parent.GetChildCount() - while siblingIndx >= 0 && siblingIndx < numSiblings - - "if the next node is not an ignored node (i.e. wont show up in the - "view) then return it - if self.parent.children[siblingIndx].path.Ignore() == 0 - return self.parent.children[siblingIndx] - endif - - "go to next node - let siblingIndx = a:direction == 1 ? siblingIndx+1 : siblingIndx-1 - endwhile - endif - endif - - return {} -endfunction - -"FUNCTION: oTreeFileNode.IsVisible() {{{3 -"returns 1 if this node should be visible according to the tree filters and -"hidden file filters (and their on/off status) -function! s:oTreeFileNode.IsVisible() dict - return !self.path.Ignore() -endfunction - - -"FUNCTION: oTreeFileNode.IsRoot() {{{3 -"returns 1 if this node is t:NERDTreeRoot -function! s:oTreeFileNode.IsRoot() dict - if !s:TreeExistsForTab() - throw "NERDTree.TreeFileNode.IsRoot exception: No tree exists for the current tab" - endif - return self.Equals(t:NERDTreeRoot) -endfunction - -"FUNCTION: oTreeFileNode.New(path) {{{3 -"Returns a new TreeNode object with the given path and parent -" -"Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -function! s:oTreeFileNode.New(path) dict - if a:path.isDirectory - return s:oTreeDirNode.New(a:path) - else - let newTreeNode = {} - let newTreeNode = copy(self) - let newTreeNode.path = a:path - let newTreeNode.parent = {} - return newTreeNode - endif -endfunction - -"FUNCTION: oTreeFileNode.Rename {{{3 -"Calls the rename method for this nodes path obj -function! s:oTreeFileNode.Rename(newName) dict - call self.path.Rename(a:newName) - call self.parent.RemoveChild(self) - - let parentPath = self.path.GetPathTrunk() - let newParent = t:NERDTreeRoot.FindNode(parentPath) - - if newParent != {} - call newParent.CreateChild(self.path, 1) - endif -endfunction - -"FUNCTION: oTreeFileNode.StrDisplay() {{{3 -" -"Returns a string that specifies how the node should be represented as a -"string -" -"Return: -"a string that can be used in the view to represent this node -function! s:oTreeFileNode.StrDisplay() dict - return self.path.StrDisplay() -endfunction - -"CLASS: oTreeDirNode {{{2 -"This class is a child of the oTreeFileNode class and constitutes the -"'Composite' part of the composite design pattern between the treenode -"classes. -"============================================================ -let s:oTreeDirNode = copy(s:oTreeFileNode) -"FUNCTION: oTreeDirNode.AddChild(treenode, inOrder) {{{3 -"Adds the given treenode to the list of children for this node -" -"Args: -"-treenode: the node to add -"-inOrder: 1 if the new node should be inserted in sorted order -function! s:oTreeDirNode.AddChild(treenode, inOrder) dict - call add(self.children, a:treenode) - let a:treenode.parent = self - - if a:inOrder - call self.SortChildren() - endif -endfunction - -"FUNCTION: oTreeDirNode.Close {{{3 -"Closes this directory -function! s:oTreeDirNode.Close() dict - let self.isOpen = 0 -endfunction - -"FUNCTION: oTreeDirNode.CloseChildren {{{3 -"Closes all the child dir nodes of this node -function! s:oTreeDirNode.CloseChildren() dict - for i in self.children - if i.path.isDirectory - call i.Close() - call i.CloseChildren() - endif - endfor -endfunction - -"FUNCTION: oTreeDirNode.CreateChild(path, inOrder) {{{3 -"Instantiates a new child node for this node with the given path. The new -"nodes parent is set to this node. -" -"Args: -"path: a Path object that this node will represent/contain -"inOrder: 1 if the new node should be inserted in sorted order -" -"Returns: -"the newly created node -function! s:oTreeDirNode.CreateChild(path, inOrder) dict - let newTreeNode = s:oTreeFileNode.New(a:path) - call self.AddChild(newTreeNode, a:inOrder) - return newTreeNode -endfunction - -"FUNCTION: oTreeDirNode.FindNode(path) {{{3 -"Will find one of the children (recursively) that has the given path -" -"Args: -"path: a path object -unlet s:oTreeDirNode.FindNode -function! s:oTreeDirNode.FindNode(path) dict - if a:path.Equals(self.path) - return self - endif - if stridx(a:path.Str(1), self.path.Str(1), 0) == -1 - return {} - endif - - if self.path.isDirectory - for i in self.children - let retVal = i.FindNode(a:path) - if retVal != {} - return retVal - endif - endfor - endif - return {} -endfunction - -"FUNCTION: oTreeDirNode.GetChildDirs() {{{3 -"Returns the number of children this node has -function! s:oTreeDirNode.GetChildCount() dict - return len(self.children) -endfunction - -"FUNCTION: oTreeDirNode.GetChildDirs() {{{3 -"Returns an array of all children of this node that are directories -" -"Return: -"an array of directory treenodes -function! s:oTreeDirNode.GetChildDirs() dict - let toReturn = [] - for i in self.children - if i.path.isDirectory - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: oTreeDirNode.GetChildFiles() {{{3 -"Returns an array of all children of this node that are files -" -"Return: -"an array of file treenodes -function! s:oTreeDirNode.GetChildFiles() dict - let toReturn = [] - for i in self.children - if i.path.isDirectory == 0 - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: oTreeDirNode.GetChild(path) {{{3 -"Returns child node of this node that has the given path or {} if no such node -"exists. -" -"This function doesnt not recurse into child dir nodes -" -"Args: -"path: a path object -function! s:oTreeDirNode.GetChild(path) dict - if stridx(a:path.Str(1), self.path.Str(1), 0) == -1 - return {} - endif - - let index = self.GetChildIndex(a:path) - if index == -1 - return {} - else - return self.children[index] - endif - -endfunction - -"FUNCTION: oTreeDirNode.GetChildByIndex(indx, visible) {{{3 -"returns the child at the given index -"Args: -"indx: the index to get the child from -"visible: 1 if only the visible children array should be used, 0 if all the -"children should be searched. -function! s:oTreeDirNode.GetChildByIndex(indx, visible) dict - let array_to_search = a:visible? self.GetVisibleChildren() : self.children - if a:indx > len(array_to_search) - throw "NERDTree.TreeDirNode.InvalidArguments exception. Index is out of bounds." - endif - return array_to_search[a:indx] -endfunction - -"FUNCTION: oTreeDirNode.GetChildIndex(path) {{{3 -"Returns the index of the child node of this node that has the given path or -"-1 if no such node exists. -" -"This function doesnt not recurse into child dir nodes -" -"Args: -"path: a path object -function! s:oTreeDirNode.GetChildIndex(path) dict - if stridx(a:path.Str(1), self.path.Str(1), 0) == -1 - return -1 - endif - - "do a binary search for the child - let a = 0 - let z = self.GetChildCount() - while a < z - let mid = (a+z)/2 - let diff = a:path.CompareTo(self.children[mid].path) - - if diff == -1 - let z = mid - elseif diff == 1 - let a = mid+1 - else - return mid - endif - endwhile - return -1 -endfunction - -"FUNCTION: oTreeDirNode.GetVisibleChildCount() {{{3 -"Returns the number of visible children this node has -function! s:oTreeDirNode.GetVisibleChildCount() dict - return len(self.GetVisibleChildren()) -endfunction - -"FUNCTION: oTreeDirNode.GetVisibleChildren() {{{3 -"Returns a list of children to display for this node, in the correct order -" -"Return: -"an array of treenodes -function! s:oTreeDirNode.GetVisibleChildren() dict - let toReturn = [] - for i in self.children - if i.path.Ignore() == 0 - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: oTreeDirNode.HasVisibleChildren {{{3 -"returns 1 if this node has any childre, 0 otherwise.. -function! s:oTreeDirNode.HasVisibleChildren() - return self.GetChildCount() != 0 -endfunction - -"FUNCTION: oTreeDirNode.InitChildren {{{3 -"Removes all childen from this node and re-reads them -" -"Args: -"silent: 1 if the function should not echo any "please wait" messages for -"large directories -" -"Return: the number of child nodes read -function! s:oTreeDirNode.InitChildren(silent) dict - "remove all the current child nodes - let self.children = [] - - "get an array of all the files in the nodes dir - let filesStr = globpath(self.path.GetDir(0), '*') . "\n" . globpath(self.path.GetDir(0), '.*') - let files = split(filesStr, "\n") - - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call s:Echo("Please wait, caching a large dir ...") - endif - - let invalidFilesFound = 0 - for i in files - - "filter out the .. and . directories - if i !~ '\.\.$' && i !~ '\.$' - - "put the next file in a new node and attach it - try - let path = s:oPath.New(i) - call self.CreateChild(path, 0) - catch /^NERDTree.Path.InvalidArguments/ - let invalidFilesFound = 1 - endtry - endif - endfor - - call self.SortChildren() - - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call s:Echo("Please wait, caching a large dir ...") - call s:Echo("Please wait, caching a large dir ... DONE (". self.GetChildCount() ." nodes cached).") - endif - - if invalidFilesFound - call s:EchoWarning("some files could not be loaded into the NERD tree") - endif - return self.GetChildCount() -endfunction -"FUNCTION: oTreeDirNode.New(path) {{{3 -"Returns a new TreeNode object with the given path and parent -" -"Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -unlet s:oTreeDirNode.New -function! s:oTreeDirNode.New(path) dict - if a:path.isDirectory != 1 - throw "NERDTree.TreeDirNode.InvalidArguments exception. A TreeDirNode object must be instantiated with a directory Path object." - endif - - let newTreeNode = copy(self) - let newTreeNode.path = a:path - - let newTreeNode.isOpen = 0 - let newTreeNode.children = [] - - let newTreeNode.parent = {} - - return newTreeNode -endfunction -"FUNCTION: oTreeDirNode.Open {{{3 -"Reads in all this nodes children -" -"Return: the number of child nodes read -function! s:oTreeDirNode.Open() dict - let self.isOpen = 1 - if self.children == [] - return self.InitChildren(0) - else - return 0 - endif -endfunction - -"FUNCTION: oTreeDirNode.OpenRecursively {{{3 -"Opens this treenode and all of its children whose paths arent 'ignored' -"because of the file filters. -" -"This method is actually a wrapper for the OpenRecursively2 method which does -"the work. -function! s:oTreeDirNode.OpenRecursively() dict - call self.OpenRecursively2(1) -endfunction - -"FUNCTION: oTreeDirNode.OpenRecursively2 {{{3 -"Dont call this method from outside this object. -" -"Opens this all children of this treenode recursively if either: -" *they arent filtered by file filters -" *a:forceOpen is 1 -" -"Args: -"forceOpen: 1 if this node should be opened regardless of file filters -function! s:oTreeDirNode.OpenRecursively2(forceOpen) dict - if self.path.Ignore() == 0 || a:forceOpen - let self.isOpen = 1 - if self.children == [] - call self.InitChildren(1) - endif - - for i in self.children - if i.path.isDirectory == 1 - call i.OpenRecursively2(0) - endif - endfor - endif -endfunction - -"FUNCTION: oTreeDirNode.Refresh {{{3 -function! s:oTreeDirNode.Refresh() dict - let newChildNodes = [] - let invalidFilesFound = 0 - - "go thru all the files/dirs under this node - let filesStr = globpath(self.path.GetDir(0), '*') . "\n" . globpath(self.path.GetDir(0), '.*') - let files = split(filesStr, "\n") - for i in files - if i !~ '\.\.$' && i !~ '\.$' - - try - "create a new path and see if it exists in this nodes children - let path = s:oPath.New(i) - let newNode = self.GetChild(path) - if newNode != {} - - "if the existing node is a dir can be refreshed then - "refresh it - if newNode.path.isDirectory && (!empty(newNode.children) || newNode.isOpen == 1) - call newNode.Refresh() - - "if we have a filenode then refresh the path - elseif newNode.path.isDirectory == 0 - call newNode.path.Refresh() - endif - - call add(newChildNodes, newNode) - - "the node doesnt exist so create it - else - let newNode = s:oTreeFileNode.New(path) - let newNode.parent = self - call add(newChildNodes, newNode) - endif - - - catch /^NERDTree.InvalidArguments/ - let invalidFilesFound = 1 - endtry - endif - endfor - - "swap this nodes children out for the children we just read/refreshed - let self.children = newChildNodes - call self.SortChildren() - - if invalidFilesFound - call s:EchoWarning("some files could not be loaded into the NERD tree") - endif -endfunction - -"FUNCTION: oTreeDirNode.RemoveChild {{{3 -" -"Removes the given treenode from this nodes set of children -" -"Args: -"treenode: the node to remove -" -"Throws a NERDTree.TreeDirNode exception if the given treenode is not found -function! s:oTreeDirNode.RemoveChild(treenode) dict - for i in range(0, self.GetChildCount()-1) - if self.children[i].Equals(a:treenode) - call remove(self.children, i) - return - endif - endfor - - throw "NERDTree.TreeDirNode exception: child node was not found" -endfunction - -"FUNCTION: oTreeDirNode.SortChildren {{{3 -" -"Sorts the children of this node according to alphabetical order and the -"directory priority. -" -function! s:oTreeDirNode.SortChildren() dict - let CompareFunc = function("s:CompareNodes") - call sort(self.children, CompareFunc) -endfunction - -"FUNCTION: oTreeDirNode.ToggleOpen {{{3 -"Opens this directory if it is closed and vice versa -function! s:oTreeDirNode.ToggleOpen() dict - if self.isOpen == 1 - call self.Close() - else - call self.Open() - endif -endfunction - -"FUNCTION: oTreeDirNode.TransplantChild(newNode) {{{3 -"Replaces the child of this with the given node (where the child node's full -"path matches a:newNode's fullpath). The search for the matching node is -"non-recursive -" -"Arg: -"newNode: the node to graft into the tree -function! s:oTreeDirNode.TransplantChild(newNode) dict - for i in range(0, self.GetChildCount()-1) - if self.children[i].Equals(a:newNode) - let self.children[i] = a:newNode - let a:newNode.parent = self - break - endif - endfor -endfunction -"============================================================ -"CLASS: oPath {{{2 -"============================================================ -let s:oPath = {} -"FUNCTION: oPath.ChangeToDir() {{{3 -function! s:oPath.ChangeToDir() dict - let dir = self.Str(1) - if self.isDirectory == 0 - let dir = self.GetPathTrunk().Str(1) - endif - - try - execute "cd " . dir - call s:Echo("CWD is now: " . getcwd()) - catch - throw "NERDTree.Path.Change exception: cannot change to " . dir - endtry -endfunction - -"FUNCTION: oPath.ChopTrailingSlash(str) {{{3 -function! s:oPath.ChopTrailingSlash(str) dict - if a:str =~ '\/$' - return substitute(a:str, "\/$", "", "") - else - return substitute(a:str, "\\$", "", "") - endif -endfunction - -"FUNCTION: oPath.CompareTo() {{{3 -" -"Compares this oPath to the given path and returns 0 if they are equal, -1 if -"this oPath is "less than" the given path, or 1 if it is "greater". -" -"Args: -"path: the path object to compare this to -" -"Return: -"1, -1 or 0 -function! s:oPath.CompareTo(path) dict - let thisPath = self.GetLastPathComponent(1) - let thatPath = a:path.GetLastPathComponent(1) - - "if the paths are the same then clearly we return 0 - if thisPath == thatPath - return 0 - endif - - let thisSS = self.GetSortOrderIndex() - let thatSS = a:path.GetSortOrderIndex() - - "compare the sort sequences, if they are different then the return - "value is easy - if thisSS < thatSS - return -1 - elseif thisSS > thatSS - return 1 - else - "if the sort sequences are the same then compare the paths - "alphabetically - let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath - if pathCompare - return -1 - else - return 1 - endif - endif -endfunction - -"FUNCTION: oPath.Create() {{{3 -" -"Factory method. -" -"Creates a path object with the given path. The path is also created on the -"filesystem. If the path already exists, a NERDTree.Path.Exists exception is -"thrown. If any other errors occur, a NERDTree.Path exception is thrown. -" -"Args: -"fullpath: the full filesystem path to the file/dir to create -function! s:oPath.Create(fullpath) dict - "bail if the a:fullpath already exists - if isdirectory(a:fullpath) || filereadable(a:fullpath) - throw "NERDTree.Path.Exists Exception: Directory Exists: '" . a:fullpath . "'" - endif - - "get the unix version of the input path - let fullpath = a:fullpath - if s:running_windows - let fullpath = s:oPath.WinToUnixPath(fullpath) - endif - - try - - "if it ends with a slash, assume its a dir create it - if fullpath =~ '\/$' - "whack the trailing slash off the end if it exists - let fullpath = substitute(fullpath, '\/$', '', '') - - call mkdir(fullpath, 'p') - - "assume its a file and create - else - call writefile([], fullpath) - endif - catch /.*/ - throw "NERDTree.Path Exception: Could not create path: '" . a:fullpath . "'" - endtry - - return s:oPath.New(fullpath) -endfunction - -"FUNCTION: oPath.Delete() {{{3 -" -"Deletes the file represented by this path. -"Deletion of directories is not supported -" -"Throws NERDTree.Path.Deletion exceptions -function! s:oPath.Delete() dict - if self.isDirectory - - let cmd = "" - if s:running_windows - "if we are runnnig windows then put quotes around the pathstring - let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(1) - else - let cmd = g:NERDTreeRemoveDirCmd . self.StrForOS(0) - endif - let success = system(cmd) - - if v:shell_error != 0 - throw "NERDTree.Path.Deletion Exception: Could not delete directory: '" . self.StrForOS(0) . "'" - endif - else - let success = delete(self.Str(0)) - if success != 0 - throw "NERDTree.Path.Deletion Exception: Could not delete file: '" . self.Str(0) . "'" - endif - endif -endfunction - -"FUNCTION: oPath.GetDir() {{{3 -" -"Gets the directory part of this path. If this path IS a directory then the -"whole thing is returned -" -"Args: -"trailingSlash: 1 if a trailing slash is to be stuck on the end of the -"returned dir -" -"Return: -"string -function! s:oPath.GetDir(trailingSlash) dict - let toReturn = '' - if self.isDirectory - let toReturn = '/'. join(self.pathSegments, '/') - else - let toReturn = '/'. join(self.pathSegments[0:-2], '/') - endif - - if a:trailingSlash && toReturn !~ '\/$' - let toReturn = toReturn . '/' - endif - - return toReturn -endfunction - -"FUNCTION: oPath.GetFile() {{{3 -" -"Returns the file component of this path. -" -"Throws NERDTree.IllegalOperation exception if the node is a directory node -function! s:oPath.GetFile() dict - if self.isDirectory == 0 - return self.GetLastPathComponent(0) - else - throw "NERDTree.Path.IllegalOperation Exception: cannot get file component of a directory path" - endif -endfunction - -"FUNCTION: oPath.GetLastPathComponent(dirSlash) {{{3 -" -"Gets the last part of this path. -" -"Args: -"dirSlash: if 1 then a trailing slash will be added to the returned value for -"directory nodes. -function! s:oPath.GetLastPathComponent(dirSlash) dict - if empty(self.pathSegments) - return '' - endif - let toReturn = self.pathSegments[-1] - if a:dirSlash && self.isDirectory - let toReturn = toReturn . '/' - endif - return toReturn -endfunction - -"FUNCTION: oPath.GetPathTrunk() {{{3 -"Gets the path without the last segment on the end. -function! s:oPath.GetPathTrunk() dict - return s:oPath.New('/' . join(self.pathSegments[0:-2], '/')) -endfunction - -"FUNCTION: oPath.GetSortOrderIndex() {{{3 -"returns the index of the pattern in g:NERDTreeSortOrder that this path matches -function! s:oPath.GetSortOrderIndex() dict - let i = 0 - while i < len(g:NERDTreeSortOrder) - if self.GetLastPathComponent(1) =~ g:NERDTreeSortOrder[i] - return i - endif - let i = i + 1 - endwhile - return g:NERDTreeSortStarIndex -endfunction - -"FUNCTION: oPath.Ignore() {{{3 -"returns true if this path should be ignored -function! s:oPath.Ignore() dict - let lastPathComponent = self.GetLastPathComponent(0) - - "filter out the user specified paths to ignore - if t:NERDTreeIgnoreEnabled - for i in g:NERDTreeIgnore - if lastPathComponent =~ i - return 1 - endif - endfor - endif - - "dont show hidden files unless instructed to - if g:NERDTreeShowHidden == 0 && lastPathComponent =~ '^\.' - return 1 - endif - - if g:NERDTreeShowFiles == 0 && self.isDirectory == 0 - return 1 - endif - - return 0 -endfunction - -"FUNCTION: oPath.Equals() {{{3 -" -"Determines whether 2 path objecs are "equal". -"They are equal if the paths they represent are the same -" -"Args: -"path: the other path obj to compare this with -function! s:oPath.Equals(path) dict - let this = self.ChopTrailingSlash(self.Str(1)) - let that = self.ChopTrailingSlash(a:path.Str(1)) - return this == that -endfunction - -"FUNCTION: oPath.New() {{{3 -" -"The Constructor for the Path object -"Throws NERDTree.Path.InvalidArguments exception. -function! s:oPath.New(fullpath) dict - let newPath = copy(self) - - call newPath.ReadInfoFromDisk(a:fullpath) - - return newPath -endfunction - -"FUNCTION: oPath.NewMinimal() {{{3 -function! s:oPath.NewMinimal(fullpath) dict - let newPath = copy(self) - - let fullpath = a:fullpath - - if s:running_windows - let fullpath = s:oPath.WinToUnixPath(fullpath) - endif - - let newPath.pathSegments = split(fullpath, '/') - - let newPath.isDirectory = isdirectory(fullpath) - - return newPath -endfunction - -"FUNCTION: oPath.ReadInfoFromDisk(fullpath) {{{3 -" -" -"Throws NERDTree.Path.InvalidArguments exception. -function! s:oPath.ReadInfoFromDisk(fullpath) dict - let fullpath = a:fullpath - - if s:running_windows - let fullpath = s:oPath.WinToUnixPath(fullpath) - endif - - let self.pathSegments = split(fullpath, '/') - - let self.isReadOnly = 0 - if isdirectory(fullpath) - let self.isDirectory = 1 - elseif filereadable(fullpath) - let self.isDirectory = 0 - let self.isReadOnly = filewritable(fullpath) == 0 - else - throw "NERDTree.Path.InvalidArguments Exception: Invalid path = " . fullpath - endif - - "grab the last part of the path (minus the trailing slash) - let lastPathComponent = self.GetLastPathComponent(0) - - "get the path to the new node with the parent dir fully resolved - let hardPath = resolve(self.StrTrunk()) . '/' . lastPathComponent - - "if the last part of the path is a symlink then flag it as such - let self.isSymLink = (resolve(hardPath) != hardPath) - if self.isSymLink - let self.symLinkDest = resolve(fullpath) - - "if the link is a dir then slap a / on the end of its dest - if isdirectory(self.symLinkDest) - - "we always wanna treat MS windows shortcuts as files for - "simplicity - if hardPath !~ '\.lnk$' - - let self.symLinkDest = self.symLinkDest . '/' - endif - endif - endif -endfunction - -"FUNCTION: oPath.Refresh() {{{3 -function! s:oPath.Refresh() dict - call self.ReadInfoFromDisk(self.Str(0)) -endfunction - -"FUNCTION: oPath.Rename() {{{3 -" -"Renames this node on the filesystem -function! s:oPath.Rename(newPath) dict - if a:newPath == '' - throw "NERDTree.Path.InvalidArguments exception. Invalid newPath for renaming = ". a:newPath - endif - - let success = rename(self.Str(0), a:newPath) - if success != 0 - throw "NERDTree.Path.Rename Exception: Could not rename: '" . self.Str(0) . "'" . 'to:' . a:newPath - endif - let self.pathSegments = split(a:newPath, '/') -endfunction - -"FUNCTION: oPath.Str(esc) {{{3 -" -"Gets the actual string path that this obj represents. -" -"Args: -"esc: if 1 then all the tricky chars in the returned string will be escaped -function! s:oPath.Str(esc) dict - let toReturn = '/' . join(self.pathSegments, '/') - if self.isDirectory && toReturn != '/' - let toReturn = toReturn . '/' - endif - - if a:esc - let toReturn = escape(toReturn, s:escape_chars) - endif - return toReturn -endfunction - -"FUNCTION: oPath.StrAbs() {{{3 -" -"Returns a string representing this path with all the symlinks resolved -" -"Return: -"string -function! s:oPath.StrAbs() dict - return resolve(self.Str(1)) -endfunction - -"FUNCTION: oPath.StrDisplay() {{{3 -" -"Returns a string that specifies how the path should be represented as a -"string -" -"Return: -"a string that can be used in the view to represent this path -function! s:oPath.StrDisplay() dict - let toReturn = self.GetLastPathComponent(1) - - if self.isSymLink - let toReturn .= ' -> ' . self.symLinkDest - endif - - if self.isReadOnly - let toReturn .= s:tree_RO_str - endif - - return toReturn -endfunction - -"FUNCTION: oPath.StrForEditCmd() {{{3 -" -"Return: the string for this path that is suitable to be used with the :edit -"command -function! s:oPath.StrForEditCmd() dict - if s:running_windows - return self.StrForOS(0) - else - return self.Str(1) - endif - -endfunction -"FUNCTION: oPath.StrForOS(esc) {{{3 -" -"Gets the string path for this path object that is appropriate for the OS. -"EG, in windows c:\foo\bar -" in *nix /foo/bar -" -"Args: -"esc: if 1 then all the tricky chars in the returned string will be -" escaped. If we are running windows then the str is double quoted instead. -function! s:oPath.StrForOS(esc) dict - let lead = s:os_slash - - "if we are running windows then slap a drive letter on the front - if s:running_windows - let lead = strpart(getcwd(), 0, 2) . s:os_slash - endif - - let toReturn = lead . join(self.pathSegments, s:os_slash) - - if a:esc - if s:running_windows - let toReturn = '"' . toReturn . '"' - else - let toReturn = escape(toReturn, s:escape_chars) - endif - endif - return toReturn -endfunction - -"FUNCTION: oPath.StrTrunk() {{{3 -"Gets the path without the last segment on the end. -function! s:oPath.StrTrunk() dict - return '/' . join(self.pathSegments[0:-2], '/') -endfunction - -"FUNCTION: oPath.WinToUnixPath(pathstr){{{3 -"Takes in a windows path and returns the unix equiv -" -"A class level method -" -"Args: -"pathstr: the windows path to convert -function! s:oPath.WinToUnixPath(pathstr) dict - let toReturn = a:pathstr - - "remove the x:\ of the front - let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") - - "convert all \ chars to / - let toReturn = substitute(toReturn, '\', '/', "g") - - return toReturn -endfunction - -" SECTION: General Functions {{{1 -"============================================================ -"FUNCTION: s:Abs(num){{{2 -"returns the absolute value of the input -function! s:Abs(num) - if a:num > 0 - return a:num - else - return 0 - a:num - end -endfunction - -"FUNCTION: s:BufInWindows(bnum){{{2 -"[[STOLEN FROM VTREEEXPLORER.VIM]] -"Determine the number of windows open to this buffer number. -"Care of Yegappan Lakshman. Thanks! -" -"Args: -"bnum: the subject buffers buffer number -function! s:BufInWindows(bnum) - let cnt = 0 - let winnum = 1 - while 1 - let bufnum = winbufnr(winnum) - if bufnum < 0 - break - endif - if bufnum == a:bnum - let cnt = cnt + 1 - endif - let winnum = winnum + 1 - endwhile - - return cnt -endfunction " >>> - -"FUNCTION: s:InitNerdTree(dir) {{{2 -"Initialized the NERD tree, where the root will be initialized with the given -"directory -" -"Arg: -"dir: the dir to init the root with -function! s:InitNerdTree(dir) - let dir = a:dir == '' ? expand('%:p:h') : a:dir - let dir = resolve(dir) - - if !isdirectory(dir) - call s:EchoWarning("Error reading: " . dir) - return - endif - - "if instructed to, then change the vim CWD to the dir the NERDTree is - "inited in - if g:NERDTreeChDirMode != 0 - exec "cd " . dir - endif - - let t:treeShowHelp = 0 - let t:NERDTreeIgnoreEnabled = 1 - - if s:TreeExistsForTab() - if s:IsTreeOpen() - call s:CloseTree() - endif - unlet t:NERDTreeRoot - endif - - let path = s:oPath.New(dir) - let t:NERDTreeRoot = s:oTreeDirNode.New(path) - call t:NERDTreeRoot.Open() - - call s:CreateTreeWin() - - call s:RenderView() -endfunction - -" Function: s:InstallDocumentation(full_name, revision) {{{2 -" Install help documentation. -" Arguments: -" full_name: Full name of this vim plugin script, including path name. -" revision: Revision of the vim script. #version# mark in the document file -" will be replaced with this string with 'v' prefix. -" Return: -" 1 if new document installed, 0 otherwise. -" Note: Cleaned and generalized by guo-peng Wen. -" -" Note about authorship: this function was taken from the vimspell plugin -" which can be found at http://www.vim.org/scripts/script.php?script_id=465 -" -function! s:InstallDocumentation(full_name, revision) - " Name of the document path based on the system we use: - if has("vms") - " No chance that this script will work with - " VMS - to much pathname juggling here. - return 1 - elseif (has("unix")) - " On UNIX like system, using forward slash: - let l:slash_char = '/' - let l:mkdir_cmd = ':silent !mkdir -p ' - else - " On M$ system, use backslash. Also mkdir syntax is different. - " This should only work on W2K and up. - let l:slash_char = '\' - let l:mkdir_cmd = ':silent !mkdir ' - endif - - let l:doc_path = l:slash_char . 'doc' - let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc' - - " Figure out document path based on full name of this script: - let l:vim_plugin_path = fnamemodify(a:full_name, ':h') - let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - "Doc path: " . l:vim_doc_path - call s:Echo("Doc path: " . l:vim_doc_path) - execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' - if (!(filewritable(l:vim_doc_path) == 2)) - " Try a default configuration in user home: - let l:vim_doc_path = expand("~") . l:doc_home - if (!(filewritable(l:vim_doc_path) == 2)) - execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' - if (!(filewritable(l:vim_doc_path) == 2)) - " Put a warning: - call s:Echo("Unable to open documentation directory") - call s:Echo("type :help add-local-help for more information.") - call s:Echo(l:vim_doc_path) - return 0 - endif - endif - endif - endif - - " Exit if we have problem to access the document directory: - if (!isdirectory(l:vim_plugin_path) || !isdirectory(l:vim_doc_path) || filewritable(l:vim_doc_path) != 2) - return 0 - endif - - " Full name of script and documentation file: - let l:script_name = fnamemodify(a:full_name, ':t') - let l:doc_name = fnamemodify(a:full_name, ':t:r') . '.txt' - let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name - let l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name - - " Bail out if document file is still up to date: - if (filereadable(l:doc_file) && getftime(l:plugin_file) < getftime(l:doc_file)) - return 0 - endif - - " Prepare window position restoring command: - if (strlen(@%)) - let l:go_back = 'b ' . bufnr("%") - else - let l:go_back = 'enew!' - endif - - " Create a new buffer & read in the plugin file (me): - setl nomodeline - exe 'enew!' - exe 'r ' . l:plugin_file - - setl modeline - let l:buf = bufnr("%") - setl noswapfile modifiable - - norm zR - norm gg - - " Delete from first line to a line starts with - " === START_DOC - 1,/^=\{3,}\s\+START_DOC\C/ d - - " Delete from a line starts with - " === END_DOC - " to the end of the documents: - /^=\{3,}\s\+END_DOC\C/,$ d - - " Remove fold marks: - :%s/{{{[1-9]/ / - - " Add modeline for help doc: the modeline string is mangled intentionally - " to avoid it be recognized by VIM: - call append(line('$'), '') - call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:') - - " Replace revision: - "exe "normal :1s/#version#/ v" . a:revision . "/\<CR>" - exe "normal! :%s/#version#/ v" . a:revision . "/\<CR>" - - " Save the help document: - exe 'w! ' . l:doc_file - exe l:go_back - exe 'bw ' . l:buf - - " Build help tags: - exe 'helptags ' . l:vim_doc_path - - return 1 -endfunction - -" Function: s:TreeExistsForTab() {{{2 -" Returns 1 if a nerd tree root exists in the current tab -function! s:TreeExistsForTab() - return exists("t:NERDTreeRoot") -endfunction - -" SECTION: Public Functions {{{1 -"============================================================ -"Returns the node that the cursor is currently on. -" -"If the cursor is not in the NERDTree window, it is temporarily put there. -" -"If no NERD tree window exists for the current tab, a NERDTree.NoTreeForTab -"exception is thrown. -" -"If the cursor is not on a node then an empty dictionary {} is returned. -function! NERDTreeGetCurrentNode() - if !s:TreeExistsForTab() || !s:IsTreeOpen() - throw "NERDTree.NoTreeForTab exception: there is no NERD tree open for the current tab" - endif - - let winnr = winnr() - if winnr != s:GetTreeWinNum() - call s:PutCursorInTreeWin() - endif - - let treenode = s:GetSelectedNode() - - if winnr != winnr() - wincmd w - endif - - return treenode -endfunction - -"Returns the path object for the current node. -" -"Subject to the same conditions as NERDTreeGetCurrentNode -function! NERDTreeGetCurrentPath() - let node = NERDTreeGetCurrentNode() - if node != {} - return node.path - else - return {} - endif -endfunction - -" SECTION: View Functions {{{1 -"============================================================ -"FUNCTION: s:CenterView() {{{2 -"centers the nerd tree window around the cursor (provided the nerd tree -"options permit) -function! s:CenterView() - if g:NERDTreeAutoCenter - let current_line = winline() - let lines_to_top = current_line - let lines_to_bottom = winheight(s:GetTreeWinNum()) - current_line - if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold - normal! zz - endif - endif -endfunction - -"FUNCTION: s:CloseTree() {{{2 -"Closes the NERD tree window -function! s:CloseTree() - if !s:IsTreeOpen() - throw "NERDTree.view.CloseTree exception: no NERDTree is open" - endif - - if winnr("$") != 1 - execute s:GetTreeWinNum() . " wincmd w" - close - execute "wincmd p" - else - :q - endif -endfunction - -"FUNCTION: s:CreateTreeWin() {{{2 -"Inits the NERD tree window. ie. opens it, sizes it, sets all the local -"options etc -function! s:CreateTreeWin() - "create the nerd tree window - let splitLocation = g:NERDTreeWinPos ? "topleft " : "belowright " - let splitMode = g:NERDTreeSplitVertical ? "vertical " : "" - let splitSize = g:NERDTreeWinSize - let t:NERDTreeWinName = localtime() . s:NERDTreeWinName - let cmd = splitLocation . splitMode . splitSize . ' new ' . t:NERDTreeWinName - silent! execute cmd - - setl winfixwidth - - "throwaway buffer options - setlocal noswapfile - setlocal buftype=nofile - setlocal bufhidden=delete - setlocal nowrap - setlocal foldcolumn=0 - setlocal nobuflisted - setlocal nospell - iabc <buffer> - - if g:NERDTreeHighlightCursorline - setlocal cursorline - endif - - " syntax highlighting - if has("syntax") && exists("g:syntax_on") && !has("syntax_items") - call s:SetupSyntaxHighlighting() - endif - - " for line continuation - let cpo_save1 = &cpo - set cpo&vim - - call s:BindMappings() -endfunction - -"FUNCTION: s:DrawTree {{{2 -"Draws the given node recursively -" -"Args: -"curNode: the node that is being rendered with this call -"depth: the current depth in the tree for this call -"drawText: 1 if we should actually draw the line for this node (if 0 then the -"child nodes are rendered only) -"vertMap: a binary array that indicates whether a vertical bar should be draw -"for each depth in the tree -"isLastChild:true if this curNode is the last child of its parent -function! s:DrawTree(curNode, depth, drawText, vertMap, isLastChild) - if a:drawText == 1 - - let treeParts = '' - - "get all the leading spaces and vertical tree parts for this line - if a:depth > 1 - for j in a:vertMap[0:-2] - if j == 1 - let treeParts = treeParts . s:tree_vert . s:tree_wid_strM1 - else - let treeParts = treeParts . s:tree_wid_str - endif - endfor - endif - - "get the last vertical tree part for this line which will be different - "if this node is the last child of its parent - if a:isLastChild - let treeParts = treeParts . s:tree_vert_last - else - let treeParts = treeParts . s:tree_vert - endif - - - "smack the appropriate dir/file symbol on the line before the file/dir - "name itself - if a:curNode.path.isDirectory - if a:curNode.isOpen - let treeParts = treeParts . s:tree_dir_open - else - let treeParts = treeParts . s:tree_dir_closed - endif - else - let treeParts = treeParts . s:tree_file - endif - let line = treeParts . a:curNode.StrDisplay() - - call setline(line(".")+1, line) - call cursor(line(".")+1, col(".")) - endif - - "if the node is an open dir, draw its children - if a:curNode.path.isDirectory == 1 && a:curNode.isOpen == 1 - - let childNodesToDraw = a:curNode.GetVisibleChildren() - if len(childNodesToDraw) > 0 - - "draw all the nodes children except the last - let lastIndx = len(childNodesToDraw)-1 - if lastIndx > 0 - for i in childNodesToDraw[0:lastIndx-1] - call s:DrawTree(i, a:depth + 1, 1, add(copy(a:vertMap), 1), 0) - endfor - endif - - "draw the last child, indicating that it IS the last - call s:DrawTree(childNodesToDraw[lastIndx], a:depth + 1, 1, add(copy(a:vertMap), 0), 1) - endif - endif -endfunction - - -"FUNCTION: s:DumpHelp {{{2 -"prints out the quick help -function! s:DumpHelp() - let old_h = @h - if t:treeShowHelp == 1 - let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n" - let @h=@h."\" ============================\n" - let @h=@h."\" File node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode == 3 ? "single" : "double") ."-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" - let @h=@h."\" ". g:NERDTreeMapPreview .": preview \n" - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" - let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let @h=@h."\" ". g:NERDTreeMapExecute.": Execute file\n" - - let @h=@h."\" \n\" ----------------------------\n" - let @h=@h."\" Directory node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode == 1 ? "double" : "single") ."-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open/close node \n" - let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" - let @h=@h."\" current node recursively\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenExpl.": Open netrw for selected\n" - let @h=@h."\" node \n" - - let @h=@h."\" \n\" ----------------------------\n" - let @h=@h."\" Tree navigation mappings~\n" - let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" - - let @h=@h."\" \n\" ----------------------------\n" - let @h=@h."\" Filesystem mappings~\n" - let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" - let @h=@h."\" but leave old root open\n" - let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let @h=@h."\" ". g:NERDTreeMapFilesystemMenu .": Show filesystem menu\n" - let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" - let @h=@h."\" selected dir\n" - - let @h=@h."\" \n\" ----------------------------\n" - let @h=@h."\" Tree filtering mappings~\n" - let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (g:NERDTreeShowHidden ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (t:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (g:NERDTreeShowFiles ? "on" : "off") . ")\n" - - let @h=@h."\" \n\" ----------------------------\n" - let @h=@h."\" Other mappings~\n" - let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" - let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n" - else - let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" - endif - - silent! put h - - let @h = old_h -endfunction -"FUNCTION: s:Echo {{{2 -"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages -" -"Args: -"msg: the message to echo -function! s:Echo(msg) - redraw - echo "NERDTree: " . a:msg -endfunction -"FUNCTION: s:EchoWarning {{{2 -"Wrapper for s:Echo, sets the message type to warningmsg for this message -"Args: -"msg: the message to echo -function! s:EchoWarning(msg) - echohl warningmsg - call s:Echo(a:msg) - echohl normal -endfunction -"FUNCTION: s:EchoError {{{2 -"Wrapper for s:Echo, sets the message type to errormsg for this message -"Args: -"msg: the message to echo -function! s:EchoError(msg) - echohl errormsg - call s:Echo(a:msg) - echohl normal -endfunction -"FUNCTION: s:FindNodeLineNumber(treenode){{{2 -"Finds the line number for the given tree node -" -"Args: -"treenode: the node to find the line no. for -function! s:FindNodeLineNumber(treenode) - "if the node is the root then return the root line no. - if a:treenode.IsRoot() - return s:FindRootNodeLineNumber() - endif - - let totalLines = line("$") - - "the path components we have matched so far - let pathcomponents = [substitute(t:NERDTreeRoot.path.Str(0), '/ *$', '', '')] - "the index of the component we are searching for - let curPathComponent = 1 - - let fullpath = a:treenode.path.Str(0) - - - let lnum = s:FindRootNodeLineNumber() - while lnum > 0 - let lnum = lnum + 1 - "have we reached the bottom of the tree? - if lnum == totalLines+1 - return -1 - endif - - let curLine = getline(lnum) - - let indent = match(curLine,s:tree_markup_reg_neg) / s:tree_wid - if indent == curPathComponent - let curLine = s:StripMarkupFromLine(curLine, 1) - - let curPath = join(pathcomponents, '/') . '/' . curLine - if stridx(fullpath, curPath, 0) == 0 - if fullpath == curPath || strpart(fullpath, len(curPath)-1,1) == '/' - let curLine = substitute(curLine, '/ *$', '', '') - call add(pathcomponents, curLine) - let curPathComponent = curPathComponent + 1 - - if fullpath == curPath - return lnum - endif - endif - endif - endif - endwhile - return -1 -endfunction - -"FUNCTION: s:FindRootNodeLineNumber(path){{{2 -"Finds the line number of the root node -function! s:FindRootNodeLineNumber() - let rootLine = 1 - while getline(rootLine) !~ '^/' - let rootLine = rootLine + 1 - endwhile - return rootLine -endfunction - -"FUNCTION: s:GetPath(ln) {{{2 -"Gets the full path to the node that is rendered on the given line number -" -"Args: -"ln: the line number to get the path for -" -"Return: -"A path if a node was selected, {} if nothing is selected. -"If the 'up a dir' line was selected then the path to the parent of the -"current root is returned -function! s:GetPath(ln) - let line = getline(a:ln) - - "check to see if we have the root node - if line =~ '^\/' - return t:NERDTreeRoot.path - endif - - " in case called from outside the tree - if line !~ '^ *[|`]' || line =~ '^$' - return {} - endif - - if line == s:tree_up_dir_line - return s:oPath.New( t:NERDTreeRoot.path.GetDir(0) ) - endif - - "get the indent level for the file (i.e. how deep in the tree it is) - "let indent = match(line,'[^-| `]') / s:tree_wid - let indent = match(line, s:tree_markup_reg_neg) / s:tree_wid - - - "remove the tree parts and the leading space - let curFile = s:StripMarkupFromLine(line, 0) - - let wasdir = 0 - if curFile =~ '/$' - let wasdir = 1 - endif - let curFile = substitute (curFile,' -> .*',"","") " remove link to - if wasdir == 1 - let curFile = substitute (curFile, '/\?$', '/', "") - endif - - - let dir = "" - let lnum = a:ln - while lnum > 0 - let lnum = lnum - 1 - let curLine = getline(lnum) - - "have we reached the top of the tree? - if curLine =~ '^/' - let sd = substitute (curLine, '[ ]*$', "", "") - let dir = sd . dir - break - endif - if curLine =~ '/$' - let lpindent = match(curLine,s:tree_markup_reg_neg) / s:tree_wid - if lpindent < indent - let indent = indent - 1 - let sd = substitute (curLine, '^' . s:tree_markup_reg . '*',"","") - let sd = substitute (sd, ' -> .*', '',"") - - " remove leading escape - let sd = substitute (sd,'^\\', "", "") - - let dir = sd . dir - continue - endif - endif - endwhile - let curFile = dir . curFile - return s:oPath.NewMinimal(curFile) -endfunction - -"FUNCTION: s:GetSelectedDir() {{{2 -"Returns the current node if it is a dir node, or else returns the current -"nodes parent -function! s:GetSelectedDir() - let currentDir = s:GetSelectedNode() - if currentDir != {} && !currentDir.IsRoot() - if currentDir.path.isDirectory == 0 - let currentDir = currentDir.parent - endif - endif - return currentDir -endfunction -"FUNCTION: s:GetSelectedNode() {{{2 -"gets the treenode that the cursor is currently over -function! s:GetSelectedNode() - try - let path = s:GetPath(line(".")) - if path == {} - return {} - endif - return t:NERDTreeRoot.FindNode(path) - catch /^NERDTree/ - return {} - endtry -endfunction - -"FUNCTION: s:GetTreeBufNum() {{{2 -"gets the nerd tree buffer number for this tab -function! s:GetTreeBufNum() - if exists("t:NERDTreeWinName") - return bufnr(t:NERDTreeWinName) - else - return -1 - endif -endfunction -"FUNCTION: s:GetTreeWinNum() {{{2 -"gets the nerd tree window number for this tab -function! s:GetTreeWinNum() - if exists("t:NERDTreeWinName") - return bufwinnr(t:NERDTreeWinName) - else - return -1 - endif -endfunction - -"FUNCTION: s:IsTreeOpen() {{{2 -function! s:IsTreeOpen() - return s:GetTreeWinNum() != -1 -endfunction - -" FUNCTION: s:JumpToChild(direction) {{{2 -" Args: -" direction: 0 if going to first child, 1 if going to last -function! s:JumpToChild(direction) - let currentNode = s:GetSelectedNode() - if currentNode == {} || currentNode.IsRoot() - call s:Echo("cannot jump to " . (a:direction ? "last" : "first") . " child") - return - end - let dirNode = currentNode.parent - let childNodes = dirNode.GetVisibleChildren() - - let targetNode = childNodes[0] - if a:direction - let targetNode = childNodes[len(childNodes) - 1] - endif - - if targetNode.Equals(currentNode) - let siblingDir = currentNode.parent.FindOpenDirSiblingWithChildren(a:direction) - if siblingDir != {} - let indx = a:direction ? siblingDir.GetVisibleChildCount()-1 : 0 - let targetNode = siblingDir.GetChildByIndex(indx, 1) - endif - endif - - call s:PutCursorOnNode(targetNode, 1) - - call s:CenterView() -endfunction - - -"FUNCTION: s:OpenDirNodeSplit(treenode) {{{2 -"Open the file represented by the given node in a new window. -"No action is taken for file nodes -" -"ARGS: -"treenode: file node to open -function! s:OpenDirNodeSplit(treenode) - if a:treenode.path.isDirectory == 1 - call s:OpenNodeSplit(a:treenode) - endif -endfunction - -"FUNCTION: s:OpenFileNode(treenode) {{{2 -"Open the file represented by the given node in the current window, splitting -"the window if needed -" -"ARGS: -"treenode: file node to open -function! s:OpenFileNode(treenode) - call s:PutCursorInTreeWin() - - if s:ShouldSplitToOpen(winnr("#")) - call s:OpenFileNodeSplit(a:treenode) - else - try - wincmd p - exec ("edit " . a:treenode.path.StrForEditCmd()) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:PutCursorInTreeWin() - call s:Echo("Cannot open file, it is already open and modified") - catch /^Vim\%((\a\+)\)\=:/ - echo v:exception - endtry - endif -endfunction - -"FUNCTION: s:OpenFileNodeSplit(treenode) {{{2 -"Open the file represented by the given node in a new window. -"No action is taken for dir nodes -" -"ARGS: -"treenode: file node to open -function! s:OpenFileNodeSplit(treenode) - if a:treenode.path.isDirectory == 0 - try - call s:OpenNodeSplit(a:treenode) - catch /^NERDTree.view.FileOpen/ - call s:Echo("Cannot open file, it is already open and modified" ) - endtry - endif -endfunction - -"FUNCTION: s:OpenNodeSplit(treenode) {{{2 -"Open the file/dir represented by the given node in a new window -" -"ARGS: -"treenode: file node to open -function! s:OpenNodeSplit(treenode) - call s:PutCursorInTreeWin() - - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " Figure out how to do the split based on the user's preferences. - " We want to split to the (left,right,top,bottom) of the explorer - " window, but we want to extract the screen real-estate from the - " window next to the explorer if possible. - " - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - if g:NERDTreeSplitVertical == 1 - let there= g:NERDTreeWinPos ? "wincmd h" : "wincmd l" - let back= g:NERDTreeWinPos ? "wincmd l" : "wincmd h" - let right=g:NERDTreeWinPos ? 1 : 0 - let below=0 - else - let there= g:NERDTreeWinPos ? "wincmd k" : "wincmd j" - let back= g:NERDTreeWinPos ? "wincmd j" : "wincmd k" - let right=0 - let below=g:NERDTreeWinPos ? 1 : 0 - endif - - " Attempt to go to adjacent window - exec(back) - - let onlyOneWin = (winnr() == s:GetTreeWinNum()) - - " If no adjacent window, set splitright and splitbelow appropriately - if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below - endif - - " Create a variable to use if splitting vertically - let splitMode = "" - if (onlyOneWin && g:NERDTreeSplitVertical) || (!onlyOneWin && !g:NERDTreeSplitVertical) - let splitMode = "vertical" - endif - - " Open the new window - try - exec("silent " . splitMode." sp " . a:treenode.path.StrForEditCmd()) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:PutCursorInTreeWin() - throw "NERDTree.view.FileOpen exception: ". a:treenode.path.Str(0) ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - do nothing - endtry - - " resize the explorer window if it is larger than the requested size - exec(there) - - if g:NERDTreeWinSize =~ '[0-9]\+' && winheight("") > g:NERDTreeWinSize - exec("silent vertical resize ".g:NERDTreeWinSize) - endif - - wincmd p - - " Restore splitmode settings - let &splitbelow=savesplitbelow - let &splitright=savesplitright -endfunction - -"FUNCTION: s:PromptToDelBuffer(bufnum, msg){{{2 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is deleted -" -"Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! s:PromptToDelBuffer(bufnum, msg) - echo a:msg - if nr2char(getchar()) == 'y' - exec "silent bdelete! " . a:bufnum - endif -endfunction - -"FUNCTION: s:PutCursorOnNode(treenode, is_jump){{{2 -"Places the cursor on the line number representing the given node -" -"Args: -"treenode: the node to put the cursor on -"is_jump: 1 if this cursor movement should be counted as a jump by vim -function! s:PutCursorOnNode(treenode, is_jump) - let ln = s:FindNodeLineNumber(a:treenode) - if ln != -1 - if a:is_jump - mark ' - endif - call cursor(ln, col(".")) - endif -endfunction - -"FUNCTION: s:PutCursorInTreeWin(){{{2 -"Places the cursor in the nerd tree window -function! s:PutCursorInTreeWin() - if !s:IsTreeOpen() - throw "NERDTree.view.InvalidOperation Exception: No NERD tree window exists" - endif - - exec s:GetTreeWinNum() . "wincmd w" -endfunction - -"FUNCTION: s:RenderView {{{2 -"The entry function for rendering the tree. Renders the root then calls -"s:DrawTree to draw the children of the root -" -"Args: -function! s:RenderView() - execute s:GetTreeWinNum() . "wincmd w" - - setlocal modifiable - - "remember the top line of the buffer and the current line so we can - "restore the view exactly how it was - let curLine = line(".") - let curCol = col(".") - let topLine = line("w0") - - "delete all lines in the buffer (being careful not to clobber a register) - :silent 1,$delete _ - - call s:DumpHelp() - - "delete the blank line before the help and add one after it - call setline(line(".")+1, " ") - call cursor(line(".")+1, col(".")) - - "add the 'up a dir' line - call setline(line(".")+1, s:tree_up_dir_line) - call cursor(line(".")+1, col(".")) - - "draw the header line - call setline(line(".")+1, t:NERDTreeRoot.path.Str(0)) - call cursor(line(".")+1, col(".")) - - "draw the tree - call s:DrawTree(t:NERDTreeRoot, 0, 0, [], t:NERDTreeRoot.GetChildCount() == 1) - - "delete the blank line at the top of the buffer - :silent 1,1delete _ - - "restore the view - call cursor(topLine, 1) - normal! zt - call cursor(curLine, curCol) - - setlocal nomodifiable -endfunction - -"FUNCTION: s:RenderViewSavingPosition {{{2 -"Renders the tree and ensures the cursor stays on the current node or the -"current nodes parent if it is no longer available upon re-rendering -function! s:RenderViewSavingPosition() - let currentNode = s:GetSelectedNode() - - "go up the tree till we find a node that will be visible or till we run - "out of nodes - while currentNode != {} && !currentNode.IsVisible() && !currentNode.IsRoot() - let currentNode = currentNode.parent - endwhile - - call s:RenderView() - - if currentNode != {} - call s:PutCursorOnNode(currentNode, 0) - endif -endfunction -"FUNCTION: s:RestoreScreenState() {{{2 -" -"Sets the screen state back to what it was when s:SaveScreenState was last -"called. -" -"Assumes the cursor is in the NERDTree window -function! s:RestoreScreenState() - if !exists("t:NERDTreeOldTopLine") || !exists("t:NERDTreeOldPos") - return - endif - - call cursor(t:NERDTreeOldTopLine, 0) - normal! zt - call setpos(".", t:NERDTreeOldPos) -endfunction - -"FUNCTION: s:SaveScreenState() {{{2 -"Saves the current cursor position in the current buffer and the window -"scroll position -" -"Assumes the cursor is in the NERDTree window -function! s:SaveScreenState() - let t:NERDTreeOldPos = getpos(".") - let t:NERDTreeOldTopLine = line("w0") -endfunction - -"FUNCTION: s:SetupSyntaxHighlighting() {{{2 -function! s:SetupSyntaxHighlighting() - "treeFlags are syntax items that should be invisible, but give clues as to - "how things should be highlighted - syn match treeFlag #\~# - syn match treeFlag #\[RO\]# - - "highlighting for the .. (up dir) line at the top of the tree - execute "syn match treeUp #". s:tree_up_dir_line ."#" - - "highlighting for the ~/+ symbols for the directory nodes - syn match treeClosable #\~\<# - syn match treeClosable #\~\.# - syn match treeOpenable #+\<# - syn match treeOpenable #+\.#he=e-1 - - "highlighting for the tree structural parts - syn match treePart #|# - syn match treePart #`# - syn match treePartFile #[|`]-#hs=s+1 contains=treePart - - "quickhelp syntax elements - syn match treeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 - syn match treeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 - syn match treeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=treeFlag - syn match treeToggleOn #".*(on)#hs=e-2,he=e-1 contains=treeHelpKey - syn match treeToggleOff #".*(off)#hs=e-3,he=e-1 contains=treeHelpKey - syn match treeHelp #^" .*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn - - "highlighting for sym links - syn match treeLink #[^-| `].* -> # - - "highlighting for readonly files - syn match treeRO #[0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag - - "highlighing for directory nodes and file nodes - syn match treeDirSlash #/# - syn match treeDir #[^-| `].*/\([ {}]\{4\}\)*$# contains=treeLink,treeDirSlash,treeOpenable,treeClosable - syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile - syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile - syn match treeCWD #^/.*$# - - if g:NERDChristmasTree - hi def link treePart Special - hi def link treePartFile Type - hi def link treeFile Macro - hi def link treeDirSlash Identifier - hi def link treeClosable Type - else - hi def link treePart Normal - hi def link treePartFile Normal - hi def link treeFile Normal - hi def link treeClosable Title - endif - - hi def link treeHelp String - hi def link treeHelpKey Identifier - hi def link treeHelpTitle Macro - hi def link treeToggleOn Question - hi def link treeToggleOff WarningMsg - - hi def link treeDir Directory - hi def link treeUp Directory - hi def link treeCWD Statement - hi def link treeLink Title - hi def link treeOpenable Title - hi def link treeFlag ignore - hi def link treeRO WarningMsg - - hi def link NERDTreeCurrentNode Search -endfunction - -"FUNCTION: s:ShouldSplitToOpen() {{{2 -"Returns 1 if opening a file from the tree in the given window requires it to -"be split -" -"Args: -"winnumber: the number of the window in question -function! s:ShouldSplitToOpen(winnumber) - if &hidden - return 0 - endif - let oldwinnr = winnr() - - exec a:winnumber . "wincmd p" - let modified = &modified - exec oldwinnr . "wincmd p" - - return winnr("$") == 1 || (modified && s:BufInWindows(winbufnr(a:winnumber)) < 2) -endfunction - -"FUNCTION: s:StripMarkupFromLine(line){{{2 -"returns the given line with all the tree parts stripped off -" -"Args: -"line: the subject line -"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = -"any spaces before the actual text of the node) -function! s:StripMarkupFromLine(line, removeLeadingSpaces) - let line = a:line - "remove the tree parts and the leading space - let line = substitute (line,"^" . s:tree_markup_reg . "*","","") - - "strip off any read only flag - let line = substitute (line, s:tree_RO_str_reg, "","") - - let wasdir = 0 - if line =~ '/$' - let wasdir = 1 - endif - let line = substitute (line,' -> .*',"","") " remove link to - if wasdir == 1 - let line = substitute (line, '/\?$', '/', "") - endif - - if a:removeLeadingSpaces - let line = substitute (line, '^ *', '', '') - endif - - return line -endfunction - -"FUNCTION: s:Toggle(dir) {{{2 -"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -"closed it is restored or initialized (if it doesnt exist) -" -"Args: -"dir: the full path for the root node (is only used if the NERD tree is being -"initialized. -function! s:Toggle(dir) - if s:TreeExistsForTab() - if !s:IsTreeOpen() - call s:CreateTreeWin() - call s:RenderView() - - call s:RestoreScreenState() - else - call s:CloseTree() - endif - else - call s:InitNerdTree(a:dir) - endif -endfunction -"SECTION: Interface bindings {{{1 -"============================================================ -"FUNCTION: s:ActivateNode() {{{2 -"If the current node is a file, open it in the previous window (or a new one -"if the previous is modified). If it is a directory then it is opened. -function! s:ActivateNode() - if getline(".") == s:tree_up_dir_line - return s:UpDir(0) - endif - let treenode = s:GetSelectedNode() - if treenode == {} - call s:EchoWarning("cannot open selected entry") - return - endif - - if treenode.path.isDirectory - call treenode.ToggleOpen() - call s:RenderView() - call s:PutCursorOnNode(treenode, 0) - else - call s:OpenFileNode(treenode) - endif -endfunction - -"FUNCTION: s:BindMappings() {{{2 -function! s:BindMappings() - " set up mappings and commands for this buffer - nnoremap <silent> <buffer> <middlerelease> :call <SID>HandleMiddleMouse()<cr> - nnoremap <silent> <buffer> <leftrelease> <leftrelease>:call <SID>CheckForActivate()<cr> - nnoremap <silent> <buffer> <2-leftmouse> :call <SID>ActivateNode()<cr> - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapActivateNode . " :call <SID>ActivateNode()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenSplit ." :call <SID>OpenEntrySplit()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreview ." :call <SID>PreviewNode(0)<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreviewSplit ." :call <SID>PreviewNode(1)<cr>" - - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapExecute ." :call <SID>ExecuteNode()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenRecursively ." :call <SID>OpenNodeRecursively()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapUpdirKeepOpen ." :call <SID>UpDir(1)<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapUpdir ." :call <SID>UpDir(0)<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapChangeRoot ." :call <SID>ChRoot()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapChdir ." :call <SID>ChCwd()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapQuit ." :NERDTreeToggle<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapRefreshRoot ." :call <SID>RefreshRoot()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapRefresh ." :call <SID>RefreshCurrent()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapHelp ." :call <SID>DisplayHelp()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleHidden ." :call <SID>ToggleShowHidden()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleFilters ." :call <SID>ToggleIgnoreFilter()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleFiles ." :call <SID>ToggleShowFiles()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapCloseDir ." :call <SID>CloseCurrentDir()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapCloseChildren ." :call <SID>CloseChildren()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapFilesystemMenu ." :call <SID>ShowFileSystemMenu()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpParent ." :call <SID>JumpToParent()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpNextSibling ." :call <SID>JumpToSibling(1)<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpPrevSibling ." :call <SID>JumpToSibling(0)<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpFirstChild ." :call <SID>JumpToFirstChild()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpLastChild ." :call <SID>JumpToLastChild()<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpRoot ." :call <SID>JumpToRoot()<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>OpenNodeNewTab(0)<cr>" - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTabSilent ." :call <SID>OpenNodeNewTab(1)<cr>" - - exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>" - - -endfunction - -"FUNCTION: s:CheckForActivate() {{{2 -"Checks if the click should open the current node, if so then activate() is -"called (directories are automatically opened if the symbol beside them is -"clicked) -function! s:CheckForActivate() - let currentNode = s:GetSelectedNode() - if currentNode != {} - let startToCur = strpart(getline(line(".")), 0, col(".")) - let char = strpart(startToCur, strlen(startToCur)-1, 1) - - "if they clicked a dir, check if they clicked on the + or ~ sign - "beside it - if currentNode.path.isDirectory - let reg = '^' . s:tree_markup_reg .'*[' . s:tree_dir_open . s:tree_dir_closed . ']$' - if startToCur =~ reg - call s:ActivateNode() - return - endif - endif - - if (g:NERDTreeMouseMode == 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode == 3 - if char !~ s:tree_markup_reg && startToCur !~ '\/$' - call s:ActivateNode() - return - endif - endif - endif -endfunction - -" FUNCTION: s:ChCwd() {{{2 -function! s:ChCwd() - let treenode = s:GetSelectedNode() - if treenode == {} - call s:Echo("Select a node first") - return - endif - - try - call treenode.path.ChangeToDir() - catch /^NERDTree.Path.Change/ - call s:EchoWarning("could not change cwd") - endtry -endfunction - -" FUNCTION: s:ChRoot() {{{2 -" changes the current root to the selected one -function! s:ChRoot() - let treenode = s:GetSelectedNode() - if treenode == {} || treenode.path.isDirectory == 0 - call s:Echo("Select a directory node first") - return - endif - - if treenode.isOpen == 0 - call treenode.Open() - endif - - let t:NERDTreeRoot = treenode - - "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode == 2 - exec "cd " . treenode.path.StrForEditCmd() - endif - - - call s:RenderView() - call s:PutCursorOnNode(t:NERDTreeRoot, 0) -endfunction - -" FUNCTION: s:CloseChildren() {{{2 -" closes all childnodes of the current node -function! s:CloseChildren() - let currentNode = s:GetSelectedDir() - if currentNode == {} - call s:Echo("Select a node first") - return - endif - - call currentNode.CloseChildren() - call s:RenderView() - call s:PutCursorOnNode(currentNode, 0) -endfunction -" FUNCTION: s:CloseCurrentDir() {{{2 -" closes the parent dir of the current node -function! s:CloseCurrentDir() - let treenode = s:GetSelectedNode() - if treenode == {} - call s:Echo("Select a node first") - return - endif - - let parent = treenode.parent - if parent.IsRoot() - call s:Echo("cannot close tree root") - else - call treenode.parent.Close() - call s:RenderView() - call s:PutCursorOnNode(treenode.parent, 0) - endif -endfunction - -" FUNCTION: s:DeleteNode() {{{2 -" if the current node is a file, pops up a dialog giving the user the option -" to delete it -function! s:DeleteNode() - let currentNode = s:GetSelectedNode() - if currentNode == {} - call s:Echo("Put the cursor on a file node first") - return - endif - - let confirmed = 0 - - if currentNode.path.isDirectory - let choice =input("Delete the current node\n" . - \ "==========================================================\n" . - \ "STOP! To delete this entire directory, type 'yes'\n" . - \ "" . currentNode.path.StrForOS(0) . ": ") - let confirmed = choice == 'yes' - else - echo "Delete the current node\n" . - \ "==========================================================\n". - \ "Are you sure you wish to delete the node:\n" . - \ "" . currentNode.path.StrForOS(0) . " (yN):" - let choice = nr2char(getchar()) - let confirmed = choice == 'y' - endif - - - if confirmed - try - call currentNode.Delete() - call s:RenderView() - - "if the node is open in a buffer, ask the user if they want to - "close that buffer - let bufnum = bufnr(currentNode.path.Str(0)) - if buflisted(bufnum) - let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) == -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:PromptToDelBuffer(bufnum, prompt) - endif - - redraw - catch /^NERDTree/ - call s:EchoWarning("Could not remove node") - endtry - else - call s:Echo("delete aborted" ) - endif - -endfunction - -" FUNCTION: s:DisplayHelp() {{{2 -" toggles the help display -function! s:DisplayHelp() - let t:treeShowHelp = t:treeShowHelp ? 0 : 1 - call s:RenderView() - call s:CenterView() -endfunction - -" FUNCTION: s:ExecuteNode() {{{2 -function! s:ExecuteNode() - let treenode = s:GetSelectedNode() - if treenode == {} || treenode.path.isDirectory - call s:Echo("Select an executable file node first" ) - else - echo "NERDTree executor\n" . - \ "==========================================================\n". - \ "Complete the command to execute (add arguments etc): \n\n" - let cmd = treenode.path.StrForOS(1) - let cmd = input(':!', cmd . ' ') - - if cmd != '' - exec ':!' . cmd - else - call s:Echo("command aborted") - endif - endif -endfunction - -" FUNCTION: s:HandleMiddleMouse() {{{2 -function! s:HandleMiddleMouse() - let curNode = s:GetSelectedNode() - if curNode == {} - call s:Echo("Put the cursor on a node first" ) - return - endif - - if curNode.path.isDirectory - call s:OpenExplorer() - else - call s:OpenEntrySplit() - endif -endfunction - - -" FUNCTION: s:InsertNewNode() {{{2 -" Adds a new node to the filesystem and then into the tree -function! s:InsertNewNode() - let curDirNode = s:GetSelectedDir() - if curDirNode == {} - call s:Echo("Put the cursor on a node first" ) - return - endif - - let newNodeName = input("Add a childnode\n". - \ "==========================================================\n". - \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . - \ "", curDirNode.path.Str(0)) - - if newNodeName == '' - call s:Echo("Node Creation Aborted.") - return - endif - - try - let newPath = s:oPath.Create(newNodeName) - - let parentNode = t:NERDTreeRoot.FindNode(newPath.GetPathTrunk()) - - let newTreeNode = s:oTreeFileNode.New(newPath) - if parentNode.isOpen || !empty(parentNode.children) - call parentNode.AddChild(newTreeNode, 1) - call s:RenderView() - call s:PutCursorOnNode(newTreeNode, 1) - endif - catch /^NERDTree/ - call s:EchoWarning("Node Not Created.") - endtry -endfunction - -" FUNCTION: s:JumpToFirstChild() {{{2 -" wrapper for the jump to child method -function! s:JumpToFirstChild() - call s:JumpToChild(0) -endfunction - -" FUNCTION: s:JumpToLastChild() {{{2 -" wrapper for the jump to child method -function! s:JumpToLastChild() - call s:JumpToChild(1) -endfunction - -" FUNCTION: s:JumpToParent() {{{2 -" moves the cursor to the parent of the current node -function! s:JumpToParent() - let currentNode = s:GetSelectedNode() - if !empty(currentNode) - if !empty(currentNode.parent) - call s:PutCursorOnNode(currentNode.parent, 1) - call s:CenterView() - else - call s:Echo("cannot jump to parent") - endif - else - call s:Echo("put the cursor on a node first") - endif -endfunction - -" FUNCTION: s:JumpToRoot() {{{2 -" moves the cursor to the root node -function! s:JumpToRoot() - call s:PutCursorOnNode(t:NERDTreeRoot, 1) - call s:CenterView() -endfunction - -" FUNCTION: s:JumpToSibling() {{{2 -" moves the cursor to the sibling of the current node in the given direction -" -" Args: -" forward: 1 if the cursor should move to the next sibling, 0 if it should -" move back to the previous sibling -function! s:JumpToSibling(forward) - let currentNode = s:GetSelectedNode() - if !empty(currentNode) - - if !currentNode.path.isDirectory - - if a:forward - let sibling = currentNode.parent.FindSibling(1) - else - let sibling = currentNode.parent - endif - - else - let sibling = currentNode.FindSibling(a:forward) - endif - - if !empty(sibling) - call s:PutCursorOnNode(sibling, 1) - call s:CenterView() - endif - else - call s:Echo("put the cursor on a node first") - endif -endfunction - -" FUNCTION: s:OpenEntrySplit() {{{2 -" Opens the currently selected file from the explorer in a -" new window -function! s:OpenEntrySplit() - let treenode = s:GetSelectedNode() - if treenode != {} - call s:OpenFileNodeSplit(treenode) - else - call s:Echo("select a node first") - endif -endfunction - -" FUNCTION: s:OpenExplorer() {{{2 -function! s:OpenExplorer() - let treenode = s:GetSelectedDir() - if treenode != {} - let oldwin = winnr() - wincmd p - if oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2) - wincmd p - call s:OpenDirNodeSplit(treenode) - else - exec ("silent edit " . treenode.path.StrForEditCmd()) - endif - else - call s:Echo("select a node first") - endif -endfunction - -" FUNCTION: s:OpenNodeNewTab(stayCurrentTab) {{{2 -" Opens the currently selected file from the explorer in a -" new tab -" -" Args: -" stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim -" will go to the tab where the new file is opened -function! s:OpenNodeNewTab(stayCurrentTab) - let treenode = s:GetSelectedNode() - if treenode != {} - let curTabNr = tabpagenr() - exec "tabedit " . treenode.path.StrForEditCmd() - if a:stayCurrentTab - exec "tabnext " . curTabNr - endif - else - call s:Echo("select a node first") - endif -endfunction - - -" FUNCTION: s:OpenNodeRecursively() {{{2 -function! s:OpenNodeRecursively() - let treenode = s:GetSelectedNode() - if treenode == {} || treenode.path.isDirectory == 0 - call s:Echo("Select a directory node first" ) - else - call s:Echo("Recursively opening node. Please wait...") - call treenode.OpenRecursively() - call s:RenderView() - redraw - call s:Echo("Recursively opening node. Please wait... DONE") - endif - -endfunction - -"FUNCTION: s:PreviewNode() {{{2 -function! s:PreviewNode(openNewWin) - let treenode = s:GetSelectedNode() - if treenode == {} || treenode.path.isDirectory - call s:Echo("Select a file node first" ) - return - endif - - if a:openNewWin - call s:OpenEntrySplit() - else - call s:ActivateNode() - end - call s:PutCursorInTreeWin() -endfunction - -" FUNCTION: s:RefreshRoot() {{{2 -" Reloads the current root. All nodes below this will be lost and the root dir -" will be reloaded. -function! s:RefreshRoot() - call s:Echo("Refreshing the root node. This could take a while...") - call t:NERDTreeRoot.Refresh() - call s:RenderView() - redraw - call s:Echo("Refreshing the root node. This could take a while... DONE") -endfunction - -" FUNCTION: s:RefreshCurrent() {{{2 -" refreshes the root for the current node -function! s:RefreshCurrent() - let treenode = s:GetSelectedDir() - if treenode == {} - call s:Echo("Refresh failed. Select a node first") - return - endif - - call s:Echo("Refreshing node. This could take a while...") - call treenode.Refresh() - call s:RenderView() - redraw - call s:Echo("Refreshing node. This could take a while... DONE") -endfunction -" FUNCTION: s:RenameCurrent() {{{2 -" allows the user to rename the current node -function! s:RenameCurrent() - let curNode = s:GetSelectedNode() - if curNode == {} - call s:Echo("Put the cursor on a node first" ) - return - endif - - let newNodePath = input("Rename the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path for the node: \n" . - \ "", curNode.path.Str(0)) - - if newNodePath == '' - call s:Echo("Node Renaming Aborted.") - return - endif - - let newNodePath = substitute(newNodePath, '\/$', '', '') - - try - let bufnum = bufnr(curNode.path.Str(0)) - - call curNode.Rename(newNodePath) - call s:RenderView() - - "if the node is open in a buffer, ask the user if they want to - "close that buffer - if bufnum != -1 - let prompt = "|\n|Node renamed.\n|\n|The old file is open in buffer ". bufnum . (bufwinnr(bufnum) == -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:PromptToDelBuffer(bufnum, prompt) - endif - - call s:PutCursorOnNode(curNode, 1) - - redraw - catch /^NERDTree/ - call s:EchoWarning("Node Not Renamed.") - endtry -endfunction - -" FUNCTION: s:ShowFileSystemMenu() {{{2 -function! s:ShowFileSystemMenu() - let curNode = s:GetSelectedNode() - if curNode == {} - call s:Echo("Put the cursor on a node first" ) - return - endif - - - echo "NERDTree Filesystem Menu\n" . - \ "==========================================================\n". - \ "Select the desired operation: \n" . - \ " (1) - Add a childnode\n". - \ " (2) - Rename the current node\n". - \ " (3) - Delete the current node\n\n" - - let choice = nr2char(getchar()) - - if choice == 1 - call s:InsertNewNode() - elseif choice == 2 - call s:RenameCurrent() - elseif choice == 3 - call s:DeleteNode() - endif -endfunction - -" FUNCTION: s:ToggleIgnoreFilter() {{{2 -" toggles the use of the NERDTreeIgnore option -function! s:ToggleIgnoreFilter() - let t:NERDTreeIgnoreEnabled = !t:NERDTreeIgnoreEnabled - call s:RenderViewSavingPosition() - call s:CenterView() -endfunction - -" FUNCTION: s:ToggleShowFiles() {{{2 -" toggles the display of hidden files -function! s:ToggleShowFiles() - let g:NERDTreeShowFiles = !g:NERDTreeShowFiles - call s:RenderViewSavingPosition() - call s:CenterView() -endfunction - -" FUNCTION: s:ToggleShowHidden() {{{2 -" toggles the display of hidden files -function! s:ToggleShowHidden() - let g:NERDTreeShowHidden = !g:NERDTreeShowHidden - call s:RenderViewSavingPosition() - call s:CenterView() -endfunction - -"FUNCTION: s:UpDir(keepState) {{{2 -"moves the tree up a level -" -"Args: -"keepState: 1 if the current root should be left open when the tree is -"re-rendered -function! s:UpDir(keepState) - let cwd = t:NERDTreeRoot.path.Str(0) - if cwd == "/" || cwd =~ '^[^/]..$' - call s:Echo("already at top dir") - else - if !a:keepState - call t:NERDTreeRoot.Close() - endif - - let oldRoot = t:NERDTreeRoot - - if empty(t:NERDTreeRoot.parent) - let path = t:NERDTreeRoot.path.GetPathTrunk() - let newRoot = s:oTreeDirNode.New(path) - call newRoot.Open() - call newRoot.TransplantChild(t:NERDTreeRoot) - let t:NERDTreeRoot = newRoot - else - let t:NERDTreeRoot = t:NERDTreeRoot.parent - - endif - - call s:RenderView() - call s:PutCursorOnNode(oldRoot, 0) - endif -endfunction - - -" SECTION: Doc installation call {{{1 -silent call s:InstallDocumentation(expand('<sfile>:p'), s:NERD_tree_version) -"============================================================ -finish -" SECTION: The help file {{{1 -"============================================================================= -" Title {{{2 -" ============================================================================ -=== START_DOC -*NERD_tree.txt* A tree explorer plugin that owns your momma! #version# - - - - - - ________ ________ _ ____________ ____ __________ ____________~ - /_ __/ / / / ____/ / | / / ____/ __ \/ __ \ /_ __/ __ \/ ____/ ____/~ - / / / /_/ / __/ / |/ / __/ / /_/ / / / / / / / /_/ / __/ / __/ ~ - / / / __ / /___ / /| / /___/ _, _/ /_/ / / / / _, _/ /___/ /___ ~ - /_/ /_/ /_/_____/ /_/ |_/_____/_/ |_/_____/ /_/ /_/ |_/_____/_____/ ~ - - - Reference Manual~ - - - - -============================================================================== -CONTENTS {{{2 *NERDTree-contents* - - 1.Intro...................................|NERDTree| - 2.Functionality provided..................|NERDTreeFunctionality| - 2.1 Commands..........................|NERDTreeCommands| - 2.2 NERD tree mappings................|NERDTreeMappings| - 2.3 The filesystem menu...............|NERDTreeFilesysMenu| - 3.Options.................................|NERDTreeOptions| - 3.1 Option summary....................|NERDTreeOptionSummary| - 3.2 Option details....................|NERDTreeOptionDetails| - 4.Public functions........................|NERDTreePublicFunctions| - 5.TODO list...............................|NERDTreeTodo| - 6.The Author..............................|NERDTreeAuthor| - 7.Changelog...............................|NERDTreeChangelog| - 8.Credits.................................|NERDTreeCredits| - -============================================================================== -1. Intro {{{2 *NERDTree* - -What is this "NERD tree"?? - -The NERD tree allows you to explore your filesystem and to open files and -directories. It presents the filesystem to you in the form of a tree which you -manipulate with the keyboard and/or mouse. It also allows you to perform -simple filesystem operations so you can alter the tree dynamically. - -The following features and functionality are provided by the NERD tree: - * Files and directories are displayed in a hierarchical tree structure - * Different highlighting is provided for the following types of nodes: - * files - * directories - * sym-links - * windows .lnk files - * read-only files - * Many (customisable) mappings are provided to manipulate the tree: - * Mappings to open/close/explore directory nodes - * Mappings to open files in new/existing windows/tabs - * Mappings to change the current root of the tree - * Mappings to navigate around the tree - * ... - * Most NERD tree navigation can also be done with the mouse - * Dynamic customisation of tree content - * custom file filters to prevent e.g. vim backup files being displayed - * optional displaying of hidden files (. files) - * files can be "turned off" so that only directories are displayed - * A textual filesystem menu is provided which allows you to - create/delete/rename file and directory nodes - * The position and size of the NERD tree window can be customised - * The order in which the nodes in the tree are listed can be customised. - * A model of your filesystem is created/maintained as you explore it. This - has several advantages: - * All filesystem information is cached and is only re-read on demand - * If you revisit a part of the tree that you left earlier in your - session, the directory nodes will be opened/closed as you left them - * The script remembers the cursor position and window position in the NERD - tree so you can toggle it off (or just close the tree window) and then - reopen it (with NERDTreeToggle) the NERD tree window will appear EXACTLY - as you left it - * You can have a separate NERD tree for each tab - -============================================================================== -2. Functionality provided {{{2 *NERDTreeFunctionality* - ------------------------------------------------------------------------------- -2.1. Commands {{{3 *NERDTreeCommands* - -:NERDTree [start-directory] *:NERDTree* - Opens a fresh NERD tree in [start-directory] or the current - directory if [start-directory] isn't specified. - For example: > - :NERDTree /home/marty/vim7/src -< will open a NERD tree in /home/marty/vim7/src. - -:NERDTreeToggle [start-directory] *:NERDTreeToggle* - If a NERD tree already exists for this tab, it is reopened and - rendered again. If no NERD tree exists for this tab then this - command acts the same as the |:NERDTree| command. - ------------------------------------------------------------------------------- -2.2. NERD tree Mappings {{{3 *NERDTreeMappings* - -Default Description~ help-tag~ -Key~ - -o.......Open selected file, or expand selected dir...............|NERDTree-o| -go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go| -t.......Open selected node in a new tab..........................|NERDTree-t| -T.......Same as 't' but keep the focus on the current tab........|NERDTree-T| -<tab>...Open selected file in a split window.....................|NERDTree-tab| -g<tab>..Same as <tab>, but leave the cursor on the NERDTree......|NERDTree-gtab| -!.......Execute the current file.................................|NERDTree-!| -O.......Recursively open the selected directory..................|NERDTree-O| -x.......Close the current nodes parent...........................|NERDTree-x| -X.......Recursively close all children of the current node.......|NERDTree-X| -e.......Open a netrw for the current dir.........................|NERDTree-e| - -double-click.......same as the |NERDTree-o| map. -middle-click.......same as |NERDTree-tab| for files, same as - |NERDTree-e| for dirs. - -P.......Jump to the root node....................................|NERDTree-P| -p.......Jump to current nodes parent.............................|NERDTree-p| -K.......Jump up inside directories at the current tree depth.....|NERDTree-K| -J.......Jump down inside directories at the current tree depth...|NERDTree-J| -<C-j>...Jump down to the next sibling of the current directory...|NERDTree-c-j| -<C-k>...Jump up to the previous sibling of the current directory.|NERDTree-c-k| - -C.......Change the tree root to the selected dir.................|NERDTree-C| -u.......Move the tree root up one directory......................|NERDTree-u| -U.......Same as 'u' except the old root node is left open........|NERDTree-U| -r.......Recursively refresh the current directory................|NERDTree-r| -R.......Recursively refresh the current root.....................|NERDTree-R| -m.......Display the filesystem menu..............................|NERDTree-m| -cd......Change the CWD to the dir of the selected node...........|NERDTree-cd| - -H.......Toggle whether hidden files displayed....................|NERDTree-H| -f.......Toggle whether the file filters are used.................|NERDTree-f| -F.......Toggle whether files are displayed.......................|NERDTree-F| - -q.......Close the NERDTree window................................|NERDTree-q| -?.......Toggle the display of the quick help.....................|NERDTree-?| - ------------------------------------------------------------------------------- - *NERDTree-o* -Default key: o -Map option: NERDTreeMapActivateNode -Applies to: files and directories. - -If a file node is selected, it is opened in the previous window. If a -directory is selected it is opened or closed depending on its current state. - ------------------------------------------------------------------------------- - *NERDTree-go* -Default key: go -Map option: None -Applies to: files. - -If a file node is selected, it is opened in the previous window, but the -cursor does not move. - -The key combo for this mapping is always "g" + NERDTreeMapActivateNode (see -|NERDTree-o|). - ------------------------------------------------------------------------------- - *NERDTree-t* -Default key: t -Map option: NERDTreeMapOpenInTab -Applies to: files and directories. - -Opens the selected file in a new tab. If a directory is selected, a netrw is -opened in a new tab. - ------------------------------------------------------------------------------- - *NERDTree-T* -Default key: T -Map option: NERDTreeMapOpenInTabSilent -Applies to: files and directories. - -The same as |NERDTree-t| except that the focus is kept in the current tab. - ------------------------------------------------------------------------------- - *NERDTree-tab* -Default key: <tab> -Map option: NERDTreeMapOpenSplit -Applies to: files. - -Opens the selected file in a new split window and puts the cursor in the new -window. - ------------------------------------------------------------------------------- - *NERDTree-gtab* -Default key: g<tab> -Map option: None -Applies to: files. - -The same as |NERDTree-tab| except that the cursor is not moved. - -The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see -|NERDTree-tab|). - ------------------------------------------------------------------------------- - *NERDTree-!* -Default key: ! -Map option: NERDTreeMapExecute -Applies to: files. - -Executes the selected file, prompting for arguments first. - ------------------------------------------------------------------------------- - *NERDTree-O* -Default key: O -Map option: NERDTreeMapOpenRecursively -Applies to: directories. - -Recursively opens the selelected directory. - -All files and directories are cached, but if a directory would not be -displayed due to file filters (see |NERDTreeIgnore| |NERDTree-f|) or the -hidden file filter (see |NERDTreeShowHidden|) then it is not opened. This is -handy, especially if you have .svn directories. - - ------------------------------------------------------------------------------- - *NERDTree-x* -Default key: x -Map option: NERDTreeMapCloseDir -Applies to: files and directories. - -Closes the parent of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-X* -Default key: X -Map option: NERDTreeMapCloseChildren -Applies to: directories. - -Recursively closes all children of the selected directory. - -Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. - ------------------------------------------------------------------------------- - *NERDTree-e* -Default key: e -Map option: NERDTreeMapOpenExpl -Applies to: files and directories. - -Opens a netrw on the selected directory, or the selected file's directory. - ------------------------------------------------------------------------------- - *NERDTree-P* -Default key: P -Map option: NERDTreeMapJumpRoot -Applies to: no restrictions. - -Jump to the tree root. - ------------------------------------------------------------------------------- - *NERDTree-p* -Default key: p -Map option: NERDTreeMapJumpParent -Applies to: files and directories. - -Jump to the parent node of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-K* -Default key: K -Map option: NERDTreeMapJumpFirstChild -Applies to: files and directories. - -Jump to the first child of the current nodes parent. - -If the cursor is already on the first node then do the following: - * loop back thru the siblings of the current nodes parent until we find an - open dir with children - * go to the first child of that node - ------------------------------------------------------------------------------- - *NERDTree-J* -Default key: J -Map option: NERDTreeMapJumpLastChild -Applies to: files and directories. - -Jump to the last child of the current nodes parent. - -If the cursor is already on the last node then do the following: - * loop forward thru the siblings of the current nodes parent until we find - an open dir with children - * go to the last child of that node - ------------------------------------------------------------------------------- - *NERDTree-c-j* -Default key: <C-j> -Map option: NERDTreeMapJumpNextSibling -Applies to: files and directories. - -If a dir node is selected, jump to the next sibling of that node. -If a file node is selected, jump to the next sibling of that nodes parent. - ------------------------------------------------------------------------------- - *NERDTree-c-k* -Default key: <C-k> -Map option: NERDTreeMapJumpPrevSibling -Applies to: files and directories. - -If a dir node is selected, jump to the previous sibling of that node. -If a file node is selected, jump to the previous sibling of that nodes parent. - ------------------------------------------------------------------------------- - *NERDTree-C* -Default key: C -Map option: NERDTreeMapChdir -Applies to: directories. - -Made the selected directory node the new tree root. - ------------------------------------------------------------------------------- - *NERDTree-u* -Default key: u -Map option: NERDTreeMapUpdir -Applies to: no restrictions. - -Move the tree root up a dir (like doing a "cd .."). - ------------------------------------------------------------------------------- - *NERDTree-U* -Default key: U -Map option: NERDTreeMapUpdirKeepOpen -Applies to: no restrictions. - -Like |NERDTree-u| except that the old tree root is kept open. - ------------------------------------------------------------------------------- - *NERDTree-r* -Default key: r -Map option: NERDTreeMapRefresh -Applies to: files and directories. - -If a dir is selected, recursively refresh that dir, i.e. scan the filesystem -for changes and represent them in the tree. - -If a file node is selected then the above is done on it's parent. - ------------------------------------------------------------------------------- - *NERDTree-R* -Default key: R -Map option: NERDTreeMapRefreshRoot -Applies to: no restrictions. - -Recursively refresh the tree root. - ------------------------------------------------------------------------------- - *NERDTree-m* -Default key: m -Map option: NERDTreeMapFilesystemMenu -Applies to: files and directories. - -Display the filesystem menu. See |NERDTreeFilesysMenu| for details. - ------------------------------------------------------------------------------- - *NERDTree-H* -Default key: H -Map option: NERDTreeMapToggleHidden -Applies to: no restrictions. - -Toggles whether hidden files are displayed. Hidden files are any -file/directory that starts with a "." - ------------------------------------------------------------------------------- - *NERDTree-f* -Default key: f -Map option: NERDTreeMapToggleFilters -Applies to: no restrictions. - -Toggles whether file filters are used. See |NERDTreeIgnore| for details. - ------------------------------------------------------------------------------- - *NERDTree-F* -Default key: F -Map option: NERDTreeMapToggleFiles -Applies to: no restrictions. - -Toggles whether file nodes are displayed. - ------------------------------------------------------------------------------- - *NERDTree-q* -Default key: q -Map option: NERDTreeMapQuit -Applies to: no restrictions. - -Closes the NERDtree window. - ------------------------------------------------------------------------------- - *NERDTree-?* -Default key: ? -Map option: NERDTreeMapHelp -Applies to: no restrictions. - -Toggles whether the quickhelp is displayed. - ------------------------------------------------------------------------------- -2.3. The filesystem menu {{{3 *NERDTreeFilesysMenu* - -The purpose of the filesystem menu is to allow you to perform basic filesystem -operations quickly from the NERD tree rather than the console. - -The filesystem menu can be accessed with 'm' mapping and has three supported -operations: > - 1. Adding nodes. - 2. Renaming nodes. - 3. Deleting nodes. -< -1. Adding nodes: -To add a node move the cursor onto (or anywhere inside) the directory you wish -to create the new node inside. Select the 'add node' option from the -filesystem menu and type a filename. If the filename you type ends with a '/' -character then a directory will be created. Once the operation is completed, -the cursor is placed on the new node. - -2. Renaming nodes: -To rename a node, put the cursor on it and select the 'rename' option from the -filesystem menu. Enter the new name for the node and it will be renamed. If -the old file is open in a buffer, you will be asked if you wish to delete that -buffer. Once the operation is complete the cursor will be placed on the -renamed node. - -3. Deleting nodes: -To delete a node put the cursor on it and select the 'delete' option from the -filesystem menu. After confirmation the node will be deleted. If a file is -deleted but still exists as a buffer you will be given the option to delete -that buffer. - -============================================================================== -3. Customisation {{{2 *NERDTreeOptions* - - ------------------------------------------------------------------------------- -3.1. Customisation summary {{{3 *NERDTreeOptionSummary* - -The script provides the following options that can customise the behaviour the -NERD tree. These options should be set in your vimrc. - -|loaded_nerd_tree| Turns off the script. - -|NERDChristmasTree| Tells the NERD tree to make itself colourful - and pretty. - -|NERDTreeAutoCenter| Controls whether the NERD tree window centers - when the cursor moves within a specified - distance to the top/bottom of the window. -|NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. - -|NERDTreeCaseSensitiveSort| Tells the NERD tree whether to be case - sensitive or not when sorting nodes. - -|NERDTreeChDirMode| Tells the NERD tree if/when it should change - vim's current working directory. - -|NERDTreeHighlightCursorline| Tell the NERD tree whether to highlight the - current cursor line. - -|NERDTreeIgnore| Tells the NERD tree which files to ignore. - -|NERDTreeMouseMode| Tells the NERD tree how to handle mouse - clicks. - -|NERDTreeShowFiles| Tells the NERD tree whether to display files - in the tree on startup. - -|NERDTreeShowHidden| Tells the NERD tree whether to display hidden - files on startup. - -|NERDTreeSortOrder| Tell the NERD tree how to sort the nodes in - the tree. - -|NERDTreeSplitVertical| Tells the script whether the NERD tree should - be created by splitting the window vertically - or horizontally. - -|NERDTreeWinPos| Tells the script where to put the NERD tree - window. - - -|NERDTreeWinSize| Sets the window size when the NERD tree is - opened. - ------------------------------------------------------------------------------- -3.2. Customisation details {{{3 *NERDTreeOptionDetails* - -To enable any of the below options you should put the given line in your -~/.vimrc - - *loaded_nerd_tree* -If this plugin is making you feel homicidal, it may be a good idea to turn it -off with this line in your vimrc: > - let loaded_nerd_tree=1 -< ------------------------------------------------------------------------------- - *NERDChristmasTree* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then some extra syntax highlighting elements are -added to the nerd tree to make it more colourful. - -Set it to 0 for a more vanilla looking tree. - ------------------------------------------------------------------------------- - *NERDTreeAutoCenter* -Values: 0 or 1. -Default: 1 - -If set to 1, the NERD tree window will center around the cursor if it moves to -within |NERDTreeAutoCenterThreshold| lines of the top/bottom of the window. - -This is ONLY done in response to tree navigation mappings, -i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-c-K| |NERDTree-p| -|NERDTree-P| - -The centering is done with a |zz| operation. - ------------------------------------------------------------------------------- - *NERDTreeAutoCenterThreshold* -Values: Any natural number. -Default: 3 - -This option controls the "sensitivity" of the NERD tree auto centering. See -|NERDTreeAutoCenter| for details. - ------------------------------------------------------------------------------- - *NERDTreeCaseSensitiveSort* -Values: 0 or 1. -Default: 0. - -By default the NERD tree does not sort nodes case sensitively, i.e. nodes -could appear like this: > - bar.c - Baz.c - blarg.c - boner.c - Foo.c -< -But, if you set this option to 1 then the case of the nodes will be taken into -account. The above nodes would then be sorted like this: > - Baz.c - Foo.c - bar.c - blarg.c - boner.c -< ------------------------------------------------------------------------------- - *NERDTreeChDirMode* - -Values: 0, 1 or 2. -Default: 1. - -Use this option to tell the script when (if at all) to change the current -working directory (CWD) for vim. - -If it is set to 0 then the CWD is never changed by the NERD tree. - -If set to 1 then the CWD is changed when the NERD tree is first loaded to the -directory it is initialized in. For example, if you start the NERD tree with > - :NERDTree /home/marty/foobar -< -then the CWD will be changed to /home/marty/foobar and will not be changed -again unless you init another NERD tree with a similar command. - -If the option is set to 2 then it behaves the same as if set to 1 except that -the CWD is changed whenever the tree root is changed. For example, if the CWD -is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new -root then the CWD will become /home/marty/foobar/baz. - -Note to windows users: it is highly recommended that you have this option set -to either 1 or 2 or else the script wont function properly if you attempt to -open a NERD tree on a different drive to the one vim is currently in. - -Authors note: at work i have this option set to 1 because i have a giant ctags -file in the root dir of my project. This way i can initialise the NERD tree -with the root dir of my project and always have ctags available to me --- no -matter where i go with the NERD tree. - ------------------------------------------------------------------------------- - *NERDTreeHighlightCursorline* -Values: 0 or 1. -Default: 1. - -If set to 1, the current cursor line in the NERD tree buffer will be -highlighted. This is done using the |cursorline| option. - ------------------------------------------------------------------------------- - *NERDTreeIgnore* -Values: a list of regular expressions. -Default: ['\~$']. - -This option is used to specify which files the NERD tree should ignore. It -must be a list of regular expressions. When the NERD tree is rendered, any -files/dirs that match any of the regex's in NERDTreeIgnore wont be displayed. - -For example if you put the following line in your vimrc: > - let NERDTreeIgnore=['\.vim$', '\~$'] -< -then all files ending in .vim or ~ will be ignored. - -Note: to tell the NERD tree not to ignore any files you must use the following -line: > - let NERDTreeIgnore=[] -< - -The file filters can be turned on and off dynamically with the |NERDTree-f| -mapping. - ------------------------------------------------------------------------------- - *NERDTreeMouseMode* -Values: 1, 2 or 3. -Default: 1. - -If set to 1 then a double click on a node is required to open it. -If set to 2 then a single click will open directory nodes, while a double -click will still be required for file nodes. -If set to 3 then a single click will open any node. - -Note: a double click anywhere on a line that a tree node is on will -activate it, but all single-click activations must be done on name of the node -itself. For example, if you have the following node: > - | | |-application.rb -< -then (to single click activate it) you must click somewhere in -'application.rb'. - ------------------------------------------------------------------------------- - *NERDTreeShowFiles* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then files are displayed in the NERD tree. If it is -set to 0 then only directories are displayed. - -This option can be toggled dynamically with the |NERDTree-F| mapping and is -useful for drastically shrinking the tree when you are navigating to a -different part of the tree. - ------------------------------------------------------------------------------- - *NERDTreeShowHidden* -Values: 0 or 1. -Default: 0. - -This option tells vim whether to display hidden files by default. This option -can be dynamically toggled with the |NERDTree-H| mapping. -Use one of the follow lines to set this option: > - let NERDTreeShowHidden=0 - let NERDTreeShowHidden=1 -< - ------------------------------------------------------------------------------- - *NERDTreeSortOrder* -Values: a list of regular expressions. -Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] - -This option is set to a list of regular expressions which are used to -specify the order of nodes under their parent. - -For example, if the option is set to: > - ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] -< -then all .vim files will be placed at the top, followed by all .c files then -all .h files. All files containing the string 'foobar' will be placed at the -end. The star is a special flag: it tells the script that every node that -doesnt match any of the other regexps should be placed here. - -If no star is present in NERDTreeSortOrder then one is automatically appended -to the array. - -The regex '\/$' should be used to match directory nodes. - -After this sorting is done, the files in each group are sorted alphabetically. - -Other examples: > - (1) ['*', '\/$'] - (2) [] - (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] -< -1. Directories will appear last, everything else will appear above. -2. Every will simply appear in alphabetical order. -3. Dirs will appear first, then ruby and php. Swap files, bak files and vim - backup files will appear last with everything else preceding them. - ------------------------------------------------------------------------------- - *NERDTreeSplitVertical* -Values: 0 or 1. -Default: 1. - -This option, along with |NERDTreeWinPos|, is used to determine where the NERD -tree window appears. - -If it is set to 1 then the NERD tree window will appear on either the left or -right side of the screen (depending on the |NERDTreeWinPos| option). - -If it set to 0 then the NERD tree window will appear at the top of the screen. - ------------------------------------------------------------------------------- - *NERDTreeWinPos* -Values: 0 or 1. -Default: 1. - -This option works in conjunction with the |NERDTreeSplitVertical| option to -determine where NERD tree window is placed on the screen. - -If the option is set to 1 then the NERD tree will appear on the left or top of -the screen (depending on the value of |NERDTreeSplitVertical|). If set to 0, -the window will appear on the right or bottom of the screen. - -This option is makes it possible to use two different explorer type -plugins simultaneously. For example, you could have the taglist plugin on the -left of the window and the NERD tree on the right. - ------------------------------------------------------------------------------- - *NERDTreeWinSize* -Values: a positive integer. -Default: 31. - -This option is used to change the size of the NERD tree when it is loaded. - -============================================================================== - *NERDTreePublicFunctions* -5. Public functions {{{2 ~ - -The script provides 2 public functions for your hacking pleasure. Their -signatures are: > - function! NERDTreeGetCurrentNode() - function! NERDTreeGetCurrentPath() -< -The first returns the node object that the cursor is currently on, while the -second returns the corresponding path object. - -This is probably a good time to mention that the script implements prototype -style OO. To see the functions that each class provides you can read look at -the code. - -Use the node objects to manipulate the structure of the tree. Use the path -objects to access the data the tree represents and to make changes to the -filesystem. - -============================================================================== -5. TODO list {{{2 *NERDTreeTodo* - -Window manager integration? - -============================================================================== -6. The Author {{{2 *NERDTreeAuthor* - -The author of the NERD tree is a terrible terrible monster called Martyzilla -who gobbles up small children with milk and sugar for breakfast. He has an odd -love/hate relationship with computers (but monsters hate everything by nature -you know...) which can be awkward for him since he is a pro computer nerd for -a living. - -He can be reached at martin_grenfell at msn.com. He would love to hear from -you, so feel free to send him suggestions and/or comments about this plugin. -Don't be shy --- the worst he can do is slaughter you and stuff you in the -fridge for later ;) - -============================================================================== -7. Changelog {{{2 *NERDTreeChangelog* - -2.6.2 - - Now when you try to open a file node into a window that is modified, the - window is not split if the &hidden option is set. Thanks to Niels Aan - de Brugh for this suggestion. - -2.6.1 - - Fixed a major bug with the <tab> mapping. Thanks to Zhang Weiwu for - emailing me. - -2.6.0 - - Extended the behaviour of <c-j/k>. Now if the cursor is on a file node - and you use <c-j/k> the cursor will jump to its PARENTS next/previous - sibling. Go :help NERDTree-c-j and :help NERDTree-c-k for info. - - Extended the behaviour of the J/K mappings. Now if the cursor is on the - last child of a node and you push J/K it will jump down to the last child - of the next/prev of its parents siblings that is open and has children. - Go :help NERDTree-J and :help NERDTree-K for info. - - The goal of these changes is to make tree navigation faster. - - Reorganised the help page a bit. - - Removed the E mapping. - - bugfixes - -2.5.0 - - Added an option to enforce case sensitivity when sorting tree nodes. - Read :help NERDTreeCaseSensitiveSort for details. (thanks to Michael - Madsen for emailing me about this). Case sensitivity defaults to off. - - Made the script echo a "please wait" style message when opening large - directories. Thanks to AOYAMA Shotaro for this suggestion. - - Added 2 public functions that can be used to retrieve the treenode and - path that the cursor is on. Read :help NERDTreePublicFunctions for - details (thanks again to AOYAMA Shotaro for the idea :). - - added 2 new mappings for file nodes: "g<tab>" and "go". These are the - same as the "<tab>" and "o" maps except that the cursor stays in the - NERDTree. Note: these maps are slaved to the o and <tab> mappings, so if - eg you remap "<tab>" to "i" then the "g<tab>" map will also be changed - to "gi". - - Renamed many of the help tags to be simpler. - - Simplified the ascii "graphics" for the filesystem menu - - Fixed bugs. - - Probably created bugs. - - Refactoring. - -2.4.0 - - Added the P mapping to jump to the tree root. - - Added window centering functionality that can be triggered when doing - using any of the tree nav mappings. Essentially, if the cursor comes - within a certain distance of the top/bottom of the window then a zz is - done in the window. Two related options were added: NERDTreeAutoCenter - to turn this functionality on/off, and NERDTreeAutoCenterThreshold to - control how close the cursor has to be to the window edge to trigger the - centering. - -2.3.0 - - Tree navigation changes: - - Added J and K mappings to jump to last/first child of the current dir. - Options to customise these mappings have also been added. - - Remapped the jump to next/prev sibling commands to be <C-j> and <C-k> by - default. - These changes should hopefully make tree navigation mappings easier to - remember and use as the j and k keys are simply reused 3 times (twice - with modifier keys). - - - Made it so that, when any of the tree filters are toggled, the cursor - stays with the selected node (or goes to its parent/grandparent/... if - that node is no longer visible) - - Fixed an error in the doc for the mouse mode option. - - Made the quickhelp correctly display the current single/double click - mappings for opening nodes as specified by the NERDTreeMouseMode option. - - Fixed a bug where the script was spazzing after prompting you to delete - a modified buffer when using the filesystem menu. - - Refactoring -2.2.3 - - Refactored the :echo output from the script. - - Fixed some minor typos in the doc. - - Made some minor changes to the output of the 'Tree filtering mappings' - part of the quickhelp - -2.2.2 - - More bugfixes... doh. - -2.2.1 - - Bug fix that was causing an exception when closing the nerd tree. Thanks - to Tim carey-smith and Yu Jun for pointing this out. - -2.2.0 - - Now 'cursorline' is set in the NERD tree buffer by default. See :help - NERDTreeHighlightCursorline for how to disable it. - -2.1.2 - - Stopped the script from clobbering the 1,2,3 .. 9 registers. - - Made it "silent!"ly delete buffers when renaming/deleting file nodes. - - Minor correction to the doc - - Fixed a bug when refreshing that was occurring when the node you - refreshed had been deleted externally. - - Fixed a bug that was occurring when you open a file that is already open - and modified. - -2.1.1 - - Added a bit more info about the buffers you are prompted to delete when - renaming/deleting nodes from the filesystem menu that are already loaded - into buffers. - - Refactoring and bugfixes - -2.1.0 - - Finally removed the blank line that always appears at the top of the - NERDTree buffer - - Added NERDTreeMouseMode option. If set to 1, then a double click is - required to activate all nodes, if set to 2 then a single click will - activate directory nodes, if set to 3 then a single click will activate - all nodes. - - Now if you delete a file node and have it open in a buffer you are given - the option to delete that buffer as well. Similarly if you rename a file - you are given the option to delete any buffers containing the old file - (if any exist) - - When you rename or create a node, the cursor is now put on the new node, - this makes it easy immediately edit the new file. - - Fixed a bug with the ! mapping that was occurring on windows with paths - containing spaces. - - Made all the mappings customisable. See |NERD_tree-mappings| for - details. A side effect is that a lot of the "double mappings" have - disappeared. E.g 'o' is now the key that is used to activate a node, - <CR> is no longer mapped to the same. - - Made the script echo warnings in some places rather than standard echos - - Insane amounts of refactoring all over the place. - -2.0.0 - - Added two new NERDChristmasTree decorations. First person to spot them - and email me gets a free copy of the NERDTree. - - Made it so that when you jump around the tree (with the p, s and S - mappings) it is counted as a jump by vim. This means if you, eg, push - 'p' one too many times then you can go `` or ctrl-o. - - Added a new option called NERDTreeSortOrder which takes an array of - regexs and is used to determine the order that the treenodes are listed - in. Go :help NERDTreeSortOrder for details. - - Removed the NERDTreeSortDirs option because it is consumed by - NERDTreeSortOrder - - Added the 'i' mapping which is the same as <tab> but requires less - effort to reach. - - Added the ! mapping which is used to execute file in the tree (after it - prompts you for arguments etc) - - -============================================================================== -8. Credits {{{2 *NERDTreeCredits* - -Thanks to Tim Carey-Smith for testing/using the NERD tree from the first -pre-beta version, for his many suggestions and for his constant stream of bug -complaints. - -Thanks to Vigil for trying it out before the first release :) and suggesting -that mappings to open files in new tabs should be implemented. - -Thanks to Nick Brettell for testing, fixing my spelling and suggesting i put a - .. (up a directory) -line in the gui. - -Thanks to Thomas Scott Urban - the author of the vtreeexplorer plugin - whose -gui code i borrowed from. - -Thanks to Terrance Cohen for pointing out a bug where the script was changing -vims CWD all over the show. - -Thanks to Yegappan Lakshmanan (author of Taglist and other orgasmically -wonderful plugins) for telling me how to fix a bug that was causing vim to go -into visual mode everytime you double clicked a node :) - -Thanks to Jason Mills for sending me a fix that allows windows paths to use -forward slashes as well as backward. - -Thanks to Michael Geddes (frogonwheels on #vim at freenode) for giving me some -tips about syntax highlighting when i was doing highlighting for the -quickhelp. - -Thanks to Yu Jun for emailing me about a bug that was occurring when closing -the tree. - -Thanks to Michael Madsen for emailing me about making case sensitivity -optional when sorting nodes. - -Thanks to AOYAMA Shotaro for suggesting that i echo a "please wait" message -when opening large directories. - -Thanks to Michael Madsen for requesting the NERDTreeCaseSensitiveSort option. - -Thanks to AOYAMA Shotaro for suggesting that a "please wait" style message be -echoed when opening large directories. Also, thanks for the suggestion of -having public functions in the script to access the internal data :D - -Thanks to Zhang Weiwu for emailing me about a bug with the the <tab> mapping -in 2.6.0 - -Thanks to Niels Aan de Brugh for the suggestion that the script now split the -window if you try to open a file in a window containing a modified buffer when -the &hidden option is set. - -=== END_DOC -" vim: set ts=4 sw=4 foldmethod=marker foldmarker={{{,}}} foldlevel=2: diff --git a/.vim/plugin/a.vim b/.vim/plugin/a.vim deleted file mode 100644 index e73817d..0000000 --- a/.vim/plugin/a.vim +++ /dev/null @@ -1,840 +0,0 @@ -" Copyright (c) 1998-2006 -" Michael Sharpe <feline@irendi.com> -" -" We grant permission to use, copy modify, distribute, and sell this -" software for any purpose without fee, provided that the above copyright -" notice and this text are not removed. We make no guarantee about the -" suitability of this software for any purpose and we are not liable -" for any damages resulting from its use. Further, we are under no -" obligation to maintain or extend this software. It is provided on an -" "as is" basis without any expressed or implied warranty. - -" Directory & regex enhancements added by Bindu Wavell who is well known on -" vim.sf.net -" -" Patch for spaces in files/directories from Nathan Stien (also reported by -" Soeren Sonnenburg) - -" Do not load a.vim if is has already been loaded. -if exists("loaded_alternateFile") - finish -endif -if (v:progname == "ex") - finish -endif -let loaded_alternateFile = 1 - -let alternateExtensionsDict = {} - -" setup the default set of alternate extensions. The user can override in thier -" .vimrc if the defaults are not suitable. To override in a .vimrc simply set a -" g:alternateExtensions_<EXT> variable to a comma separated list of alternates, -" where <EXT> is the extension to map. -" E.g. let g:alternateExtensions_CPP = "inc,h,H,HPP,hpp" -" let g:alternateExtensions_{'aspx.cs'} = "aspx" - - -" This variable will be increased when an extension with greater number of dots -" is added by the AddAlternateExtensionMapping call. -let s:maxDotsInExtension = 1 - -" Function : AddAlternateExtensionMapping (PRIVATE) -" Purpose : simple helper function to add the default alternate extension -" mappings. -" Args : extension -- the extension to map -" alternates -- comma separated list of alternates extensions -" Returns : nothing -" Author : Michael Sharpe <feline@irendi.com> -function! <SID>AddAlternateExtensionMapping(extension, alternates) - " This code does not actually work for variables like foo{'a.b.c.d.e'} - "let varName = "g:alternateExtensions_" . a:extension - "if (!exists(varName)) - " let g:alternateExtensions_{a:extension} = a:alternates - "endif - - " This code handles extensions which contains a dot. exists() fails with - " such names. - "let v:errmsg = "" - " FIXME this line causes ex to return 1 instead of 0 for some reason?? - "silent! echo g:alternateExtensions_{a:extension} - "if (v:errmsg != "") - "let g:alternateExtensions_{a:extension} = a:alternates - "endif - - let g:alternateExtensionsDict[a:extension] = a:alternates - let dotsNumber = strlen(substitute(a:extension, "[^.]", "", "g")) - if s:maxDotsInExtension < dotsNumber - let s:maxDotsInExtension = dotsNumber - endif -endfunction - - -" Add all the default extensions -" Mappings for C and C++ -call <SID>AddAlternateExtensionMapping('h',"c,cpp,cxx,cc,CC") -call <SID>AddAlternateExtensionMapping('H',"C,CPP,CXX,CC") -call <SID>AddAlternateExtensionMapping('hpp',"cpp,c") -call <SID>AddAlternateExtensionMapping('HPP',"CPP,C") -call <SID>AddAlternateExtensionMapping('c',"h") -call <SID>AddAlternateExtensionMapping('C',"H") -call <SID>AddAlternateExtensionMapping('cpp',"h,hpp") -call <SID>AddAlternateExtensionMapping('CPP',"H,HPP") -call <SID>AddAlternateExtensionMapping('cc',"h") -call <SID>AddAlternateExtensionMapping('CC',"H,h") -call <SID>AddAlternateExtensionMapping('cxx',"h") -call <SID>AddAlternateExtensionMapping('CXX',"H") -" Mappings for PSL7 -call <SID>AddAlternateExtensionMapping('psl',"ph") -call <SID>AddAlternateExtensionMapping('ph',"psl") -" Mappings for ADA -call <SID>AddAlternateExtensionMapping('adb',"ads") -call <SID>AddAlternateExtensionMapping('ads',"adb") -" Mappings for lex and yacc files -call <SID>AddAlternateExtensionMapping('l',"y,yacc,ypp") -call <SID>AddAlternateExtensionMapping('lex',"yacc,y,ypp") -call <SID>AddAlternateExtensionMapping('lpp',"ypp,y,yacc") -call <SID>AddAlternateExtensionMapping('y',"l,lex,lpp") -call <SID>AddAlternateExtensionMapping('yacc',"lex,l,lpp") -call <SID>AddAlternateExtensionMapping('ypp',"lpp,l,lex") -" Mappings for OCaml -call <SID>AddAlternateExtensionMapping('ml',"mli") -call <SID>AddAlternateExtensionMapping('mli',"ml") -" ASP stuff -call <SID>AddAlternateExtensionMapping('aspx.cs', 'aspx') -call <SID>AddAlternateExtensionMapping('aspx.vb', 'aspx') -call <SID>AddAlternateExtensionMapping('aspx', 'aspx.cs,aspx.vb') - -" Setup default search path, unless the user has specified -" a path in their [._]vimrc. -if (!exists('g:alternateSearchPath')) - let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc' -endif - -" If this variable is true then a.vim will not alternate to a file/buffer which -" does not exist. E.g while editing a.c and the :A will not swtich to a.h -" unless it exists. -if (!exists('g:alternateNoDefaultAlternate')) - " by default a.vim will alternate to a file which does not exist - let g:alternateNoDefaultAlternate = 0 -endif - -" If this variable is true then a.vim will convert the alternate filename to a -" filename relative to the current working directory. -" Feature by Nathan Huizinga -if (!exists('g:alternateRelativeFiles')) - " by default a.vim will not convert the filename to one relative to the - " current working directory - let g:alternateRelativeFiles = 0 -endif - - -" Function : GetNthItemFromList (PRIVATE) -" Purpose : Support reading items from a comma seperated list -" Used to iterate all the extensions in an extension spec -" Used to iterate all path prefixes -" Args : list -- the list (extension spec, file paths) to iterate -" n -- the extension to get -" Returns : the nth item (extension, path) from the list (extension -" spec), or "" for failure -" Author : Michael Sharpe <feline@irendi.com> -" History : Renamed from GetNthExtensionFromSpec to GetNthItemFromList -" to reflect a more generic use of this function. -- Bindu -function! <SID>GetNthItemFromList(list, n) - let itemStart = 0 - let itemEnd = -1 - let pos = 0 - let item = "" - let i = 0 - while (i != a:n) - let itemStart = itemEnd + 1 - let itemEnd = match(a:list, ",", itemStart) - let i = i + 1 - if (itemEnd == -1) - if (i == a:n) - let itemEnd = strlen(a:list) - endif - break - endif - endwhile - if (itemEnd != -1) - let item = strpart(a:list, itemStart, itemEnd - itemStart) - endif - return item -endfunction - -" Function : ExpandAlternatePath (PRIVATE) -" Purpose : Expand path info. A path with a prefix of "wdr:" will be -" treated as relative to the working directory (i.e. the -" directory where vim was started.) A path prefix of "abs:" will -" be treated as absolute. No prefix or "sfr:" will result in the -" path being treated as relative to the source file (see sfPath -" argument). -" -" A prefix of "reg:" will treat the pathSpec as a regular -" expression substitution that is applied to the source file -" path. The format is: -" -" reg:<sep><pattern><sep><subst><sep><flag><sep> -" -" <sep> seperator character, we often use one of [/|%#] -" <pattern> is what you are looking for -" <subst> is the output pattern -" <flag> can be g for global replace or empty -" -" EXAMPLE: 'reg:/inc/src/g/' will replace every instance -" of 'inc' with 'src' in the source file path. It is possible -" to use match variables so you could do something like: -" 'reg:|src/\([^/]*\)|inc/\1||' (see 'help :substitute', -" 'help pattern' and 'help sub-replace-special' for more details -" -" NOTE: a.vim uses ',' (comma) internally so DON'T use it -" in your regular expressions or other pathSpecs unless you update -" the rest of the a.vim code to use some other seperator. -" -" Args : pathSpec -- path component (or substitution patterns) -" sfPath -- source file path -" Returns : a path that can be used by AlternateFile() -" Author : Bindu Wavell <bindu@wavell.net> -function! <SID>ExpandAlternatePath(pathSpec, sfPath) - let prfx = strpart(a:pathSpec, 0, 4) - if (prfx == "wdr:" || prfx == "abs:") - let path = strpart(a:pathSpec, 4) - elseif (prfx == "reg:") - let re = strpart(a:pathSpec, 4) - let sep = strpart(re, 0, 1) - let patend = match(re, sep, 1) - let pat = strpart(re, 1, patend - 1) - let subend = match(re, sep, patend + 1) - let sub = strpart(re, patend+1, subend - patend - 1) - let flag = strpart(re, strlen(re) - 2) - if (flag == sep) - let flag = '' - endif - let path = substitute(a:sfPath, pat, sub, flag) - "call confirm('PAT: [' . pat . '] SUB: [' . sub . ']') - "call confirm(a:sfPath . ' => ' . path) - else - let path = a:pathSpec - if (prfx == "sfr:") - let path = strpart(path, 4) - endif - let path = a:sfPath . "/" . path - endif - return path -endfunction - -" Function : FindFileInSearchPath (PRIVATE) -" Purpose : Searches for a file in the search path list -" Args : filename -- name of the file to search for -" pathList -- the path list to search -" relPathBase -- the path which relative paths are expanded from -" Returns : An expanded filename if found, the empty string otherwise -" Author : Michael Sharpe (feline@irendi.com) -" History : inline code written by Bindu Wavell originally -function! <SID>FindFileInSearchPath(fileName, pathList, relPathBase) - let filepath = "" - let m = 1 - let pathListLen = strlen(a:pathList) - if (pathListLen > 0) - while (1) - let pathSpec = <SID>GetNthItemFromList(a:pathList, m) - if (pathSpec != "") - let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase) - let fullname = path . "/" . a:fileName - let foundMatch = <SID>BufferOrFileExists(fullname) - if (foundMatch) - let filepath = fullname - break - endif - else - break - endif - let m = m + 1 - endwhile - endif - return filepath -endfunction - -" Function : FindFileInSearchPathEx (PRIVATE) -" Purpose : Searches for a file in the search path list -" Args : filename -- name of the file to search for -" pathList -- the path list to search -" relPathBase -- the path which relative paths are expanded from -" count -- find the count'th occurence of the file on the path -" Returns : An expanded filename if found, the empty string otherwise -" Author : Michael Sharpe (feline@irendi.com) -" History : Based on <SID>FindFileInSearchPath() but with extensions -function! <SID>FindFileInSearchPathEx(fileName, pathList, relPathBase, count) - let filepath = "" - let m = 1 - let spath = "" - let pathListLen = strlen(a:pathList) - if (pathListLen > 0) - while (1) - let pathSpec = <SID>GetNthItemFromList(a:pathList, m) - if (pathSpec != "") - let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase) - if (spath != "") - let spath = spath . ',' - endif - let spath = spath . path - else - break - endif - let m = m + 1 - endwhile - endif - - if (&path != "") - if (spath != "") - let spath = spath . ',' - endif - let spath = spath . &path - endif - - let filepath = findfile(a:fileName, spath, a:count) - return filepath -endfunction - -" Function : EnumerateFilesByExtension (PRIVATE) -" Purpose : enumerates all files by a particular list of alternate extensions. -" Args : path -- path of a file (not including the file) -" baseName -- base name of the file to be expanded -" extension -- extension whose alternates are to be enumerated -" Returns : comma separated list of files with extensions -" Author : Michael Sharpe <feline@irendi.com> -function! EnumerateFilesByExtension(path, baseName, extension) - let enumeration = "" - let extSpec = "" - let v:errmsg = "" - silent! echo g:alternateExtensions_{a:extension} - if (v:errmsg == "") - let extSpec = g:alternateExtensions_{a:extension} - endif - if (extSpec == "") - if (has_key(g:alternateExtensionsDict, a:extension)) - let extSpec = g:alternateExtensionsDict[a:extension] - endif - endif - if (extSpec != "") - let n = 1 - let done = 0 - while (!done) - let ext = <SID>GetNthItemFromList(extSpec, n) - if (ext != "") - if (a:path != "") - let newFilename = a:path . "/" . a:baseName . "." . ext - else - let newFilename = a:baseName . "." . ext - endif - if (enumeration == "") - let enumeration = newFilename - else - let enumeration = enumeration . "," . newFilename - endif - else - let done = 1 - endif - let n = n + 1 - endwhile - endif - return enumeration -endfunction - -" Function : EnumerateFilesByExtensionInPath (PRIVATE) -" Purpose : enumerates all files by expanding the path list and the extension -" list. -" Args : baseName -- base name of the file -" extension -- extension whose alternates are to be enumerated -" pathList -- the list of paths to enumerate -" relPath -- the path of the current file for expansion of relative -" paths in the path list. -" Returns : A comma separated list of paths with extensions -" Author : Michael Sharpe <feline@irendi.com> -function! EnumerateFilesByExtensionInPath(baseName, extension, pathList, relPathBase) - let enumeration = "" - let filepath = "" - let m = 1 - let pathListLen = strlen(a:pathList) - if (pathListLen > 0) - while (1) - let pathSpec = <SID>GetNthItemFromList(a:pathList, m) - if (pathSpec != "") - let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase) - let pe = EnumerateFilesByExtension(path, a:baseName, a:extension) - if (enumeration == "") - let enumeration = pe - else - let enumeration = enumeration . "," . pe - endif - else - break - endif - let m = m + 1 - endwhile - endif - return enumeration -endfunction - -" Function : DetermineExtension (PRIVATE) -" Purpose : Determines the extension of a filename based on the register -" alternate extension. This allow extension which contain dots to -" be considered. E.g. foo.aspx.cs to foo.aspx where an alternate -" exists for the aspx.cs extension. Note that this will only accept -" extensions which contain less than 5 dots. This is only -" implemented in this manner for simplicity...it is doubtful that -" this will be a restriction in non-contrived situations. -" Args : The path to the file to find the extension in -" Returns : The matched extension if any -" Author : Michael Sharpe (feline@irendi.com) -" History : idea from Tom-Erik Duestad -" Notes : there is some magic occuring here. The exists() function does not -" work well when the curly brace variable has dots in it. And why -" should it, dots are not valid in variable names. But the exists -" function is wierd too. Lets say foo_c does exist. Then -" exists("foo_c.e.f") will be true...even though the variable does -" not exist. However the curly brace variables do work when the -" variable has dots in it. E.g foo_{'c'} is different from -" foo_{'c.d.e'}...and foo_{'c'} is identical to foo_c and -" foo_{'c.d.e'} is identical to foo_c.d.e right? Yes in the current -" implementation of vim. To trick vim to test for existence of such -" variables echo the curly brace variable and look for an error -" message. -function! DetermineExtension(path) - let mods = ":t" - let i = 0 - while i <= s:maxDotsInExtension - let mods = mods . ":e" - let extension = fnamemodify(a:path, mods) - if (has_key(g:alternateExtensionsDict, extension)) - return extension - endif - let v:errmsg = "" - silent! echo g:alternateExtensions_{extension} - if (v:errmsg == "") - return extension - endif - let i = i + 1 - endwhile - return "" -endfunction - -" Function : AlternateFile (PUBLIC) -" Purpose : Opens a new buffer by looking at the extension of the current -" buffer and finding the corresponding file. E.g. foo.c <--> foo.h -" Args : accepts one argument. If present it used the argument as the new -" extension. -" Returns : nothing -" Author : Michael Sharpe <feline@irendi.com> -" History : + When an alternate can't be found in the same directory as the -" source file, a search path will be traversed looking for the -" alternates. -" + Moved some code into a separate function, minor optimization -" + rework to favor files in memory based on complete enumeration of -" all files extensions and paths -function! AlternateFile(splitWindow, ...) - let extension = DetermineExtension(expand("%:p")) - let baseName = substitute(expand("%:t"), "\." . extension . '$', "", "") - let currentPath = expand("%:p:h") - - if (a:0 != 0) - let newFullname = currentPath . "/" . baseName . "." . a:1 - call <SID>FindOrCreateBuffer(newFullname, a:splitWindow, 0) - else - let allfiles = "" - if (extension != "") - let allfiles1 = EnumerateFilesByExtension(currentPath, baseName, extension) - let allfiles2 = EnumerateFilesByExtensionInPath(baseName, extension, g:alternateSearchPath, currentPath) - - if (allfiles1 != "") - if (allfiles2 != "") - let allfiles = allfiles1 . ',' . allfiles2 - else - let allfiles = allfiles1 - endif - else - let allfiles = allfiles2 - endif - endif - - if (allfiles != "") - let bestFile = "" - let bestScore = 0 - let score = 0 - let n = 1 - - let onefile = <SID>GetNthItemFromList(allfiles, n) - let bestFile = onefile - while (onefile != "" && score < 2) - let score = <SID>BufferOrFileExists(onefile) - if (score > bestScore) - let bestScore = score - let bestFile = onefile - endif - let n = n + 1 - let onefile = <SID>GetNthItemFromList(allfiles, n) - endwhile - - if (bestScore == 0 && g:alternateNoDefaultAlternate == 1) - echo "No existing alternate available" - else - call <SID>FindOrCreateBuffer(bestFile, a:splitWindow, 1) - let b:AlternateAllFiles = allfiles - endif - else - echo "No alternate file/buffer available" - endif - endif -endfunction - -" Function : AlternateOpenFileUnderCursor (PUBLIC) -" Purpose : Opens file under the cursor -" Args : splitWindow -- indicates how to open the file -" Returns : Nothing -" Author : Michael Sharpe (feline@irendi.com) www.irendi.com -function! AlternateOpenFileUnderCursor(splitWindow,...) - let cursorFile = (a:0 > 0) ? a:1 : expand("<cfile>") - let currentPath = expand("%:p:h") - let openCount = 1 - - let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, openCount) - if (fileName != "") - call <SID>FindOrCreateBuffer(fileName, a:splitWindow, 1) - let b:openCount = openCount - let b:cursorFile = cursorFile - let b:currentPath = currentPath - else - echo "Can't find file" - endif -endfunction - -" Function : AlternateOpenNextFile (PUBLIC) -" Purpose : Opens the next file corresponding to the search which found the -" current file -" Args : bang -- indicates what to do if the current file has not been -" saved -" Returns : nothing -" Author : Michael Sharpe (feline@irendi.com) www.irendi.com -function! AlternateOpenNextFile(bang) - let cursorFile = "" - if (exists("b:cursorFile")) - let cursorFile = b:cursorFile - endif - - let currentPath = "" - if (exists("b:currentPath")) - let currentPath = b:currentPath - endif - - let openCount = 0 - if (exists("b:openCount")) - let openCount = b:openCount + 1 - endif - - if (cursorFile != "" && currentPath != "" && openCount != 0) - let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, openCount) - if (fileName != "") - call <SID>FindOrCreateBuffer(fileName, "n".a:bang, 0) - let b:openCount = openCount - let b:cursorFile = cursorFile - let b:currentPath = currentPath - else - let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, 1) - if (fileName != "") - call <SID>FindOrCreateBuffer(fileName, "n".a:bang, 0) - let b:openCount = 1 - let b:cursorFile = cursorFile - let b:currentPath = currentPath - else - echo "Can't find next file" - endif - endif - endif -endfunction - -comm! -nargs=? -bang IH call AlternateOpenFileUnderCursor("n<bang>", <f-args>) -comm! -nargs=? -bang IHS call AlternateOpenFileUnderCursor("h<bang>", <f-args>) -comm! -nargs=? -bang IHV call AlternateOpenFileUnderCursor("v<bang>", <f-args>) -comm! -nargs=? -bang IHT call AlternateOpenFileUnderCursor("t<bang>", <f-args>) -comm! -nargs=? -bang IHN call AlternateOpenNextFile("<bang>") -"imap <Leader>ih <ESC>:IHS<CR> -nmap <Leader>ih :IHS<CR> -"imap <Leader>is <ESC>:IHS<CR>:A<CR> -nmap <Leader>is :IHS<CR>:A<CR> -"imap <Leader>ihn <ESC>:IHN<CR> -nmap <Leader>ihn :IHN<CR> - -"function! <SID>PrintList(theList) -" let n = 1 -" let oneFile = <SID>GetNthItemFromList(a:theList, n) -" while (oneFile != "") -" let n = n + 1 -" let oneFile = <SID>GetNthItemFromList(a:theList, n) -" endwhile -"endfunction - -" Function : NextAlternate (PUBLIC) -" Purpose : Used to cycle through any other alternate file which existed on -" the search path. -" Args : bang (IN) - used to implement the AN vs AN! functionality -" Returns : nothing -" Author : Michael Sharpe <feline@irendi.com> -function! NextAlternate(bang) - if (exists('b:AlternateAllFiles')) - let currentFile = expand("%") - let n = 1 - let onefile = <SID>GetNthItemFromList(b:AlternateAllFiles, n) - while (onefile != "" && !<SID>EqualFilePaths(fnamemodify(onefile,":p"), fnamemodify(currentFile,":p"))) - let n = n + 1 - let onefile = <SID>GetNthItemFromList(b:AlternateAllFiles, n) - endwhile - - if (onefile != "") - let stop = n - let n = n + 1 - let foundAlternate = 0 - let nextAlternate = "" - while (n != stop) - let nextAlternate = <SID>GetNthItemFromList(b:AlternateAllFiles, n) - if (nextAlternate == "") - let n = 1 - continue - endif - let n = n + 1 - if (<SID>EqualFilePaths(fnamemodify(nextAlternate, ":p"), fnamemodify(currentFile, ":p"))) - continue - endif - if (filereadable(nextAlternate)) - " on cygwin filereadable("foo.H") returns true if "foo.h" exists - if (has("unix") && $WINDIR != "" && fnamemodify(nextAlternate, ":p") ==? fnamemodify(currentFile, ":p")) - continue - endif - let foundAlternate = 1 - break - endif - endwhile - if (foundAlternate == 1) - let s:AlternateAllFiles = b:AlternateAllFiles - "silent! execute ":e".a:bang." " . nextAlternate - call <SID>FindOrCreateBuffer(nextAlternate, "n".a:bang, 0) - let b:AlternateAllFiles = s:AlternateAllFiles - else - echo "Only this alternate file exists" - endif - else - echo "Could not find current file in alternates list" - endif - else - echo "No other alternate files exist" - endif -endfunction - -comm! -nargs=? -bang A call AlternateFile("n<bang>", <f-args>) -comm! -nargs=? -bang AS call AlternateFile("h<bang>", <f-args>) -comm! -nargs=? -bang AV call AlternateFile("v<bang>", <f-args>) -comm! -nargs=? -bang AT call AlternateFile("t<bang>", <f-args>) -comm! -nargs=? -bang AN call NextAlternate("<bang>") - -" Function : BufferOrFileExists (PRIVATE) -" Purpose : determines if a buffer or a readable file exists -" Args : fileName (IN) - name of the file to check -" Returns : 2 if it exists in memory, 1 if it exists, 0 otherwise -" Author : Michael Sharpe <feline@irendi.com> -" History : Updated code to handle buffernames using just the -" filename and not the path. -function! <SID>BufferOrFileExists(fileName) - let result = 0 - - let lastBuffer = bufnr("$") - let i = 1 - while i <= lastBuffer - if <SID>EqualFilePaths(expand("#".i.":p"), a:fileName) - let result = 2 - break - endif - let i = i + 1 - endwhile - - if (!result) - let bufName = fnamemodify(a:fileName,":t") - let memBufName = bufname(bufName) - if (memBufName != "") - let memBufBasename = fnamemodify(memBufName, ":t") - if (bufName == memBufBasename) - let result = 2 - endif - endif - - if (!result) - let result = bufexists(bufName) || bufexists(a:fileName) || filereadable(a:fileName) - endif - endif - - if (!result) - let result = filereadable(a:fileName) - endif - return result -endfunction - -" Function : FindOrCreateBuffer (PRIVATE) -" Purpose : searches the buffer list (:ls) for the specified filename. If -" found, checks the window list for the buffer. If the buffer is in -" an already open window, it switches to the window. If the buffer -" was not in a window, it switches to that buffer. If the buffer did -" not exist, it creates it. -" Args : filename (IN) -- the name of the file -" doSplit (IN) -- indicates whether the window should be split -" ("v", "h", "n", "v!", "h!", "n!", "t", "t!") -" findSimilar (IN) -- indicate weather existing buffers should be -" prefered -" Returns : nothing -" Author : Michael Sharpe <feline@irendi.com> -" History : + bufname() was not working very well with the possibly strange -" paths that can abound with the search path so updated this -" slightly. -- Bindu -" + updated window switching code to make it more efficient -- Bindu -" Allow ! to be applied to buffer/split/editing commands for more -" vim/vi like consistency -" + implemented fix from Matt Perry -function! <SID>FindOrCreateBuffer(fileName, doSplit, findSimilar) - " Check to see if the buffer is already open before re-opening it. - let FILENAME = escape(a:fileName, ' ') - let bufNr = -1 - let lastBuffer = bufnr("$") - let i = 1 - if (a:findSimilar) - while i <= lastBuffer - if <SID>EqualFilePaths(expand("#".i.":p"), a:fileName) - let bufNr = i - break - endif - let i = i + 1 - endwhile - - if (bufNr == -1) - let bufName = bufname(a:fileName) - let bufFilename = fnamemodify(a:fileName,":t") - - if (bufName == "") - let bufName = bufname(bufFilename) - endif - - if (bufName != "") - let tail = fnamemodify(bufName, ":t") - if (tail != bufFilename) - let bufName = "" - endif - endif - if (bufName != "") - let bufNr = bufnr(bufName) - let FILENAME = bufName - endif - endif - endif - - if (g:alternateRelativeFiles == 1) - let FILENAME = fnamemodify(FILENAME, ":p:.") - endif - - let splitType = a:doSplit[0] - let bang = a:doSplit[1] - if (bufNr == -1) - " Buffer did not exist....create it - let v:errmsg="" - if (splitType == "h") - silent! execute ":split".bang." " . FILENAME - elseif (splitType == "v") - silent! execute ":vsplit".bang." " . FILENAME - elseif (splitType == "t") - silent! execute ":tab split".bang." " . FILENAME - else - silent! execute ":e".bang." " . FILENAME - endif - if (v:errmsg != "") - echo v:errmsg - endif - else - - " Find the correct tab corresponding to the existing buffer - let tabNr = -1 - " iterate tab pages - for i in range(tabpagenr('$')) - " get the list of buffers in the tab - let tabList = tabpagebuflist(i + 1) - let idx = 0 - " iterate each buffer in the list - while idx < len(tabList) - " if it matches the buffer we are looking for... - if (tabList[idx] == bufNr) - " ... save the number - let tabNr = i + 1 - break - endif - let idx = idx + 1 - endwhile - if (tabNr != -1) - break - endif - endfor - " switch the the tab containing the buffer - if (tabNr != -1) - execute "tabn ".tabNr - endif - - " Buffer was already open......check to see if it is in a window - let bufWindow = bufwinnr(bufNr) - if (bufWindow == -1) - " Buffer was not in a window so open one - let v:errmsg="" - if (splitType == "h") - silent! execute ":sbuffer".bang." " . FILENAME - elseif (splitType == "v") - silent! execute ":vert sbuffer " . FILENAME - elseif (splitType == "t") - silent! execute ":tab sbuffer " . FILENAME - else - silent! execute ":buffer".bang." " . FILENAME - endif - if (v:errmsg != "") - echo v:errmsg - endif - else - " Buffer is already in a window so switch to the window - execute bufWindow."wincmd w" - if (bufWindow != winnr()) - " something wierd happened...open the buffer - let v:errmsg="" - if (splitType == "h") - silent! execute ":split".bang." " . FILENAME - elseif (splitType == "v") - silent! execute ":vsplit".bang." " . FILENAME - elseif (splitType == "t") - silent! execute ":tab split".bang." " . FILENAME - else - silent! execute ":e".bang." " . FILENAME - endif - if (v:errmsg != "") - echo v:errmsg - endif - endif - endif - endif -endfunction - -" Function : EqualFilePaths (PRIVATE) -" Purpose : Compares two paths. Do simple string comparison anywhere but on -" Windows. On Windows take into account that file paths could differ -" in usage of separators and the fact that case does not matter. -" "c:\WINDOWS" is the same path as "c:/windows". has("win32unix") Vim -" version does not count as one having Windows path rules. -" Args : path1 (IN) -- first path -" path2 (IN) -- second path -" Returns : 1 if path1 is equal to path2, 0 otherwise. -" Author : Ilya Bobir <ilya@po4ta.com> -function! <SID>EqualFilePaths(path1, path2) - if has("win16") || has("win32") || has("win64") || has("win95") - return substitute(a:path1, "\/", "\\", "g") ==? substitute(a:path2, "\/", "\\", "g") - else - return a:path1 == a:path2 - endif -endfunction diff --git a/.vim/plugin/autotag.vim b/.vim/plugin/autotag.vim deleted file mode 100644 index 8bb2d0e..0000000 --- a/.vim/plugin/autotag.vim +++ /dev/null @@ -1,150 +0,0 @@ -" This file supplies automatic tag regeneration when saving files -" There's a problem with ctags when run with -a (append) -" ctags doesn't remove entries for the supplied source file that no longer exist -" so this script (implemented in python) finds a tags file for the file vim has -" just saved, removes all entries for that source file and *then* runs ctags -a - -if has("python") - -python << EEOOFF -import os -import string -import os.path -import fileinput -import sys -import vim - -def echo(str): - str=str.replace('\\', '\\\\') - str=str.replace('"', "'") - vim.command("redraw | echo \"%s\"" % str) - -class AutoTag: - def __init__(self, excludesuffix="", ctags_cmd="ctags", verbose=0): - self.tags = {} - self.excludesuffix = [ "." + s for s in excludesuffix.split(".") ] - verbose = long(verbose) - if verbose > 0: - self.verbose = verbose - else: - self.verbose = 0 - self.sep_used_by_ctags = '/' - self.cwd = os.getcwd() - self.ctags_cmd = ctags_cmd - self.count = 0 - - def findTagFile(self, source): - ( drive, file ) = os.path.splitdrive(source) - while file: - file = os.path.dirname(file) - tagsFile = os.path.join(drive, file, "tags") - self.diag(2, "does %s exist?", tagsFile) - if os.path.isfile(tagsFile): - self.diag(2, "Found tags file %s", tagsFile) - return tagsFile - elif not file or file == os.sep or file == "//" or file == "\\\\": - self.diag(2, "exhausted search for tag file for %s", source) - return None - self.diag(2, "Nope. :-| %s does NOT exist", tagsFile) - return None - - def addSource(self, source): - if not source: - return - if os.path.splitext(source)[1] in self.excludesuffix: - self.diag(1, "Ignoring excluded file " + source) - return - tagsFile = self.findTagFile(source) - if tagsFile: - self.diag(2, "if tagsFile:") - relativeSource = source[len(os.path.dirname(tagsFile)):] - self.diag(2, "relativeSource = source[len(os.path.dirname(tagsFile)):]") - if relativeSource[0] == os.sep: - self.diag(2, "if relativeSource[0] == os.sep:") - relativeSource = relativeSource[1:] - self.diag(2, "relativeSource = relativeSource[1:]") - if os.sep != self.sep_used_by_ctags: - self.diag(2, "if os.sep != self.sep_used_by_ctags:") - relativeSource = string.replace(relativeSource, os.sep, self.sep_used_by_ctags) - self.diag(2, "relativeSource = string.replace(relativeSource, os.sep, self.sep_used_by_ctags)") - if self.tags.has_key(tagsFile): - self.diag(2, "if self.tags.has_key(tagsFile):") - self.tags[tagsFile].append(relativeSource) - self.diag(2, "self.tags[tagsFile].append(relativeSource)") - else: - self.diag(2, "else:") - self.tags[tagsFile] = [ relativeSource ] - self.diag(2, "self.tags[tagsFile] = [ relativeSource ]") - - def stripTags(self, tagsFile, sources): - self.diag(1, "Removing tags for %s from tags file %s", (sources, tagsFile)) - backup = ".SAFE" - for line in fileinput.input(files=tagsFile, inplace=True, backup=backup): - if line[-1:] == '\n': - line = line[:-1] - if line[-1:] == '\r': - line = line[:-1] - if line[0] == "!": - print line - else: - fields = string.split(line, "\t") - if len(fields) > 3: - found = False - for source in sources: - if fields[1] == source: - found = True - break - if not found: - print line - else: - print line - os.unlink(tagsFile + backup) - - def rebuildTagFiles(self): - for tagsFile in self.tags.keys(): - tagsDir = os.path.dirname(tagsFile) - sources = self.tags[tagsFile] - os.chdir(tagsDir) - self.stripTags(tagsFile, sources) - cmd = "%s -a " % self.ctags_cmd - for source in sources: - if os.path.isfile(source): - cmd += " '%s'" % source - self.diag(1, "%s: %s", (tagsDir, cmd)) - (ch_in, ch_out) = os.popen2(cmd) - for line in ch_out: - pass - os.chdir(self.cwd) - - def diag(self, level, msg, args = None): - if msg and args: - msg = msg % args - if level <= self.verbose: - echo(msg) -EEOOFF - -function! AutoTag() -python << EEOOFF -at = AutoTag(vim.eval("g:autotagExcludeSuffixes"), vim.eval("g:autotagCtagsCmd"), long(vim.eval("g:autotagVerbosityLevel"))) -at.addSource(vim.eval("expand(\"%:p\")")) -at.rebuildTagFiles() -EEOOFF -endfunction - -if !exists("g:autotagVerbosityLevel") - let g:autotagVerbosityLevel=0 -endif -if !exists("g:autotagExcludeSuffixes") - let g:autotagExcludeSuffixes="tml.xml" -endif -if !exists("g:autotagCtagsCmd") - let g:autotagCtagsCmd="ctags" -endif -if !exists("g:autotag_autocmd_set") - let g:autotag_autocmd_set=1 - autocmd BufWritePost,FileWritePost * call AutoTag () -endif - -endif " has("python") - -" vim:sw=3:ts=3 diff --git a/.vim/plugin/scmCloseParens.vim b/.vim/plugin/scmCloseParens.vim deleted file mode 100644 index 8aca684..0000000 --- a/.vim/plugin/scmCloseParens.vim +++ /dev/null @@ -1,58 +0,0 @@ -" Description: Simple script (hack ?) that closes opened parens -" Author: Adrien Pierard <pierarda#iro.umontreal.ca> -" Modified: 04/05/07 -" Version: 0.1 -" -" Usage: I mapped it to <Leader>p -" So, just go to normal mode, and type the shortcut, or :call -" RunScmCloseParens() yourself - - -let b:msg = "" -let b:bcpt = 0 - -function! SetCursorWhereItIsGoodToPutItEh() - let line = substitute(getline("."), "\\s\\+$", "", "") - call setline(line("."),line) - norm $ - let charUnderCursor = strpart(line("."), col(".") - 1, 1) - norm a) - call CountAsMuchAsPossible() -endfunction - -function! CountAsMuchAsPossible() - let cpt = 0 - while (CanWeGoOn() > 0) - let cpt = cpt + 1 - call OhGetBackAndSetAnotherOne() - endwhile - let line = substitute(getline("."), ")$", "", "") - call setline(line("."),line) - let b:cpt = cpt -endfunction - -function! CanWeGoOn() - return (searchpair('(', '', ')' , 'b' )) -endfunction - -function! OhGetBackAndSetAnotherOne() - call searchpair('(', '', ')') - norm a) - -endfunction - -function! InitScmCloseParens() - if ! exists("g:ScmCloseParens") - let g:ScmCloseParens = "Scheme on you !" - execute 'nmap <Leader>p :call RunScmCloseParens()<Cr>' - endif -endfunction - -fun! RunScmCloseParens() - let b:bcpt = 0 - call SetCursorWhereItIsGoodToPutItEh() - norm :echo b:bcpt -endfunction - -call InitScmCloseParens() - diff --git a/.vim/plugin/surround.vim b/.vim/plugin/surround.vim deleted file mode 100644 index ec00098..0000000 --- a/.vim/plugin/surround.vim +++ /dev/null @@ -1,727 +0,0 @@ -" surround.vim - Surroundings -" Maintainer: Tim Pope <vimNOSPAM@tpope.info> -" GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim -" $Id: surround.vim,v 1.16 2006/11/06 05:53:09 tpope Exp $ -" Help is below; it may be read here. Alternatively, after the plugin is -" installed and running, :call SurroundHelp() to install a proper help file. - -" *surround.txt* Plugin for deleting, changing, and adding "surroundings" -" -" Author: Tim Pope <vimNOSPAM@tpope.info> *surround-author* -" License: Same terms as Vim itself (see |license|) -" -" This plugin is only available if 'compatible' is not set. -" -" Introduction: *surround* -" -" This plugin is a tool for dealing with pairs of "surroundings." Examples -" of surroundings include parentheses, quotes, and HTML tags. They are -" closely related to what Vim refers to as |text-objects|. Provided -" are mappings to allow for removing, changing, and adding surroundings. -" -" Details follow on the exact semantics, but first, consider the following -" examples. An asterisk (*) is used to denote the cursor position. -" -" Old text Command New text ~ -" "Hello *world!" ds" Hello world! -" [123+4*56]/2 cs]) (123+456)/2 -" "Look ma, I'm *HTML!" cs"<q> <q>Look ma, I'm HTML!</q> -" if *x>3 { ysW( if ( x>3 ) { -" my $str = *whee!; vlllls' my $str = 'whee!'; -" -" While a few features of this plugin will work in older versions of Vim, -" Vim 7 is recommended for full functionality. -" -" Mappings: *surround-mappings* -" -" Delete surroundings is *ds*. The next character given determines the target -" to delete. The exact nature of the target are explained in -" |surround-targets| but essentially it is the last character of a -" |text-object|. This mapping deletes the difference between the "inner" -" object and "an" object. This is easiest to understand with some examples: -" -" Old text Command New text ~ -" "Hello *world!" ds" Hello world! -" (123+4*56)/2 ds) 123+456/2 -" <div>Yo!*</div> dst Yo! -" -" Change surroundings is *cs*. It takes two arguments, a target like with -" |ds|, and a replacement. Details about the second argument can be found -" below in |surround-replacements|. Once again, examples are in order. -" -" Old text Command New text ~ -" "Hello *world!" cs"' 'Hello world!' -" "Hello *world!" cs"<q> <q>Hello world!</q> -" (123+4*56)/2 cs)] [123+456]/2 -" (123+4*56)/2 cs)[ [ 123+456 ]/2 -" <div>Yo!*</div> cst<p> <p>Yo!</p> -" -" *ys* takes an valid Vim motion or text object as the first object, and wraps -" it using the second argument as with |cs|. (Unfortunately there's no good -" mnemonic for "ys"). -" -" Old text Command New text ~ -" Hello w*orld! ysiw) Hello (world)! -" -" As a special case, *yss* operates on the current line, ignoring leading -" whitespace. -" -" Old text Command New text ~ -" Hello w*orld! yssB {Hello world!} -" -" There is also *yS* and *ySS* which indent the surrounded text and place it -" on a line of its own. -" -" In visual mode, a simple "s" with an argument wraps the selection. This is -" referred to as the *vs* mapping, although ordinarily there will be -" additional keystrokes between the v and s. In linewise visual mode, the -" surroundings are placed on separate lines. In blockwise visual mode, each -" line is surrounded. -" -" An "S" in visual mode (*vS*) behaves similarly but always places the -" surroundings on separate lines. Additionally, the surrounded text is -" indented. In blockwise visual mode, using "S" instead of "s" instead skips -" trailing whitespace. -" -" Note that "s" and "S" already have valid meaning in visual mode, but it is -" identical to "c". If you have muscle memory for "s" and would like to use a -" different key, add your own mapping and the existing one will be disabled. -" > -" vmap <Leader>s <Plug>Vsurround -" vmap <Leader>S <Plug>VSurround -" < -" Finally, there is an experimental insert mode mapping on <C-S>. Beware that -" this won't work on terminals with flow control (if you accidentally freeze -" your terminal, use <C-Q> to unfreeze it). The mapping inserts the specified -" surroundings and puts the cursor between them. If, immediately after <C-S> -" and before the replacement, a second <C-S> or carriage return is pressed, -" the prefix, cursor, and suffix will be placed on three separate lines. If -" this is a common use case you can add a mapping for it as well. -" > -" imap <C-Z> <Plug>Isurround<CR> -" < -" Targets: *surround-targets* -" -" The |ds| and |cs| commands both take a target as their first argument. The -" possible targets are based closely on the |text-objects| provided by Vim. -" In order for a target to work, the corresponding text object must be -" supported in the version of Vim used (Vim 7 adds several text objects, and -" thus is highly recommended). All targets are currently just one character. -" -" Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves -" and their counterpart. If the opening mark is used, contained whitespace is -" also trimmed. The targets b, B, r, and a are aliases for ), }, ], and > -" (the first two mirror Vim; the second two are completely arbitrary and -" subject to change). -" -" Three quote marks, ', ", `, represent themselves, in pairs. They are only -" searched for on the current line. -" -" A t is a pair of HTML or XML tags. See |tag-blocks| for details. Remember -" that you can specify a numerical argument if you want to get to a tag other -" than the innermost one. -" -" The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|, -" respectively. These are special in that they have nothing do delete, and -" used with |ds| they are a no-op. With |cs|, one could consider them a -" slight shortcut for ysi (cswb == ysiwb, more or less). -" -" A p represents a |paragraph|. This behaves similarly to w, W, and s above; -" however, newlines are sometimes added and/or removed. -" -" Replacements: *surround-replacements* -" -" A replacement argument is a single character, and is required by |cs|, |ys|, -" and |vs|. Undefined replacement characters (with the exception of -" alphabetic characters) default to placing themselves at the beginning and -" end of the destination, which can be useful for characters like / and |. -" -" If either ), }, ], or > is used, the text is wrapped in the appropriate -" pair of characters. Similar behavior can be found with (, {, and [ (but not -" <), which append an additional space to the inside. Like with the targets -" above, b, B, r, and a are aliases for ), }, ], and >. -" -" If t or < is used, Vim prompts for an HTML/XML tag to insert. You may -" specify attributes here and they will be stripped from the closing tag. -" End your input by pressing <CR> or >. As an experimental feature, if , or -" <C-T> is used, the tags will appear on lines by themselves. -" -" An experimental replacement of a LaTeX environment is provided on \ and l. -" The name of the environment and any arguments will be input from a prompt. -" The following shows the resulting environment from csp\tabular}{lc<CR> -" > -" \begin{tabular}{lc} -" \end{tabular} -" < -" Customizing: *surround-customizing* -" -" The following adds a potential replacement on "-" (ASCII 45) in PHP files. -" (To determine the ASCII code to use, :echo char2nr("-")). The carriage -" return will be replaced by the original text. -" > -" autocmd FileType php let b:surround_45 = "<?php \r ?>" -" < -" This can be used in a PHP file as in the following example. -" -" Old text Command New text ~ -" print "Hello *world!" yss- <?php print "Hello world!" ?> -" -" Additionally, one can use a global variable for globally available -" replacements. -" > -" let g:surround_45 = "<% \r %>" -" let g:surround_61 = "<%= \r %>" -" < -" Issues: *surround-issues* -" -" Vim could potentially get confused when deleting/changing occurs at the very -" end of the line. Please report any repeatable instances of this. -" -" Do we need to use |inputsave()|/|inputrestore()| with the tag replacement? -" -" Customization isn't very flexible. Need a system that allows for prompting, -" like with HTML tags and LaTeX environments. -" -" Indenting is handled haphazardly. Need to decide the most appropriate -" behavior and implement it. Right now one can do :let b:surround_indent = 1 -" (or the global equivalent) to enable automatic re-indenting by Vim via |=|; -" should this be the default? -" -" It would be nice if |.| would work to repeat an operation. - -" ============================================================================ - -" Exit quickly when: -" - this plugin was already loaded (or disabled) -" - when 'compatible' is set -if (exists("g:loaded_surround") && g:loaded_surround) || &cp - finish -endif -let g:loaded_surround = 1 - -let s:cpo_save = &cpo -set cpo&vim - -function! SurroundHelp() " {{{1 - if !isdirectory(s:dir."/doc/") && exists("*mkdir") - call mkdir(s:dir."/doc/") - endif - let old_hidden = &hidden - let old_cpo = &cpo - set hidden - set cpo&vim - exe "split ".fnamemodify(s:dir."/doc/surround.txt",":~") - setlocal noai modifiable noreadonly - %d_ - exe "0r ".fnamemodify(s:file,":~") - norm "_d}}"_dG - a - vim:tw=78:ts=8:ft=help:norl: -. - 1d_ - %s/^" \=// - silent! %s/^\(\u\l\+\):\(\s\+\*\)/\U\1 \2/ - setlocal noreadonly - write - bwipe! - let &hidden = old_hidden - let &cpo = old_cpo - exe "helptags ".fnamemodify(s:dir."/doc",":~") - help surround -endfunction -let s:file = expand("<sfile>:p") -let s:dir = expand("<sfile>:p:h:h") " }}}1 - -" Input functions {{{1 - -function! s:getchar() - let c = getchar() - if c =~ '^\d\+$' - let c = nr2char(c) - endif - return c -endfunction - -function! s:inputtarget() - let c = s:getchar() - while c =~ '^\d\+$' - let c = c . s:getchar() - endwhile - if c == " " - let c = c . s:getchar() - endif - if c =~ "\<Esc>\|\<C-C>\|\0" - return "" - else - return c - endif -endfunction - -function! s:inputreplacement() - "echo '-- SURROUND --' - let c = s:getchar() - if c == " " - let c = c . s:getchar() - endif - if c =~ "\<Esc>" || c =~ "\<C-C>" - return "" - else - return c - endif -endfunction - -function! s:beep() - exe "norm! \<Esc>" - return "" -endfunction - -function! s:redraw() - redraw - return "" -endfunction - -" }}}1 - -" Wrapping functions {{{1 - -function! s:extractbefore(str) - if a:str =~ '\r' - return matchstr(a:str,'.*\ze\r') - else - return matchstr(a:str,'.*\ze\n') - endif -endfunction - -function! s:extractafter(str) - if a:str =~ '\r' - return matchstr(a:str,'\r\zs.*') - else - return matchstr(a:str,'\n\zs.*') - endif -endfunction - -function! s:repeat(str,count) - let cnt = a:count - let str = "" - while cnt > 0 - let str = str . a:str - let cnt = cnt - 1 - endwhile - return str -endfunction - -function! s:fixindent(str,spc) - let str = substitute(a:str,'\t',s:repeat(' ',&sw),'g') - let spc = substitute(a:spc,'\t',s:repeat(' ',&sw),'g') - let str = substitute(str,'\(\n\|\%^\).\@=','\1'.spc,'g') - if ! &et - let str = substitute(str,'\s\{'.&ts.'\}',"\t",'g') - endif - return str -endfunction - -function! s:wrap(string,char,type,...) - let keeper = a:string - let newchar = a:char - let type = a:type - let linemode = type ==# 'V' ? 1 : 0 - let special = a:0 ? a:1 : 0 - let before = "" - let after = "" - if type == "V" - let initspaces = matchstr(keeper,'\%^\s*') - else - let initspaces = matchstr(getline('.'),'\%^\s*') - endif - " Duplicate b's are just placeholders (removed) - let pairs = "b()B{}r[]a<>" - let extraspace = "" - if newchar =~ '^ ' - let newchar = strpart(newchar,1) - let extraspace = ' ' - endif - let idx = stridx(pairs,newchar) - if exists("b:surround_".char2nr(newchar)) - let before = s:extractbefore(b:surround_{char2nr(newchar)}) - let after = s:extractafter(b:surround_{char2nr(newchar)}) - elseif exists("g:surround_".char2nr(newchar)) - let before = s:extractbefore(g:surround_{char2nr(newchar)}) - let after = s:extractafter(g:surround_{char2nr(newchar)}) - elseif newchar ==# "p" - let before = "\n" - let after = "\n\n" - elseif newchar =~# "[tT\<C-T><,]" - "let dounmapr = 0 - let dounmapb = 0 - "if !mapcheck("<CR>","c") - "let dounmapr = 1 - "cnoremap <CR> ><CR> - "endif - if !mapcheck(">","c") - let dounmapb= 1 - cnoremap > ><CR> - endif - let default = "" - if newchar ==# "T" - if !exists("s:lastdel") - let s:lastdel = "" - endif - let default = matchstr(s:lastdel,'<\zs.\{-\}\ze>') - endif - let tag = input("<",default) - echo "<".substitute(tag,'>*$','>','') - "if dounmapr - "silent! cunmap <CR> - "endif - if dounmapb - silent! cunmap > - endif - if tag != "" - let tag = substitute(tag,'>*$','','') - let before = "<".tag.">" - let after = "</".substitute(tag," .*",'','').">" - if newchar == "\<C-T>" || newchar == "," - if type ==# "v" || type ==# "V" - let before = before . "\n\t" - endif - if type ==# "v" - let after = "\n". after - endif - endif - endif - elseif newchar ==# 'l' || newchar == '\' - " LaTeX - let env = input('\begin{') - let env = '{' . env - let env = env . s:closematch(env) - echo '\begin'.env - if env != "" - let before = '\begin'.env - let after = '\end'.matchstr(env,'[^}]*').'}' - endif - "if type ==# 'v' || type ==# 'V' - "let before = before ."\n\t" - "endif - "if type ==# 'v' - "let after = "\n".initspaces.after - "endif - elseif newchar ==# 'f' || newchar ==# 'F' - let fnc = input('function: ') - if fnc != "" - let before = substitute(fnc,'($','','').'(' - let after = ')' - if newchar ==# 'F' - let before = before . ' ' - let after = ' ' . after - endif - endif - elseif idx >= 0 - let spc = (idx % 3) == 1 ? " " : "" - let idx = idx / 3 * 3 - let before = strpart(pairs,idx+1,1) . spc - let after = spc . strpart(pairs,idx+2,1) - elseif newchar !~ '\a' - let before = newchar - let after = newchar - else - let before = '' - let after = '' - endif - "let before = substitute(before,'\n','\n'.initspaces,'g') - let after = substitute(after ,'\n','\n'.initspaces,'g') - "let after = substitute(after,"\n\\s*\<C-U>\\s*",'\n','g') - if type ==# 'V' || (special && type ==# "v") - let before = substitute(before,' \+$','','') - let after = substitute(after ,'^ \+','','') - if after !~ '^\n' - let after = initspaces.after - endif - if keeper !~ '\n$' && after !~ '^\n' - let keeper = keeper . "\n" - endif - if before !~ '\n\s*$' - let before = before . "\n" - if special - let before = before . "\t" - endif - endif - endif - if type ==# 'V' - let before = initspaces.before - endif - if before =~ '\n\s*\%$' - if type ==# 'v' - let keeper = initspaces.keeper - endif - let padding = matchstr(before,'\n\zs\s\+\%$') - let before = substitute(before,'\n\s\+\%$','\n','') - let keeper = s:fixindent(keeper,padding) - endif - if type ==# 'V' - let keeper = before.keeper.after - elseif type =~ "^\<C-V>" - " Really we should be iterating over the buffer - let repl = substitute(before,'[\\~]','\\&','g').'\1'.substitute(after,'[\\~]','\\&','g') - let repl = substitute(repl,'\n',' ','g') - let keeper = substitute(keeper."\n",'\(.\{-\}\)\('.(special ? '\s\{-\}' : '').'\n\)',repl.'\n','g') - let keeper = substitute(keeper,'\n\%$','','') - else - let keeper = before.extraspace.keeper.extraspace.after - endif - return keeper -endfunction - -function! s:wrapreg(reg,char,...) - let orig = getreg(a:reg) - let type = substitute(getregtype(a:reg),'\d\+$','','') - let special = a:0 ? a:1 : 0 - let new = s:wrap(orig,a:char,type,special) - call setreg(a:reg,new,type) -endfunction -" }}}1 - -function! s:insert(...) " {{{1 - " Optional argument causes the result to appear on 3 lines, not 1 - "call inputsave() - let linemode = a:0 ? a:1 : 0 - let char = s:inputreplacement() - while char == "\<CR>" || char == "\<C-S>" - " TODO: use total count for additional blank lines - let linemode = linemode + 1 - let char = s:inputreplacement() - endwhile - "call inputrestore() - if char == "" - return "" - endif - "call inputsave() - let reg_save = @@ - call setreg('"',"\r",'v') - call s:wrapreg('"',char,linemode) - "if linemode - "call setreg('"',substitute(getreg('"'),'^\s\+','',''),'c') - "endif - if col('.') > col('$') - norm! p`] - else - norm! P`] - endif - call search('\r','bW') - let @@ = reg_save - return "\<Del>" -endfunction " }}}1 - -function! s:reindent() " {{{1 - if (exists("b:surround_indent") || exists("g:surround_indent")) - silent norm! '[='] - endif -endfunction " }}}1 - -function! s:dosurround(...) " {{{1 - let scount = v:count1 - let char = (a:0 ? a:1 : s:inputtarget()) - let spc = "" - if char =~ '^\d\+' - let scount = scount * matchstr(char,'^\d\+') - let char = substitute(char,'^\d\+','','') - endif - if char =~ '^ ' - let char = strpart(char,1) - let spc = 1 - endif - if char == 'a' - let char = '>' - endif - if char == 'r' - let char = ']' - endif - let newchar = "" - if a:0 > 1 - let newchar = a:2 - if newchar == "\<Esc>" || newchar == "\<C-C>" || newchar == "" - return s:beep() - endif - endif - let append = "" - let original = getreg('"') - let otype = getregtype('"') - call setreg('"',"") - exe "norm d".(scount==1 ? "": scount)."i".char - "exe "norm vi".char."d" - let keeper = getreg('"') - let okeeper = keeper " for reindent below - if keeper == "" - call setreg('"',original,otype) - return "" - endif - let oldline = getline('.') - let oldlnum = line('.') - if char ==# "p" - "let append = matchstr(keeper,'\n*\%$') - "let keeper = substitute(keeper,'\n*\%$','','') - call setreg('"','','V') - elseif char ==# "s" || char ==# "w" || char ==# "W" - " Do nothing - call setreg('"','') - elseif char =~ "[\"'`]" - exe "norm! i \<Esc>d2i".char - call setreg('"',substitute(getreg('"'),' ','','')) - else - exe "norm! da".char - endif - let removed = getreg('"') - let rem2 = substitute(removed,'\n.*','','') - let oldhead = strpart(oldline,0,strlen(oldline)-strlen(rem2)) - let oldtail = strpart(oldline, strlen(oldline)-strlen(rem2)) - let regtype = getregtype('"') - if char == 'p' - let regtype = "V" - endif - if char =~# '[\[({<T]' || spc - let keeper = substitute(keeper,'^\s\+','','') - let keeper = substitute(keeper,'\s\+$','','') - endif - if col("']") == col("$") && col('.') + 1 == col('$') - "let keeper = substitute(keeper,'^\n\s*','','') - "let keeper = substitute(keeper,'\n\s*$','','') - if oldhead =~# '^\s*$' && a:0 < 2 - "let keeper = substitute(keeper,oldhead.'\%$','','') - let keeper = substitute(keeper,'\%^\n'.oldhead.'\(\s*.\{-\}\)\n\s*\%$','\1','') - endif - let pcmd = "p" - else - if oldhead == "" && a:0 < 2 - "let keeper = substitute(keeper,'\%^\n\(.*\)\n\%$','\1','') - endif - let pcmd = "P" - endif - if line('.') < oldlnum && regtype ==# "V" - let pcmd = "p" - endif - call setreg('"',keeper,regtype) - if newchar != "" - call s:wrapreg('"',newchar) - endif - silent exe "norm! ".pcmd.'`[' - if removed =~ '\n' || okeeper =~ '\n' || getreg('"') =~ '\n' - call s:reindent() - else - endif - if getline('.') =~ '^\s\+$' && keeper =~ '^\s*\n' - silent norm! cc - endif - call setreg('"',removed,regtype) - let s:lastdel = removed -endfunction " }}}1 - -function! s:changesurround() " {{{1 - let a = s:inputtarget() - if a == "" - return s:beep() - endif - let b = s:inputreplacement() - if b == "" - return s:beep() - endif - call s:dosurround(a,b) -endfunction " }}}1 - -function! s:opfunc(type,...) " {{{1 - let char = s:inputreplacement() - if char == "" - return s:beep() - endif - let reg = '"' - let sel_save = &selection - let &selection = "inclusive" - let reg_save = getreg(reg) - let reg_type = getregtype(reg) - let type = a:type - if a:type == "char" - silent exe 'norm! `[v`]"'.reg."y" - let type = 'v' - elseif a:type == "line" - silent exe 'norm! `[V`]"'.reg."y" - let type = 'V' - elseif a:type ==# "v" || a:type ==# "V" || a:type ==# "\<C-V>" - silent exe 'norm! gv"'.reg."y" - elseif a:type =~ '^\d\+$' - silent exe 'norm! ^v'.a:type.'$h"'.reg.'y' - else - let &selection = sel_save - return s:beep() - endif - let keeper = getreg(reg) - if type == "v" - let append = matchstr(keeper,'\s*$') - let keeper = substitute(keeper,'\s*$','','') - endif - call setreg(reg,keeper,type) - call s:wrapreg(reg,char,a:0) - if type == "v" && append != "" - call setreg(reg,append,"ac") - endif - silent exe 'norm! gv'.(reg == '"' ? '' : '"' . reg).'p`[' - if type == 'V' || (getreg(reg) =~ '\n' && type == 'v') - call s:reindent() - endif - call setreg(reg,reg_save,reg_type) - let &selection = sel_save -endfunction - -function! s:opfunc2(arg) - call s:opfunc(a:arg,1) -endfunction " }}}1 - -function! s:closematch(str) " {{{1 - " Close an open (, {, [, or < on the command line. - let tail = matchstr(a:str,'.[^\[\](){}<>]*$') - if tail =~ '^\[.\+' - return "]" - elseif tail =~ '^(.\+' - return ")" - elseif tail =~ '^{.\+' - return "}" - elseif tail =~ '^<.+' - return ">" - else - return "" - endif -endfunction " }}}1 - -nnoremap <silent> <Plug>Dsurround :<C-U>call <SID>dosurround(<SID>inputtarget())<CR> -nnoremap <silent> <Plug>Csurround :<C-U>call <SID>changesurround()<CR> -nnoremap <silent> <Plug>Yssurround :<C-U>call <SID>opfunc(v:count1)<CR> -nnoremap <silent> <Plug>YSsurround :<C-U>call <SID>opfunc2(v:count1)<CR> -" <C-U> discards the numerical argument but there's not much we can do with it -nnoremap <silent> <Plug>Ysurround :<C-U>set opfunc=<SID>opfunc<CR>g@ -nnoremap <silent> <Plug>YSurround :<C-U>set opfunc=<SID>opfunc2<CR>g@ -vnoremap <silent> <Plug>Vsurround :<C-U>call <SID>opfunc(visualmode())<CR> -vnoremap <silent> <Plug>VSurround :<C-U>call <SID>opfunc2(visualmode())<CR> -inoremap <silent> <Plug>Isurround <C-R>=<SID>insert()<CR> -inoremap <silent> <Plug>ISurround <C-R>=<SID>insert(1)<CR> - -if !exists("g:surround_no_mappings") || ! g:surround_no_mappings - nmap ds <Plug>Dsurround - nmap cs <Plug>Csurround - nmap ys <Plug>Ysurround - nmap yS <Plug>YSurround - nmap yss <Plug>Yssurround - nmap ySs <Plug>YSsurround - nmap ySS <Plug>YSsurround - if !hasmapto("<Plug>Vsurround","v") - vmap s <Plug>Vsurround - endif - if !hasmapto("<Plug>VSurround","v") - vmap S <Plug>VSurround - endif - if !hasmapto("<Plug>Isurround","i") && !mapcheck("<C-S>","i") - imap <C-S> <Plug>Isurround - endif - "Implemented internally instead - "imap <C-S><C-S> <Plug>ISurround -endif - -let &cpo = s:cpo_save - -" vim:set ft=vim sw=4 sts=4 et: diff --git a/.vim/plugin/tEchoPair.vim b/.vim/plugin/tEchoPair.vim deleted file mode 100644 index b1f3c19..0000000 --- a/.vim/plugin/tEchoPair.vim +++ /dev/null @@ -1,369 +0,0 @@ -" tEchoPair.vim -" @Author: Thomas Link (mailto:samul AT web de?subject=vim-tEchoPair) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-03-24. -" @Last Change: 2007-03-27. -" @Revision: 0.1.175 - -if &cp || exists("loaded_techopair") - finish -endif -let loaded_techopair = 1 - -" if !exists('g:tEchoPairStyle') | let g:tEchoPairStyle = 'inner' | endif -if !exists('g:tEchoPairStyle') | let g:tEchoPairStyle = 'indicate' | endif -if !exists('g:tEchoPairInstall') | let g:tEchoPairInstall = [] | endif - -if !exists('g:tEchoPairIndicateOpen') | let g:tEchoPairIndicateOpen = ' <<<&' | endif -if !exists('g:tEchoPairIndicateClose') | let g:tEchoPairIndicateClose = '&>>> ' | endif -if !exists('g:tEchoPairIndicateCursor') | let g:tEchoPairIndicateCursor = ' <<<&>>> ' | endif - -if !exists('g:tEchoPairs') - " \ 'viki': [ - " \ 'fold;-1', - " \ ], - let g:tEchoPairs = { - \ 'ruby': [ - \ ['(', ')'], - \ ['{', '}'], - \ ['[', ']'], - \ ['\<\(module\|class\|def\|begin\|do\|if\|unless\)\>', '', '\<end\>', 'TEchoSkipRuby()'], - \ ], - \ 'vim': [ - \ ['(', ')'], - \ ['{', '}'], - \ ['[', ']'], - \ ['\<for\>', '\<endfor\?\>'], - \ ['\<wh\(i\(l\(e\)\?\)\?\)\?\>', '\<endw\(h\(i\(l\(e\)\?\)\?\)\?\)\?\>'], - \ ['\<if\>', '\<end\(i\(f\)\?\)\?\>'], - \ ['\<try\>', '\<endt\(r\(y\)\?\)\?\>'], - \ ['\<fu\(n\(c\(tion\)\?\)\?\)\?\>', '\<endf\(u\(n\(c\(tion\)\?\)\?\)\?\)\?\>'], - \ ] - \ } -endif - -if !exists('g:tEchoPairStyle_inner') - let g:tEchoPairStyle_inner = ['lisp', 'scheme'] -endif - -if !exists('g:tEchoPairStyle_indicate') - let g:tEchoPairStyle_indicate = [] -endif - -if !exists('g:tEchoPairStyles') -endif - -let s:tEchoPairStyles = [] - -fun! TEchoCollectStyles() - redir => vars - silent let - redir END - let s:tEchoPairStyles = split(vars, '\n') - call filter(s:tEchoPairStyles, 'v:val =~ ''^tEchoPairStyle_''') - call map(s:tEchoPairStyles, 'matchstr(v:val, ''^tEchoPairStyle_\zs\S\+'')') -endf - -" fun! TEchoPair(backwards, type, ?what, ?[args]) -fun! TEchoPair(backwards, type, ...) - let lz = &lazyredraw - set lazyredraw - try - let w0 = line('w0') - let l0 = line('.') - let c0 = col('.') - " let c0 = col['.'] - let pos = getpos('.') - let what = a:0 >= 1 ? a:1 : '.' - if a:type == 'rx' - let args0 = a:0 >= 2 ? a:2 : [] - let args = [] - " call add(args, '\V'. escape(get(args0, 0, '('), '\')) - call add(args, '\V'. get(args0, 0, '(')) - " let m = escape(get(args0, 1, ''), '\') - let m = get(args0, 1, '') - call add(args, empty(m) ? m : '\V'.m) - " call add(args, '\V'. escape(get(args0, 2, ')'), '\')) - call add(args, '\V'. get(args0, 2, ')')) - call add(args, a:backwards ? 'bW' : 'W') - let args += args0[3:-1] - echom "DBG searchpairs: ". string(args) - " echom "DBG TEchoPair: ". string(args) - let what = a:backwards ? args[0] : args[2] - let this = a:backwards ? args[2] : args[0] - " echom 'DBG '. what .' '. a:backwards .' '. expand('<cword>') .' '. (expand('<cword>')=~ '\V\^'. what .'\$') - if a:backwards - if expand('<cword>') =~ '\V\^'. this .'\$' - call search('\V'. this, 'cb', l0) - endif - else - if expand('<cword>') =~ '\V\^'. this .'\$' - call search('\V'. this, 'c', l0) - endif - endif - call call('searchpair', args) - elseif a:type =~ '^fold' - let fold_args = split(a:type, ';') - if a:backwards - call s:Normal('[z', 'silent!') - else - call s:Normal(']z', 'silent!') - endif - let lineshift = get(fold_args, a:backwards ? 1 : 2, 0) - if lineshift > 0 - call s:Normal(lineshift .'j', 'silent!') - elseif lineshift < 0 - call s:Normal((-lineshift) .'k', 'silent!') - endif - endif - " else - " if a:backwards - " exec 'norm! ['. a:what - " else - " exec 'norm! ]'. a:what - " endif - " endif - let l1 = line('.') - let c1 = col('.') - if l1 != l0 - if a:backwards - let c0 = col('$') - else - " let c0 = matchend(getline(l1), '^\s*') - 1 - let c0 = matchend(getline(l1), '^\s*') - endif - endif - let text = getline(l1) - if empty(s:tEchoPairStyles) - call TEchoCollectStyles() - endif - if exists('b:tEchoPairStyle') - let style = b:tEchoPairStyle - else - let style = g:tEchoPairStyle - for s in s:tEchoPairStyles - if index(g:tEchoPairStyle_{s}, &filetype) != -1 - let style = s - endif - endfor - endif - " if l1 < l0 || c1 < c0 - if a:backwards - let text = TEchoPair_open_{style}(what, text, c0, l0, c1, l1) - else - let text = TEchoPair_close_{style}(what, text, c0, l0, c1, l1) - endif - if &debug != '' - echo text . ' '. a:backwards .':'. c0.'x'.l0.'-'.c1.'x'.l1 - else - echo text - endif - let b:tEchoPair = text - call s:Normal(w0 .'zt') - call setpos('.', pos) - " return a:what - finally - let &lz = lz - endtry -endf - -fun! s:Normal(cmd, ...) - let p = a:0 >= 1 ? a:1 : '' - let m = mode() - if m ==? 's' || m == '' - exec p .' norm! '. a:cmd - else - exec p .'norm! '. a:cmd - endif -endf - -fun! TEchoPair_open_inner(what, text, c0, l0, c1, l1) - return strpart(a:text, a:c1 - 1, a:c0 - a:c1) -endf - -fun! TEchoPair_close_inner(what, text, c0, l0, c1, l1) - return strpart(a:text, a:c0, a:c1 - a:c0) -endf - -fun! TEchoPair_open_indicate(what, text, c0, l0, c1, l1) - let text = s:IndicateCursor(a:text, a:c0, a:l0, a:c1, a:l1) - " let text = a:l1.': '. substitute(text, '\V\%'. a:c1 .'c'. a:what, ' <<<&<<< ', '') - let text = a:l1.': '. substitute(text, '\V\%'. a:c1 .'c'. a:what, g:tEchoPairIndicateOpen, '') - let cmdh = s:GetCmdHeight() - if cmdh > 1 - let acc = [text] - for i in range(a:l1 + 1, a:l1 + cmdh - 1) - if i > a:l0 - break - endif - " call add(acc, i.': '. s:IndicateCursor(getline(i), a:c0, a:l0, a:c1, i)) - call add(acc, i.': '. getline(i)) - endfor - let text = join(acc, "\<c-j>") - endif - return text -endf - -fun! TEchoPair_close_indicate(what, text, c0, l0, c1, l1) - " let text = substitute(a:text, '\V\%'. a:c1 .'c'. a:what, ' >>>&>>> ', '') - let text = substitute(a:text, '\V\%'. a:c1 .'c'. a:what, g:tEchoPairIndicateClose, '') - let text = a:l1.': '. s:IndicateCursor(text, a:c0, a:l0, a:c1, a:l1) - let cmdh = s:GetCmdHeight() - if cmdh > 1 - let acc = [text] - for i in range(a:l1 - 1, a:l1 - cmdh + 1, -1) - if i < a:l0 - break - endif - " call insert(acc, i.': '. s:IndicateCursor(getline(i), a:c0, a:l0, a:c1, i)) - call insert(acc, i.': '. getline(i)) - endfor - let text = join(acc, "\<c-j>") - endif - return text -endf - -fun! s:IndicateCursor(text, c0, l0, c1, l1) - if a:l0 == a:l1 - return substitute(a:text, '\%'. a:c0 .'c.', g:tEchoPairIndicateCursor, '') - else - return a:text - endif -endf - -fun! s:GetCmdHeight() - let ch = &cmdheight - if mode() == 'i' && &showmode - let ch -= 1 - endif - return ch -endf - -fun! TEchoSkipRuby() - let n = synIDattr(synID(line('.'), col('.'), 1), 'name') - return (n =~ '^ruby\(Comment\|String\)$') -endf - -fun! TEchoPairReset() - augroup TEchoPair - au! - augroup END -endf -" call TEchoPairReset() - -fun! TEchoPairInstall(pattern, ...) - augroup TEchoPair - if a:0 >= 1 - let list = a:1 - elseif has_key(g:tEchoPairs, &filetype) - let list = g:tEchoPairs[&filetype] - else - " [a b] - " [['(', ')'], ['{', '}']] - let list = split(&matchpairs, ',') - call map(list, 'split(v:val, ":")') - endif - for i in list - if type(i) == 1 - if i =~ '^fold' - exec 'au CursorMoved '. a:pattern .' if foldclosed(line(".")) == -1 '. - \ ' | keepjumps call TEchoPair(1, '. string(i) .') | endif' - endif - elseif type(i) == 3 - if len(i) == 2 - let [io, ie] = i - call insert(i, '', 1) - let im = '' - else - let [io, im, ie; rest] = i - endif - if len(io) == 1 - let condo = 'getline(".")[col(".") - 1] == '. string(io) - else - " let condo = 'strpart(getline("."), col(".") - 1) =~ ''\V\^'''. string(io) - let condo = 'expand("<cword>") =~ ''\V\^'. io .'\$''' - endif - if len(ie) == 1 - let conde = 'getline(".")[col(".") - 1] == '. string(ie) - else - " let conde = 'strpart(getline("."), col(".") - 1) =~ ''\V\^'''. string(io) - let conde = 'expand("<cword>") =~ ''\V\^'. ie .'\$''' - endif - exec 'au CursorMoved '. a:pattern .' if '. condo . - \ ' | keepjumps call TEchoPair(0, "rx", '. string(ie) .', '. string(i) .') | endif' - exec 'au CursorMoved '. a:pattern .' if '. conde . - \ ' | keepjumps call TEchoPair(1, "rx", '. string(io) .', '. string(i) .') | endif' - exec 'au CursorMovedI '. a:pattern .' if '. condo . - \ ' | keepjumps call TEchoPair(0, "rx", '. string(ie) .', '. string(i) .') | endif' - exec 'au CursorMovedI '. a:pattern .' if '. conde . - \ ' | keepjumps call TEchoPair(1, "rx", '. string(io) .', '. string(i) .') | endif' - endif - endfor - augroup END -endf - -" command! TEchoPairInstallGlobal call TEchoPairInstall('*') -command! TEchoPairInstallBuffer call TEchoPairInstall(expand('%:p')) - -for ft in g:tEchoPairInstall - exec 'au Filetype '. ft .' TEchoPairInstallBuffer' -endfor - - -finish -____________________________________________________________________ - -tEchoPair.vim -- Display matching parenthesis in the echo area - - -VIM is an excellent editor but in comparison too e.g. emacs it lacks a -minor feature that makes editing lisp code somewhat cumbersome. While -VIM can highlight the matching parenthesis, this doesn't help much with -long functions when the matching parenthesis is off the screen. -Emacs users are better off in such a situation, since emace displays the -matching line in the echo area. - -This plugin tries to mimic Emacs's behaviour. - - -In order to enable this plugin, you choose between the following -options: - TEchoPairInstallBuffer ... enable for the current buffer - - call TEchoPairInstall('*') ... enable globally - - let g:tEchoPairInstall = ['lisp', 'scheme'] ... enable for certain - filetypes - - -Currently, there are the following display modes: - indicate ... Display the whole line and highlight the matching - parenthesis. If 'cmdheight' is greater than 1, additional lines - are display. - - inner ... Display the inner text Emacs-style. - -In order to see the matching parenthesis when 'showmode' is on, set -'cmdheight' to something greater than 1. - -You can select the preferred display mode on a filetype basis, by -setting g:tEchoPairStyle_{STYLE}. - -Example: - let g:tEchoPairStyle_inner = ['lisp', 'scheme'] - let g:tEchoPairStyle_indicate = ['java'] - - -The pairs are usually deduced from the value of 'matchpairs' unless -there is an entry for the current buffer's filetype in g:tEchoPairs. For -the following filetypes custom pairs are pre-defined: - - ruby - - vim - - -CHANGES - -0.1: -Initial release - diff --git a/.vim/plugin/taglist.vim b/.vim/plugin/taglist.vim deleted file mode 100644 index 59901f6..0000000 --- a/.vim/plugin/taglist.vim +++ /dev/null @@ -1,4546 +0,0 @@ -" File: taglist.vim -" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) -" Version: 4.5 -" Last Modified: September 21, 2007 -" Copyright: Copyright (C) 2002-2007 Yegappan Lakshmanan -" Permission is hereby granted to use and distribute this code, -" with or without modifications, provided that this copyright -" notice is copied with it. Like anything else that's free, -" taglist.vim is provided *as is* and comes with no warranty of any -" kind, either expressed or implied. In no event will the copyright -" holder be liable for any damamges resulting from the use of this -" software. -" -" The "Tag List" plugin is a source code browser plugin for Vim and provides -" an overview of the structure of the programming language files and allows -" you to efficiently browse through source code files for different -" programming languages. You can visit the taglist plugin home page for more -" information: -" -" http://vim-taglist.sourceforge.net -" -" You can subscribe to the taglist mailing list to post your questions -" or suggestions for improvement or to report bugs. Visit the following -" page for subscribing to the mailing list: -" -" http://groups.yahoo.com/group/taglist/ -" -" For more information about using this plugin, after installing the -" taglist plugin, use the ":help taglist" command. -" -" Installation -" ------------ -" 1. Download the taglist.zip file and unzip the files to the $HOME/.vim -" or the $HOME/vimfiles or the $VIM/vimfiles directory. This should -" unzip the following two files (the directory structure should be -" preserved): -" -" plugin/taglist.vim - main taglist plugin file -" doc/taglist.txt - documentation (help) file -" -" Refer to the 'add-plugin', 'add-global-plugin' and 'runtimepath' -" Vim help pages for more details about installing Vim plugins. -" 2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or -" $VIM/vimfiles/doc directory, start Vim and run the ":helptags ." -" command to process the taglist help file. -" 3. If the exuberant ctags utility is not present in your PATH, then set the -" Tlist_Ctags_Cmd variable to point to the location of the exuberant ctags -" utility (not to the directory) in the .vimrc file. -" 4. If you are running a terminal/console version of Vim and the -" terminal doesn't support changing the window width then set the -" 'Tlist_Inc_Winwidth' variable to 0 in the .vimrc file. -" 5. Restart Vim. -" 6. You can now use the ":TlistToggle" command to open/close the taglist -" window. You can use the ":help taglist" command to get more -" information about using the taglist plugin. -" -" ****************** Do not modify after this line ************************ - -" Line continuation used here -let s:cpo_save = &cpo -set cpo&vim - -if !exists('loaded_taglist') - " First time loading the taglist plugin - " - " To speed up the loading of Vim, the taglist plugin uses autoload - " mechanism to load the taglist functions. - " Only define the configuration variables, user commands and some - " auto-commands and finish sourcing the file - - " The taglist plugin requires the built-in Vim system() function. If this - " function is not available, then don't load the plugin. - if !exists('*system') - echomsg 'Taglist: Vim system() built-in function is not available. ' . - \ 'Plugin is not loaded.' - let loaded_taglist = 'no' - let &cpo = s:cpo_save - finish - endif - - " Location of the exuberant ctags tool - if !exists('Tlist_Ctags_Cmd') - if executable('exuberant-ctags') - " On Debian Linux, exuberant ctags is installed - " as exuberant-ctags - let Tlist_Ctags_Cmd = 'exuberant-ctags' - elseif executable('exctags') - " On Free-BSD, exuberant ctags is installed as exctags - let Tlist_Ctags_Cmd = 'exctags' - elseif executable('ctags') - let Tlist_Ctags_Cmd = 'ctags' - elseif executable('ctags.exe') - let Tlist_Ctags_Cmd = 'ctags.exe' - elseif executable('tags') - let Tlist_Ctags_Cmd = 'tags' - else - echomsg 'Taglist: Exuberant ctags (http://ctags.sf.net) ' . - \ 'not found in PATH. Plugin is not loaded.' - " Skip loading the plugin - let loaded_taglist = 'no' - let &cpo = s:cpo_save - finish - endif - endif - - - " Automatically open the taglist window on Vim startup - if !exists('Tlist_Auto_Open') - let Tlist_Auto_Open = 0 - endif - - " When the taglist window is toggle opened, move the cursor to the - " taglist window - if !exists('Tlist_GainFocus_On_ToggleOpen') - let Tlist_GainFocus_On_ToggleOpen = 0 - endif - - " Process files even when the taglist window is not open - if !exists('Tlist_Process_File_Always') - let Tlist_Process_File_Always = 0 - endif - - if !exists('Tlist_Show_Menu') - let Tlist_Show_Menu = 0 - endif - - " Tag listing sort type - 'name' or 'order' - if !exists('Tlist_Sort_Type') - let Tlist_Sort_Type = 'order' - endif - - " Tag listing window split (horizontal/vertical) control - if !exists('Tlist_Use_Horiz_Window') - let Tlist_Use_Horiz_Window = 0 - endif - - " Open the vertically split taglist window on the left or on the right - " side. This setting is relevant only if Tlist_Use_Horiz_Window is set to - " zero (i.e. only for vertically split windows) - if !exists('Tlist_Use_Right_Window') - let Tlist_Use_Right_Window = 0 - endif - - " Increase Vim window width to display vertically split taglist window. - " For MS-Windows version of Vim running in a MS-DOS window, this must be - " set to 0 otherwise the system may hang due to a Vim limitation. - if !exists('Tlist_Inc_Winwidth') - if (has('win16') || has('win95')) && !has('gui_running') - let Tlist_Inc_Winwidth = 0 - else - let Tlist_Inc_Winwidth = 1 - endif - endif - - " Vertically split taglist window width setting - if !exists('Tlist_WinWidth') - let Tlist_WinWidth = 30 - endif - - " Horizontally split taglist window height setting - if !exists('Tlist_WinHeight') - let Tlist_WinHeight = 10 - endif - - " Display tag prototypes or tag names in the taglist window - if !exists('Tlist_Display_Prototype') - let Tlist_Display_Prototype = 0 - endif - - " Display tag scopes in the taglist window - if !exists('Tlist_Display_Tag_Scope') - let Tlist_Display_Tag_Scope = 1 - endif - - " Use single left mouse click to jump to a tag. By default this is disabled. - " Only double click using the mouse will be processed. - if !exists('Tlist_Use_SingleClick') - let Tlist_Use_SingleClick = 0 - endif - - " Control whether additional help is displayed as part of the taglist or - " not. Also, controls whether empty lines are used to separate the tag - " tree. - if !exists('Tlist_Compact_Format') - let Tlist_Compact_Format = 0 - endif - - " Exit Vim if only the taglist window is currently open. By default, this is - " set to zero. - if !exists('Tlist_Exit_OnlyWindow') - let Tlist_Exit_OnlyWindow = 0 - endif - - " Automatically close the folds for the non-active files in the taglist - " window - if !exists('Tlist_File_Fold_Auto_Close') - let Tlist_File_Fold_Auto_Close = 0 - endif - - " Close the taglist window when a tag is selected - if !exists('Tlist_Close_On_Select') - let Tlist_Close_On_Select = 0 - endif - - " Automatically update the taglist window to display tags for newly - " edited files - if !exists('Tlist_Auto_Update') - let Tlist_Auto_Update = 1 - endif - - " Automatically highlight the current tag - if !exists('Tlist_Auto_Highlight_Tag') - let Tlist_Auto_Highlight_Tag = 1 - endif - - " Automatically highlight the current tag on entering a buffer - if !exists('Tlist_Highlight_Tag_On_BufEnter') - let Tlist_Highlight_Tag_On_BufEnter = 1 - endif - - " Enable fold column to display the folding for the tag tree - if !exists('Tlist_Enable_Fold_Column') - let Tlist_Enable_Fold_Column = 1 - endif - - " Display the tags for only one file in the taglist window - if !exists('Tlist_Show_One_File') - let Tlist_Show_One_File = 0 - endif - - if !exists('Tlist_Max_Submenu_Items') - let Tlist_Max_Submenu_Items = 20 - endif - - if !exists('Tlist_Max_Tag_Length') - let Tlist_Max_Tag_Length = 10 - endif - - " Do not change the name of the taglist title variable. The winmanager - " plugin relies on this name to determine the title for the taglist - " plugin. - let TagList_title = "__Tag_List__" - - " Taglist debug messages - let s:tlist_msg = '' - - " Define the taglist autocommand to automatically open the taglist window - " on Vim startup - if g:Tlist_Auto_Open - autocmd VimEnter * nested call s:Tlist_Window_Check_Auto_Open() - endif - - " Refresh the taglist - if g:Tlist_Process_File_Always - autocmd BufEnter * call s:Tlist_Refresh() - endif - - if g:Tlist_Show_Menu - autocmd GUIEnter * call s:Tlist_Menu_Init() - endif - - " When the taglist buffer is created when loading a Vim session file, - " the taglist buffer needs to be initialized. The BufFilePost event - " is used to handle this case. - autocmd BufFilePost __Tag_List__ call s:Tlist_Vim_Session_Load() - - " Define the user commands to manage the taglist window - command! -nargs=0 -bar TlistToggle call s:Tlist_Window_Toggle() - command! -nargs=0 -bar TlistOpen call s:Tlist_Window_Open() - " For backwards compatiblity define the Tlist command - command! -nargs=0 -bar Tlist TlistToggle - command! -nargs=+ -complete=file TlistAddFiles - \ call s:Tlist_Add_Files(<f-args>) - command! -nargs=+ -complete=dir TlistAddFilesRecursive - \ call s:Tlist_Add_Files_Recursive(<f-args>) - command! -nargs=0 -bar TlistClose call s:Tlist_Window_Close() - command! -nargs=0 -bar TlistUpdate call s:Tlist_Update_Current_File() - command! -nargs=0 -bar TlistHighlightTag call s:Tlist_Window_Highlight_Tag( - \ fnamemodify(bufname('%'), ':p'), line('.'), 2, 1) - " For backwards compatiblity define the TlistSync command - command! -nargs=0 -bar TlistSync TlistHighlightTag - command! -nargs=* -complete=buffer TlistShowPrototype - \ echo Tlist_Get_Tag_Prototype_By_Line(<f-args>) - command! -nargs=* -complete=buffer TlistShowTag - \ echo Tlist_Get_Tagname_By_Line(<f-args>) - command! -nargs=* -complete=file TlistSessionLoad - \ call s:Tlist_Session_Load(<q-args>) - command! -nargs=* -complete=file TlistSessionSave - \ call s:Tlist_Session_Save(<q-args>) - command! -bar TlistLock let Tlist_Auto_Update=0 - command! -bar TlistUnlock let Tlist_Auto_Update=1 - - " Commands for enabling/disabling debug and to display debug messages - command! -nargs=? -complete=file -bar TlistDebug - \ call s:Tlist_Debug_Enable(<q-args>) - command! -nargs=0 -bar TlistUndebug call s:Tlist_Debug_Disable() - command! -nargs=0 -bar TlistMessages call s:Tlist_Debug_Show() - - " Define autocommands to autoload the taglist plugin when needed. - - " Trick to get the current script ID - map <SID>xx <SID>xx - let s:tlist_sid = substitute(maparg('<SID>xx'), '<SNR>\(\d\+_\)xx$', - \ '\1', '') - unmap <SID>xx - - exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_* source ' . - \ escape(expand('<sfile>'), ' ') - exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Window_* source ' . - \ escape(expand('<sfile>'), ' ') - exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Menu_* source ' . - \ escape(expand('<sfile>'), ' ') - exe 'autocmd FuncUndefined Tlist_* source ' . - \ escape(expand('<sfile>'), ' ') - exe 'autocmd FuncUndefined TagList_* source ' . - \ escape(expand('<sfile>'), ' ') - - let loaded_taglist = 'fast_load_done' - - if g:Tlist_Show_Menu && has('gui_running') - call s:Tlist_Menu_Init() - endif - - " restore 'cpo' - let &cpo = s:cpo_save - finish -endif - -if !exists('s:tlist_sid') - " Two or more versions of taglist plugin are installed. Don't - " load this version of the plugin. - finish -endif - -unlet! s:tlist_sid - -if loaded_taglist != 'fast_load_done' - " restore 'cpo' - let &cpo = s:cpo_save - finish -endif - -" Taglist plugin functionality is available -let loaded_taglist = 'available' - -"------------------- end of user configurable options -------------------- - -" Default language specific settings for supported file types and tag types -" -" Variable name format: -" -" s:tlist_def_{vim_ftype}_settings -" -" vim_ftype - Filetype detected by Vim -" -" Value format: -" -" <ctags_ftype>;<flag>:<name>;<flag>:<name>;... -" -" ctags_ftype - File type supported by exuberant ctags -" flag - Flag supported by exuberant ctags to generate a tag type -" name - Name of the tag type used in the taglist window to display the -" tags of this type -" - -" assembly language -let s:tlist_def_asm_settings = 'asm;d:define;l:label;m:macro;t:type' - -" aspperl language -let s:tlist_def_aspperl_settings = 'asp;f:function;s:sub;v:variable' - -" aspvbs language -let s:tlist_def_aspvbs_settings = 'asp;f:function;s:sub;v:variable' - -" awk language -let s:tlist_def_awk_settings = 'awk;f:function' - -" beta language -let s:tlist_def_beta_settings = 'beta;f:fragment;s:slot;v:pattern' - -" c language -let s:tlist_def_c_settings = 'c;d:macro;g:enum;s:struct;u:union;t:typedef;' . - \ 'v:variable;f:function' - -" c++ language -let s:tlist_def_cpp_settings = 'c++;n:namespace;v:variable;d:macro;t:typedef;' . - \ 'c:class;g:enum;s:struct;u:union;f:function' - -" c# language -let s:tlist_def_cs_settings = 'c#;d:macro;t:typedef;n:namespace;c:class;' . - \ 'E:event;g:enum;s:struct;i:interface;' . - \ 'p:properties;m:method' - -" cobol language -let s:tlist_def_cobol_settings = 'cobol;d:data;f:file;g:group;p:paragraph;' . - \ 'P:program;s:section' - -" eiffel language -let s:tlist_def_eiffel_settings = 'eiffel;c:class;f:feature' - -" erlang language -let s:tlist_def_erlang_settings = 'erlang;d:macro;r:record;m:module;f:function' - -" expect (same as tcl) language -let s:tlist_def_expect_settings = 'tcl;c:class;f:method;p:procedure' - -" fortran language -let s:tlist_def_fortran_settings = 'fortran;p:program;b:block data;' . - \ 'c:common;e:entry;i:interface;k:type;l:label;m:module;' . - \ 'n:namelist;t:derived;v:variable;f:function;s:subroutine' - -" HTML language -let s:tlist_def_html_settings = 'html;a:anchor;f:javascript function' - -" java language -let s:tlist_def_java_settings = 'java;p:package;c:class;i:interface;' . - \ 'f:field;m:method' - -" javascript language -let s:tlist_def_javascript_settings = 'javascript;f:function' - -" lisp language -let s:tlist_def_lisp_settings = 'lisp;f:function' - -" lua language -let s:tlist_def_lua_settings = 'lua;f:function' - -" makefiles -let s:tlist_def_make_settings = 'make;m:macro' - -" pascal language -let s:tlist_def_pascal_settings = 'pascal;f:function;p:procedure' - -" perl language -let s:tlist_def_perl_settings = 'perl;c:constant;l:label;p:package;s:subroutine' - -" php language -let s:tlist_def_php_settings = 'php;c:class;d:constant;v:variable;f:function' - -" python language -let s:tlist_def_python_settings = 'python;c:class;m:member;f:function' - -" rexx language -let s:tlist_def_rexx_settings = 'rexx;s:subroutine' - -" ruby language -let s:tlist_def_ruby_settings = 'ruby;c:class;f:method;F:function;' . - \ 'm:singleton method' - -" scheme language -let s:tlist_def_scheme_settings = 'scheme;s:set;f:function' - -" shell language -let s:tlist_def_sh_settings = 'sh;f:function' - -" C shell language -let s:tlist_def_csh_settings = 'sh;f:function' - -" Z shell language -let s:tlist_def_zsh_settings = 'sh;f:function' - -" slang language -let s:tlist_def_slang_settings = 'slang;n:namespace;f:function' - -" sml language -let s:tlist_def_sml_settings = 'sml;e:exception;c:functor;s:signature;' . - \ 'r:structure;t:type;v:value;f:function' - -" sql language -let s:tlist_def_sql_settings = 'sql;c:cursor;F:field;P:package;r:record;' . - \ 's:subtype;t:table;T:trigger;v:variable;f:function;p:procedure' - -" tcl language -let s:tlist_def_tcl_settings = 'tcl;c:class;f:method;m:method;p:procedure' - -" vera language -let s:tlist_def_vera_settings = 'vera;c:class;d:macro;e:enumerator;' . - \ 'f:function;g:enum;m:member;p:program;' . - \ 'P:prototype;t:task;T:typedef;v:variable;' . - \ 'x:externvar' - -"verilog language -let s:tlist_def_verilog_settings = 'verilog;m:module;c:constant;P:parameter;' . - \ 'e:event;r:register;t:task;w:write;p:port;v:variable;f:function' - -" vim language -let s:tlist_def_vim_settings = 'vim;a:autocmds;v:variable;f:function' - -" yacc language -let s:tlist_def_yacc_settings = 'yacc;l:label' - -"------------------- end of language specific options -------------------- - -" Vim window size is changed by the taglist plugin or not -let s:tlist_winsize_chgd = -1 -" Taglist window is maximized or not -let s:tlist_win_maximized = 0 -" Name of files in the taglist -let s:tlist_file_names='' -" Number of files in the taglist -let s:tlist_file_count = 0 -" Number of filetypes supported by taglist -let s:tlist_ftype_count = 0 -" Is taglist part of other plugins like winmanager or cream? -let s:tlist_app_name = "none" -" Are we displaying brief help text -let s:tlist_brief_help = 1 -" List of files removed on user request -let s:tlist_removed_flist = "" -" Index of current file displayed in the taglist window -let s:tlist_cur_file_idx = -1 -" Taglist menu is empty or not -let s:tlist_menu_empty = 1 - -" An autocommand is used to refresh the taglist window when entering any -" buffer. We don't want to refresh the taglist window if we are entering the -" file window from one of the taglist functions. The 'Tlist_Skip_Refresh' -" variable is used to skip the refresh of the taglist window and is set -" and cleared appropriately. -let s:Tlist_Skip_Refresh = 0 - -" Tlist_Window_Display_Help() -function! s:Tlist_Window_Display_Help() - if s:tlist_app_name == "winmanager" - " To handle a bug in the winmanager plugin, add a space at the - " last line - call setline('$', ' ') - endif - - if s:tlist_brief_help - " Add the brief help - call append(0, '" Press <F1> to display help text') - else - " Add the extensive help - call append(0, '" <enter> : Jump to tag definition') - call append(1, '" o : Jump to tag definition in new window') - call append(2, '" p : Preview the tag definition') - call append(3, '" <space> : Display tag prototype') - call append(4, '" u : Update tag list') - call append(5, '" s : Select sort field') - call append(6, '" d : Remove file from taglist') - call append(7, '" x : Zoom-out/Zoom-in taglist window') - call append(8, '" + : Open a fold') - call append(9, '" - : Close a fold') - call append(10, '" * : Open all folds') - call append(11, '" = : Close all folds') - call append(12, '" [[ : Move to the start of previous file') - call append(13, '" ]] : Move to the start of next file') - call append(14, '" q : Close the taglist window') - call append(15, '" <F1> : Remove help text') - endif -endfunction - -" Tlist_Window_Toggle_Help_Text() -" Toggle taglist plugin help text between the full version and the brief -" version -function! s:Tlist_Window_Toggle_Help_Text() - if g:Tlist_Compact_Format - " In compact display mode, do not display help - return - endif - - " Include the empty line displayed after the help text - let brief_help_size = 1 - let full_help_size = 16 - - setlocal modifiable - - " Set report option to a huge value to prevent informational messages - " while deleting the lines - let old_report = &report - set report=99999 - - " Remove the currently highlighted tag. Otherwise, the help text - " might be highlighted by mistake - match none - - " Toggle between brief and full help text - if s:tlist_brief_help - let s:tlist_brief_help = 0 - - " Remove the previous help - exe '1,' . brief_help_size . ' delete _' - - " Adjust the start/end line numbers for the files - call s:Tlist_Window_Update_Line_Offsets(0, 1, full_help_size - brief_help_size) - else - let s:tlist_brief_help = 1 - - " Remove the previous help - exe '1,' . full_help_size . ' delete _' - - " Adjust the start/end line numbers for the files - call s:Tlist_Window_Update_Line_Offsets(0, 0, full_help_size - brief_help_size) - endif - - call s:Tlist_Window_Display_Help() - - " Restore the report option - let &report = old_report - - setlocal nomodifiable -endfunction - -" Taglist debug support -let s:tlist_debug = 0 - -" File for storing the debug messages -let s:tlist_debug_file = '' - -" Tlist_Debug_Enable -" Enable logging of taglist debug messages. -function! s:Tlist_Debug_Enable(...) - let s:tlist_debug = 1 - - " Check whether a valid file name is supplied. - if a:1 != '' - let s:tlist_debug_file = fnamemodify(a:1, ':p') - - " Empty the log file - exe 'redir! > ' . s:tlist_debug_file - redir END - - " Check whether the log file is present/created - if !filewritable(s:tlist_debug_file) - call s:Tlist_Warning_Msg('Taglist: Unable to create log file ' - \ . s:tlist_debug_file) - let s:tlist_debug_file = '' - endif - endif -endfunction - -" Tlist_Debug_Disable -" Disable logging of taglist debug messages. -function! s:Tlist_Debug_Disable(...) - let s:tlist_debug = 0 - let s:tlist_debug_file = '' -endfunction - -" Tlist_Debug_Show -" Display the taglist debug messages in a new window -function! s:Tlist_Debug_Show() - if s:tlist_msg == '' - call s:Tlist_Warning_Msg('Taglist: No debug messages') - return - endif - - " Open a new window to display the taglist debug messages - new taglist_debug.txt - " Delete all the lines (if the buffer already exists) - silent! %delete _ - " Add the messages - silent! put =s:tlist_msg - " Move the cursor to the first line - normal! gg -endfunction - -" Tlist_Log_Msg -" Log the supplied debug message along with the time -function! s:Tlist_Log_Msg(msg) - if s:tlist_debug - if s:tlist_debug_file != '' - exe 'redir >> ' . s:tlist_debug_file - silent echon strftime('%H:%M:%S') . ': ' . a:msg . "\n" - redir END - else - " Log the message into a variable - " Retain only the last 3000 characters - let len = strlen(s:tlist_msg) - if len > 3000 - let s:tlist_msg = strpart(s:tlist_msg, len - 3000) - endif - let s:tlist_msg = s:tlist_msg . strftime('%H:%M:%S') . ': ' . - \ a:msg . "\n" - endif - endif -endfunction - -" Tlist_Warning_Msg() -" Display a message using WarningMsg highlight group -function! s:Tlist_Warning_Msg(msg) - echohl WarningMsg - echomsg a:msg - echohl None -endfunction - -" Last returned file index for file name lookup. -" Used to speed up file lookup -let s:tlist_file_name_idx_cache = -1 - -" Tlist_Get_File_Index() -" Return the index of the specified filename -function! s:Tlist_Get_File_Index(fname) - if s:tlist_file_count == 0 || a:fname == '' - return -1 - endif - - " If the new filename is same as the last accessed filename, then - " return that index - if s:tlist_file_name_idx_cache != -1 && - \ s:tlist_file_name_idx_cache < s:tlist_file_count - if s:tlist_{s:tlist_file_name_idx_cache}_filename == a:fname - " Same as the last accessed file - return s:tlist_file_name_idx_cache - endif - endif - - " First, check whether the filename is present - let s_fname = a:fname . "\n" - let i = stridx(s:tlist_file_names, s_fname) - if i == -1 - let s:tlist_file_name_idx_cache = -1 - return -1 - endif - - " Second, compute the file name index - let nl_txt = substitute(strpart(s:tlist_file_names, 0, i), "[^\n]", '', 'g') - let s:tlist_file_name_idx_cache = strlen(nl_txt) - return s:tlist_file_name_idx_cache -endfunction - -" Last returned file index for line number lookup. -" Used to speed up file lookup -let s:tlist_file_lnum_idx_cache = -1 - -" Tlist_Window_Get_File_Index_By_Linenum() -" Return the index of the filename present in the specified line number -" Line number refers to the line number in the taglist window -function! s:Tlist_Window_Get_File_Index_By_Linenum(lnum) - call s:Tlist_Log_Msg('Tlist_Window_Get_File_Index_By_Linenum (' . a:lnum . ')') - - " First try to see whether the new line number is within the range - " of the last returned file - if s:tlist_file_lnum_idx_cache != -1 && - \ s:tlist_file_lnum_idx_cache < s:tlist_file_count - if a:lnum >= s:tlist_{s:tlist_file_lnum_idx_cache}_start && - \ a:lnum <= s:tlist_{s:tlist_file_lnum_idx_cache}_end - return s:tlist_file_lnum_idx_cache - endif - endif - - let fidx = -1 - - if g:Tlist_Show_One_File - " Displaying only one file in the taglist window. Check whether - " the line is within the tags displayed for that file - if s:tlist_cur_file_idx != -1 - if a:lnum >= s:tlist_{s:tlist_cur_file_idx}_start - \ && a:lnum <= s:tlist_{s:tlist_cur_file_idx}_end - let fidx = s:tlist_cur_file_idx - endif - - endif - else - " Do a binary search in the taglist - let left = 0 - let right = s:tlist_file_count - 1 - - while left < right - let mid = (left + right) / 2 - - if a:lnum >= s:tlist_{mid}_start && a:lnum <= s:tlist_{mid}_end - let s:tlist_file_lnum_idx_cache = mid - return mid - endif - - if a:lnum < s:tlist_{mid}_start - let right = mid - 1 - else - let left = mid + 1 - endif - endwhile - - if left >= 0 && left < s:tlist_file_count - \ && a:lnum >= s:tlist_{left}_start - \ && a:lnum <= s:tlist_{left}_end - let fidx = left - endif - endif - - let s:tlist_file_lnum_idx_cache = fidx - - return fidx -endfunction - -" Tlist_Exe_Cmd_No_Acmds -" Execute the specified Ex command after disabling autocommands -function! s:Tlist_Exe_Cmd_No_Acmds(cmd) - let old_eventignore = &eventignore - set eventignore=all - exe a:cmd - let &eventignore = old_eventignore -endfunction - -" Tlist_Skip_File() -" Check whether tag listing is supported for the specified file -function! s:Tlist_Skip_File(filename, ftype) - " Skip buffers with no names and buffers with filetype not set - if a:filename == '' || a:ftype == '' - return 1 - endif - - " Skip files which are not supported by exuberant ctags - " First check whether default settings for this filetype are available. - " If it is not available, then check whether user specified settings are - " available. If both are not available, then don't list the tags for this - " filetype - let var = 's:tlist_def_' . a:ftype . '_settings' - if !exists(var) - let var = 'g:tlist_' . a:ftype . '_settings' - if !exists(var) - return 1 - endif - endif - - " Skip files which are not readable or files which are not yet stored - " to the disk - if !filereadable(a:filename) - return 1 - endif - - return 0 -endfunction - -" Tlist_User_Removed_File -" Returns 1 if a file is removed by a user from the taglist -function! s:Tlist_User_Removed_File(filename) - return stridx(s:tlist_removed_flist, a:filename . "\n") != -1 -endfunction - -" Tlist_Update_Remove_List -" Update the list of user removed files from the taglist -" add == 1, add the file to the removed list -" add == 0, delete the file from the removed list -function! s:Tlist_Update_Remove_List(filename, add) - if a:add - let s:tlist_removed_flist = s:tlist_removed_flist . a:filename . "\n" - else - let idx = stridx(s:tlist_removed_flist, a:filename . "\n") - let text_before = strpart(s:tlist_removed_flist, 0, idx) - let rem_text = strpart(s:tlist_removed_flist, idx) - let next_idx = stridx(rem_text, "\n") - let text_after = strpart(rem_text, next_idx + 1) - - let s:tlist_removed_flist = text_before . text_after - endif -endfunction - -" Tlist_FileType_Init -" Initialize the ctags arguments and tag variable for the specified -" file type -function! s:Tlist_FileType_Init(ftype) - call s:Tlist_Log_Msg('Tlist_FileType_Init (' . a:ftype . ')') - " If the user didn't specify any settings, then use the default - " ctags args. Otherwise, use the settings specified by the user - let var = 'g:tlist_' . a:ftype . '_settings' - if exists(var) - " User specified ctags arguments - let settings = {var} . ';' - else - " Default ctags arguments - let var = 's:tlist_def_' . a:ftype . '_settings' - if !exists(var) - " No default settings for this file type. This filetype is - " not supported - return 0 - endif - let settings = s:tlist_def_{a:ftype}_settings . ';' - endif - - let msg = 'Taglist: Invalid ctags option setting - ' . settings - - " Format of the option that specifies the filetype and ctags arugments: - " - " <language_name>;flag1:name1;flag2:name2;flag3:name3 - " - - " Extract the file type to pass to ctags. This may be different from the - " file type detected by Vim - let pos = stridx(settings, ';') - if pos == -1 - call s:Tlist_Warning_Msg(msg) - return 0 - endif - let ctags_ftype = strpart(settings, 0, pos) - if ctags_ftype == '' - call s:Tlist_Warning_Msg(msg) - return 0 - endif - " Make sure a valid filetype is supplied. If the user didn't specify a - " valid filetype, then the ctags option settings may be treated as the - " filetype - if ctags_ftype =~ ':' - call s:Tlist_Warning_Msg(msg) - return 0 - endif - - " Remove the file type from settings - let settings = strpart(settings, pos + 1) - if settings == '' - call s:Tlist_Warning_Msg(msg) - return 0 - endif - - " Process all the specified ctags flags. The format is - " flag1:name1;flag2:name2;flag3:name3 - let ctags_flags = '' - let cnt = 0 - while settings != '' - " Extract the flag - let pos = stridx(settings, ':') - if pos == -1 - call s:Tlist_Warning_Msg(msg) - return 0 - endif - let flag = strpart(settings, 0, pos) - if flag == '' - call s:Tlist_Warning_Msg(msg) - return 0 - endif - " Remove the flag from settings - let settings = strpart(settings, pos + 1) - - " Extract the tag type name - let pos = stridx(settings, ';') - if pos == -1 - call s:Tlist_Warning_Msg(msg) - return 0 - endif - let name = strpart(settings, 0, pos) - if name == '' - call s:Tlist_Warning_Msg(msg) - return 0 - endif - let settings = strpart(settings, pos + 1) - - let cnt = cnt + 1 - - let s:tlist_{a:ftype}_{cnt}_name = flag - let s:tlist_{a:ftype}_{cnt}_fullname = name - let ctags_flags = ctags_flags . flag - endwhile - - let s:tlist_{a:ftype}_ctags_args = '--language-force=' . ctags_ftype . - \ ' --' . ctags_ftype . '-types=' . ctags_flags - let s:tlist_{a:ftype}_count = cnt - let s:tlist_{a:ftype}_ctags_flags = ctags_flags - - " Save the filetype name - let s:tlist_ftype_{s:tlist_ftype_count}_name = a:ftype - let s:tlist_ftype_count = s:tlist_ftype_count + 1 - - return 1 -endfunction - -" Tlist_Detect_Filetype -" Determine the filetype for the specified file using the filetypedetect -" autocmd. -function! s:Tlist_Detect_Filetype(fname) - " Ignore the filetype autocommands - let old_eventignore = &eventignore - set eventignore=FileType - - " Save the 'filetype', as this will be changed temporarily - let old_filetype = &filetype - - " Run the filetypedetect group of autocommands to determine - " the filetype - exe 'doautocmd filetypedetect BufRead ' . a:fname - - " Save the detected filetype - let ftype = &filetype - - " Restore the previous state - let &filetype = old_filetype - let &eventignore = old_eventignore - - return ftype -endfunction - -" Tlist_Get_Buffer_Filetype -" Get the filetype for the specified buffer -function! s:Tlist_Get_Buffer_Filetype(bnum) - let buf_ft = getbufvar(a:bnum, '&filetype') - - if bufloaded(a:bnum) - " For loaded buffers, the 'filetype' is already determined - return buf_ft - endif - - " For unloaded buffers, if the 'filetype' option is set, return it - if buf_ft != '' - return buf_ft - endif - - " Skip non-existent buffers - if !bufexists(a:bnum) - return '' - endif - - " For buffers whose filetype is not yet determined, try to determine - " the filetype - let bname = bufname(a:bnum) - - return s:Tlist_Detect_Filetype(bname) -endfunction - -" Tlist_Discard_TagInfo -" Discard the stored tag information for a file -function! s:Tlist_Discard_TagInfo(fidx) - call s:Tlist_Log_Msg('Tlist_Discard_TagInfo (' . - \ s:tlist_{a:fidx}_filename . ')') - let ftype = s:tlist_{a:fidx}_filetype - - " Discard information about the tags defined in the file - let i = 1 - while i <= s:tlist_{a:fidx}_tag_count - let fidx_i = 's:tlist_' . a:fidx . '_' . i - unlet! {fidx_i}_tag - unlet! {fidx_i}_tag_name - unlet! {fidx_i}_tag_type - unlet! {fidx_i}_ttype_idx - unlet! {fidx_i}_tag_proto - unlet! {fidx_i}_tag_searchpat - unlet! {fidx_i}_tag_linenum - let i = i + 1 - endwhile - - let s:tlist_{a:fidx}_tag_count = 0 - - " Discard information about tag type groups - let i = 1 - while i <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{i}_name - if s:tlist_{a:fidx}_{ttype} != '' - let fidx_ttype = 's:tlist_' . a:fidx . '_' . ttype - let {fidx_ttype} = '' - let {fidx_ttype}_offset = 0 - let cnt = {fidx_ttype}_count - let {fidx_ttype}_count = 0 - let j = 1 - while j <= cnt - unlet! {fidx_ttype}_{j} - let j = j + 1 - endwhile - endif - let i = i + 1 - endwhile - - " Discard the stored menu command also - let s:tlist_{a:fidx}_menu_cmd = '' -endfunction - -" Tlist_Window_Update_Line_Offsets -" Update the line offsets for tags for files starting from start_idx -" and displayed in the taglist window by the specified offset -function! s:Tlist_Window_Update_Line_Offsets(start_idx, increment, offset) - let i = a:start_idx - - while i < s:tlist_file_count - if s:tlist_{i}_visible - " Update the start/end line number only if the file is visible - if a:increment - let s:tlist_{i}_start = s:tlist_{i}_start + a:offset - let s:tlist_{i}_end = s:tlist_{i}_end + a:offset - else - let s:tlist_{i}_start = s:tlist_{i}_start - a:offset - let s:tlist_{i}_end = s:tlist_{i}_end - a:offset - endif - endif - let i = i + 1 - endwhile -endfunction - -" Tlist_Discard_FileInfo -" Discard the stored information for a file -function! s:Tlist_Discard_FileInfo(fidx) - call s:Tlist_Log_Msg('Tlist_Discard_FileInfo (' . - \ s:tlist_{a:fidx}_filename . ')') - call s:Tlist_Discard_TagInfo(a:fidx) - - let ftype = s:tlist_{a:fidx}_filetype - - let i = 1 - while i <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{i}_name - unlet! s:tlist_{a:fidx}_{ttype} - unlet! s:tlist_{a:fidx}_{ttype}_offset - unlet! s:tlist_{a:fidx}_{ttype}_count - let i = i + 1 - endwhile - - unlet! s:tlist_{a:fidx}_filename - unlet! s:tlist_{a:fidx}_sort_type - unlet! s:tlist_{a:fidx}_filetype - unlet! s:tlist_{a:fidx}_mtime - unlet! s:tlist_{a:fidx}_start - unlet! s:tlist_{a:fidx}_end - unlet! s:tlist_{a:fidx}_valid - unlet! s:tlist_{a:fidx}_visible - unlet! s:tlist_{a:fidx}_tag_count - unlet! s:tlist_{a:fidx}_menu_cmd -endfunction - -" Tlist_Window_Remove_File_From_Display -" Remove the specified file from display -function! s:Tlist_Window_Remove_File_From_Display(fidx) - call s:Tlist_Log_Msg('Tlist_Window_Remove_File_From_Display (' . - \ s:tlist_{a:fidx}_filename . ')') - " If the file is not visible then no need to remove it - if !s:tlist_{a:fidx}_visible - return - endif - - " Remove the tags displayed for the specified file from the window - let start = s:tlist_{a:fidx}_start - " Include the empty line after the last line also - if g:Tlist_Compact_Format - let end = s:tlist_{a:fidx}_end - else - let end = s:tlist_{a:fidx}_end + 1 - endif - - setlocal modifiable - exe 'silent! ' . start . ',' . end . 'delete _' - setlocal nomodifiable - - " Correct the start and end line offsets for all the files following - " this file, as the tags for this file are removed - call s:Tlist_Window_Update_Line_Offsets(a:fidx + 1, 0, end - start + 1) -endfunction - -" Tlist_Remove_File -" Remove the file under the cursor or the specified file index -" user_request - User requested to remove the file from taglist -function! s:Tlist_Remove_File(file_idx, user_request) - let fidx = a:file_idx - - if fidx == -1 - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(line('.')) - if fidx == -1 - return - endif - endif - call s:Tlist_Log_Msg('Tlist_Remove_File (' . - \ s:tlist_{fidx}_filename . ', ' . a:user_request . ')') - - let save_winnr = winnr() - let winnum = bufwinnr(g:TagList_title) - if winnum != -1 - " Taglist window is open, remove the file from display - - if save_winnr != winnum - let old_eventignore = &eventignore - set eventignore=all - exe winnum . 'wincmd w' - endif - - call s:Tlist_Window_Remove_File_From_Display(fidx) - - if save_winnr != winnum - exe save_winnr . 'wincmd w' - let &eventignore = old_eventignore - endif - endif - - let fname = s:tlist_{fidx}_filename - - if a:user_request - " As the user requested to remove the file from taglist, - " add it to the removed list - call s:Tlist_Update_Remove_List(fname, 1) - endif - - " Remove the file name from the taglist list of filenames - let idx = stridx(s:tlist_file_names, fname . "\n") - let text_before = strpart(s:tlist_file_names, 0, idx) - let rem_text = strpart(s:tlist_file_names, idx) - let next_idx = stridx(rem_text, "\n") - let text_after = strpart(rem_text, next_idx + 1) - let s:tlist_file_names = text_before . text_after - - call s:Tlist_Discard_FileInfo(fidx) - - " Shift all the file variables by one index - let i = fidx + 1 - - while i < s:tlist_file_count - let j = i - 1 - - let s:tlist_{j}_filename = s:tlist_{i}_filename - let s:tlist_{j}_sort_type = s:tlist_{i}_sort_type - let s:tlist_{j}_filetype = s:tlist_{i}_filetype - let s:tlist_{j}_mtime = s:tlist_{i}_mtime - let s:tlist_{j}_start = s:tlist_{i}_start - let s:tlist_{j}_end = s:tlist_{i}_end - let s:tlist_{j}_valid = s:tlist_{i}_valid - let s:tlist_{j}_visible = s:tlist_{i}_visible - let s:tlist_{j}_tag_count = s:tlist_{i}_tag_count - let s:tlist_{j}_menu_cmd = s:tlist_{i}_menu_cmd - - let k = 1 - while k <= s:tlist_{j}_tag_count - let s:tlist_{j}_{k}_tag = s:tlist_{i}_{k}_tag - let s:tlist_{j}_{k}_tag_name = s:tlist_{i}_{k}_tag_name - let s:tlist_{j}_{k}_tag_type = s:Tlist_Get_Tag_Type_By_Tag(i, k) - let s:tlist_{j}_{k}_ttype_idx = s:tlist_{i}_{k}_ttype_idx - let s:tlist_{j}_{k}_tag_proto = s:Tlist_Get_Tag_Prototype(i, k) - let s:tlist_{j}_{k}_tag_searchpat = s:Tlist_Get_Tag_SearchPat(i, k) - let s:tlist_{j}_{k}_tag_linenum = s:Tlist_Get_Tag_Linenum(i, k) - let k = k + 1 - endwhile - - let ftype = s:tlist_{i}_filetype - - let k = 1 - while k <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{k}_name - let s:tlist_{j}_{ttype} = s:tlist_{i}_{ttype} - let s:tlist_{j}_{ttype}_offset = s:tlist_{i}_{ttype}_offset - let s:tlist_{j}_{ttype}_count = s:tlist_{i}_{ttype}_count - if s:tlist_{j}_{ttype} != '' - let l = 1 - while l <= s:tlist_{j}_{ttype}_count - let s:tlist_{j}_{ttype}_{l} = s:tlist_{i}_{ttype}_{l} - let l = l + 1 - endwhile - endif - let k = k + 1 - endwhile - - " As the file and tag information is copied to the new index, - " discard the previous information - call s:Tlist_Discard_FileInfo(i) - - let i = i + 1 - endwhile - - " Reduce the number of files displayed - let s:tlist_file_count = s:tlist_file_count - 1 - - if g:Tlist_Show_One_File - " If the tags for only one file is displayed and if we just - " now removed that file, then invalidate the current file idx - if s:tlist_cur_file_idx == fidx - let s:tlist_cur_file_idx = -1 - endif - endif -endfunction - -" Tlist_Window_Goto_Window -" Goto the taglist window -function! s:Tlist_Window_Goto_Window() - let winnum = bufwinnr(g:TagList_title) - if winnum != -1 - if winnr() != winnum - call s:Tlist_Exe_Cmd_No_Acmds(winnum . 'wincmd w') - endif - endif -endfunction - -" Tlist_Window_Create -" Create a new taglist window. If it is already open, jump to it -function! s:Tlist_Window_Create() - call s:Tlist_Log_Msg('Tlist_Window_Create()') - " If the window is open, jump to it - let winnum = bufwinnr(g:TagList_title) - if winnum != -1 - " Jump to the existing window - if winnr() != winnum - exe winnum . 'wincmd w' - endif - return - endif - - " If used with winmanager don't open windows. Winmanager will handle - " the window/buffer management - if s:tlist_app_name == "winmanager" - return - endif - - " Create a new window. If user prefers a horizontal window, then open - " a horizontally split window. Otherwise open a vertically split - " window - if g:Tlist_Use_Horiz_Window - " Open a horizontally split window - let win_dir = 'botright' - " Horizontal window height - let win_size = g:Tlist_WinHeight - else - if s:tlist_winsize_chgd == -1 - " Open a vertically split window. Increase the window size, if - " needed, to accomodate the new window - if g:Tlist_Inc_Winwidth && - \ &columns < (80 + g:Tlist_WinWidth) - " Save the original window position - let s:tlist_pre_winx = getwinposx() - let s:tlist_pre_winy = getwinposy() - - " one extra column is needed to include the vertical split - let &columns= &columns + g:Tlist_WinWidth + 1 - - let s:tlist_winsize_chgd = 1 - else - let s:tlist_winsize_chgd = 0 - endif - endif - - if g:Tlist_Use_Right_Window - " Open the window at the rightmost place - let win_dir = 'botright vertical' - else - " Open the window at the leftmost place - let win_dir = 'topleft vertical' - endif - let win_size = g:Tlist_WinWidth - endif - - " If the tag listing temporary buffer already exists, then reuse it. - " Otherwise create a new buffer - let bufnum = bufnr(g:TagList_title) - if bufnum == -1 - " Create a new buffer - let wcmd = g:TagList_title - else - " Edit the existing buffer - let wcmd = '+buffer' . bufnum - endif - - " Create the taglist window - exe 'silent! ' . win_dir . ' ' . win_size . 'split ' . wcmd - - " Save the new window position - let s:tlist_winx = getwinposx() - let s:tlist_winy = getwinposy() - - " Initialize the taglist window - call s:Tlist_Window_Init() -endfunction - -" Tlist_Window_Zoom -" Zoom (maximize/minimize) the taglist window -function! s:Tlist_Window_Zoom() - if s:tlist_win_maximized - " Restore the window back to the previous size - if g:Tlist_Use_Horiz_Window - exe 'resize ' . g:Tlist_WinHeight - else - exe 'vert resize ' . g:Tlist_WinWidth - endif - let s:tlist_win_maximized = 0 - else - " Set the window size to the maximum possible without closing other - " windows - if g:Tlist_Use_Horiz_Window - resize - else - vert resize - endif - let s:tlist_win_maximized = 1 - endif -endfunction - -" Tlist_Ballon_Expr -" When the mouse cursor is over a tag in the taglist window, display the -" tag prototype (balloon) -function! Tlist_Ballon_Expr() - " Get the file index - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(v:beval_lnum) - if fidx == -1 - return '' - endif - - " Get the tag output line for the current tag - let tidx = s:Tlist_Window_Get_Tag_Index(fidx, v:beval_lnum) - if tidx == 0 - return '' - endif - - " Get the tag search pattern and display it - return s:Tlist_Get_Tag_Prototype(fidx, tidx) -endfunction - -" Tlist_Window_Check_Width -" Check the width of the taglist window. For horizontally split windows, the -" 'winfixheight' option is used to fix the height of the window. For -" vertically split windows, Vim doesn't support the 'winfixwidth' option. So -" need to handle window width changes from this function. -function! s:Tlist_Window_Check_Width() - let tlist_winnr = bufwinnr(g:TagList_title) - if tlist_winnr == -1 - return - endif - - let width = winwidth(tlist_winnr) - if width != g:Tlist_WinWidth - call s:Tlist_Log_Msg("Tlist_Window_Check_Width: Changing window " . - \ "width from " . width . " to " . g:Tlist_WinWidth) - let save_winnr = winnr() - if save_winnr != tlist_winnr - call s:Tlist_Exe_Cmd_No_Acmds(tlist_winnr . 'wincmd w') - endif - exe 'vert resize ' . g:Tlist_WinWidth - if save_winnr != tlist_winnr - call s:Tlist_Exe_Cmd_No_Acmds('wincmd p') - endif - endif -endfunction - -" Tlist_Window_Exit_Only_Window -" If the 'Tlist_Exit_OnlyWindow' option is set, then exit Vim if only the -" taglist window is present. -function! s:Tlist_Window_Exit_Only_Window() - " Before quitting Vim, delete the taglist buffer so that - " the '0 mark is correctly set to the previous buffer. - if v:version < 700 - if winbufnr(2) == -1 - bdelete - quit - endif - else - if winbufnr(2) == -1 - if tabpagenr('$') == 1 - " Only one tag page is present - bdelete - quit - else - " More than one tab page is present. Close only the current - " tab page - close - endif - endif - endif -endfunction - -" Tlist_Window_Init -" Set the default options for the taglist window -function! s:Tlist_Window_Init() - call s:Tlist_Log_Msg('Tlist_Window_Init()') - - " The 'readonly' option should not be set for the taglist buffer. - " If Vim is started as "view/gview" or if the ":view" command is - " used, then the 'readonly' option is set for all the buffers. - " Unset it for the taglist buffer - setlocal noreadonly - - " Set the taglist buffer filetype to taglist - setlocal filetype=taglist - - " Define taglist window element highlighting - syntax match TagListComment '^" .*' - syntax match TagListFileName '^[^" ].*$' - syntax match TagListTitle '^ \S.*$' - syntax match TagListTagScope '\s\[.\{-\}\]$' - - " Define the highlighting only if colors are supported - if has('gui_running') || &t_Co > 2 - " Colors to highlight various taglist window elements - " If user defined highlighting group exists, then use them. - " Otherwise, use default highlight groups. - if hlexists('MyTagListTagName') - highlight link TagListTagName MyTagListTagName - else - highlight default link TagListTagName Search - endif - " Colors to highlight comments and titles - if hlexists('MyTagListComment') - highlight link TagListComment MyTagListComment - else - highlight clear TagListComment - highlight default link TagListComment Comment - endif - if hlexists('MyTagListTitle') - highlight link TagListTitle MyTagListTitle - else - highlight clear TagListTitle - highlight default link TagListTitle Title - endif - if hlexists('MyTagListFileName') - highlight link TagListFileName MyTagListFileName - else - highlight clear TagListFileName - highlight default TagListFileName guibg=Grey ctermbg=darkgray - \ guifg=white ctermfg=white - endif - if hlexists('MyTagListTagScope') - highlight link TagListTagScope MyTagListTagScope - else - highlight clear TagListTagScope - highlight default link TagListTagScope Identifier - endif - else - highlight default TagListTagName term=reverse cterm=reverse - endif - - " Folding related settings - setlocal foldenable - setlocal foldminlines=0 - setlocal foldmethod=manual - setlocal foldlevel=9999 - if g:Tlist_Enable_Fold_Column - setlocal foldcolumn=3 - else - setlocal foldcolumn=0 - endif - setlocal foldtext=v:folddashes.getline(v:foldstart) - - if s:tlist_app_name != "winmanager" - " Mark buffer as scratch - silent! setlocal buftype=nofile - if s:tlist_app_name == "none" - silent! setlocal bufhidden=delete - endif - silent! setlocal noswapfile - " Due to a bug in Vim 6.0, the winbufnr() function fails for unlisted - " buffers. So if the taglist buffer is unlisted, multiple taglist - " windows will be opened. This bug is fixed in Vim 6.1 and above - if v:version >= 601 - silent! setlocal nobuflisted - endif - endif - - silent! setlocal nowrap - - " If the 'number' option is set in the source window, it will affect the - " taglist window. So forcefully disable 'number' option for the taglist - " window - silent! setlocal nonumber - - " Use fixed height when horizontally split window is used - if g:Tlist_Use_Horiz_Window - if v:version >= 602 - set winfixheight - endif - endif - if !g:Tlist_Use_Horiz_Window && v:version >= 700 - set winfixwidth - endif - - " Setup balloon evaluation to display tag prototype - if v:version >= 700 && has('balloon_eval') - setlocal balloonexpr=Tlist_Ballon_Expr() - set ballooneval - endif - - " Setup the cpoptions properly for the maps to work - let old_cpoptions = &cpoptions - set cpoptions&vim - - " Create buffer local mappings for jumping to the tags and sorting the list - nnoremap <buffer> <silent> <CR> - \ :call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR> - nnoremap <buffer> <silent> o - \ :call <SID>Tlist_Window_Jump_To_Tag('newwin')<CR> - nnoremap <buffer> <silent> p - \ :call <SID>Tlist_Window_Jump_To_Tag('preview')<CR> - nnoremap <buffer> <silent> P - \ :call <SID>Tlist_Window_Jump_To_Tag('prevwin')<CR> - if v:version >= 700 - nnoremap <buffer> <silent> t - \ :call <SID>Tlist_Window_Jump_To_Tag('checktab')<CR> - nnoremap <buffer> <silent> <C-t> - \ :call <SID>Tlist_Window_Jump_To_Tag('newtab')<CR> - endif - nnoremap <buffer> <silent> <2-LeftMouse> - \ :call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR> - nnoremap <buffer> <silent> s - \ :call <SID>Tlist_Change_Sort('cmd', 'toggle', '')<CR> - nnoremap <buffer> <silent> + :silent! foldopen<CR> - nnoremap <buffer> <silent> - :silent! foldclose<CR> - nnoremap <buffer> <silent> * :silent! %foldopen!<CR> - nnoremap <buffer> <silent> = :silent! %foldclose<CR> - nnoremap <buffer> <silent> <kPlus> :silent! foldopen<CR> - nnoremap <buffer> <silent> <kMinus> :silent! foldclose<CR> - nnoremap <buffer> <silent> <kMultiply> :silent! %foldopen!<CR> - nnoremap <buffer> <silent> <Space> :call <SID>Tlist_Window_Show_Info()<CR> - nnoremap <buffer> <silent> u :call <SID>Tlist_Window_Update_File()<CR> - nnoremap <buffer> <silent> d :call <SID>Tlist_Remove_File(-1, 1)<CR> - nnoremap <buffer> <silent> x :call <SID>Tlist_Window_Zoom()<CR> - nnoremap <buffer> <silent> [[ :call <SID>Tlist_Window_Move_To_File(-1)<CR> - nnoremap <buffer> <silent> <BS> :call <SID>Tlist_Window_Move_To_File(-1)<CR> - nnoremap <buffer> <silent> ]] :call <SID>Tlist_Window_Move_To_File(1)<CR> - nnoremap <buffer> <silent> <Tab> :call <SID>Tlist_Window_Move_To_File(1)<CR> - nnoremap <buffer> <silent> <F1> :call <SID>Tlist_Window_Toggle_Help_Text()<CR> - nnoremap <buffer> <silent> q :close<CR> - - " Insert mode mappings - inoremap <buffer> <silent> <CR> - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR> - " Windows needs return - inoremap <buffer> <silent> <Return> - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR> - inoremap <buffer> <silent> o - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('newwin')<CR> - inoremap <buffer> <silent> p - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('preview')<CR> - inoremap <buffer> <silent> P - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('prevwin')<CR> - if v:version >= 700 - inoremap <buffer> <silent> t - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('checktab')<CR> - inoremap <buffer> <silent> <C-t> - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('newtab')<CR> - endif - inoremap <buffer> <silent> <2-LeftMouse> - \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR> - inoremap <buffer> <silent> s - \ <C-o>:call <SID>Tlist_Change_Sort('cmd', 'toggle', '')<CR> - inoremap <buffer> <silent> + <C-o>:silent! foldopen<CR> - inoremap <buffer> <silent> - <C-o>:silent! foldclose<CR> - inoremap <buffer> <silent> * <C-o>:silent! %foldopen!<CR> - inoremap <buffer> <silent> = <C-o>:silent! %foldclose<CR> - inoremap <buffer> <silent> <kPlus> <C-o>:silent! foldopen<CR> - inoremap <buffer> <silent> <kMinus> <C-o>:silent! foldclose<CR> - inoremap <buffer> <silent> <kMultiply> <C-o>:silent! %foldopen!<CR> - inoremap <buffer> <silent> <Space> <C-o>:call - \ <SID>Tlist_Window_Show_Info()<CR> - inoremap <buffer> <silent> u - \ <C-o>:call <SID>Tlist_Window_Update_File()<CR> - inoremap <buffer> <silent> d <C-o>:call <SID>Tlist_Remove_File(-1, 1)<CR> - inoremap <buffer> <silent> x <C-o>:call <SID>Tlist_Window_Zoom()<CR> - inoremap <buffer> <silent> [[ <C-o>:call <SID>Tlist_Window_Move_To_File(-1)<CR> - inoremap <buffer> <silent> <BS> <C-o>:call <SID>Tlist_Window_Move_To_File(-1)<CR> - inoremap <buffer> <silent> ]] <C-o>:call <SID>Tlist_Window_Move_To_File(1)<CR> - inoremap <buffer> <silent> <Tab> <C-o>:call <SID>Tlist_Window_Move_To_File(1)<CR> - inoremap <buffer> <silent> <F1> <C-o>:call <SID>Tlist_Window_Toggle_Help_Text()<CR> - inoremap <buffer> <silent> q <C-o>:close<CR> - - " Map single left mouse click if the user wants this functionality - if g:Tlist_Use_SingleClick == 1 - " Contributed by Bindu Wavell - " attempt to perform single click mapping, it would be much - " nicer if we could nnoremap <buffer> ... however vim does - " not fire the <buffer> <leftmouse> when you use the mouse - " to enter a buffer. - let clickmap = ':if bufname("%") =~ "__Tag_List__" <bar> ' . - \ 'call <SID>Tlist_Window_Jump_To_Tag("useopen") ' . - \ '<bar> endif <CR>' - if maparg('<leftmouse>', 'n') == '' - " no mapping for leftmouse - exe ':nnoremap <silent> <leftmouse> <leftmouse>' . clickmap - else - " we have a mapping - let mapcmd = ':nnoremap <silent> <leftmouse> <leftmouse>' - let mapcmd = mapcmd . substitute(substitute( - \ maparg('<leftmouse>', 'n'), '|', '<bar>', 'g'), - \ '\c^<leftmouse>', '', '') - let mapcmd = mapcmd . clickmap - exe mapcmd - endif - endif - - " Define the taglist autocommands - augroup TagListAutoCmds - autocmd! - " Display the tag prototype for the tag under the cursor. - autocmd CursorHold __Tag_List__ call s:Tlist_Window_Show_Info() - " Highlight the current tag periodically - autocmd CursorHold * silent call s:Tlist_Window_Highlight_Tag( - \ fnamemodify(bufname('%'), ':p'), line('.'), 1, 0) - - " Adjust the Vim window width when taglist window is closed - autocmd BufUnload __Tag_List__ call s:Tlist_Post_Close_Cleanup() - " Close the fold for this buffer when leaving the buffer - if g:Tlist_File_Fold_Auto_Close - autocmd BufEnter * silent - \ call s:Tlist_Window_Open_File_Fold(expand('<abuf>')) - endif - " Exit Vim itself if only the taglist window is present (optional) - if g:Tlist_Exit_OnlyWindow - autocmd BufEnter __Tag_List__ nested - \ call s:Tlist_Window_Exit_Only_Window() - endif - if s:tlist_app_name != "winmanager" && - \ !g:Tlist_Process_File_Always && - \ (!has('gui_running') || !g:Tlist_Show_Menu) - " Auto refresh the taglist window - autocmd BufEnter * call s:Tlist_Refresh() - endif - - if !g:Tlist_Use_Horiz_Window - if v:version < 700 - autocmd WinEnter * call s:Tlist_Window_Check_Width() - endif - endif - if v:version >= 700 - autocmd TabEnter * silent call s:Tlist_Refresh_Folds() - endif - augroup end - - " Restore the previous cpoptions settings - let &cpoptions = old_cpoptions -endfunction - -" Tlist_Window_Refresh -" Display the tags for all the files in the taglist window -function! s:Tlist_Window_Refresh() - call s:Tlist_Log_Msg('Tlist_Window_Refresh()') - " Set report option to a huge value to prevent informational messages - " while deleting the lines - let old_report = &report - set report=99999 - - " Mark the buffer as modifiable - setlocal modifiable - - " Delete the contents of the buffer to the black-hole register - silent! %delete _ - - " As we have cleared the taglist window, mark all the files - " as not visible - let i = 0 - while i < s:tlist_file_count - let s:tlist_{i}_visible = 0 - let i = i + 1 - endwhile - - if g:Tlist_Compact_Format == 0 - " Display help in non-compact mode - call s:Tlist_Window_Display_Help() - endif - - " Mark the buffer as not modifiable - setlocal nomodifiable - - " Restore the report option - let &report = old_report - - " If the tags for only one file should be displayed in the taglist - " window, then no need to add the tags here. The bufenter autocommand - " will add the tags for that file. - if g:Tlist_Show_One_File - return - endif - - " List all the tags for the previously processed files - " Do this only if taglist is configured to display tags for more than - " one file. Otherwise, when Tlist_Show_One_File is configured, - " tags for the wrong file will be displayed. - let i = 0 - while i < s:tlist_file_count - call s:Tlist_Window_Refresh_File(s:tlist_{i}_filename, - \ s:tlist_{i}_filetype) - let i = i + 1 - endwhile - - if g:Tlist_Auto_Update - " Add and list the tags for all buffers in the Vim buffer list - let i = 1 - let last_bufnum = bufnr('$') - while i <= last_bufnum - if buflisted(i) - let fname = fnamemodify(bufname(i), ':p') - let ftype = s:Tlist_Get_Buffer_Filetype(i) - " If the file doesn't support tag listing, skip it - if !s:Tlist_Skip_File(fname, ftype) - call s:Tlist_Window_Refresh_File(fname, ftype) - endif - endif - let i = i + 1 - endwhile - endif - - " If Tlist_File_Fold_Auto_Close option is set, then close all the folds - if g:Tlist_File_Fold_Auto_Close - " Close all the folds - silent! %foldclose - endif - - " Move the cursor to the top of the taglist window - normal! gg -endfunction - -" Tlist_Post_Close_Cleanup() -" Close the taglist window and adjust the Vim window width -function! s:Tlist_Post_Close_Cleanup() - call s:Tlist_Log_Msg('Tlist_Post_Close_Cleanup()') - " Mark all the files as not visible - let i = 0 - while i < s:tlist_file_count - let s:tlist_{i}_visible = 0 - let i = i + 1 - endwhile - - " Remove the taglist autocommands - silent! autocmd! TagListAutoCmds - - " Clear all the highlights - match none - - silent! syntax clear TagListTitle - silent! syntax clear TagListComment - silent! syntax clear TagListTagScope - - " Remove the left mouse click mapping if it was setup initially - if g:Tlist_Use_SingleClick - if hasmapto('<LeftMouse>') - nunmap <LeftMouse> - endif - endif - - if s:tlist_app_name != "winmanager" - if g:Tlist_Use_Horiz_Window || g:Tlist_Inc_Winwidth == 0 || - \ s:tlist_winsize_chgd != 1 || - \ &columns < (80 + g:Tlist_WinWidth) - " No need to adjust window width if using horizontally split taglist - " window or if columns is less than 101 or if the user chose not to - " adjust the window width - else - " If the user didn't manually move the window, then restore the window - " position to the pre-taglist position - if s:tlist_pre_winx != -1 && s:tlist_pre_winy != -1 && - \ getwinposx() == s:tlist_winx && - \ getwinposy() == s:tlist_winy - exe 'winpos ' . s:tlist_pre_winx . ' ' . s:tlist_pre_winy - endif - - " Adjust the Vim window width - let &columns= &columns - (g:Tlist_WinWidth + 1) - endif - endif - - let s:tlist_winsize_chgd = -1 - - " Reset taglist state variables - if s:tlist_app_name == "winmanager" - let s:tlist_app_name = "none" - endif - let s:tlist_window_initialized = 0 -endfunction - -" Tlist_Window_Refresh_File() -" List the tags defined in the specified file in a Vim window -function! s:Tlist_Window_Refresh_File(filename, ftype) - call s:Tlist_Log_Msg('Tlist_Window_Refresh_File (' . a:filename . ')') - " First check whether the file already exists - let fidx = s:Tlist_Get_File_Index(a:filename) - if fidx != -1 - let file_listed = 1 - else - let file_listed = 0 - endif - - if !file_listed - " Check whether this file is removed based on user request - " If it is, then don't display the tags for this file - if s:Tlist_User_Removed_File(a:filename) - return - endif - endif - - if file_listed && s:tlist_{fidx}_visible - " Check whether the file tags are currently valid - if s:tlist_{fidx}_valid - " Goto the first line in the file - exe s:tlist_{fidx}_start - - " If the line is inside a fold, open the fold - if foldclosed('.') != -1 - exe "silent! " . s:tlist_{fidx}_start . "," . - \ s:tlist_{fidx}_end . "foldopen!" - endif - return - endif - - " Discard and remove the tags for this file from display - call s:Tlist_Discard_TagInfo(fidx) - call s:Tlist_Window_Remove_File_From_Display(fidx) - endif - - " Process and generate a list of tags defined in the file - if !file_listed || !s:tlist_{fidx}_valid - let ret_fidx = s:Tlist_Process_File(a:filename, a:ftype) - if ret_fidx == -1 - return - endif - let fidx = ret_fidx - endif - - " Set report option to a huge value to prevent informational messages - " while adding lines to the taglist window - let old_report = &report - set report=99999 - - if g:Tlist_Show_One_File - " Remove the previous file - if s:tlist_cur_file_idx != -1 - call s:Tlist_Window_Remove_File_From_Display(s:tlist_cur_file_idx) - let s:tlist_{s:tlist_cur_file_idx}_visible = 0 - let s:tlist_{s:tlist_cur_file_idx}_start = 0 - let s:tlist_{s:tlist_cur_file_idx}_end = 0 - endif - let s:tlist_cur_file_idx = fidx - endif - - " Mark the buffer as modifiable - setlocal modifiable - - " Add new files to the end of the window. For existing files, add them at - " the same line where they were previously present. If the file is not - " visible, then add it at the end - if s:tlist_{fidx}_start == 0 || !s:tlist_{fidx}_visible - if g:Tlist_Compact_Format - let s:tlist_{fidx}_start = line('$') - else - let s:tlist_{fidx}_start = line('$') + 1 - endif - endif - - let s:tlist_{fidx}_visible = 1 - - " Goto the line where this file should be placed - if g:Tlist_Compact_Format - exe s:tlist_{fidx}_start - else - exe s:tlist_{fidx}_start - 1 - endif - - let txt = fnamemodify(s:tlist_{fidx}_filename, ':t') . ' (' . - \ fnamemodify(s:tlist_{fidx}_filename, ':p:h') . ')' - if g:Tlist_Compact_Format == 0 - silent! put =txt - else - silent! put! =txt - " Move to the next line - exe line('.') + 1 - endif - let file_start = s:tlist_{fidx}_start - - " Add the tag names grouped by tag type to the buffer with a title - let i = 1 - let ttype_cnt = s:tlist_{a:ftype}_count - while i <= ttype_cnt - let ttype = s:tlist_{a:ftype}_{i}_name - " Add the tag type only if there are tags for that type - let fidx_ttype = 's:tlist_' . fidx . '_' . ttype - let ttype_txt = {fidx_ttype} - if ttype_txt != '' - let txt = ' ' . s:tlist_{a:ftype}_{i}_fullname - if g:Tlist_Compact_Format == 0 - let ttype_start_lnum = line('.') + 1 - silent! put =txt - else - let ttype_start_lnum = line('.') - silent! put! =txt - endif - silent! put =ttype_txt - - let {fidx_ttype}_offset = ttype_start_lnum - file_start - - " create a fold for this tag type - let fold_start = ttype_start_lnum - let fold_end = fold_start + {fidx_ttype}_count - exe fold_start . ',' . fold_end . 'fold' - - " Adjust the cursor position - if g:Tlist_Compact_Format == 0 - exe ttype_start_lnum + {fidx_ttype}_count - else - exe ttype_start_lnum + {fidx_ttype}_count + 1 - endif - - if g:Tlist_Compact_Format == 0 - " Separate the tag types by a empty line - silent! put ='' - endif - endif - let i = i + 1 - endwhile - - if s:tlist_{fidx}_tag_count == 0 - if g:Tlist_Compact_Format == 0 - silent! put ='' - endif - endif - - let s:tlist_{fidx}_end = line('.') - 1 - - " Create a fold for the entire file - exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'fold' - exe 'silent! ' . s:tlist_{fidx}_start . ',' . - \ s:tlist_{fidx}_end . 'foldopen!' - - " Goto the starting line for this file, - exe s:tlist_{fidx}_start - - if s:tlist_app_name == "winmanager" - " To handle a bug in the winmanager plugin, add a space at the - " last line - call setline('$', ' ') - endif - - " Mark the buffer as not modifiable - setlocal nomodifiable - - " Restore the report option - let &report = old_report - - " Update the start and end line numbers for all the files following this - " file - let start = s:tlist_{fidx}_start - " include the empty line after the last line - if g:Tlist_Compact_Format - let end = s:tlist_{fidx}_end - else - let end = s:tlist_{fidx}_end + 1 - endif - call s:Tlist_Window_Update_Line_Offsets(fidx + 1, 1, end - start + 1) - - " Now that we have updated the taglist window, update the tags - " menu (if present) - if g:Tlist_Show_Menu - call s:Tlist_Menu_Update_File(1) - endif -endfunction - -" Tlist_Init_File -" Initialize the variables for a new file -function! s:Tlist_Init_File(filename, ftype) - call s:Tlist_Log_Msg('Tlist_Init_File (' . a:filename . ')') - " Add new files at the end of the list - let fidx = s:tlist_file_count - let s:tlist_file_count = s:tlist_file_count + 1 - " Add the new file name to the taglist list of file names - let s:tlist_file_names = s:tlist_file_names . a:filename . "\n" - - " Initialize the file variables - let s:tlist_{fidx}_filename = a:filename - let s:tlist_{fidx}_sort_type = g:Tlist_Sort_Type - let s:tlist_{fidx}_filetype = a:ftype - let s:tlist_{fidx}_mtime = -1 - let s:tlist_{fidx}_start = 0 - let s:tlist_{fidx}_end = 0 - let s:tlist_{fidx}_valid = 0 - let s:tlist_{fidx}_visible = 0 - let s:tlist_{fidx}_tag_count = 0 - let s:tlist_{fidx}_menu_cmd = '' - - " Initialize the tag type variables - let i = 1 - while i <= s:tlist_{a:ftype}_count - let ttype = s:tlist_{a:ftype}_{i}_name - let s:tlist_{fidx}_{ttype} = '' - let s:tlist_{fidx}_{ttype}_offset = 0 - let s:tlist_{fidx}_{ttype}_count = 0 - let i = i + 1 - endwhile - - return fidx -endfunction - -" Tlist_Get_Tag_Type_By_Tag -" Return the tag type for the specified tag index -function! s:Tlist_Get_Tag_Type_By_Tag(fidx, tidx) - let ttype_var = 's:tlist_' . a:fidx . '_' . a:tidx . '_tag_type' - - " Already parsed and have the tag name - if exists(ttype_var) - return {ttype_var} - endif - - let tag_line = s:tlist_{a:fidx}_{a:tidx}_tag - let {ttype_var} = s:Tlist_Extract_Tagtype(tag_line) - - return {ttype_var} -endfunction - -" Tlist_Get_Tag_Prototype -function! s:Tlist_Get_Tag_Prototype(fidx, tidx) - let tproto_var = 's:tlist_' . a:fidx . '_' . a:tidx . '_tag_proto' - - " Already parsed and have the tag prototype - if exists(tproto_var) - return {tproto_var} - endif - - " Parse and extract the tag prototype - let tag_line = s:tlist_{a:fidx}_{a:tidx}_tag - let start = stridx(tag_line, '/^') + 2 - let end = stridx(tag_line, '/;"' . "\t") - if tag_line[end - 1] == '$' - let end = end -1 - endif - let tag_proto = strpart(tag_line, start, end - start) - let {tproto_var} = substitute(tag_proto, '\s*', '', '') - - return {tproto_var} -endfunction - -" Tlist_Get_Tag_SearchPat -function! s:Tlist_Get_Tag_SearchPat(fidx, tidx) - let tpat_var = 's:tlist_' . a:fidx . '_' . a:tidx . '_tag_searchpat' - - " Already parsed and have the tag search pattern - if exists(tpat_var) - return {tpat_var} - endif - - " Parse and extract the tag search pattern - let tag_line = s:tlist_{a:fidx}_{a:tidx}_tag - let start = stridx(tag_line, '/^') + 2 - let end = stridx(tag_line, '/;"' . "\t") - if tag_line[end - 1] == '$' - let end = end -1 - endif - let {tpat_var} = '\V\^' . strpart(tag_line, start, end - start) . - \ (tag_line[end] == '$' ? '\$' : '') - - return {tpat_var} -endfunction - -" Tlist_Get_Tag_Linenum -" Return the tag line number, given the tag index -function! s:Tlist_Get_Tag_Linenum(fidx, tidx) - let tline_var = 's:tlist_' . a:fidx . '_' . a:tidx . '_tag_linenum' - - " Already parsed and have the tag line number - if exists(tline_var) - return {tline_var} - endif - - " Parse and extract the tag line number - let tag_line = s:tlist_{a:fidx}_{a:tidx}_tag - let start = strridx(tag_line, 'line:') + 5 - let end = strridx(tag_line, "\t") - if end < start - let {tline_var} = strpart(tag_line, start) + 0 - else - let {tline_var} = strpart(tag_line, start, end - start) + 0 - endif - - return {tline_var} -endfunction - -" Tlist_Parse_Tagline -" Parse a tag line from the ctags output. Separate the tag output based on the -" tag type and store it in the tag type variable. -" The format of each line in the ctags output is: -" -" tag_name<TAB>file_name<TAB>ex_cmd;"<TAB>extension_fields -" -function! s:Tlist_Parse_Tagline(tag_line) - if a:tag_line == '' - " Skip empty lines - return - endif - - " Extract the tag type - let ttype = s:Tlist_Extract_Tagtype(a:tag_line) - - " Make sure the tag type is a valid and supported one - if ttype == '' || stridx(s:ctags_flags, ttype) == -1 - " Line is not in proper tags format or Tag type is not supported - return - endif - - " Update the total tag count - let s:tidx = s:tidx + 1 - - " The following variables are used to optimize this code. Vim is slow in - " using curly brace names. To reduce the amount of processing needed, the - " curly brace variables are pre-processed here - let fidx_tidx = 's:tlist_' . s:fidx . '_' . s:tidx - let fidx_ttype = 's:tlist_' . s:fidx . '_' . ttype - - " Update the count of this tag type - let ttype_idx = {fidx_ttype}_count + 1 - let {fidx_ttype}_count = ttype_idx - - " Store the ctags output for this tag - let {fidx_tidx}_tag = a:tag_line - - " Store the tag index and the tag type index (back pointers) - let {fidx_ttype}_{ttype_idx} = s:tidx - let {fidx_tidx}_ttype_idx = ttype_idx - - " Extract the tag name - let tag_name = strpart(a:tag_line, 0, stridx(a:tag_line, "\t")) - - " Extract the tag scope/prototype - if g:Tlist_Display_Prototype - let ttxt = ' ' . s:Tlist_Get_Tag_Prototype(s:fidx, s:tidx) - else - let ttxt = ' ' . tag_name - - " Add the tag scope, if it is available and is configured. Tag - " scope is the last field after the 'line:<num>\t' field - if g:Tlist_Display_Tag_Scope - let tag_scope = s:Tlist_Extract_Tag_Scope(a:tag_line) - if tag_scope != '' - let ttxt = ttxt . ' [' . tag_scope . ']' - endif - endif - endif - - " Add this tag to the tag type variable - let {fidx_ttype} = {fidx_ttype} . ttxt . "\n" - - " Save the tag name - let {fidx_tidx}_tag_name = tag_name -endfunction - -" Tlist_Process_File -" Get the list of tags defined in the specified file and store them -" in Vim variables. Returns the file index where the tags are stored. -function! s:Tlist_Process_File(filename, ftype) - call s:Tlist_Log_Msg('Tlist_Process_File (' . a:filename . ', ' . - \ a:ftype . ')') - " Check whether this file is supported - if s:Tlist_Skip_File(a:filename, a:ftype) - return -1 - endif - - " If the tag types for this filetype are not yet created, then create - " them now - let var = 's:tlist_' . a:ftype . '_count' - if !exists(var) - if s:Tlist_FileType_Init(a:ftype) == 0 - return -1 - endif - endif - - " If this file is already processed, then use the cached values - let fidx = s:Tlist_Get_File_Index(a:filename) - if fidx == -1 - " First time, this file is loaded - let fidx = s:Tlist_Init_File(a:filename, a:ftype) - else - " File was previously processed. Discard the tag information - call s:Tlist_Discard_TagInfo(fidx) - endif - - let s:tlist_{fidx}_valid = 1 - - " Exuberant ctags arguments to generate a tag list - let ctags_args = ' -f - --format=2 --excmd=pattern --fields=nks ' - - " Form the ctags argument depending on the sort type - if s:tlist_{fidx}_sort_type == 'name' - let ctags_args = ctags_args . '--sort=yes' - else - let ctags_args = ctags_args . '--sort=no' - endif - - " Add the filetype specific arguments - let ctags_args = ctags_args . ' ' . s:tlist_{a:ftype}_ctags_args - - " Ctags command to produce output with regexp for locating the tags - let ctags_cmd = g:Tlist_Ctags_Cmd . ctags_args - let ctags_cmd = ctags_cmd . ' "' . a:filename . '"' - - if &shellxquote == '"' - " Double-quotes within double-quotes will not work in the - " command-line.If the 'shellxquote' option is set to double-quotes, - " then escape the double-quotes in the ctags command-line. - let ctags_cmd = escape(ctags_cmd, '"') - endif - - " In Windows 95, if not using cygwin, disable the 'shellslash' - " option. Otherwise, this will cause problems when running the - " ctags command. - if has('win95') && !has('win32unix') - let old_shellslash = &shellslash - set noshellslash - endif - - if has('win32') && !has('win32unix') && !has('win95') - \ && (&shell =~ 'cmd.exe') - " Windows does not correctly deal with commands that have more than 1 - " set of double quotes. It will strip them all resulting in: - " 'C:\Program' is not recognized as an internal or external command - " operable program or batch file. To work around this, place the - " command inside a batch file and call the batch file. - " Do this only on Win2K, WinXP and above. - " Contributed by: David Fishburn. - let s:taglist_tempfile = fnamemodify(tempname(), ':h') . - \ '\taglist.cmd' - exe 'redir! > ' . s:taglist_tempfile - silent echo ctags_cmd - redir END - - call s:Tlist_Log_Msg('Cmd inside batch file: ' . ctags_cmd) - let ctags_cmd = '"' . s:taglist_tempfile . '"' - endif - - call s:Tlist_Log_Msg('Cmd: ' . ctags_cmd) - - " Run ctags and get the tag list - let cmd_output = system(ctags_cmd) - - " Restore the value of the 'shellslash' option. - if has('win95') && !has('win32unix') - let &shellslash = old_shellslash - endif - - if exists('s:taglist_tempfile') - " Delete the temporary cmd file created on MS-Windows - call delete(s:taglist_tempfile) - endif - - " Handle errors - if v:shell_error - let msg = "Taglist: Failed to generate tags for " . a:filename - call s:Tlist_Warning_Msg(msg) - if cmd_output != '' - call s:Tlist_Warning_Msg(cmd_output) - endif - return fidx - endif - - " Store the modification time for the file - let s:tlist_{fidx}_mtime = getftime(a:filename) - - " No tags for current file - if cmd_output == '' - call s:Tlist_Log_Msg('No tags defined in ' . a:filename) - return fidx - endif - - call s:Tlist_Log_Msg('Generated tags information for ' . a:filename) - - if v:version > 601 - " The following script local variables are used by the - " Tlist_Parse_Tagline() function. - let s:ctags_flags = s:tlist_{a:ftype}_ctags_flags - let s:fidx = fidx - let s:tidx = 0 - - " Process the ctags output one line at a time. The substitute() - " command is used to parse the tag lines instead of using the - " matchstr()/stridx()/strpart() functions for performance reason - call substitute(cmd_output, "\\([^\n]\\+\\)\n", - \ '\=s:Tlist_Parse_Tagline(submatch(1))', 'g') - - " Save the number of tags for this file - let s:tlist_{fidx}_tag_count = s:tidx - - " The following script local variables are no longer needed - unlet! s:ctags_flags - unlet! s:tidx - unlet! s:fidx - else - " Due to a bug in Vim earlier than version 6.1, - " we cannot use substitute() to parse the ctags output. - " Instead the slow str*() functions are used - let ctags_flags = s:tlist_{a:ftype}_ctags_flags - let tidx = 0 - - while cmd_output != '' - " Extract one line at a time - let idx = stridx(cmd_output, "\n") - let one_line = strpart(cmd_output, 0, idx) - " Remove the line from the tags output - let cmd_output = strpart(cmd_output, idx + 1) - - if one_line == '' - " Line is not in proper tags format - continue - endif - - " Extract the tag type - let ttype = s:Tlist_Extract_Tagtype(one_line) - - " Make sure the tag type is a valid and supported one - if ttype == '' || stridx(ctags_flags, ttype) == -1 - " Line is not in proper tags format or Tag type is not - " supported - continue - endif - - " Update the total tag count - let tidx = tidx + 1 - - " The following variables are used to optimize this code. Vim is - " slow in using curly brace names. To reduce the amount of - " processing needed, the curly brace variables are pre-processed - " here - let fidx_tidx = 's:tlist_' . fidx . '_' . tidx - let fidx_ttype = 's:tlist_' . fidx . '_' . ttype - - " Update the count of this tag type - let ttype_idx = {fidx_ttype}_count + 1 - let {fidx_ttype}_count = ttype_idx - - " Store the ctags output for this tag - let {fidx_tidx}_tag = one_line - - " Store the tag index and the tag type index (back pointers) - let {fidx_ttype}_{ttype_idx} = tidx - let {fidx_tidx}_ttype_idx = ttype_idx - - " Extract the tag name - let tag_name = strpart(one_line, 0, stridx(one_line, "\t")) - - " Extract the tag scope/prototype - if g:Tlist_Display_Prototype - let ttxt = ' ' . s:Tlist_Get_Tag_Prototype(fidx, tidx) - else - let ttxt = ' ' . tag_name - - " Add the tag scope, if it is available and is configured. Tag - " scope is the last field after the 'line:<num>\t' field - if g:Tlist_Display_Tag_Scope - let tag_scope = s:Tlist_Extract_Tag_Scope(one_line) - if tag_scope != '' - let ttxt = ttxt . ' [' . tag_scope . ']' - endif - endif - endif - - " Add this tag to the tag type variable - let {fidx_ttype} = {fidx_ttype} . ttxt . "\n" - - " Save the tag name - let {fidx_tidx}_tag_name = tag_name - endwhile - - " Save the number of tags for this file - let s:tlist_{fidx}_tag_count = tidx - endif - - call s:Tlist_Log_Msg('Processed ' . s:tlist_{fidx}_tag_count . - \ ' tags in ' . a:filename) - - return fidx -endfunction - -" Tlist_Update_File -" Update the tags for a file (if needed) -function! Tlist_Update_File(filename, ftype) - call s:Tlist_Log_Msg('Tlist_Update_File (' . a:filename . ')') - " If the file doesn't support tag listing, skip it - if s:Tlist_Skip_File(a:filename, a:ftype) - return - endif - - " Convert the file name to a full path - let fname = fnamemodify(a:filename, ':p') - - " First check whether the file already exists - let fidx = s:Tlist_Get_File_Index(fname) - - if fidx != -1 && s:tlist_{fidx}_valid - " File exists and the tags are valid - " Check whether the file was modified after the last tags update - " If it is modified, then update the tags - if s:tlist_{fidx}_mtime == getftime(fname) - return - endif - else - " If the tags were removed previously based on a user request, - " as we are going to update the tags (based on the user request), - " remove the filename from the deleted list - call s:Tlist_Update_Remove_List(fname, 0) - endif - - " If the taglist window is opened, update it - let winnum = bufwinnr(g:TagList_title) - if winnum == -1 - " Taglist window is not present. Just update the taglist - " and return - call s:Tlist_Process_File(fname, a:ftype) - else - if g:Tlist_Show_One_File && s:tlist_cur_file_idx != -1 - " If tags for only one file are displayed and we are not - " updating the tags for that file, then no need to - " refresh the taglist window. Otherwise, the taglist - " window should be updated. - if s:tlist_{s:tlist_cur_file_idx}_filename != fname - call s:Tlist_Process_File(fname, a:ftype) - return - endif - endif - - " Save the current window number - let save_winnr = winnr() - - " Goto the taglist window - call s:Tlist_Window_Goto_Window() - - " Save the cursor position - let save_line = line('.') - let save_col = col('.') - - " Update the taglist window - call s:Tlist_Window_Refresh_File(fname, a:ftype) - - " Restore the cursor position - if v:version >= 601 - call cursor(save_line, save_col) - else - exe save_line - exe 'normal! ' . save_col . '|' - endif - - if winnr() != save_winnr - " Go back to the original window - call s:Tlist_Exe_Cmd_No_Acmds(save_winnr . 'wincmd w') - endif - endif - - " Update the taglist menu - if g:Tlist_Show_Menu - call s:Tlist_Menu_Update_File(1) - endif -endfunction - -" Tlist_Window_Close -" Close the taglist window -function! s:Tlist_Window_Close() - call s:Tlist_Log_Msg('Tlist_Window_Close()') - " Make sure the taglist window exists - let winnum = bufwinnr(g:TagList_title) - if winnum == -1 - call s:Tlist_Warning_Msg('Error: Taglist window is not open') - return - endif - - if winnr() == winnum - " Already in the taglist window. Close it and return - if winbufnr(2) != -1 - " If a window other than the taglist window is open, - " then only close the taglist window. - close - endif - else - " Goto the taglist window, close it and then come back to the - " original window - let curbufnr = bufnr('%') - exe winnum . 'wincmd w' - close - " Need to jump back to the original window only if we are not - " already in that window - let winnum = bufwinnr(curbufnr) - if winnr() != winnum - exe winnum . 'wincmd w' - endif - endif -endfunction - -" Tlist_Window_Mark_File_Window -" Mark the current window as the file window to use when jumping to a tag. -" Only if the current window is a non-plugin, non-preview and non-taglist -" window -function! s:Tlist_Window_Mark_File_Window() - if getbufvar('%', '&buftype') == '' && !&previewwindow - let w:tlist_file_window = "yes" - endif -endfunction - -" Tlist_Window_Open -" Open and refresh the taglist window -function! s:Tlist_Window_Open() - call s:Tlist_Log_Msg('Tlist_Window_Open()') - " If the window is open, jump to it - let winnum = bufwinnr(g:TagList_title) - if winnum != -1 - " Jump to the existing window - if winnr() != winnum - exe winnum . 'wincmd w' - endif - return - endif - - if s:tlist_app_name == "winmanager" - " Taglist plugin is no longer part of the winmanager app - let s:tlist_app_name = "none" - endif - - " Get the filename and filetype for the specified buffer - let curbuf_name = fnamemodify(bufname('%'), ':p') - let curbuf_ftype = s:Tlist_Get_Buffer_Filetype('%') - let cur_lnum = line('.') - - " Mark the current window as the desired window to open a file when a tag - " is selected. - call s:Tlist_Window_Mark_File_Window() - - " Open the taglist window - call s:Tlist_Window_Create() - - call s:Tlist_Window_Refresh() - - if g:Tlist_Show_One_File - " Add only the current buffer and file - " - " If the file doesn't support tag listing, skip it - if !s:Tlist_Skip_File(curbuf_name, curbuf_ftype) - call s:Tlist_Window_Refresh_File(curbuf_name, curbuf_ftype) - endif - endif - - if g:Tlist_File_Fold_Auto_Close - " Open the fold for the current file, as all the folds in - " the taglist window are closed - let fidx = s:Tlist_Get_File_Index(curbuf_name) - if fidx != -1 - exe "silent! " . s:tlist_{fidx}_start . "," . - \ s:tlist_{fidx}_end . "foldopen!" - endif - endif - - " Highlight the current tag - call s:Tlist_Window_Highlight_Tag(curbuf_name, cur_lnum, 1, 1) -endfunction - -" Tlist_Window_Toggle() -" Open or close a taglist window -function! s:Tlist_Window_Toggle() - call s:Tlist_Log_Msg('Tlist_Window_Toggle()') - " If taglist window is open then close it. - let winnum = bufwinnr(g:TagList_title) - if winnum != -1 - call s:Tlist_Window_Close() - return - endif - - call s:Tlist_Window_Open() - - " Go back to the original window, if Tlist_GainFocus_On_ToggleOpen is not - " set - if !g:Tlist_GainFocus_On_ToggleOpen - call s:Tlist_Exe_Cmd_No_Acmds('wincmd p') - endif - - " Update the taglist menu - if g:Tlist_Show_Menu - call s:Tlist_Menu_Update_File(0) - endif -endfunction - -" Tlist_Process_Filelist -" Process multiple files. Each filename is separated by "\n" -" Returns the number of processed files -function! s:Tlist_Process_Filelist(file_names) - let flist = a:file_names - - " Enable lazy screen updates - let old_lazyredraw = &lazyredraw - set lazyredraw - - " Keep track of the number of processed files - let fcnt = 0 - - " Process one file at a time - while flist != '' - let nl_idx = stridx(flist, "\n") - let one_file = strpart(flist, 0, nl_idx) - - " Remove the filename from the list - let flist = strpart(flist, nl_idx + 1) - - if one_file == '' - continue - endif - - " Skip directories - if isdirectory(one_file) - continue - endif - - let ftype = s:Tlist_Detect_Filetype(one_file) - - echon "\r " - echon "\rProcessing tags for " . fnamemodify(one_file, ':p:t') - - let fcnt = fcnt + 1 - - call Tlist_Update_File(one_file, ftype) - endwhile - - " Clear the displayed informational messages - echon "\r " - - " Restore the previous state - let &lazyredraw = old_lazyredraw - - return fcnt -endfunction - -" Tlist_Process_Dir -" Process the files in a directory matching the specified pattern -function! s:Tlist_Process_Dir(dir_name, pat) - let flist = glob(a:dir_name . '/' . a:pat) . "\n" - - let fcnt = s:Tlist_Process_Filelist(flist) - - let len = strlen(a:dir_name) - if a:dir_name[len - 1] == '\' || a:dir_name[len - 1] == '/' - let glob_expr = a:dir_name . '*' - else - let glob_expr = a:dir_name . '/*' - endif - let all_files = glob(glob_expr) . "\n" - - while all_files != '' - let nl_idx = stridx(all_files, "\n") - let one_file = strpart(all_files, 0, nl_idx) - - let all_files = strpart(all_files, nl_idx + 1) - if one_file == '' - continue - endif - - " Skip non-directory names - if !isdirectory(one_file) - continue - endif - - echon "\r " - echon "\rProcessing files in directory " . fnamemodify(one_file, ':t') - let fcnt = fcnt + s:Tlist_Process_Dir(one_file, a:pat) - endwhile - - return fcnt -endfunction - -" Tlist_Add_Files_Recursive -" Add files recursively from a directory -function! s:Tlist_Add_Files_Recursive(dir, ...) - let dir_name = fnamemodify(a:dir, ':p') - if !isdirectory(dir_name) - call s:Tlist_Warning_Msg('Error: ' . dir_name . ' is not a directory') - return - endif - - if a:0 == 1 - " User specified file pattern - let pat = a:1 - else - " Default file pattern - let pat = '*' - endif - - echon "\r " - echon "\rProcessing files in directory " . fnamemodify(dir_name, ':t') - let fcnt = s:Tlist_Process_Dir(dir_name, pat) - - echon "\rAdded " . fcnt . " files to the taglist" -endfunction - -" Tlist_Add_Files -" Add the specified list of files to the taglist -function! s:Tlist_Add_Files(...) - let flist = '' - let i = 1 - - " Get all the files matching the file patterns supplied as argument - while i <= a:0 - let flist = flist . glob(a:{i}) . "\n" - let i = i + 1 - endwhile - - if flist == '' - call s:Tlist_Warning_Msg('Error: No matching files are found') - return - endif - - let fcnt = s:Tlist_Process_Filelist(flist) - echon "\rAdded " . fcnt . " files to the taglist" -endfunction - -" Tlist_Extract_Tagtype -" Extract the tag type from the tag text -function! s:Tlist_Extract_Tagtype(tag_line) - " The tag type is after the tag prototype field. The prototype field - " ends with the /;"\t string. We add 4 at the end to skip the characters - " in this special string.. - let start = strridx(a:tag_line, '/;"' . "\t") + 4 - let end = strridx(a:tag_line, 'line:') - 1 - let ttype = strpart(a:tag_line, start, end - start) - - return ttype -endfunction - -" Tlist_Extract_Tag_Scope -" Extract the tag scope from the tag text -function! s:Tlist_Extract_Tag_Scope(tag_line) - let start = strridx(a:tag_line, 'line:') - let end = strridx(a:tag_line, "\t") - if end <= start - return '' - endif - - let tag_scope = strpart(a:tag_line, end + 1) - let tag_scope = strpart(tag_scope, stridx(tag_scope, ':') + 1) - - return tag_scope -endfunction - -" Tlist_Refresh() -" Refresh the taglist -function! s:Tlist_Refresh() - call s:Tlist_Log_Msg('Tlist_Refresh (Skip_Refresh = ' . - \ s:Tlist_Skip_Refresh . ', ' . bufname('%') . ')') - " If we are entering the buffer from one of the taglist functions, then - " no need to refresh the taglist window again. - if s:Tlist_Skip_Refresh - " We still need to update the taglist menu - if g:Tlist_Show_Menu - call s:Tlist_Menu_Update_File(0) - endif - return - endif - - " If part of the winmanager plugin and not configured to process - " tags always and not configured to display the tags menu, then return - if (s:tlist_app_name == 'winmanager') && !g:Tlist_Process_File_Always - \ && !g:Tlist_Show_Menu - return - endif - - " Skip buffers with 'buftype' set to nofile, nowrite, quickfix or help - if &buftype != '' - return - endif - - let filename = fnamemodify(bufname('%'), ':p') - let ftype = s:Tlist_Get_Buffer_Filetype('%') - - " If the file doesn't support tag listing, skip it - if s:Tlist_Skip_File(filename, ftype) - return - endif - - let tlist_win = bufwinnr(g:TagList_title) - - " If the taglist window is not opened and not configured to process - " tags always and not displaying the tags menu, then return - if tlist_win == -1 && !g:Tlist_Process_File_Always && !g:Tlist_Show_Menu - return - endif - - let fidx = s:Tlist_Get_File_Index(filename) - if fidx == -1 - " Check whether this file is removed based on user request - " If it is, then don't display the tags for this file - if s:Tlist_User_Removed_File(filename) - return - endif - - " If the taglist should not be auto updated, then return - if !g:Tlist_Auto_Update - return - endif - endif - - let cur_lnum = line('.') - - if fidx == -1 - " Update the tags for the file - let fidx = s:Tlist_Process_File(filename, ftype) - else - let mtime = getftime(filename) - if s:tlist_{fidx}_mtime != mtime - " Invalidate the tags listed for this file - let s:tlist_{fidx}_valid = 0 - - " Update the taglist and the window - call Tlist_Update_File(filename, ftype) - - " Store the new file modification time - let s:tlist_{fidx}_mtime = mtime - endif - endif - - " Update the taglist window - if tlist_win != -1 - " Disable screen updates - let old_lazyredraw = &lazyredraw - set nolazyredraw - - " Save the current window number - let save_winnr = winnr() - - " Goto the taglist window - call s:Tlist_Window_Goto_Window() - - if !g:Tlist_Auto_Highlight_Tag || !g:Tlist_Highlight_Tag_On_BufEnter - " Save the cursor position - let save_line = line('.') - let save_col = col('.') - endif - - " Update the taglist window - call s:Tlist_Window_Refresh_File(filename, ftype) - - " Open the fold for the file - exe "silent! " . s:tlist_{fidx}_start . "," . - \ s:tlist_{fidx}_end . "foldopen!" - - if g:Tlist_Highlight_Tag_On_BufEnter && g:Tlist_Auto_Highlight_Tag - if g:Tlist_Show_One_File && s:tlist_cur_file_idx != fidx - " If displaying tags for only one file in the taglist - " window and about to display the tags for a new file, - " then center the current tag line for the new file - let center_tag_line = 1 - else - let center_tag_line = 0 - endif - - " Highlight the current tag - call s:Tlist_Window_Highlight_Tag(filename, cur_lnum, 1, center_tag_line) - else - " Restore the cursor position - if v:version >= 601 - call cursor(save_line, save_col) - else - exe save_line - exe 'normal! ' . save_col . '|' - endif - endif - - " Jump back to the original window - if save_winnr != winnr() - call s:Tlist_Exe_Cmd_No_Acmds(save_winnr . 'wincmd w') - endif - - " Restore screen updates - let &lazyredraw = old_lazyredraw - endif - - " Update the taglist menu - if g:Tlist_Show_Menu - call s:Tlist_Menu_Update_File(0) - endif -endfunction - -" Tlist_Change_Sort() -" Change the sort order of the tag listing -" caller == 'cmd', command used in the taglist window -" caller == 'menu', taglist menu -" action == 'toggle', toggle sort from name to order and vice versa -" action == 'set', set the sort order to sort_type -function! s:Tlist_Change_Sort(caller, action, sort_type) - call s:Tlist_Log_Msg('Tlist_Change_Sort (caller = ' . a:caller . - \ ', action = ' . a:action . ', sort_type = ' . a:sort_type . ')') - if a:caller == 'cmd' - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(line('.')) - if fidx == -1 - return - endif - - " Remove the previous highlighting - match none - elseif a:caller == 'menu' - let fidx = s:Tlist_Get_File_Index(fnamemodify(bufname('%'), ':p')) - if fidx == -1 - return - endif - endif - - if a:action == 'toggle' - let sort_type = s:tlist_{fidx}_sort_type - - " Toggle the sort order from 'name' to 'order' and vice versa - if sort_type == 'name' - let s:tlist_{fidx}_sort_type = 'order' - else - let s:tlist_{fidx}_sort_type = 'name' - endif - else - let s:tlist_{fidx}_sort_type = a:sort_type - endif - - " Invalidate the tags listed for this file - let s:tlist_{fidx}_valid = 0 - - if a:caller == 'cmd' - " Save the current line for later restoration - let curline = '\V\^' . getline('.') . '\$' - - call s:Tlist_Window_Refresh_File(s:tlist_{fidx}_filename, - \ s:tlist_{fidx}_filetype) - - exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'foldopen!' - - " Go back to the cursor line before the tag list is sorted - call search(curline, 'w') - - call s:Tlist_Menu_Update_File(1) - else - call s:Tlist_Menu_Remove_File() - - call s:Tlist_Refresh() - endif -endfunction - -" Tlist_Update_Current_File() -" Update taglist for the current buffer by regenerating the tag list -" Contributed by WEN Guopeng. -function! s:Tlist_Update_Current_File() - call s:Tlist_Log_Msg('Tlist_Update_Current_File()') - if winnr() == bufwinnr(g:TagList_title) - " In the taglist window. Update the current file - call s:Tlist_Window_Update_File() - else - " Not in the taglist window. Update the current buffer - let filename = fnamemodify(bufname('%'), ':p') - let fidx = s:Tlist_Get_File_Index(filename) - if fidx != -1 - let s:tlist_{fidx}_valid = 0 - endif - let ft = s:Tlist_Get_Buffer_Filetype('%') - call Tlist_Update_File(filename, ft) - endif -endfunction - -" Tlist_Window_Update_File() -" Update the tags displayed in the taglist window -function! s:Tlist_Window_Update_File() - call s:Tlist_Log_Msg('Tlist_Window_Update_File()') - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(line('.')) - if fidx == -1 - return - endif - - " Remove the previous highlighting - match none - - " Save the current line for later restoration - let curline = '\V\^' . getline('.') . '\$' - - let s:tlist_{fidx}_valid = 0 - - " Update the taglist window - call s:Tlist_Window_Refresh_File(s:tlist_{fidx}_filename, - \ s:tlist_{fidx}_filetype) - - exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'foldopen!' - - " Go back to the tag line before the list is updated - call search(curline, 'w') -endfunction - -" Tlist_Window_Get_Tag_Type_By_Linenum() -" Return the tag type index for the specified line in the taglist window -function! s:Tlist_Window_Get_Tag_Type_By_Linenum(fidx, lnum) - let ftype = s:tlist_{a:fidx}_filetype - - " Determine to which tag type the current line number belongs to using the - " tag type start line number and the number of tags in a tag type - let i = 1 - while i <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{i}_name - let start_lnum = - \ s:tlist_{a:fidx}_start + s:tlist_{a:fidx}_{ttype}_offset - let end = start_lnum + s:tlist_{a:fidx}_{ttype}_count - if a:lnum >= start_lnum && a:lnum <= end - break - endif - let i = i + 1 - endwhile - - " Current line doesn't belong to any of the displayed tag types - if i > s:tlist_{ftype}_count - return '' - endif - - return ttype -endfunction - -" Tlist_Window_Get_Tag_Index() -" Return the tag index for the specified line in the taglist window -function! s:Tlist_Window_Get_Tag_Index(fidx, lnum) - let ttype = s:Tlist_Window_Get_Tag_Type_By_Linenum(a:fidx, a:lnum) - - " Current line doesn't belong to any of the displayed tag types - if ttype == '' - return 0 - endif - - " Compute the index into the displayed tags for the tag type - let ttype_lnum = s:tlist_{a:fidx}_start + s:tlist_{a:fidx}_{ttype}_offset - let tidx = a:lnum - ttype_lnum - if tidx == 0 - return 0 - endif - - " Get the corresponding tag line and return it - return s:tlist_{a:fidx}_{ttype}_{tidx} -endfunction - -" Tlist_Window_Highlight_Line -" Highlight the current line -function! s:Tlist_Window_Highlight_Line() - " Clear previously selected name - match none - - " Highlight the current line - if g:Tlist_Display_Prototype == 0 - let pat = '/\%' . line('.') . 'l\s\+\zs.*/' - else - let pat = '/\%' . line('.') . 'l.*/' - endif - - exe 'match TagListTagName ' . pat -endfunction - -" Tlist_Window_Open_File -" Open the specified file in either a new window or an existing window -" and place the cursor at the specified tag pattern -function! s:Tlist_Window_Open_File(win_ctrl, filename, tagpat) - call s:Tlist_Log_Msg('Tlist_Window_Open_File (' . a:filename . ',' . - \ a:win_ctrl . ')') - let prev_Tlist_Skip_Refresh = s:Tlist_Skip_Refresh - let s:Tlist_Skip_Refresh = 1 - - if s:tlist_app_name == "winmanager" - " Let the winmanager edit the file - call WinManagerFileEdit(a:filename, a:win_ctrl == 'newwin') - else - - if a:win_ctrl == 'newtab' - " Create a new tab - exe 'tabnew ' . escape(a:filename, ' ') - " Open the taglist window in the new tab - call s:Tlist_Window_Open() - endif - - if a:win_ctrl == 'checktab' - " Check whether the file is present in any of the tabs. - " If the file is present in the current tab, then use the - " current tab. - if bufwinnr(a:filename) != -1 - let file_present_in_tab = 1 - let i = tabpagenr() - else - let i = 1 - let bnum = bufnr(a:filename) - let file_present_in_tab = 0 - while i <= tabpagenr('$') - if index(tabpagebuflist(i), bnum) != -1 - let file_present_in_tab = 1 - break - endif - let i += 1 - endwhile - endif - - if file_present_in_tab - " Goto the tab containing the file - exe 'tabnext ' . i - else - " Open a new tab - exe 'tabnew ' . escape(a:filename, ' ') - - " Open the taglist window - call s:Tlist_Window_Open() - endif - endif - - let winnum = -1 - if a:win_ctrl == 'prevwin' - " Open the file in the previous window, if it is usable - let cur_win = winnr() - wincmd p - if &buftype == '' && !&previewwindow - exe "edit " . escape(a:filename, ' ') - let winnum = winnr() - else - " Previous window is not usable - exe cur_win . 'wincmd w' - endif - endif - - " Goto the window containing the file. If the window is not there, open a - " new window - if winnum == -1 - let winnum = bufwinnr(a:filename) - endif - - if winnum == -1 - " Locate the previously used window for opening a file - let fwin_num = 0 - let first_usable_win = 0 - - let i = 1 - let bnum = winbufnr(i) - while bnum != -1 - if getwinvar(i, 'tlist_file_window') == 'yes' - let fwin_num = i - break - endif - if first_usable_win == 0 && - \ getbufvar(bnum, '&buftype') == '' && - \ !getwinvar(i, '&previewwindow') - " First non-taglist, non-plugin and non-preview window - let first_usable_win = i - endif - let i = i + 1 - let bnum = winbufnr(i) - endwhile - - " If a previously used window is not found, then use the first - " non-taglist window - if fwin_num == 0 - let fwin_num = first_usable_win - endif - - if fwin_num != 0 - " Jump to the file window - exe fwin_num . "wincmd w" - - " If the user asked to jump to the tag in a new window, then split - " the existing window into two. - if a:win_ctrl == 'newwin' - split - endif - exe "edit " . escape(a:filename, ' ') - else - " Open a new window - if g:Tlist_Use_Horiz_Window - exe 'leftabove split ' . escape(a:filename, ' ') - else - if winbufnr(2) == -1 - " Only the taglist window is present - if g:Tlist_Use_Right_Window - exe 'leftabove vertical split ' . - \ escape(a:filename, ' ') - else - exe 'rightbelow vertical split ' . - \ escape(a:filename, ' ') - endif - - " Go to the taglist window to change the window size to - " the user configured value - call s:Tlist_Exe_Cmd_No_Acmds('wincmd p') - if g:Tlist_Use_Horiz_Window - exe 'resize ' . g:Tlist_WinHeight - else - exe 'vertical resize ' . g:Tlist_WinWidth - endif - " Go back to the file window - call s:Tlist_Exe_Cmd_No_Acmds('wincmd p') - else - " A plugin or help window is also present - wincmd w - exe 'leftabove split ' . escape(a:filename, ' ') - endif - endif - endif - " Mark the window, so that it can be reused. - call s:Tlist_Window_Mark_File_Window() - else - if v:version >= 700 - " If the file is opened in more than one window, then check - " whether the last accessed window has the selected file. - " If it does, then use that window. - let lastwin_bufnum = winbufnr(winnr('#')) - if bufnr(a:filename) == lastwin_bufnum - let winnum = winnr('#') - endif - endif - exe winnum . 'wincmd w' - - " If the user asked to jump to the tag in a new window, then split the - " existing window into two. - if a:win_ctrl == 'newwin' - split - endif - endif - endif - - " Jump to the tag - if a:tagpat != '' - " Add the current cursor position to the jump list, so that user can - " jump back using the ' and ` marks. - mark ' - silent call search(a:tagpat, 'w') - - " Bring the line to the middle of the window - normal! z. - - " If the line is inside a fold, open the fold - if foldclosed('.') != -1 - .foldopen - endif - endif - - " If the user selects to preview the tag then jump back to the - " taglist window - if a:win_ctrl == 'preview' - " Go back to the taglist window - let winnum = bufwinnr(g:TagList_title) - exe winnum . 'wincmd w' - else - " If the user has selected to close the taglist window, when a - " tag is selected, close the taglist window - if g:Tlist_Close_On_Select - call s:Tlist_Window_Goto_Window() - close - - " Go back to the window displaying the selected file - let wnum = bufwinnr(a:filename) - if wnum != -1 && wnum != winnr() - call s:Tlist_Exe_Cmd_No_Acmds(wnum . 'wincmd w') - endif - endif - endif - - let s:Tlist_Skip_Refresh = prev_Tlist_Skip_Refresh -endfunction - -" Tlist_Window_Jump_To_Tag() -" Jump to the location of the current tag -" win_ctrl == useopen - Reuse the existing file window -" win_ctrl == newwin - Open a new window -" win_ctrl == preview - Preview the tag -" win_ctrl == prevwin - Open in previous window -" win_ctrl == newtab - Open in new tab -function! s:Tlist_Window_Jump_To_Tag(win_ctrl) - call s:Tlist_Log_Msg('Tlist_Window_Jump_To_Tag(' . a:win_ctrl . ')') - " Do not process comment lines and empty lines - let curline = getline('.') - if curline =~ '^\s*$' || curline[0] == '"' - return - endif - - " If inside a closed fold, then use the first line of the fold - " and jump to the file. - let lnum = foldclosed('.') - if lnum == -1 - " Jump to the selected tag or file - let lnum = line('.') - else - " Open the closed fold - .foldopen! - endif - - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(lnum) - if fidx == -1 - return - endif - - " Get the tag output for the current tag - let tidx = s:Tlist_Window_Get_Tag_Index(fidx, lnum) - if tidx != 0 - let tagpat = s:Tlist_Get_Tag_SearchPat(fidx, tidx) - - " Highlight the tagline - call s:Tlist_Window_Highlight_Line() - else - " Selected a line which is not a tag name. Just edit the file - let tagpat = '' - endif - - call s:Tlist_Window_Open_File(a:win_ctrl, s:tlist_{fidx}_filename, tagpat) -endfunction - -" Tlist_Window_Show_Info() -" Display information about the entry under the cursor -function! s:Tlist_Window_Show_Info() - call s:Tlist_Log_Msg('Tlist_Window_Show_Info()') - - " Clear the previously displayed line - echo - - " Do not process comment lines and empty lines - let curline = getline('.') - if curline =~ '^\s*$' || curline[0] == '"' - return - endif - - " If inside a fold, then don't display the prototype - if foldclosed('.') != -1 - return - endif - - let lnum = line('.') - - " Get the file index - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(lnum) - if fidx == -1 - return - endif - - if lnum == s:tlist_{fidx}_start - " Cursor is on a file name - let fname = s:tlist_{fidx}_filename - if strlen(fname) > 50 - let fname = fnamemodify(fname, ':t') - endif - echo fname . ', Filetype=' . s:tlist_{fidx}_filetype . - \ ', Tag count=' . s:tlist_{fidx}_tag_count - return - endif - - " Get the tag output line for the current tag - let tidx = s:Tlist_Window_Get_Tag_Index(fidx, lnum) - if tidx == 0 - " Cursor is on a tag type - let ttype = s:Tlist_Window_Get_Tag_Type_By_Linenum(fidx, lnum) - if ttype == '' - return - endif - - let ttype_name = '' - - let ftype = s:tlist_{fidx}_filetype - let i = 1 - while i <= s:tlist_{ftype}_count - if ttype == s:tlist_{ftype}_{i}_name - let ttype_name = s:tlist_{ftype}_{i}_fullname - break - endif - let i = i + 1 - endwhile - - echo 'Tag type=' . ttype_name . - \ ', Tag count=' . s:tlist_{fidx}_{ttype}_count - return - endif - - " Get the tag search pattern and display it - echo s:Tlist_Get_Tag_Prototype(fidx, tidx) -endfunction - -" Tlist_Find_Nearest_Tag_Idx -" Find the tag idx nearest to the supplied line number -" Returns -1, if a tag couldn't be found for the specified line number -function! s:Tlist_Find_Nearest_Tag_Idx(fidx, linenum) - let sort_type = s:tlist_{a:fidx}_sort_type - - let left = 1 - let right = s:tlist_{a:fidx}_tag_count - - if sort_type == 'order' - " Tags sorted by order, use a binary search. - " The idea behind this function is taken from the ctags.vim script (by - " Alexey Marinichev) available at the Vim online website. - - " If the current line is the less than the first tag, then no need to - " search - let first_lnum = s:Tlist_Get_Tag_Linenum(a:fidx, 1) - - if a:linenum < first_lnum - return -1 - endif - - while left < right - let middle = (right + left + 1) / 2 - let middle_lnum = s:Tlist_Get_Tag_Linenum(a:fidx, middle) - - if middle_lnum == a:linenum - let left = middle - break - endif - - if middle_lnum > a:linenum - let right = middle - 1 - else - let left = middle - endif - endwhile - else - " Tags sorted by name, use a linear search. (contributed by Dave - " Eggum). - " Look for a tag with a line number less than or equal to the supplied - " line number. If multiple tags are found, then use the tag with the - " line number closest to the supplied line number. IOW, use the tag - " with the highest line number. - let closest_lnum = 0 - let final_left = 0 - while left <= right - let lnum = s:Tlist_Get_Tag_Linenum(a:fidx, left) - - if lnum < a:linenum && lnum > closest_lnum - let closest_lnum = lnum - let final_left = left - elseif lnum == a:linenum - let closest_lnum = lnum - let final_left = left - break - else - let left = left + 1 - endif - endwhile - if closest_lnum == 0 - return -1 - endif - if left >= right - let left = final_left - endif - endif - - return left -endfunction - -" Tlist_Window_Highlight_Tag() -" Highlight the current tag -" cntx == 1, Called by the taglist plugin itself -" cntx == 2, Forced by the user through the TlistHighlightTag command -" center = 1, move the tag line to the center of the taglist window -function! s:Tlist_Window_Highlight_Tag(filename, cur_lnum, cntx, center) - " Highlight the current tag only if the user configured the - " taglist plugin to do so or if the user explictly invoked the - " command to highlight the current tag. - if !g:Tlist_Auto_Highlight_Tag && a:cntx == 1 - return - endif - - if a:filename == '' - return - endif - - " Make sure the taglist window is present - let winnum = bufwinnr(g:TagList_title) - if winnum == -1 - call s:Tlist_Warning_Msg('Error: Taglist window is not open') - return - endif - - let fidx = s:Tlist_Get_File_Index(a:filename) - if fidx == -1 - return - endif - - " If the file is currently not displayed in the taglist window, then retrn - if !s:tlist_{fidx}_visible - return - endif - - " If there are no tags for this file, then no need to proceed further - if s:tlist_{fidx}_tag_count == 0 - return - endif - - " Ignore all autocommands - let old_ei = &eventignore - set eventignore=all - - " Save the original window number - let org_winnr = winnr() - - if org_winnr == winnum - let in_taglist_window = 1 - else - let in_taglist_window = 0 - endif - - " Go to the taglist window - if !in_taglist_window - exe winnum . 'wincmd w' - endif - - " Clear previously selected name - match none - - let tidx = s:Tlist_Find_Nearest_Tag_Idx(fidx, a:cur_lnum) - if tidx == -1 - " Make sure the current tag line is visible in the taglist window. - " Calling the winline() function makes the line visible. Don't know - " of a better way to achieve this. - let lnum = line('.') - - if lnum < s:tlist_{fidx}_start || lnum > s:tlist_{fidx}_end - " Move the cursor to the beginning of the file - exe s:tlist_{fidx}_start - endif - - if foldclosed('.') != -1 - .foldopen - endif - - call winline() - - if !in_taglist_window - exe org_winnr . 'wincmd w' - endif - - " Restore the autocommands - let &eventignore = old_ei - return - endif - - " Extract the tag type - let ttype = s:Tlist_Get_Tag_Type_By_Tag(fidx, tidx) - - " Compute the line number - " Start of file + Start of tag type + offset - let lnum = s:tlist_{fidx}_start + s:tlist_{fidx}_{ttype}_offset + - \ s:tlist_{fidx}_{tidx}_ttype_idx - - " Goto the line containing the tag - exe lnum - - " Open the fold - if foldclosed('.') != -1 - .foldopen - endif - - if a:center - " Move the tag line to the center of the taglist window - normal! z. - else - " Make sure the current tag line is visible in the taglist window. - " Calling the winline() function makes the line visible. Don't know - " of a better way to achieve this. - call winline() - endif - - " Highlight the tag name - call s:Tlist_Window_Highlight_Line() - - " Go back to the original window - if !in_taglist_window - exe org_winnr . 'wincmd w' - endif - - " Restore the autocommands - let &eventignore = old_ei - return -endfunction - -" Tlist_Get_Tag_Prototype_By_Line -" Get the prototype for the tag on or before the specified line number in the -" current buffer -function! Tlist_Get_Tag_Prototype_By_Line(...) - if a:0 == 0 - " Arguments are not supplied. Use the current buffer name - " and line number - let filename = bufname('%') - let linenr = line('.') - elseif a:0 == 2 - " Filename and line number are specified - let filename = a:1 - let linenr = a:2 - if linenr !~ '\d\+' - " Invalid line number - return "" - endif - else - " Sufficient arguments are not supplied - let msg = 'Usage: Tlist_Get_Tag_Prototype_By_Line <filename> ' . - \ '<line_number>' - call s:Tlist_Warning_Msg(msg) - return "" - endif - - " Expand the file to a fully qualified name - let filename = fnamemodify(filename, ':p') - if filename == '' - return "" - endif - - let fidx = s:Tlist_Get_File_Index(filename) - if fidx == -1 - return "" - endif - - " If there are no tags for this file, then no need to proceed further - if s:tlist_{fidx}_tag_count == 0 - return "" - endif - - " Get the tag text using the line number - let tidx = s:Tlist_Find_Nearest_Tag_Idx(fidx, linenr) - if tidx == -1 - return "" - endif - - return s:Tlist_Get_Tag_Prototype(fidx, tidx) -endfunction - -" Tlist_Get_Tagname_By_Line -" Get the tag name on or before the specified line number in the -" current buffer -function! Tlist_Get_Tagname_By_Line(...) - if a:0 == 0 - " Arguments are not supplied. Use the current buffer name - " and line number - let filename = bufname('%') - let linenr = line('.') - elseif a:0 == 2 - " Filename and line number are specified - let filename = a:1 - let linenr = a:2 - if linenr !~ '\d\+' - " Invalid line number - return "" - endif - else - " Sufficient arguments are not supplied - let msg = 'Usage: Tlist_Get_Tagname_By_Line <filename> <line_number>' - call s:Tlist_Warning_Msg(msg) - return "" - endif - - " Make sure the current file has a name - let filename = fnamemodify(filename, ':p') - if filename == '' - return "" - endif - - let fidx = s:Tlist_Get_File_Index(filename) - if fidx == -1 - return "" - endif - - " If there are no tags for this file, then no need to proceed further - if s:tlist_{fidx}_tag_count == 0 - return "" - endif - - " Get the tag name using the line number - let tidx = s:Tlist_Find_Nearest_Tag_Idx(fidx, linenr) - if tidx == -1 - return "" - endif - - return s:tlist_{fidx}_{tidx}_tag_name -endfunction - -" Tlist_Window_Move_To_File -" Move the cursor to the beginning of the current file or the next file -" or the previous file in the taglist window -" dir == -1, move to start of current or previous function -" dir == 1, move to start of next function -function! s:Tlist_Window_Move_To_File(dir) - if foldlevel('.') == 0 - " Cursor is on a non-folded line (it is not in any of the files) - " Move it to a folded line - if a:dir == -1 - normal! zk - else - " While moving down to the start of the next fold, - " no need to do go to the start of the next file. - normal! zj - return - endif - endif - - let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(line('.')) - if fidx == -1 - return - endif - - let cur_lnum = line('.') - - if a:dir == -1 - if cur_lnum > s:tlist_{fidx}_start - " Move to the beginning of the current file - exe s:tlist_{fidx}_start - return - endif - - if fidx != 0 - " Move to the beginning of the previous file - let fidx = fidx - 1 - else - " Cursor is at the first file, wrap around to the last file - let fidx = s:tlist_file_count - 1 - endif - - exe s:tlist_{fidx}_start - return - else - " Move to the beginning of the next file - let fidx = fidx + 1 - - if fidx >= s:tlist_file_count - " Cursor is at the last file, wrap around to the first file - let fidx = 0 - endif - - if s:tlist_{fidx}_start != 0 - exe s:tlist_{fidx}_start - endif - return - endif -endfunction - -" Tlist_Session_Load -" Load a taglist session (information about all the displayed files -" and the tags) from the specified file -function! s:Tlist_Session_Load(...) - if a:0 == 0 || a:1 == '' - call s:Tlist_Warning_Msg('Usage: TlistSessionLoad <filename>') - return - endif - - let sessionfile = a:1 - - if !filereadable(sessionfile) - let msg = 'Taglist: Error - Unable to open file ' . sessionfile - call s:Tlist_Warning_Msg(msg) - return - endif - - " Mark the current window as the file window - call s:Tlist_Window_Mark_File_Window() - - " Source the session file - exe 'source ' . sessionfile - - let new_file_count = g:tlist_file_count - unlet! g:tlist_file_count - - let i = 0 - while i < new_file_count - let ftype = g:tlist_{i}_filetype - unlet! g:tlist_{i}_filetype - - if !exists('s:tlist_' . ftype . '_count') - if s:Tlist_FileType_Init(ftype) == 0 - let i = i + 1 - continue - endif - endif - - let fname = g:tlist_{i}_filename - unlet! g:tlist_{i}_filename - - let fidx = s:Tlist_Get_File_Index(fname) - if fidx != -1 - let s:tlist_{fidx}_visible = 0 - let i = i + 1 - continue - else - " As we are loading the tags from the session file, if this - " file was previously deleted by the user, now we need to - " add it back. So remove the file from the deleted list. - call s:Tlist_Update_Remove_List(fname, 0) - endif - - let fidx = s:Tlist_Init_File(fname, ftype) - - let s:tlist_{fidx}_filename = fname - - let s:tlist_{fidx}_sort_type = g:tlist_{i}_sort_type - unlet! g:tlist_{i}_sort_type - - let s:tlist_{fidx}_filetype = ftype - let s:tlist_{fidx}_mtime = getftime(fname) - - let s:tlist_{fidx}_start = 0 - let s:tlist_{fidx}_end = 0 - - let s:tlist_{fidx}_valid = 1 - - let s:tlist_{fidx}_tag_count = g:tlist_{i}_tag_count - unlet! g:tlist_{i}_tag_count - - let j = 1 - while j <= s:tlist_{fidx}_tag_count - let s:tlist_{fidx}_{j}_tag = g:tlist_{i}_{j}_tag - let s:tlist_{fidx}_{j}_tag_name = g:tlist_{i}_{j}_tag_name - let s:tlist_{fidx}_{j}_ttype_idx = g:tlist_{i}_{j}_ttype_idx - unlet! g:tlist_{i}_{j}_tag - unlet! g:tlist_{i}_{j}_tag_name - unlet! g:tlist_{i}_{j}_ttype_idx - let j = j + 1 - endwhile - - let j = 1 - while j <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{j}_name - - if exists('g:tlist_' . i . '_' . ttype) - let s:tlist_{fidx}_{ttype} = g:tlist_{i}_{ttype} - unlet! g:tlist_{i}_{ttype} - let s:tlist_{fidx}_{ttype}_offset = 0 - let s:tlist_{fidx}_{ttype}_count = g:tlist_{i}_{ttype}_count - unlet! g:tlist_{i}_{ttype}_count - - let k = 1 - while k <= s:tlist_{fidx}_{ttype}_count - let s:tlist_{fidx}_{ttype}_{k} = g:tlist_{i}_{ttype}_{k} - unlet! g:tlist_{i}_{ttype}_{k} - let k = k + 1 - endwhile - else - let s:tlist_{fidx}_{ttype} = '' - let s:tlist_{fidx}_{ttype}_offset = 0 - let s:tlist_{fidx}_{ttype}_count = 0 - endif - - let j = j + 1 - endwhile - - let i = i + 1 - endwhile - - " If the taglist window is open, then update it - let winnum = bufwinnr(g:TagList_title) - if winnum != -1 - let save_winnr = winnr() - - " Goto the taglist window - call s:Tlist_Window_Goto_Window() - - " Refresh the taglist window - call s:Tlist_Window_Refresh() - - " Go back to the original window - if save_winnr != winnr() - call s:Tlist_Exe_Cmd_No_Acmds('wincmd p') - endif - endif -endfunction - -" Tlist_Session_Save -" Save a taglist session (information about all the displayed files -" and the tags) into the specified file -function! s:Tlist_Session_Save(...) - if a:0 == 0 || a:1 == '' - call s:Tlist_Warning_Msg('Usage: TlistSessionSave <filename>') - return - endif - - let sessionfile = a:1 - - if s:tlist_file_count == 0 - " There is nothing to save - call s:Tlist_Warning_Msg('Warning: Taglist is empty. Nothing to save.') - return - endif - - if filereadable(sessionfile) - let ans = input('Do you want to overwrite ' . sessionfile . ' (Y/N)?') - if ans !=? 'y' - return - endif - - echo "\n" - endif - - let old_verbose = &verbose - set verbose&vim - - exe 'redir! > ' . sessionfile - - silent! echo '" Taglist session file. This file is auto-generated.' - silent! echo '" File information' - silent! echo 'let tlist_file_count = ' . s:tlist_file_count - - let i = 0 - - while i < s:tlist_file_count - " Store information about the file - silent! echo 'let tlist_' . i . "_filename = '" . - \ s:tlist_{i}_filename . "'" - silent! echo 'let tlist_' . i . '_sort_type = "' . - \ s:tlist_{i}_sort_type . '"' - silent! echo 'let tlist_' . i . '_filetype = "' . - \ s:tlist_{i}_filetype . '"' - silent! echo 'let tlist_' . i . '_tag_count = ' . - \ s:tlist_{i}_tag_count - " Store information about all the tags - let j = 1 - while j <= s:tlist_{i}_tag_count - let txt = escape(s:tlist_{i}_{j}_tag, '"\\') - silent! echo 'let tlist_' . i . '_' . j . '_tag = "' . txt . '"' - silent! echo 'let tlist_' . i . '_' . j . '_tag_name = "' . - \ s:tlist_{i}_{j}_tag_name . '"' - silent! echo 'let tlist_' . i . '_' . j . '_ttype_idx' . ' = ' . - \ s:tlist_{i}_{j}_ttype_idx - let j = j + 1 - endwhile - - " Store information about all the tags grouped by their type - let ftype = s:tlist_{i}_filetype - let j = 1 - while j <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{j}_name - if s:tlist_{i}_{ttype}_count != 0 - let txt = escape(s:tlist_{i}_{ttype}, '"\') - let txt = substitute(txt, "\n", "\\\\n", 'g') - silent! echo 'let tlist_' . i . '_' . ttype . ' = "' . - \ txt . '"' - silent! echo 'let tlist_' . i . '_' . ttype . '_count = ' . - \ s:tlist_{i}_{ttype}_count - let k = 1 - while k <= s:tlist_{i}_{ttype}_count - silent! echo 'let tlist_' . i . '_' . ttype . '_' . k . - \ ' = ' . s:tlist_{i}_{ttype}_{k} - let k = k + 1 - endwhile - endif - let j = j + 1 - endwhile - - silent! echo - - let i = i + 1 - endwhile - - redir END - - let &verbose = old_verbose -endfunction - -" Tlist_Buffer_Removed -" A buffer is removed from the Vim buffer list. Remove the tags defined -" for that file -function! s:Tlist_Buffer_Removed(filename) - call s:Tlist_Log_Msg('Tlist_Buffer_Removed (' . a:filename . ')') - - " Make sure a valid filename is supplied - if a:filename == '' - return - endif - - " Get tag list index of the specified file - let fidx = s:Tlist_Get_File_Index(a:filename) - if fidx == -1 - " File not present in the taglist - return - endif - - " Remove the file from the list - call s:Tlist_Remove_File(fidx, 0) -endfunction - -" When a buffer is deleted, remove the file from the taglist -autocmd BufDelete * silent call s:Tlist_Buffer_Removed(expand('<afile>:p')) - -" Tlist_Window_Open_File_Fold -" Open the fold for the specified file and close the fold for all the -" other files -function! s:Tlist_Window_Open_File_Fold(acmd_bufnr) - call s:Tlist_Log_Msg('Tlist_Window_Open_File_Fold (' . a:acmd_bufnr . ')') - - " Make sure the taglist window is present - let winnum = bufwinnr(g:TagList_title) - if winnum == -1 - call s:Tlist_Warning_Msg('Taglist: Error - Taglist window is not open') - return - endif - - " Save the original window number - let org_winnr = winnr() - if org_winnr == winnum - let in_taglist_window = 1 - else - let in_taglist_window = 0 - endif - - if in_taglist_window - " When entering the taglist window, no need to update the folds - return - endif - - " Go to the taglist window - if !in_taglist_window - call s:Tlist_Exe_Cmd_No_Acmds(winnum . 'wincmd w') - endif - - " Close all the folds - silent! %foldclose - - " Get tag list index of the specified file - let fname = fnamemodify(bufname(a:acmd_bufnr + 0), ':p') - if filereadable(fname) - let fidx = s:Tlist_Get_File_Index(fname) - if fidx != -1 - " Open the fold for the file - exe "silent! " . s:tlist_{fidx}_start . "," . - \ s:tlist_{fidx}_end . "foldopen" - endif - endif - - " Go back to the original window - if !in_taglist_window - call s:Tlist_Exe_Cmd_No_Acmds(org_winnr . 'wincmd w') - endif -endfunction - -" Tlist_Window_Check_Auto_Open -" Open the taglist window automatically on Vim startup. -" Open the window only when files present in any of the Vim windows support -" tags. -function! s:Tlist_Window_Check_Auto_Open() - let open_window = 0 - - let i = 1 - let buf_num = winbufnr(i) - while buf_num != -1 - let filename = fnamemodify(bufname(buf_num), ':p') - let ft = s:Tlist_Get_Buffer_Filetype(buf_num) - if !s:Tlist_Skip_File(filename, ft) - let open_window = 1 - break - endif - let i = i + 1 - let buf_num = winbufnr(i) - endwhile - - if open_window - call s:Tlist_Window_Toggle() - endif -endfunction - -" Tlist_Refresh_Folds -" Remove and create the folds for all the files displayed in the taglist -" window. Used after entering a tab. If this is not done, then the folds -" are not properly created for taglist windows displayed in multiple tabs. -function! s:Tlist_Refresh_Folds() - let winnum = bufwinnr(g:TagList_title) - if winnum == -1 - return - endif - - let save_wnum = winnr() - exe winnum . 'wincmd w' - - " First remove all the existing folds - normal! zE - - " Create the folds for each in the tag list - let fidx = 0 - while fidx < s:tlist_file_count - let ftype = s:tlist_{fidx}_filetype - - " Create the folds for each tag type in a file - let j = 1 - while j <= s:tlist_{ftype}_count - let ttype = s:tlist_{ftype}_{j}_name - if s:tlist_{fidx}_{ttype}_count - let s = s:tlist_{fidx}_start + s:tlist_{fidx}_{ttype}_offset - let e = s + s:tlist_{fidx}_{ttype}_count - exe s . ',' . e . 'fold' - endif - let j = j + 1 - endwhile - - exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'fold' - exe 'silent! ' . s:tlist_{fidx}_start . ',' . - \ s:tlist_{fidx}_end . 'foldopen!' - let fidx = fidx + 1 - endwhile - - exe save_wnum . 'wincmd w' -endfunction - -function! s:Tlist_Menu_Add_Base_Menu() - call s:Tlist_Log_Msg('Adding the base menu') - - " Add the menu - anoremenu <silent> T&ags.Refresh\ menu :call <SID>Tlist_Menu_Refresh()<CR> - anoremenu <silent> T&ags.Sort\ menu\ by.Name - \ :call <SID>Tlist_Change_Sort('menu', 'set', 'name')<CR> - anoremenu <silent> T&ags.Sort\ menu\ by.Order - \ :call <SID>Tlist_Change_Sort('menu', 'set', 'order')<CR> - anoremenu T&ags.-SEP1- : - - if &mousemodel =~ 'popup' - anoremenu <silent> PopUp.T&ags.Refresh\ menu - \ :call <SID>Tlist_Menu_Refresh()<CR> - anoremenu <silent> PopUp.T&ags.Sort\ menu\ by.Name - \ :call <SID>Tlist_Change_Sort('menu', 'set', 'name')<CR> - anoremenu <silent> PopUp.T&ags.Sort\ menu\ by.Order - \ :call <SID>Tlist_Change_Sort('menu', 'set', 'order')<CR> - anoremenu PopUp.T&ags.-SEP1- : - endif -endfunction - -let s:menu_char_prefix = - \ '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - -" Tlist_Menu_Get_Tag_Type_Cmd -" Get the menu command for the specified tag type -" fidx - File type index -" ftype - File Type -" add_ttype_name - To add or not to add the tag type name to the menu entries -" ttype_idx - Tag type index -function! s:Tlist_Menu_Get_Tag_Type_Cmd(fidx, ftype, add_ttype_name, ttype_idx) - " Curly brace variable name optimization - let ftype_ttype_idx = a:ftype . '_' . a:ttype_idx - - let ttype = s:tlist_{ftype_ttype_idx}_name - if a:add_ttype_name - " If the tag type name contains space characters, escape it. This - " will be used to create the menu entries. - let ttype_fullname = escape(s:tlist_{ftype_ttype_idx}_fullname, ' ') - endif - - " Curly brace variable name optimization - let fidx_ttype = a:fidx . '_' . ttype - - " Number of tag entries for this tag type - let tcnt = s:tlist_{fidx_ttype}_count - if tcnt == 0 " No entries for this tag type - return '' - endif - - let mcmd = '' - - " Create the menu items for the tags. - " Depending on the number of tags of this type, split the menu into - " multiple sub-menus, if needed. - if tcnt > g:Tlist_Max_Submenu_Items - let j = 1 - while j <= tcnt - let final_index = j + g:Tlist_Max_Submenu_Items - 1 - if final_index > tcnt - let final_index = tcnt - endif - - " Extract the first and last tag name and form the - " sub-menu name - let tidx = s:tlist_{fidx_ttype}_{j} - let first_tag = s:tlist_{a:fidx}_{tidx}_tag_name - - let tidx = s:tlist_{fidx_ttype}_{final_index} - let last_tag = s:tlist_{a:fidx}_{tidx}_tag_name - - " Truncate the names, if they are greater than the - " max length - let first_tag = strpart(first_tag, 0, g:Tlist_Max_Tag_Length) - let last_tag = strpart(last_tag, 0, g:Tlist_Max_Tag_Length) - - " Form the menu command prefix - let m_prefix = 'anoremenu <silent> T\&ags.' - if a:add_ttype_name - let m_prefix = m_prefix . ttype_fullname . '.' - endif - let m_prefix = m_prefix . first_tag . '\.\.\.' . last_tag . '.' - - " Character prefix used to number the menu items (hotkey) - let m_prefix_idx = 0 - - while j <= final_index - let tidx = s:tlist_{fidx_ttype}_{j} - - let tname = s:tlist_{a:fidx}_{tidx}_tag_name - - let mcmd = mcmd . m_prefix . '\&' . - \ s:menu_char_prefix[m_prefix_idx] . '\.' . - \ tname . ' :call <SID>Tlist_Menu_Jump_To_Tag(' . - \ tidx . ')<CR>|' - - let m_prefix_idx = m_prefix_idx + 1 - let j = j + 1 - endwhile - endwhile - else - " Character prefix used to number the menu items (hotkey) - let m_prefix_idx = 0 - - let m_prefix = 'anoremenu <silent> T\&ags.' - if a:add_ttype_name - let m_prefix = m_prefix . ttype_fullname . '.' - endif - let j = 1 - while j <= tcnt - let tidx = s:tlist_{fidx_ttype}_{j} - - let tname = s:tlist_{a:fidx}_{tidx}_tag_name - - let mcmd = mcmd . m_prefix . '\&' . - \ s:menu_char_prefix[m_prefix_idx] . '\.' . - \ tname . ' :call <SID>Tlist_Menu_Jump_To_Tag(' . tidx - \ . ')<CR>|' - - let m_prefix_idx = m_prefix_idx + 1 - let j = j + 1 - endwhile - endif - - return mcmd -endfunction - -" Update the taglist menu with the tags for the specified file -function! s:Tlist_Menu_File_Refresh(fidx) - call s:Tlist_Log_Msg('Refreshing the tag menu for ' . s:tlist_{a:fidx}_filename) - " The 'B' flag is needed in the 'cpoptions' option - let old_cpoptions = &cpoptions - set cpoptions&vim - - exe s:tlist_{a:fidx}_menu_cmd - - " Update the popup menu (if enabled) - if &mousemodel =~ 'popup' - let cmd = substitute(s:tlist_{a:fidx}_menu_cmd, ' T\\&ags\.', - \ ' PopUp.T\\\&ags.', "g") - exe cmd - endif - - " The taglist menu is not empty now - let s:tlist_menu_empty = 0 - - " Restore the 'cpoptions' settings - let &cpoptions = old_cpoptions -endfunction - -" Tlist_Menu_Update_File -" Add the taglist menu -function! s:Tlist_Menu_Update_File(clear_menu) - if !has('gui_running') - " Not running in GUI mode - return - endif - - call s:Tlist_Log_Msg('Updating the tag menu, clear_menu = ' . a:clear_menu) - - " Remove the tags menu - if a:clear_menu - call s:Tlist_Menu_Remove_File() - - endif - - " Skip buffers with 'buftype' set to nofile, nowrite, quickfix or help - if &buftype != '' - return - endif - - let filename = fnamemodify(bufname('%'), ':p') - let ftype = s:Tlist_Get_Buffer_Filetype('%') - - " If the file doesn't support tag listing, skip it - if s:Tlist_Skip_File(filename, ftype) - return - endif - - let fidx = s:Tlist_Get_File_Index(filename) - if fidx == -1 || !s:tlist_{fidx}_valid - " Check whether this file is removed based on user request - " If it is, then don't display the tags for this file - if s:Tlist_User_Removed_File(filename) - return - endif - - " Process the tags for the file - let fidx = s:Tlist_Process_File(filename, ftype) - if fidx == -1 - return - endif - endif - - let fname = escape(fnamemodify(bufname('%'), ':t'), '.') - if fname != '' - exe 'anoremenu T&ags.' . fname . ' <Nop>' - anoremenu T&ags.-SEP2- : - endif - - if !s:tlist_{fidx}_tag_count - return - endif - - if s:tlist_{fidx}_menu_cmd != '' - " Update the menu with the cached command - call s:Tlist_Menu_File_Refresh(fidx) - - return - endif - - " We are going to add entries to the tags menu, so the menu won't be - " empty - let s:tlist_menu_empty = 0 - - let cmd = '' - - " Determine whether the tag type name needs to be added to the menu - " If more than one tag type is present in the taglisting for a file, - " then the tag type name needs to be present - let add_ttype_name = -1 - let i = 1 - while i <= s:tlist_{ftype}_count && add_ttype_name < 1 - let ttype = s:tlist_{ftype}_{i}_name - if s:tlist_{fidx}_{ttype}_count - let add_ttype_name = add_ttype_name + 1 - endif - let i = i + 1 - endwhile - - " Process the tags by the tag type and get the menu command - let i = 1 - while i <= s:tlist_{ftype}_count - let mcmd = s:Tlist_Menu_Get_Tag_Type_Cmd(fidx, ftype, add_ttype_name, i) - if mcmd != '' - let cmd = cmd . mcmd - endif - - let i = i + 1 - endwhile - - " Cache the menu command for reuse - let s:tlist_{fidx}_menu_cmd = cmd - - " Update the menu - call s:Tlist_Menu_File_Refresh(fidx) -endfunction - -" Tlist_Menu_Remove_File -" Remove the tags displayed in the tags menu -function! s:Tlist_Menu_Remove_File() - if !has('gui_running') || s:tlist_menu_empty - return - endif - - call s:Tlist_Log_Msg('Removing the tags menu for a file') - - " Cleanup the Tags menu - silent! unmenu T&ags - if &mousemodel =~ 'popup' - silent! unmenu PopUp.T&ags - endif - - " Add a dummy menu item to retain teared off menu - noremenu T&ags.Dummy l - - silent! unmenu! T&ags - if &mousemodel =~ 'popup' - silent! unmenu! PopUp.T&ags - endif - - call s:Tlist_Menu_Add_Base_Menu() - - " Remove the dummy menu item - unmenu T&ags.Dummy - - let s:tlist_menu_empty = 1 -endfunction - -" Tlist_Menu_Refresh -" Refresh the taglist menu -function! s:Tlist_Menu_Refresh() - call s:Tlist_Log_Msg('Refreshing the tags menu') - let fidx = s:Tlist_Get_File_Index(fnamemodify(bufname('%'), ':p')) - if fidx != -1 - " Invalidate the cached menu command - let s:tlist_{fidx}_menu_cmd = '' - endif - - " Update the taglist, menu and window - call s:Tlist_Update_Current_File() -endfunction - -" Tlist_Menu_Jump_To_Tag -" Jump to the selected tag -function! s:Tlist_Menu_Jump_To_Tag(tidx) - let fidx = s:Tlist_Get_File_Index(fnamemodify(bufname('%'), ':p')) - if fidx == -1 - return - endif - - let tagpat = s:Tlist_Get_Tag_SearchPat(fidx, a:tidx) - if tagpat == '' - return - endif - - " Add the current cursor position to the jump list, so that user can - " jump back using the ' and ` marks. - mark ' - - silent call search(tagpat, 'w') - - " Bring the line to the middle of the window - normal! z. - - " If the line is inside a fold, open the fold - if foldclosed('.') != -1 - .foldopen - endif -endfunction - -" Tlist_Menu_Init -" Initialize the taglist menu -function! s:Tlist_Menu_Init() - call s:Tlist_Menu_Add_Base_Menu() - - " Automatically add the tags defined in the current file to the menu - augroup TagListMenuCmds - autocmd! - - if !g:Tlist_Process_File_Always - autocmd BufEnter * call s:Tlist_Refresh() - endif - autocmd BufLeave * call s:Tlist_Menu_Remove_File() - augroup end - - call s:Tlist_Menu_Update_File(0) -endfunction - -" Tlist_Vim_Session_Load -" Initialize the taglist window/buffer, which is created when loading -" a Vim session file. -function! s:Tlist_Vim_Session_Load() - call s:Tlist_Log_Msg('Tlist_Vim_Session_Load') - - " Initialize the taglist window - call s:Tlist_Window_Init() - - " Refresh the taglist window - call s:Tlist_Window_Refresh() -endfunction - -" Tlist_Set_App -" Set the name of the external plugin/application to which taglist -" belongs. -" Taglist plugin is part of another plugin like cream or winmanager. -function! Tlist_Set_App(name) - if a:name == "" - return - endif - - let s:tlist_app_name = a:name -endfunction - -" Winmanager integration - -" Initialization required for integration with winmanager -function! TagList_Start() - " If current buffer is not taglist buffer, then don't proceed - if bufname('%') != '__Tag_List__' - return - endif - - call Tlist_Set_App('winmanager') - - " Get the current filename from the winmanager plugin - let bufnum = WinManagerGetLastEditedFile() - if bufnum != -1 - let filename = fnamemodify(bufname(bufnum), ':p') - let ftype = s:Tlist_Get_Buffer_Filetype(bufnum) - endif - - " Initialize the taglist window, if it is not already initialized - if !exists('s:tlist_window_initialized') || !s:tlist_window_initialized - call s:Tlist_Window_Init() - call s:Tlist_Window_Refresh() - let s:tlist_window_initialized = 1 - endif - - " Update the taglist window - if bufnum != -1 - if !s:Tlist_Skip_File(filename, ftype) && g:Tlist_Auto_Update - call s:Tlist_Window_Refresh_File(filename, ftype) - endif - endif -endfunction - -function! TagList_IsValid() - return 0 -endfunction - -function! TagList_WrapUp() - return 0 -endfunction - -" restore 'cpo' -let &cpo = s:cpo_save -unlet s:cpo_save - diff --git a/.vim/plugin/toggle_words.vim b/.vim/plugin/toggle_words.vim deleted file mode 100644 index 2d79df5..0000000 --- a/.vim/plugin/toggle_words.vim +++ /dev/null @@ -1,67 +0,0 @@ -" toggle_words.vim -" Author: Vincent Wang (linsong dot qizi at gmail dot com) -" Created: Fri Oct 13 07:51:16 CST 2006 -" Requires: Vim Ver7.0+ -" Version: 1.0 -" TODO: -" -" Documentation: -" The purpose of this plugin is very simple, it can toggle words among -" ['true', 'false'], ['on', 'off'], ['yes', 'no'], ['if', 'elseif', 'else', -" 'endif'] etc . It will search the candicates words to toggle based on -" current filetype, for example, you can put the following configuration -" into your .vimrc to define some words for python: -" let g:toggle_words_dict = {'python': [['if', 'elif', 'else'], ['True', -" 'False']]} -" -" There are some default words for toggling predefined in the -" script(g:_toogle_words_dict) that will work for all filetypes. -" Any comment, suggestion, bug report are welcomed. - -if v:version < 700 - "TODO: maybe I should make this script works under vim7.0 - echo "This script required vim7.0 or above version." - finish -endif - -if exists("g:load_toggle_words") - finish -endif - -let s:keepcpo= &cpo -set cpo&vim - -let g:load_toggle_words = "1.0" - -let g:_toggle_words_dict = {'*': [['true', 'false'], ['on', 'off'], ['yes', 'no'], ['+', '-'], ['define', 'undef'], ['if', 'elseif', 'else', 'endif'], ['>', '<'], ['{', '}'], ['(', ')'], ['[', ']'] ], } - -if exists('g:toggle_words_dict') - :call extend(g:_toggle_words_dict, g:toggle_words_dict) -endif - -function! s:ToggleWord() - let cur_filetype = &filetype - if ! has_key(g:_toggle_words_dict, cur_filetype) - let words_candicates_array = g:_toggle_words_dict['*'] - else - let words_candicates_array = g:_toggle_words_dict[cur_filetype] + g:_toggle_words_dict['*'] - endif - let cur_word = expand("<cword>") - for words_candicates in words_candicates_array - let index = index(words_candicates, cur_word) - if index != -1 - let new_word_index = (index+1)%len(words_candicates) - let new_word = words_candicates[new_word_index] - " use the new word to replace the old word - exec "norm ciw" . new_word . "" - break - endif - endfor -endfunction - -command! ToggleWord :call <SID>ToggleWord() <CR> -nmap ,t :call <SID>ToggleWord()<CR> -vmap ,t <ESC>:call <SID>ToggleWord()<CR> - -let &cpo= s:keepcpo -unlet s:keepcpo diff --git a/.vim/plugin/vcsbzr.vim b/.vim/plugin/vcsbzr.vim deleted file mode 100644 index 60dc455..0000000 --- a/.vim/plugin/vcsbzr.vim +++ /dev/null @@ -1,254 +0,0 @@ -" vim600: set foldmethod=marker: -" -" BZR extension for VCSCommand. -" -" Version: VCS development -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2009 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Options documentation: {{{2 -" -" VCSCommandBZRExec -" This variable specifies the BZR executable. If not set, it defaults to -" 'bzr' executed from the user's executable path. - -" Section: Plugin header {{{1 - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -runtime plugin/vcscommand.vim - -if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr')) - " BZR is not installed - finish -endif - -" Section: Variable initialization {{{1 - -let s:bzrFunctions = {} - -" Section: Utility functions {{{1 - -" Function: s:DoCommand(cmd, cmdName, statusText) {{{2 -" Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the -" command argument. -function! s:DoCommand(cmd, cmdName, statusText, options) - if VCSCommandGetVCSType(expand('%')) == 'BZR' - let fullCmd = VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) - else - throw 'BZR VCSCommand plugin called on non-BZR item.' - endif -endfunction - -" Section: VCS function implementations {{{1 - -" Function: s:bzrFunctions.Identify(buffer) {{{2 -function! s:bzrFunctions.Identify(buffer) - let fileName = resolve(bufname(a:buffer)) - let statusText = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' info "' . fileName . '"') - if(v:shell_error) - return 0 - else - return 1 - endif -endfunction - -" Function: s:bzrFunctions.Add() {{{2 -function! s:bzrFunctions.Add(argList) - return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {}) -endfunction - -" Function: s:bzrFunctions.Annotate(argList) {{{2 -function! s:bzrFunctions.Annotate(argList) - if len(a:argList) == 0 - if &filetype == 'BZRAnnotate' - " Perform annotation of the version indicated by the current line. - let caption = matchstr(getline('.'),'\v^\s+\zs\d+') - let options = ' -r' . caption - else - let caption = '' - let options = '' - endif - elseif len(a:argList) == 1 && a:argList[0] !~ '^-' - let caption = a:argList[0] - let options = ' -r' . caption - else - let caption = join(a:argList, ' ') - let options = ' ' . caption - endif - - let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {}) - if resultBuffer > 0 - normal 1G2dd - set filetype=BZRAnnotate - endif - return resultBuffer -endfunction - -" Function: s:bzrFunctions.Commit(argList) {{{2 -function! s:bzrFunctions.Commit(argList) - let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {}) - if resultBuffer == 0 - echomsg 'No commit needed.' - endif -endfunction - -" Function: s:bzrFunctions.Delete() {{{2 -function! s:bzrFunctions.Delete(argList) - return s:DoCommand(join(['rm'] + a:argList, ' '), 'rm', join(a:argList, ' '), {}) -endfunction - -" Function: s:bzrFunctions.Diff(argList) {{{2 -function! s:bzrFunctions.Diff(argList) - if len(a:argList) == 0 - let revOptions = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let revOptions = ['-r' . join(a:argList, '..')] - let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')' - else - " Pass-through - let caption = join(a:argList, ' ') - let revOptions = a:argList - endif - - let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1}) - if resultBuffer > 0 - set filetype=diff - else - echomsg 'No differences found' - endif - return resultBuffer -endfunction - -" Function: s:bzrFunctions.GetBufferInfo() {{{2 -" Provides version control details for the current file. Current version -" number and current repository version number are required to be returned by -" the vcscommand plugin. -" Returns: List of results: [revision, repository] - -function! s:bzrFunctions.GetBufferInfo() - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let fileName = resolve(bufname(originalBuffer)) - let statusText = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' status -S "' . fileName . '"') - let revision = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' revno "' . fileName . '"') - if(v:shell_error) - return [] - endif - - " File not under BZR control. - if statusText =~ '^?' - return ['Unknown'] - endif - - let [flags, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)')[1:2] - if revision == '' - " Error - return ['Unknown'] - elseif flags =~ '^A' - return ['New', 'New'] - else - return [revision, repository] - endif -endfunction - -" Function: s:bzrFunctions.Info(argList) {{{2 -function! s:bzrFunctions.Info(argList) - return s:DoCommand(join(['version-info'] + a:argList, ' '), 'version-info', join(a:argList, ' '), {}) -endfunction - -" Function: s:bzrFunctions.Lock(argList) {{{2 -function! s:bzrFunctions.Lock(argList) - echomsg 'bzr lock is not necessary' -endfunction - -" Function: s:bzrFunctions.Log() {{{2 -function! s:bzrFunctions.Log(argList) - if len(a:argList) == 0 - let options = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let options = ['-r' . join(a:argList, ':')] - let caption = options[0] - else - " Pass-through - let options = a:argList - let caption = join(a:argList, ' ') - endif - - let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {}) - return resultBuffer -endfunction - -" Function: s:bzrFunctions.Revert(argList) {{{2 -function! s:bzrFunctions.Revert(argList) - return s:DoCommand('revert', 'revert', '', {}) -endfunction - -" Function: s:bzrFunctions.Review(argList) {{{2 -function! s:bzrFunctions.Review(argList) - if len(a:argList) == 0 - let versiontag = '(current)' - let versionOption = '' - else - let versiontag = a:argList[0] - let versionOption = ' -r ' . versiontag . ' ' - endif - - let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {}) - if resultBuffer > 0 - let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer -endfunction - -" Function: s:bzrFunctions.Status(argList) {{{2 -function! s:bzrFunctions.Status(argList) - let options = ['-S'] - if len(a:argList) == 0 - let options = a:argList - endif - return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {}) -endfunction - -" Function: s:bzrFunctions.Unlock(argList) {{{2 -function! s:bzrFunctions.Unlock(argList) - echomsg 'bzr unlock is not necessary' -endfunction -" Function: s:bzrFunctions.Update(argList) {{{2 -function! s:bzrFunctions.Update(argList) - return s:DoCommand('update', 'update', '', {}) -endfunction - -" Section: Plugin Registration {{{1 -call VCSCommandRegisterModule('BZR', expand('<sfile>'), s:bzrFunctions, []) - -let &cpo = s:save_cpo diff --git a/.vim/plugin/vcscommand.vim b/.vim/plugin/vcscommand.vim deleted file mode 100644 index 2070e1a..0000000 --- a/.vim/plugin/vcscommand.vim +++ /dev/null @@ -1,1344 +0,0 @@ -" vim600: set foldmethod=marker: -" -" Vim plugin to assist in working with files under control of various Version -" Control Systems, such as CVS, SVN, SVK, and git. -" -" Version: 1.99.31 -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2008 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Provides functions to invoke various source control commands on the current -" file (either the current buffer, or, in the case of an directory buffer, the -" directory and all subdirectories associated with the current buffer). The -" output of the commands is captured in a new scratch window. -" -" This plugin needs additional extension plugins, each specific to a source -" control system, to function. Those plugins should be placed in a -" subdirectory of the standard plugin directory named 'vcscommand'. Several -" options include the name of the version control system in the option name. -" Such options use the placeholder text '{VCSType}', which would be replaced -" in actual usage with 'CVS' or 'SVN', for instance. -" -" Command documentation {{{2 -" -" VCSAdd Adds the current file to source control. -" -" VCSAnnotate[!] Displays the current file with each line annotated with the -" version in which it was most recently changed. If an -" argument is given, the argument is used as a revision -" number to display. If not given an argument, it uses the -" most recent version of the file on the current branch. -" Additionally, if the current buffer is a VCSAnnotate buffer -" already, the version number on the current line is used. -" -" If '!' is used, the view of the annotated buffer is split -" so that the annotation is in a separate window from the -" content, and each is highlighted separately. -" -" VCSBlame Alias for 'VCSAnnotate'. -" -" VCSCommit[!] Commits changes to the current file to source control. -" -" If called with arguments, the arguments are the log message. -" -" If '!' is used, an empty log message is committed. -" -" If called with no arguments, this is a two-step command. -" The first step opens a buffer to accept a log message. -" When that buffer is written, it is automatically closed and -" the file is committed using the information from that log -" message. The commit can be abandoned if the log message -" buffer is deleted or wiped before being written. -" -" VCSDelete Deletes the current file and removes it from source control. -" -" VCSDiff With no arguments, this displays the differences between -" the current file and its parent version under source -" control in a new scratch buffer. -" -" With one argument, the diff is performed on the -" current file against the specified revision. -" -" With two arguments, the diff is performed between the -" specified revisions of the current file. -" -" This command uses the 'VCSCommand{VCSType}DiffOpt' variable -" to specify diff options. If that variable does not exist, -" a plugin-specific default is used. If you wish to have no -" options, then set it to the empty string. -" -" VCSGotoOriginal Jumps to the source buffer if the current buffer is a VCS -" scratch buffer. If VCSGotoOriginal[!] is used, remove all -" VCS scratch buffers associated with the original file. -" -" VCSInfo Displays extended information about the current file in a -" new scratch buffer. -" -" VCSLock Locks the current file in order to prevent other users from -" concurrently modifying it. The exact semantics of this -" command depend on the underlying VCS. -" -" VCSLog Displays the version history of the current file in a new -" scratch buffer. -" -" VCSRemove Alias for 'VCSDelete'. -" -" VCSRevert Replaces the modified version of the current file with the -" most recent version from the repository. -" -" VCSReview Displays a particular version of the current file in a new -" scratch buffer. If no argument is given, the most recent -" version of the file on the current branch is retrieved. -" -" VCSStatus Displays versioning information about the current file in a -" new scratch buffer. -" -" VCSUnlock Unlocks the current file in order to allow other users from -" concurrently modifying it. The exact semantics of this -" command depend on the underlying VCS. -" -" VCSUpdate Updates the current file with any relevant changes from the -" repository. -" -" VCSVimDiff Uses vimdiff to display differences between versions of the -" current file. -" -" If no revision is specified, the most recent version of the -" file on the current branch is used. With one argument, -" that argument is used as the revision as above. With two -" arguments, the differences between the two revisions is -" displayed using vimdiff. -" -" With either zero or one argument, the original buffer is -" used to perform the vimdiff. When the scratch buffer is -" closed, the original buffer will be returned to normal -" mode. -" -" Once vimdiff mode is started using the above methods, -" additional vimdiff buffers may be added by passing a single -" version argument to the command. There may be up to 4 -" vimdiff buffers total. -" -" Using the 2-argument form of the command resets the vimdiff -" to only those 2 versions. Additionally, invoking the -" command on a different file will close the previous vimdiff -" buffers. -" -" Mapping documentation: {{{2 -" -" By default, a mapping is defined for each command. User-provided mappings -" can be used instead by mapping to <Plug>CommandName, for instance: -" -" nmap ,ca <Plug>VCSAdd -" -" The default mappings are as follow: -" -" <Leader>ca VCSAdd -" <Leader>cn VCSAnnotate -" <Leader>cN VCSAnnotate! -" <Leader>cc VCSCommit -" <Leader>cD VCSDelete -" <Leader>cd VCSDiff -" <Leader>cg VCSGotoOriginal -" <Leader>cG VCSGotoOriginal! -" <Leader>ci VCSInfo -" <Leader>cl VCSLog -" <Leader>cL VCSLock -" <Leader>cr VCSReview -" <Leader>cs VCSStatus -" <Leader>cu VCSUpdate -" <Leader>cU VCSUnlock -" <Leader>cv VCSVimDiff -" -" Options documentation: {{{2 -" -" Several variables are checked by the script to determine behavior as follow: -" -" VCSCommandCommitOnWrite -" This variable, if set to a non-zero value, causes the pending commit to -" take place immediately as soon as the log message buffer is written. If -" set to zero, only the VCSCommit mapping will cause the pending commit to -" occur. If not set, it defaults to 1. -" -" VCSCommandDeleteOnHide -" This variable, if set to a non-zero value, causes the temporary VCS result -" buffers to automatically delete themselves when hidden. -" -" VCSCommand{VCSType}DiffOpt -" This variable, if set, determines the options passed to the diff command -" of the underlying VCS. Each VCS plugin defines a default value. -" -" VCSCommandDiffSplit -" This variable overrides the VCSCommandSplit variable, but only for buffers -" created with VCSVimDiff. -" -" VCSCommandDisableAll -" This variable, if set, prevents the plugin or any extensions from loading -" at all. This is useful when a single runtime distribution is used on -" multiple systems with varying versions. -" -" VCSCommandDisableMappings -" This variable, if set to a non-zero value, prevents the default command -" mappings from being set. -" -" VCSCommandDisableExtensionMappings -" This variable, if set to a non-zero value, prevents the default command -" mappings from being set for commands specific to an individual VCS. -" -" VCSCommandEdit -" This variable controls whether to split the current window to display a -" scratch buffer ('split'), or to display it in the current buffer ('edit'). -" If not set, it defaults to 'split'. -" -" VCSCommandEnableBufferSetup -" This variable, if set to a non-zero value, activates VCS buffer management -" mode. This mode means that the buffer variable 'VCSRevision' is set if -" the file is VCS-controlled. This is useful for displaying version -" information in the status bar. Additional options may be set by -" individual VCS plugins. -" -" VCSCommandMappings -" This variable, if set, overrides the default mappings used for shortcuts. -" It should be a List of 2-element Lists, each containing a shortcut and -" function name pair. -" -" VCSCommandMapPrefix -" This variable, if set, overrides the default mapping prefix ('<Leader>c'). -" This allows customization of the mapping space used by the vcscommand -" shortcuts. -" -" VCSCommandResultBufferNameExtension -" This variable, if set to a non-blank value, is appended to the name of the -" VCS command output buffers. For example, '.vcs'. Using this option may -" help avoid problems caused by autocommands dependent on file extension. -" -" VCSCommandResultBufferNameFunction -" This variable, if set, specifies a custom function for naming VCS command -" output buffers. This function will be passed the following arguments: -" -" command - name of the VCS command being executed (such as 'Log' or -" 'Diff'). -" -" originalBuffer - buffer number of the source file. -" -" vcsType - type of VCS controlling this file (such as 'CVS' or 'SVN'). -" -" statusText - extra text associated with the VCS action (such as version -" numbers). -" -" VCSCommandSplit -" This variable controls the orientation of the various window splits that -" may occur (such as with VCSVimDiff, when using a VCS command on a VCS -" command buffer, or when the 'VCSCommandEdit' variable is set to 'split'. -" If set to 'horizontal', the resulting windows will be on stacked on top of -" one another. If set to 'vertical', the resulting windows will be -" side-by-side. If not set, it defaults to 'horizontal' for all but -" VCSVimDiff windows. -" -" VCSCommandVCSTypeOverride -" This variable allows the VCS type detection to be overridden on a -" path-by-path basis. The value of this variable is expected to be a List -" of Lists. Each high-level List item is a List containing two elements. -" The first element is a regular expression that will be matched against the -" full file name of a given buffer. If it matches, the second element will -" be used as the VCS type. -" -" Event documentation {{{2 -" For additional customization, VCSCommand.vim uses User event autocommand -" hooks. Each event is in the VCSCommand group, and different patterns -" match the various hooks. -" -" For instance, the following could be added to the vimrc to provide a 'q' -" mapping to quit a VCS scratch buffer: -" -" augroup VCSCommand -" au VCSCommand User VCSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr> -" augroup END -" -" The following hooks are available: -" -" VCSBufferCreated This event is fired just after a VCS command -" output buffer is created. It is executed -" within the context of the new buffer. -" -" VCSBufferSetup This event is fired just after VCS buffer setup -" occurs, if enabled. -" -" VCSPluginInit This event is fired when the VCSCommand plugin -" first loads. -" -" VCSPluginFinish This event is fired just after the VCSCommand -" plugin loads. -" -" VCSVimDiffFinish This event is fired just after the VCSVimDiff -" command executes to allow customization of, -" for instance, window placement and focus. -" -" Section: Plugin header {{{1 - -" loaded_VCSCommand is set to 1 when the initialization begins, and 2 when it -" completes. This allows various actions to only be taken by functions after -" system initialization. - -if exists('VCSCommandDisableAll') - finish -endif - -if exists('loaded_VCSCommand') - finish -endif -let loaded_VCSCommand = 1 - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -" Section: Event group setup {{{1 - -augroup VCSCommand -augroup END - -augroup VCSCommandCommit -augroup END - -" Section: Plugin initialization {{{1 -silent do VCSCommand User VCSPluginInit - -" Section: Constants declaration {{{1 - -let g:VCSCOMMAND_IDENTIFY_EXACT = 1 -let g:VCSCOMMAND_IDENTIFY_INEXACT = -1 - -" Section: Script variable initialization {{{1 - -" plugin-specific information: {vcs -> [script, {command -> function}, {key -> mapping}]} -let s:plugins = {} - -" temporary values of overridden configuration variables -let s:optionOverrides = {} - -" state flag used to vary behavior of certain automated actions -let s:isEditFileRunning = 0 - -" commands needed to restore diff buffers to their original state -unlet! s:vimDiffRestoreCmd - -" original buffer currently reflected in vimdiff windows -unlet! s:vimDiffSourceBuffer - -" -unlet! s:vimDiffScratchList - -" Section: Utility functions {{{1 - -" Function: s:ReportError(mapping) {{{2 -" Displays the given error in a consistent faction. This is intended to be -" invoked from a catch statement. - -function! s:ReportError(error) - echohl WarningMsg|echomsg 'VCSCommand: ' . a:error|echohl None -endfunction - - -" Function: s:CreateMapping(shortcut, expansion, display) {{{2 -" Creates the given mapping by prepending the contents of -" 'VCSCommandMapPrefix' (by default '<Leader>c') to the given shortcut and -" mapping it to the given plugin function. If a mapping exists for the -" specified shortcut + prefix, emit an error but continue. If a mapping -" exists for the specified function, do nothing. - -function! s:CreateMapping(shortcut, expansion, display) - let lhs = VCSCommandGetOption('VCSCommandMapPrefix', '<Leader>c') . a:shortcut - if !hasmapto(a:expansion) - try - execute 'nmap <silent> <unique>' lhs a:expansion - catch /^Vim(.*):E227:/ - if(&verbose != 0) - echohl WarningMsg|echomsg 'VCSCommand: mapping ''' . lhs . ''' already exists, refusing to overwrite. The mapping for ' . a:display . ' will not be available.'|echohl None - endif - endtry - endif -endfunction - -" Function: s:ExecuteExtensionMapping(mapping) {{{2 -" Invokes the appropriate extension mapping depending on the type of the -" current buffer. - -function! s:ExecuteExtensionMapping(mapping) - let buffer = bufnr('%') - let vcsType = VCSCommandGetVCSType(buffer) - if !has_key(s:plugins, vcsType) - throw 'Unknown VCS type: ' . vcsType - endif - if !has_key(s:plugins[vcsType][2], a:mapping) - throw 'This extended mapping is not defined for ' . vcsType - endif - silent execute 'normal' ':' . s:plugins[vcsType][2][a:mapping] . "\<CR>" -endfunction - -" Function: s:ExecuteVCSCommand(command, argList) {{{2 -" Calls the indicated plugin-specific VCS command on the current buffer. -" Returns: buffer number of resulting output scratch buffer, or -1 if an error -" occurs. - -function! s:ExecuteVCSCommand(command, argList) - try - let buffer = bufnr('%') - - let vcsType = VCSCommandGetVCSType(buffer) - if !has_key(s:plugins, vcsType) - throw 'Unknown VCS type: ' . vcsType - endif - - let originalBuffer = VCSCommandGetOriginalBuffer(buffer) - let bufferName = bufname(originalBuffer) - - " It is already known that the directory is under VCS control. No further - " checks are needed. Otherwise, perform some basic sanity checks to avoid - " VCS-specific error messages from confusing things. - if !isdirectory(bufferName) - if !filereadable(bufferName) - throw 'No such file ' . bufferName - endif - endif - - let functionMap = s:plugins[vcsType][1] - if !has_key(functionMap, a:command) - throw 'Command ''' . a:command . ''' not implemented for ' . vcsType - endif - return functionMap[a:command](a:argList) - catch - call s:ReportError(v:exception) - return -1 - endtry -endfunction - -" Function: s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText) {{{2 -" Default method of generating the name for VCS result buffers. This can be -" overridden with the VCSResultBufferNameFunction variable. - -function! s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText) - let fileName = bufname(a:originalBuffer) - let bufferName = a:vcsType . ' ' . a:command - if strlen(a:statusText) > 0 - let bufferName .= ' ' . a:statusText - endif - let bufferName .= ' ' . fileName - let counter = 0 - let versionedBufferName = bufferName - while buflisted(versionedBufferName) - let counter += 1 - let versionedBufferName = bufferName . ' (' . counter . ')' - endwhile - return versionedBufferName -endfunction - -" Function: s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsType, statusText) {{{2 -" Method of generating the name for VCS result buffers that uses the original -" file name with the VCS type and command appended as extensions. - -function! s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsType, statusText) - let fileName = bufname(a:originalBuffer) - let bufferName = a:vcsType . ' ' . a:command - if strlen(a:statusText) > 0 - let bufferName .= ' ' . a:statusText - endif - let bufferName .= ' ' . fileName . VCSCommandGetOption('VCSCommandResultBufferNameExtension', '.vcs') - let counter = 0 - let versionedBufferName = bufferName - while buflisted(versionedBufferName) - let counter += 1 - let versionedBufferName = '(' . counter . ') ' . bufferName - endwhile - return versionedBufferName -endfunction - -" Function: s:EditFile(command, originalBuffer, statusText) {{{2 -" Creates a new buffer of the given name and associates it with the given -" original buffer. - -function! s:EditFile(command, originalBuffer, statusText) - let vcsType = getbufvar(a:originalBuffer, 'VCSCommandVCSType') - - " Protect against useless buffer set-up - let s:isEditFileRunning += 1 - try - let editCommand = VCSCommandGetOption('VCSCommandEdit', 'split') - if editCommand == 'split' - if VCSCommandGetOption('VCSCommandSplit', 'horizontal') == 'horizontal' - rightbelow split - else - vert rightbelow split - endif - endif - - enew - - call s:SetupScratchBuffer(a:command, vcsType, a:originalBuffer, a:statusText) - - finally - let s:isEditFileRunning -= 1 - endtry -endfunction - -" Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2 -" Creates convenience buffer variables and the name of a vcscommand result -" buffer. - -function! s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) - let nameExtension = VCSCommandGetOption('VCSCommandResultBufferNameExtension', '') - if nameExtension == '' - let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferName') - else - let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferNameWithExtension') - endif - - let name = call(nameFunction, [a:command, a:originalBuffer, a:vcsType, a:statusText]) - - let b:VCSCommandCommand = a:command - let b:VCSCommandOriginalBuffer = a:originalBuffer - let b:VCSCommandSourceFile = bufname(a:originalBuffer) - let b:VCSCommandVCSType = a:vcsType - if a:statusText != '' - let b:VCSCommandStatusText = a:statusText - endif - - setlocal buftype=nofile - setlocal noswapfile - let &filetype = a:vcsType . a:command - - if VCSCommandGetOption('VCSCommandDeleteOnHide', 0) - setlocal bufhidden=delete - endif - silent noautocmd file `=name` -endfunction - -" Function: s:SetupBuffer() {{{2 -" Attempts to set the b:VCSCommandBufferInfo variable - -function! s:SetupBuffer() - if (exists('b:VCSCommandBufferSetup') && b:VCSCommandBufferSetup) - " This buffer is already set up. - return - endif - - if !isdirectory(@%) && (strlen(&buftype) > 0 || !filereadable(@%)) - " No special status for special buffers other than directory buffers. - return - endif - - if !VCSCommandGetOption('VCSCommandEnableBufferSetup', 0) || s:isEditFileRunning > 0 - unlet! b:VCSCommandBufferSetup - return - endif - - try - let vcsType = VCSCommandGetVCSType(bufnr('%')) - let b:VCSCommandBufferInfo = s:plugins[vcsType][1].GetBufferInfo() - silent do VCSCommand User VCSBufferSetup - catch /No suitable plugin/ - " This is not a VCS-controlled file. - let b:VCSCommandBufferInfo = [] - endtry - - let b:VCSCommandBufferSetup = 1 -endfunction - -" Function: s:MarkOrigBufferForSetup(buffer) {{{2 -" Resets the buffer setup state of the original buffer for a given VCS scratch -" buffer. -" Returns: The VCS buffer number in a passthrough mode. - -function! s:MarkOrigBufferForSetup(buffer) - checktime - if a:buffer > 0 - let origBuffer = VCSCommandGetOriginalBuffer(a:buffer) - " This should never not work, but I'm paranoid - if origBuffer != a:buffer - call setbufvar(origBuffer, 'VCSCommandBufferSetup', 0) - endif - endif - return a:buffer -endfunction - -" Function: s:OverrideOption(option, [value]) {{{2 -" Provides a temporary override for the given VCS option. If no value is -" passed, the override is disabled. - -function! s:OverrideOption(option, ...) - if a:0 == 0 - call remove(s:optionOverrides[a:option], -1) - else - if !has_key(s:optionOverrides, a:option) - let s:optionOverrides[a:option] = [] - endif - call add(s:optionOverrides[a:option], a:1) - endif -endfunction - -" Function: s:WipeoutCommandBuffers() {{{2 -" Clears all current VCS output buffers of the specified type for a given source. - -function! s:WipeoutCommandBuffers(originalBuffer, VCSCommand) - let buffer = 1 - while buffer <= bufnr('$') - if getbufvar(buffer, 'VCSCommandOriginalBuffer') == a:originalBuffer - if getbufvar(buffer, 'VCSCommandCommand') == a:VCSCommand - execute 'bw' buffer - endif - endif - let buffer = buffer + 1 - endwhile -endfunction - -" Function: s:VimDiffRestore(vimDiffBuff) {{{2 -" Checks whether the given buffer is one whose deletion should trigger -" restoration of an original buffer after it was diffed. If so, it executes -" the appropriate setting command stored with that original buffer. - -function! s:VimDiffRestore(vimDiffBuff) - let s:isEditFileRunning += 1 - try - if exists('s:vimDiffSourceBuffer') - if a:vimDiffBuff == s:vimDiffSourceBuffer - " Original file is being removed. - unlet! s:vimDiffSourceBuffer - unlet! s:vimDiffRestoreCmd - unlet! s:vimDiffScratchList - else - let index = index(s:vimDiffScratchList, a:vimDiffBuff) - if index >= 0 - call remove(s:vimDiffScratchList, index) - if len(s:vimDiffScratchList) == 0 - if exists('s:vimDiffRestoreCmd') - " All scratch buffers are gone, reset the original. - " Only restore if the source buffer is still in Diff mode - - let sourceWinNR = bufwinnr(s:vimDiffSourceBuffer) - if sourceWinNR != -1 - " The buffer is visible in at least one window - let currentWinNR = winnr() - while winbufnr(sourceWinNR) != -1 - if winbufnr(sourceWinNR) == s:vimDiffSourceBuffer - execute sourceWinNR . 'wincmd w' - if getwinvar(0, '&diff') - execute s:vimDiffRestoreCmd - endif - endif - let sourceWinNR = sourceWinNR + 1 - endwhile - execute currentWinNR . 'wincmd w' - else - " The buffer is hidden. It must be visible in order to set the - " diff option. - let currentBufNR = bufnr('') - execute 'hide buffer' s:vimDiffSourceBuffer - if getwinvar(0, '&diff') - execute s:vimDiffRestoreCmd - endif - execute 'hide buffer' currentBufNR - endif - - unlet s:vimDiffRestoreCmd - endif - " All buffers are gone. - unlet s:vimDiffSourceBuffer - unlet s:vimDiffScratchList - endif - endif - endif - endif - finally - let s:isEditFileRunning -= 1 - endtry -endfunction - -" Section: Generic VCS command functions {{{1 - -" Function: s:VCSAnnotate(...) {{{2 -function! s:VCSAnnotate(bang, ...) - try - let annotateBuffer = s:ExecuteVCSCommand('Annotate', a:000) - if annotateBuffer == -1 - return -1 - endif - if a:bang == '!' && VCSCommandGetOption('VCSCommandDisableSplitAnnotate', 0) == 0 - let vcsType = VCSCommandGetVCSType(annotateBuffer) - let functionMap = s:plugins[vcsType][1] - let splitRegex = '' - if has_key(s:plugins[vcsType][1], 'AnnotateSplitRegex') - let splitRegex = s:plugins[vcsType][1]['AnnotateSplitRegex'] - endif - let splitRegex = VCSCommandGetOption('VCSCommand' . vcsType . 'AnnotateSplitRegex', splitRegex) - if splitRegex == '' - return annotateBuffer - endif - let originalBuffer = VCSCommandGetOriginalBuffer(annotateBuffer) - let originalFileType = getbufvar(originalBuffer, '&ft') - let annotateFileType = getbufvar(annotateBuffer, '&ft') - execute "normal 0zR\<c-v>G/" . splitRegex . "/e\<cr>d" - call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype')) - set scrollbind - leftabove vert new - normal 0P - execute "normal" . col('$') . "\<c-w>|" - call s:SetupScratchBuffer('annotate', vcsType, originalBuffer, 'header') - wincmd l - endif - return annotateBuffer - catch - call s:ReportError(v:exception) - return -1 - endtry -endfunction - -" Function: s:VCSCommit() {{{2 -function! s:VCSCommit(bang, message) - try - let vcsType = VCSCommandGetVCSType(bufnr('%')) - if !has_key(s:plugins, vcsType) - throw 'Unknown VCS type: ' . vcsType - endif - - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - - " Handle the commit message being specified. If a message is supplied, it - " is used; if bang is supplied, an empty message is used; otherwise, the - " user is provided a buffer from which to edit the commit message. - - if strlen(a:message) > 0 || a:bang == '!' - return s:VCSFinishCommit([a:message], originalBuffer) - endif - - call s:EditFile('commitlog', originalBuffer, '') - setlocal ft=vcscommit - - " Create a commit mapping. - - nnoremap <silent> <buffer> <Plug>VCSCommit :call <SID>VCSFinishCommitWithBuffer()<CR> - - silent 0put ='VCS: ----------------------------------------------------------------------' - silent put ='VCS: Please enter log message. Lines beginning with ''VCS:'' are removed automatically.' - silent put ='VCS: To finish the commit, Type <leader>cc (or your own <Plug>VCSCommit mapping)' - - if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1 - setlocal buftype=acwrite - au VCSCommandCommit BufWriteCmd <buffer> call s:VCSFinishCommitWithBuffer() - silent put ='VCS: or write this buffer' - endif - - silent put ='VCS: ----------------------------------------------------------------------' - $ - setlocal nomodified - catch - call s:ReportError(v:exception) - return -1 - endtry -endfunction - -" Function: s:VCSFinishCommitWithBuffer() {{{2 -" Wrapper for s:VCSFinishCommit which is called only from a commit log buffer -" which removes all lines starting with 'VCS:'. - -function! s:VCSFinishCommitWithBuffer() - setlocal nomodified - let currentBuffer = bufnr('%') - let logMessageList = getbufline('%', 1, '$') - call filter(logMessageList, 'v:val !~ ''^\s*VCS:''') - let resultBuffer = s:VCSFinishCommit(logMessageList, b:VCSCommandOriginalBuffer) - if resultBuffer >= 0 - execute 'bw' currentBuffer - endif - return resultBuffer -endfunction - -" Function: s:VCSFinishCommit(logMessageList, originalBuffer) {{{2 -function! s:VCSFinishCommit(logMessageList, originalBuffer) - let shellSlashBak = &shellslash - try - set shellslash - let messageFileName = tempname() - call writefile(a:logMessageList, messageFileName) - try - let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName]) - if resultBuffer < 0 - return resultBuffer - endif - return s:MarkOrigBufferForSetup(resultBuffer) - finally - call delete(messageFileName) - endtry - finally - let &shellslash = shellSlashBak - endtry -endfunction - -" Function: s:VCSGotoOriginal(bang) {{{2 -function! s:VCSGotoOriginal(bang) - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - if originalBuffer > 0 - let origWinNR = bufwinnr(originalBuffer) - if origWinNR == -1 - execute 'buffer' originalBuffer - else - execute origWinNR . 'wincmd w' - endif - if a:bang == '!' - let buffnr = 1 - let buffmaxnr = bufnr('$') - while buffnr <= buffmaxnr - if getbufvar(buffnr, 'VCSCommandOriginalBuffer') == originalBuffer - execute 'bw' buffnr - endif - let buffnr = buffnr + 1 - endwhile - endif - endif -endfunction - -" Function: s:VCSVimDiff(...) {{{2 -function! s:VCSVimDiff(...) - try - let vcsType = VCSCommandGetVCSType(bufnr('%')) - if !has_key(s:plugins, vcsType) - throw 'Unknown VCS type: ' . vcsType - endif - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let s:isEditFileRunning = s:isEditFileRunning + 1 - try - " If there's already a VimDiff'ed window, restore it. - " There may only be one VCSVimDiff original window at a time. - - if exists('s:vimDiffSourceBuffer') && s:vimDiffSourceBuffer != originalBuffer - " Clear the existing vimdiff setup by removing the result buffers. - call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') - endif - - let orientation = &diffopt =~ 'horizontal' ? 'horizontal' : 'vertical' - let orientation = VCSCommandGetOption('VCSCommandSplit', orientation) - let orientation = VCSCommandGetOption('VCSCommandDiffSplit', orientation) - - " Split and diff - if(a:0 == 2) - " Reset the vimdiff system, as 2 explicit versions were provided. - if exists('s:vimDiffSourceBuffer') - call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') - endif - let resultBuffer = s:plugins[vcsType][1].Review([a:1]) - if resultBuffer < 0 - echomsg 'Can''t open revision ' . a:1 - return resultBuffer - endif - let b:VCSCommandCommand = 'vimdiff' - diffthis - let s:vimDiffScratchList = [resultBuffer] - " If no split method is defined, cheat, and set it to vertical. - try - call s:OverrideOption('VCSCommandSplit', orientation) - let resultBuffer = s:plugins[vcsType][1].Review([a:2]) - finally - call s:OverrideOption('VCSCommandSplit') - endtry - if resultBuffer < 0 - echomsg 'Can''t open revision ' . a:1 - return resultBuffer - endif - let b:VCSCommandCommand = 'vimdiff' - diffthis - let s:vimDiffScratchList += [resultBuffer] - else - " Add new buffer - call s:OverrideOption('VCSCommandEdit', 'split') - try - " Force splitting behavior, otherwise why use vimdiff? - call s:OverrideOption('VCSCommandSplit', orientation) - try - if(a:0 == 0) - let resultBuffer = s:plugins[vcsType][1].Review([]) - else - let resultBuffer = s:plugins[vcsType][1].Review([a:1]) - endif - finally - call s:OverrideOption('VCSCommandSplit') - endtry - finally - call s:OverrideOption('VCSCommandEdit') - endtry - if resultBuffer < 0 - echomsg 'Can''t open current revision' - return resultBuffer - endif - let b:VCSCommandCommand = 'vimdiff' - diffthis - - if !exists('s:vimDiffSourceBuffer') - " New instance of vimdiff. - let s:vimDiffScratchList = [resultBuffer] - - " This could have been invoked on a VCS result buffer, not the - " original buffer. - wincmd W - execute 'buffer' originalBuffer - " Store info for later original buffer restore - let s:vimDiffRestoreCmd = - \ 'call setbufvar('.originalBuffer.', ''&diff'', '.getbufvar(originalBuffer, '&diff').')' - \ . '|call setbufvar('.originalBuffer.', ''&foldcolumn'', '.getbufvar(originalBuffer, '&foldcolumn').')' - \ . '|call setbufvar('.originalBuffer.', ''&foldenable'', '.getbufvar(originalBuffer, '&foldenable').')' - \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')' - \ . '|call setbufvar('.originalBuffer.', ''&foldlevel'', '''.getbufvar(originalBuffer, '&foldlevel').''')' - \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')' - \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')' - \ . '|if &foldmethod==''manual''|execute ''normal zE''|endif' - diffthis - wincmd w - else - " Adding a window to an existing vimdiff - let s:vimDiffScratchList += [resultBuffer] - endif - endif - - let s:vimDiffSourceBuffer = originalBuffer - - " Avoid executing the modeline in the current buffer after the autocommand. - - let currentBuffer = bufnr('%') - let saveModeline = getbufvar(currentBuffer, '&modeline') - try - call setbufvar(currentBuffer, '&modeline', 0) - silent do VCSCommand User VCSVimDiffFinish - finally - call setbufvar(currentBuffer, '&modeline', saveModeline) - endtry - return resultBuffer - finally - let s:isEditFileRunning = s:isEditFileRunning - 1 - endtry - catch - call s:ReportError(v:exception) - return -1 - endtry -endfunction - -" Section: Public functions {{{1 - -" Function: VCSCommandGetVCSType() {{{2 -" Sets the b:VCSCommandVCSType variable in the given buffer to the -" appropriate source control system name. -" -" This uses the Identify extension function to test the buffer. If the -" Identify function returns VCSCOMMAND_IDENTIFY_EXACT, the match is considered -" exact. If the Identify function returns VCSCOMMAND_IDENTIFY_INEXACT, the -" match is considered inexact, and is only applied if no exact match is found. -" Multiple inexact matches is currently considered an error. - -function! VCSCommandGetVCSType(buffer) - let vcsType = getbufvar(a:buffer, 'VCSCommandVCSType') - if strlen(vcsType) > 0 - return vcsType - endif - if exists("g:VCSCommandVCSTypeOverride") - let fullpath = fnamemodify(bufname(a:buffer), ':p') - for [path, vcsType] in g:VCSCommandVCSTypeOverride - if match(fullpath, path) > -1 - call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType) - return vcsType - endif - endfor - endif - let matches = [] - for vcsType in keys(s:plugins) - let identified = s:plugins[vcsType][1].Identify(a:buffer) - if identified - if identified == g:VCSCOMMAND_IDENTIFY_EXACT - let matches = [vcsType] - break - else - let matches += [vcsType] - endif - endif - endfor - if len(matches) == 1 - call setbufvar(a:buffer, 'VCSCommandVCSType', matches[0]) - return matches[0] - elseif len(matches) == 0 - throw 'No suitable plugin' - else - throw 'Too many matching VCS: ' . join(matches) - endif -endfunction - -" Function: VCSCommandChdir(directory) {{{2 -" Changes the current directory, respecting :lcd changes. - -function! VCSCommandChdir(directory) - let command = 'cd' - if exists("*haslocaldir") && haslocaldir() - let command = 'lcd' - endif - execute command escape(a:directory, ' ') -endfunction - -" Function: VCSCommandChangeToCurrentFileDir() {{{2 -" Go to the directory in which the given file is located. - -function! VCSCommandChangeToCurrentFileDir(fileName) - let oldCwd = getcwd() - let newCwd = fnamemodify(resolve(a:fileName), ':p:h') - if strlen(newCwd) > 0 - call VCSCommandChdir(newCwd) - endif - return oldCwd -endfunction - -" Function: VCSCommandGetOriginalBuffer(vcsBuffer) {{{2 -" Attempts to locate the original file to which VCS operations were applied -" for a given buffer. - -function! VCSCommandGetOriginalBuffer(vcsBuffer) - let origBuffer = getbufvar(a:vcsBuffer, 'VCSCommandOriginalBuffer') - if origBuffer - if bufexists(origBuffer) - return origBuffer - else - " Original buffer no longer exists. - throw 'Original buffer for this VCS buffer no longer exists.' - endif - else - " No original buffer - return a:vcsBuffer - endif -endfunction - -" Function: VCSCommandRegisterModule(name, file, commandMap) {{{2 -" Allows VCS modules to register themselves. - -function! VCSCommandRegisterModule(name, path, commandMap, mappingMap) - let s:plugins[a:name] = [a:path, a:commandMap, a:mappingMap] - if !empty(a:mappingMap) - \ && !VCSCommandGetOption('VCSCommandDisableMappings', 0) - \ && !VCSCommandGetOption('VCSCommandDisableExtensionMappings', 0) - for shortcut in keys(a:mappingMap) - let expansion = ":call <SID>ExecuteExtensionMapping('" . shortcut . "')<CR>" - call s:CreateMapping(shortcut, expansion, a:name . " extension mapping " . shortcut) - endfor - endif -endfunction - -" Function: VCSCommandDoCommand(cmd, cmdName, statusText, [options]) {{{2 -" General skeleton for VCS function execution. The given command is executed -" after appending the current buffer name (or substituting it for -" <VCSCOMMANDFILE>, if such a token is present). The output is captured in a -" new buffer. -" -" The optional 'options' Dictionary may contain the following options: -" allowNonZeroExit: if non-zero, if the underlying VCS command has a -" non-zero exit status, the command is still considered -" successfuly. This defaults to zero. -" Returns: name of the new command buffer containing the command results - -function! VCSCommandDoCommand(cmd, cmdName, statusText, options) - let allowNonZeroExit = 0 - if has_key(a:options, 'allowNonZeroExit') - let allowNonZeroExit = a:options.allowNonZeroExit - endif - - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - if originalBuffer == -1 - throw 'Original buffer no longer exists, aborting.' - endif - - let path = resolve(bufname(originalBuffer)) - - " Work with netrw or other systems where a directory listing is displayed in - " a buffer. - - if isdirectory(path) - let fileName = '.' - else - let fileName = fnamemodify(path, ':t') - endif - - if match(a:cmd, '<VCSCOMMANDFILE>') > 0 - let fullCmd = substitute(a:cmd, '<VCSCOMMANDFILE>', fileName, 'g') - else - let fullCmd = a:cmd . ' "' . fileName . '"' - endif - - " Change to the directory of the current buffer. This is done for CVS, but - " is left in for other systems as it does not affect them negatively. - - let oldCwd = VCSCommandChangeToCurrentFileDir(path) - try - let output = system(fullCmd) - finally - call VCSCommandChdir(oldCwd) - endtry - - " HACK: if line endings in the repository have been corrupted, the output - " of the command will be confused. - let output = substitute(output, "\r", '', 'g') - - if v:shell_error && !allowNonZeroExit - if strlen(output) == 0 - throw 'Version control command failed' - else - let output = substitute(output, '\n', ' ', 'g') - throw 'Version control command failed: ' . output - endif - endif - - if strlen(output) == 0 - " Handle case of no output. In this case, it is important to check the - " file status, especially since cvs edit/unedit may change the attributes - " of the file with no visible output. - - checktime - return 0 - endif - - call s:EditFile(a:cmdName, originalBuffer, a:statusText) - - silent 0put=output - - " The last command left a blank line at the end of the buffer. If the - " last line is folded (a side effect of the 'put') then the attempt to - " remove the blank line will kill the last fold. - " - " This could be fixed by explicitly detecting whether the last line is - " within a fold, but I prefer to simply unfold the result buffer altogether. - - if has('folding') - normal zR - endif - - $d - 1 - - " Define the environment and execute user-defined hooks. - - silent do VCSCommand User VCSBufferCreated - return bufnr('%') -endfunction - -" Function: VCSCommandGetOption(name, default) {{{2 -" Grab a user-specified option to override the default provided. Options are -" searched in the window, buffer, then global spaces. - -function! VCSCommandGetOption(name, default) - if has_key(s:optionOverrides, a:name) && len(s:optionOverrides[a:name]) > 0 - return s:optionOverrides[a:name][-1] - elseif exists('w:' . a:name) - return w:{a:name} - elseif exists('b:' . a:name) - return b:{a:name} - elseif exists('g:' . a:name) - return g:{a:name} - else - return a:default - endif -endfunction - -" Function: VCSCommandDisableBufferSetup() {{{2 -" Global function for deactivating the buffer autovariables. - -function! VCSCommandDisableBufferSetup() - let g:VCSCommandEnableBufferSetup = 0 - silent! augroup! VCSCommandPlugin -endfunction - -" Function: VCSCommandEnableBufferSetup() {{{2 -" Global function for activating the buffer autovariables. - -function! VCSCommandEnableBufferSetup() - let g:VCSCommandEnableBufferSetup = 1 - augroup VCSCommandPlugin - au! - au BufEnter * call s:SetupBuffer() - augroup END - - " Only auto-load if the plugin is fully loaded. This gives other plugins a - " chance to run. - if g:loaded_VCSCommand == 2 - call s:SetupBuffer() - endif -endfunction - -" Function: VCSCommandGetStatusLine() {{{2 -" Default (sample) status line entry for VCS-controlled files. This is only -" useful if VCS-managed buffer mode is on (see the VCSCommandEnableBufferSetup -" variable for how to do this). - -function! VCSCommandGetStatusLine() - if exists('b:VCSCommandCommand') - " This is a result buffer. Return nothing because the buffer name - " contains information already. - return '' - endif - - if exists('b:VCSCommandVCSType') - \ && exists('g:VCSCommandEnableBufferSetup') - \ && g:VCSCommandEnableBufferSetup - \ && exists('b:VCSCommandBufferInfo') - return '[' . join(extend([b:VCSCommandVCSType], b:VCSCommandBufferInfo), ' ') . ']' - else - return '' - endif -endfunction - -" Section: Command definitions {{{1 -" Section: Primary commands {{{2 -com! -nargs=* VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', [<f-args>])) -com! -nargs=* -bang VCSAnnotate call s:VCSAnnotate(<q-bang>, <f-args>) -com! -nargs=* -bang VCSBlame call s:VCSAnnotate(<q-bang>, <f-args>) -com! -nargs=? -bang VCSCommit call s:VCSCommit(<q-bang>, <q-args>) -com! -nargs=* VCSDelete call s:ExecuteVCSCommand('Delete', [<f-args>]) -com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', [<f-args>]) -com! -nargs=0 -bang VCSGotoOriginal call s:VCSGotoOriginal(<q-bang>) -com! -nargs=* VCSInfo call s:ExecuteVCSCommand('Info', [<f-args>]) -com! -nargs=* VCSLock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Lock', [<f-args>])) -com! -nargs=* VCSLog call s:ExecuteVCSCommand('Log', [<f-args>]) -com! -nargs=* VCSRemove call s:ExecuteVCSCommand('Delete', [<f-args>]) -com! -nargs=0 VCSRevert call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Revert', [])) -com! -nargs=? VCSReview call s:ExecuteVCSCommand('Review', [<f-args>]) -com! -nargs=* VCSStatus call s:ExecuteVCSCommand('Status', [<f-args>]) -com! -nargs=* VCSUnlock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Unlock', [<f-args>])) -com! -nargs=0 VCSUpdate call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Update', [])) -com! -nargs=* VCSVimDiff call s:VCSVimDiff(<f-args>) - -" Section: VCS buffer management commands {{{2 -com! VCSCommandDisableBufferSetup call VCSCommandDisableBufferSetup() -com! VCSCommandEnableBufferSetup call VCSCommandEnableBufferSetup() - -" Allow reloading VCSCommand.vim -com! VCSReload let savedPlugins = s:plugins|let s:plugins = {}|aunmenu Plugin.VCS|unlet! g:loaded_VCSCommand|runtime plugin/vcscommand.vim|for plugin in values(savedPlugins)|execute 'source' plugin[0]|endfor|unlet savedPlugins - -" Section: Plugin command mappings {{{1 -nnoremap <silent> <Plug>VCSAdd :VCSAdd<CR> -nnoremap <silent> <Plug>VCSAnnotate :VCSAnnotate<CR> -nnoremap <silent> <Plug>VCSCommit :VCSCommit<CR> -nnoremap <silent> <Plug>VCSDelete :VCSDelete<CR> -nnoremap <silent> <Plug>VCSDiff :VCSDiff<CR> -nnoremap <silent> <Plug>VCSGotoOriginal :VCSGotoOriginal<CR> -nnoremap <silent> <Plug>VCSClearAndGotoOriginal :VCSGotoOriginal!<CR> -nnoremap <silent> <Plug>VCSInfo :VCSInfo<CR> -nnoremap <silent> <Plug>VCSLock :VCSLock<CR> -nnoremap <silent> <Plug>VCSLog :VCSLog<CR> -nnoremap <silent> <Plug>VCSRevert :VCSRevert<CR> -nnoremap <silent> <Plug>VCSReview :VCSReview<CR> -nnoremap <silent> <Plug>VCSSplitAnnotate :VCSAnnotate!<CR> -nnoremap <silent> <Plug>VCSStatus :VCSStatus<CR> -nnoremap <silent> <Plug>VCSUnlock :VCSUnlock<CR> -nnoremap <silent> <Plug>VCSUpdate :VCSUpdate<CR> -nnoremap <silent> <Plug>VCSVimDiff :VCSVimDiff<CR> - -" Section: Default mappings {{{1 - -let s:defaultMappings = [ - \['a', 'VCSAdd'], - \['c', 'VCSCommit'], - \['D', 'VCSDelete'], - \['d', 'VCSDiff'], - \['G', 'VCSClearAndGotoOriginal'], - \['g', 'VCSGotoOriginal'], - \['i', 'VCSInfo'], - \['L', 'VCSLock'], - \['l', 'VCSLog'], - \['N', 'VCSSplitAnnotate'], - \['n', 'VCSAnnotate'], - \['q', 'VCSRevert'], - \['r', 'VCSReview'], - \['s', 'VCSStatus'], - \['U', 'VCSUnlock'], - \['u', 'VCSUpdate'], - \['v', 'VCSVimDiff'], - \] - -if !VCSCommandGetOption('VCSCommandDisableMappings', 0) - for [shortcut, vcsFunction] in VCSCommandGetOption('VCSCommandMappings', s:defaultMappings) - call s:CreateMapping(shortcut, '<Plug>' . vcsFunction, '''' . vcsFunction . '''') - endfor -endif - -" Section: Menu items {{{1 -amenu <silent> &Plugin.VCS.&Add <Plug>VCSAdd -amenu <silent> &Plugin.VCS.A&nnotate <Plug>VCSAnnotate -amenu <silent> &Plugin.VCS.&Commit <Plug>VCSCommit -amenu <silent> &Plugin.VCS.Delete <Plug>VCSDelete -amenu <silent> &Plugin.VCS.&Diff <Plug>VCSDiff -amenu <silent> &Plugin.VCS.&Info <Plug>VCSInfo -amenu <silent> &Plugin.VCS.&Log <Plug>VCSLog -amenu <silent> &Plugin.VCS.Revert <Plug>VCSRevert -amenu <silent> &Plugin.VCS.&Review <Plug>VCSReview -amenu <silent> &Plugin.VCS.&Status <Plug>VCSStatus -amenu <silent> &Plugin.VCS.&Update <Plug>VCSUpdate -amenu <silent> &Plugin.VCS.&VimDiff <Plug>VCSVimDiff - -" Section: Autocommands to restore vimdiff state {{{1 -augroup VimDiffRestore - au! - au BufUnload * call s:VimDiffRestore(str2nr(expand('<abuf>'))) -augroup END - -" Section: Optional activation of buffer management {{{1 - -if VCSCommandGetOption('VCSCommandEnableBufferSetup', 0) - call VCSCommandEnableBufferSetup() -endif - -" Section: VIM shutdown hook {{{1 - -" Close all result buffers when VIM exits, to prevent them from being restored -" via viminfo. - -" Function: s:CloseAllResultBuffers() {{{2 -" Closes all vcscommand result buffers. -function! s:CloseAllResultBuffers() - " This avoids using bufdo as that may load buffers already loaded in another - " vim process, resulting in an error. - let buffnr = 1 - let buffmaxnr = bufnr('$') - while buffnr <= buffmaxnr - if getbufvar(buffnr, 'VCSCommandOriginalBuffer') != "" - execute 'bw' buffnr - endif - let buffnr = buffnr + 1 - endwhile -endfunction - -augroup VCSCommandVIMShutdown - au! - au VimLeavePre * call s:CloseAllResultBuffers() -augroup END - -" Section: Plugin completion {{{1 - -let loaded_VCSCommand = 2 - -silent do VCSCommand User VCSPluginFinish - -let &cpo = s:save_cpo diff --git a/.vim/plugin/vcscvs.vim b/.vim/plugin/vcscvs.vim deleted file mode 100644 index a548276..0000000 --- a/.vim/plugin/vcscvs.vim +++ /dev/null @@ -1,453 +0,0 @@ -" vim600: set foldmethod=marker: -" -" CVS extension for VCSCommand. -" -" Version: VCS development -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Command documentation {{{2 -" -" The following commands only apply to files under CVS source control. -" -" CVSEdit Performs "cvs edit" on the current file. -" -" CVSEditors Performs "cvs editors" on the current file. -" -" CVSUnedit Performs "cvs unedit" on the current file. -" -" CVSWatch Takes an argument which must be one of [on|off|add|remove]. -" Performs "cvs watch" with the given argument on the current -" file. -" -" CVSWatchers Performs "cvs watchers" on the current file. -" -" CVSWatchAdd Alias for "CVSWatch add" -" -" CVSWatchOn Alias for "CVSWatch on" -" -" CVSWatchOff Alias for "CVSWatch off" -" -" CVSWatchRemove Alias for "CVSWatch remove" -" -" Mapping documentation: {{{2 -" -" By default, a mapping is defined for each command. User-provided mappings -" can be used instead by mapping to <Plug>CommandName, for instance: -" -" nnoremap ,ce <Plug>CVSEdit -" -" The default mappings are as follow: -" -" <Leader>ce CVSEdit -" <Leader>cE CVSEditors -" <Leader>ct CVSUnedit -" <Leader>cwv CVSWatchers -" <Leader>cwa CVSWatchAdd -" <Leader>cwn CVSWatchOn -" <Leader>cwf CVSWatchOff -" <Leader>cwr CVSWatchRemove -" -" Options documentation: {{{2 -" -" VCSCommandCVSExec -" This variable specifies the CVS executable. If not set, it defaults to -" 'cvs' executed from the user's executable path. -" -" VCSCommandCVSDiffOpt -" This variable, if set, determines the options passed to the cvs diff -" command. If not set, it defaults to 'u'. - -" Section: Plugin header {{{1 - -if exists('VCSCommandDisableAll') - finish -endif - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -runtime plugin/vcscommand.vim - -if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs')) - " CVS is not installed - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -" Section: Variable initialization {{{1 - -let s:cvsFunctions = {} - -" Section: Utility functions {{{1 - -" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 -" Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the -" command argument. -function! s:DoCommand(cmd, cmdName, statusText, options) - if VCSCommandGetVCSType(expand('%')) == 'CVS' - let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd - let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) - - if ret > 0 - if getline(line('$')) =~ '^cvs \w\+: closing down connection' - $d - 1 - endif - - endif - - return ret - else - throw 'CVS VCSCommand plugin called on non-CVS item.' - endif -endfunction - -" Function: GetRevision() {{{2 -" Function for retrieving the current buffer's revision number. -" Returns: Revision number or an empty string if an error occurs. - -function! GetRevision() - if !exists('b:VCSCommandBufferInfo') - let b:VCSCommandBufferInfo = s:cvsFunctions.GetBufferInfo() - endif - - if len(b:VCSCommandBufferInfo) > 0 - return b:VCSCommandBufferInfo[0] - else - return '' - endif -endfunction - -" Section: VCS function implementations {{{1 - -" Function: s:cvsFunctions.Identify(buffer) {{{2 -function! s:cvsFunctions.Identify(buffer) - let fileName = resolve(bufname(a:buffer)) - if isdirectory(fileName) - let directoryName = fileName - else - let directoryName = fnamemodify(fileName, ':h') - endif - if strlen(directoryName) > 0 - let CVSRoot = directoryName . '/CVS/Root' - else - let CVSRoot = 'CVS/Root' - endif - if filereadable(CVSRoot) - return 1 - else - return 0 - endif -endfunction - -" Function: s:cvsFunctions.Add(argList) {{{2 -function! s:cvsFunctions.Add(argList) - return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {}) -endfunction - -" Function: s:cvsFunctions.Annotate(argList) {{{2 -function! s:cvsFunctions.Annotate(argList) - if len(a:argList) == 0 - if &filetype == 'CVSAnnotate' - " This is a CVSAnnotate buffer. Perform annotation of the version - " indicated by the current line. - let caption = matchstr(getline('.'),'\v^[0-9.]+') - - if VCSCommandGetOption('VCSCommandCVSAnnotateParent', 0) != 0 - if caption != '1.1' - let revmaj = matchstr(caption,'\v[0-9.]+\ze\.[0-9]+') - let revmin = matchstr(caption,'\v[0-9.]+\.\zs[0-9]+') - 1 - if revmin == 0 - " Jump to ancestor branch - let caption = matchstr(revmaj,'\v[0-9.]+\ze\.[0-9]+') - else - let caption = revmaj . "." . revmin - endif - endif - endif - - let options = ['-r' . caption] - else - " CVS defaults to pulling HEAD, regardless of current branch. - " Therefore, always pass desired revision. - let caption = '' - let options = ['-r' . GetRevision()] - endif - elseif len(a:argList) == 1 && a:argList[0] !~ '^-' - let caption = a:argList[0] - let options = ['-r' . caption] - else - let caption = join(a:argList) - let options = a:argList - endif - - let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption, {}) - if resultBuffer > 0 - set filetype=CVSAnnotate - " Remove header lines from standard error - silent v/^\d\+\%(\.\d\+\)\+/d - endif - return resultBuffer -endfunction - -" Function: s:cvsFunctions.Commit(argList) {{{2 -function! s:cvsFunctions.Commit(argList) - let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {}) - if resultBuffer == 0 - echomsg 'No commit needed.' - endif - return resultBuffer -endfunction - -" Function: s:cvsFunctions.Delete() {{{2 -" By default, use the -f option to remove the file first. If options are -" passed in, use those instead. -function! s:cvsFunctions.Delete(argList) - let options = ['-f'] - let caption = '' - if len(a:argList) > 0 - let options = a:argList - let caption = join(a:argList, ' ') - endif - return s:DoCommand(join(['remove'] + options, ' '), 'delete', caption, {}) -endfunction - -" Function: s:cvsFunctions.Diff(argList) {{{2 -function! s:cvsFunctions.Diff(argList) - if len(a:argList) == 0 - let revOptions = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let revOptions = ['-r' . join(a:argList, ' -r')] - let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')' - else - " Pass-through - let caption = join(a:argList, ' ') - let revOptions = a:argList - endif - - let cvsDiffOpt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u') - if cvsDiffOpt == '' - let diffOptions = [] - else - let diffOptions = ['-' . cvsDiffOpt] - endif - - let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1}) - if resultBuffer > 0 - set filetype=diff - else - echomsg 'No differences found' - endif - return resultBuffer -endfunction - -" Function: s:cvsFunctions.GetBufferInfo() {{{2 -" Provides version control details for the current file. Current version -" number and current repository version number are required to be returned by -" the vcscommand plugin. This CVS extension adds branch name to the return -" list as well. -" Returns: List of results: [revision, repository, branch] - -function! s:cvsFunctions.GetBufferInfo() - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let fileName = bufname(originalBuffer) - if isdirectory(fileName) - let tag = '' - if filereadable(fileName . '/CVS/Tag') - let tagFile = readfile(fileName . '/CVS/Tag') - if len(tagFile) == 1 - let tag = substitute(tagFile[0], '^T', '', '') - endif - endif - return [tag] - endif - let realFileName = fnamemodify(resolve(fileName), ':t') - if !filereadable(fileName) - return ['Unknown'] - endif - let oldCwd = VCSCommandChangeToCurrentFileDir(fileName) - try - let statusText=system(VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' status "' . realFileName . '"') - if(v:shell_error) - return [] - endif - let revision=substitute(statusText, '^\_.*Working revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\)\_.*$', '\1', '') - - " We can still be in a CVS-controlled directory without this being a CVS - " file - if match(revision, '^New file!$') >= 0 - let revision='New' - elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') <0 - return ['Unknown'] - endif - - let branch=substitute(statusText, '^\_.*Sticky Tag:\s\+\(\d\+\%(\.\d\+\)\+\|\a[A-Za-z0-9-_]*\|(none)\).*$', '\1', '') - let repository=substitute(statusText, '^\_.*Repository revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\|No revision control file\)\_.*$', '\1', '') - let repository=substitute(repository, '^New file!\|No revision control file$', 'New', '') - return [revision, repository, branch] - finally - call VCSCommandChdir(oldCwd) - endtry -endfunction - -" Function: s:cvsFunctions.Log() {{{2 -function! s:cvsFunctions.Log(argList) - if len(a:argList) == 0 - let options = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let options = ['-r' . join(a:argList, ':')] - let caption = options[0] - else - " Pass-through - let options = a:argList - let caption = join(a:argList, ' ') - endif - - let resultBuffer=s:DoCommand(join(['log'] + options), 'log', caption, {}) - if resultBuffer > 0 - set filetype=rcslog - endif - return resultBuffer -endfunction - -" Function: s:cvsFunctions.Revert(argList) {{{2 -function! s:cvsFunctions.Revert(argList) - return s:DoCommand('update -C', 'revert', '', {}) -endfunction - -" Function: s:cvsFunctions.Review(argList) {{{2 -function! s:cvsFunctions.Review(argList) - if len(a:argList) == 0 - let versiontag = '(current)' - let versionOption = '' - else - let versiontag = a:argList[0] - let versionOption = ' -r ' . versiontag . ' ' - endif - - let resultBuffer = s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {}) - if resultBuffer > 0 - let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer -endfunction - -" Function: s:cvsFunctions.Status(argList) {{{2 -function! s:cvsFunctions.Status(argList) - return s:DoCommand(join(['status'] + a:argList, ' '), 'status', join(a:argList, ' '), {}) -endfunction - -" Function: s:cvsFunctions.Update(argList) {{{2 -function! s:cvsFunctions.Update(argList) - return s:DoCommand('update', 'update', '', {}) -endfunction - -" Section: CVS-specific functions {{{1 - -" Function: s:CVSEdit() {{{2 -function! s:CVSEdit() - return s:DoCommand('edit', 'cvsedit', '', {}) -endfunction - -" Function: s:CVSEditors() {{{2 -function! s:CVSEditors() - return s:DoCommand('editors', 'cvseditors', '', {}) -endfunction - -" Function: s:CVSUnedit() {{{2 -function! s:CVSUnedit() - return s:DoCommand('unedit', 'cvsunedit', '', {}) -endfunction - -" Function: s:CVSWatch(onoff) {{{2 -function! s:CVSWatch(onoff) - if a:onoff !~ '^\c\%(on\|off\|add\|remove\)$' - echoerr 'Argument to CVSWatch must be one of [on|off|add|remove]' - return -1 - end - return s:DoCommand('watch ' . tolower(a:onoff), 'cvswatch', '', {}) -endfunction - -" Function: s:CVSWatchers() {{{2 -function! s:CVSWatchers() - return s:DoCommand('watchers', 'cvswatchers', '', {}) -endfunction - -" Annotate setting {{{2 -let s:cvsFunctions.AnnotateSplitRegex = '): ' - -" Section: Command definitions {{{1 -" Section: Primary commands {{{2 -com! CVSEdit call s:CVSEdit() -com! CVSEditors call s:CVSEditors() -com! CVSUnedit call s:CVSUnedit() -com! -nargs=1 CVSWatch call s:CVSWatch(<f-args>) -com! CVSWatchAdd call s:CVSWatch('add') -com! CVSWatchOn call s:CVSWatch('on') -com! CVSWatchOff call s:CVSWatch('off') -com! CVSWatchRemove call s:CVSWatch('remove') -com! CVSWatchers call s:CVSWatchers() - -" Section: Plugin command mappings {{{1 - -let s:cvsExtensionMappings = {} -let mappingInfo = [ - \['CVSEdit', 'CVSEdit', 'e'], - \['CVSEditors', 'CVSEditors', 'E'], - \['CVSUnedit', 'CVSUnedit', 't'], - \['CVSWatchers', 'CVSWatchers', 'wv'], - \['CVSWatchAdd', 'CVSWatch add', 'wa'], - \['CVSWatchOff', 'CVSWatch off', 'wf'], - \['CVSWatchOn', 'CVSWatch on', 'wn'], - \['CVSWatchRemove', 'CVSWatch remove', 'wr'] - \] - -for [pluginName, commandText, shortCut] in mappingInfo - execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>' - if !hasmapto('<Plug>' . pluginName) - let s:cvsExtensionMappings[shortCut] = commandText - endif -endfor - -" Section: Menu items {{{1 -amenu <silent> &Plugin.VCS.CVS.&Edit <Plug>CVSEdit -amenu <silent> &Plugin.VCS.CVS.Ed&itors <Plug>CVSEditors -amenu <silent> &Plugin.VCS.CVS.Unedi&t <Plug>CVSUnedit -amenu <silent> &Plugin.VCS.CVS.&Watchers <Plug>CVSWatchers -amenu <silent> &Plugin.VCS.CVS.WatchAdd <Plug>CVSWatchAdd -amenu <silent> &Plugin.VCS.CVS.WatchOn <Plug>CVSWatchOn -amenu <silent> &Plugin.VCS.CVS.WatchOff <Plug>CVSWatchOff -amenu <silent> &Plugin.VCS.CVS.WatchRemove <Plug>CVSWatchRemove - -" Section: Plugin Registration {{{1 -call VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings) - -let &cpo = s:save_cpo diff --git a/.vim/plugin/vcsgit.vim b/.vim/plugin/vcsgit.vim deleted file mode 100644 index d2eb50f..0000000 --- a/.vim/plugin/vcsgit.vim +++ /dev/null @@ -1,260 +0,0 @@ -" vim600: set foldmethod=marker: -" -" git extension for VCSCommand. -" -" Version: VCS development -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2008 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Options documentation: {{{2 -" -" VCSCommandGitExec -" This variable specifies the git executable. If not set, it defaults to -" 'git' executed from the user's executable path. -" -" VCSCommandGitDiffOpt -" This variable, if set, determines the default options passed to the -" VCSDiff command. If any options (starting with '-') are passed to the -" command, this variable is not used. - -" Section: Plugin header {{{1 - -if exists('VCSCommandDisableAll') - finish -endif - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -runtime plugin/vcscommand.vim - -if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git')) - " git is not installed - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -" Section: Variable initialization {{{1 - -let s:gitFunctions = {} - -" Section: Utility functions {{{1 - -" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 -" Wrapper to VCSCommandDoCommand to add the name of the git executable to the -" command argument. -function! s:DoCommand(cmd, cmdName, statusText, options) - if VCSCommandGetVCSType(expand('%')) == 'git' - let fullCmd = VCSCommandGetOption('VCSCommandGitExec', 'git',) . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) - else - throw 'git VCSCommand plugin called on non-git item.' - endif -endfunction - -" Section: VCS function implementations {{{1 - -" Function: s:gitFunctions.Identify(buffer) {{{2 -" This function only returns an inexact match due to the detection method used -" by git, which simply traverses the directory structure upward. -function! s:gitFunctions.Identify(buffer) - let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer))) - try - call system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --is-inside-work-tree') - if(v:shell_error) - return 0 - else - return g:VCSCOMMAND_IDENTIFY_INEXACT - endif - finally - call VCSCommandChdir(oldCwd) - endtry -endfunction - -" Function: s:gitFunctions.Add(argList) {{{2 -function! s:gitFunctions.Add(argList) - return s:DoCommand(join(['add'] + ['-v'] + a:argList, ' '), 'add', join(a:argList, ' '), {}) -endfunction - -" Function: s:gitFunctions.Annotate(argList) {{{2 -function! s:gitFunctions.Annotate(argList) - if len(a:argList) == 0 - if &filetype == 'gitAnnotate' - " Perform annotation of the version indicated by the current line. - let options = matchstr(getline('.'),'^\x\+') - else - let options = '' - endif - elseif len(a:argList) == 1 && a:argList[0] !~ '^-' - let options = a:argList[0] - else - let options = join(a:argList, ' ') - endif - - let resultBuffer = s:DoCommand('blame ' . options . ' -- ', 'annotate', options, {}) - if resultBuffer > 0 - normal 1G - set filetype=gitAnnotate - endif - return resultBuffer -endfunction - -" Function: s:gitFunctions.Commit(argList) {{{2 -function! s:gitFunctions.Commit(argList) - let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {}) - if resultBuffer == 0 - echomsg 'No commit needed.' - endif - return resultBuffer -endfunction - -" Function: s:gitFunctions.Delete() {{{2 -" All options are passed through. -function! s:gitFunctions.Delete(argList) - let options = a:argList - let caption = join(a:argList, ' ') - return s:DoCommand(join(['rm'] + options, ' '), 'delete', caption, {}) -endfunction - -" Function: s:gitFunctions.Diff(argList) {{{2 -" Pass-through call to git-diff. If no options (starting with '-') are found, -" then the options in the 'VCSCommandGitDiffOpt' variable are added. -function! s:gitFunctions.Diff(argList) - let gitDiffOpt = VCSCommandGetOption('VCSCommandGitDiffOpt', '') - if gitDiffOpt == '' - let diffOptions = [] - else - let diffOptions = [gitDiffOpt] - for arg in a:argList - if arg =~ '^-' - let diffOptions = [] - break - endif - endfor - endif - - let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {}) - if resultBuffer > 0 - set filetype=diff - else - echomsg 'No differences found' - endif - return resultBuffer -endfunction - -" Function: s:gitFunctions.GetBufferInfo() {{{2 -" Provides version control details for the current file. Current version -" number and current repository version number are required to be returned by -" the vcscommand plugin. This CVS extension adds branch name to the return -" list as well. -" Returns: List of results: [revision, repository, branch] - -function! s:gitFunctions.GetBufferInfo() - let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%'))) - try - let branch = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' symbolic-ref -q HEAD'), '\n$', '', '') - if v:shell_error - let branch = 'DETACHED' - else - let branch = substitute(branch, '^refs/heads/', '', '') - endif - - let info = [branch] - - for method in split(VCSCommandGetOption('VCSCommandGitDescribeArgList', (',tags,all,always')), ',', 1) - if method != '' - let method = ' --' . method - endif - let tag = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' describe' . method), '\n$', '', '') - if !v:shell_error - call add(info, tag) - break - endif - endfor - - return info - finally - call VCSCommandChdir(oldCwd) - endtry -endfunction - -" Function: s:gitFunctions.Log() {{{2 -function! s:gitFunctions.Log(argList) - let resultBuffer=s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {}) - if resultBuffer > 0 - set filetype=gitlog - endif - return resultBuffer -endfunction - -" Function: s:gitFunctions.Revert(argList) {{{2 -function! s:gitFunctions.Revert(argList) - return s:DoCommand('checkout', 'revert', '', {}) -endfunction - -" Function: s:gitFunctions.Review(argList) {{{2 -function! s:gitFunctions.Review(argList) - if len(a:argList) == 0 - let revision = 'HEAD' - else - let revision = a:argList[0] - endif - - let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%')))) - try - let prefix = system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --show-prefix') - finally - call VCSCommandChdir(oldCwd) - endtry - - let prefix = substitute(prefix, '\n$', '', '') - let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"' - let resultBuffer = s:DoCommand('show ' . blob, 'review', revision, {}) - if resultBuffer > 0 - let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer -endfunction - -" Function: s:gitFunctions.Status(argList) {{{2 -function! s:gitFunctions.Status(argList) - return s:DoCommand(join(['status'] + a:argList), 'status', join(a:argList), {'allowNonZeroExit': 1}) -endfunction - -" Function: s:gitFunctions.Update(argList) {{{2 -function! s:gitFunctions.Update(argList) - throw "This command is not implemented for git because file-by-file update doesn't make much sense in that context. If you have an idea for what it should do, please let me know." -endfunction - -" Annotate setting {{{2 -let s:gitFunctions.AnnotateSplitRegex = ') ' - -" Section: Plugin Registration {{{1 -call VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, []) - -let &cpo = s:save_cpo diff --git a/.vim/plugin/vcshg.vim b/.vim/plugin/vcshg.vim deleted file mode 100755 index deff5cd..0000000 --- a/.vim/plugin/vcshg.vim +++ /dev/null @@ -1,275 +0,0 @@ -" vim600: set foldmethod=marker: -" -" Mercurial extension for VCSCommand. -" -" Version: VCS development -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2009 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Options documentation: {{{2 -" -" VCSCommandHGExec -" This variable specifies the mercurial executable. If not set, it defaults -" to 'hg' executed from the user's executable path. -" -" VCSCommandHGDiffExt -" This variable, if set, sets the external diff program used by Subversion. -" -" VCSCommandHGDiffOpt -" This variable, if set, determines the options passed to the hg diff -" command (such as 'u', 'w', or 'b'). - -" Section: Plugin header {{{1 - -if exists('VCSCommandDisableAll') - finish -endif - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -runtime plugin/vcscommand.vim - -if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg')) - " HG is not installed - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -" Section: Variable initialization {{{1 - -let s:hgFunctions = {} - -" Section: Utility functions {{{1 - -" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 -" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the -" command argument. -function! s:DoCommand(cmd, cmdName, statusText, options) - if VCSCommandGetVCSType(expand('%')) == 'HG' - let fullCmd = VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) - else - throw 'HG VCSCommand plugin called on non-HG item.' - endif -endfunction - -" Section: VCS function implementations {{{1 - -" Function: s:hgFunctions.Identify(buffer) {{{2 -function! s:hgFunctions.Identify(buffer) - call system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' root') - if(v:shell_error) - return 0 - else - return g:VCSCOMMAND_IDENTIFY_INEXACT - endif -endfunction - -" Function: s:hgFunctions.Add() {{{2 -function! s:hgFunctions.Add(argList) - return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {}) -endfunction - -" Function: s:hgFunctions.Annotate(argList) {{{2 -function! s:hgFunctions.Annotate(argList) - if len(a:argList) == 0 - if &filetype == 'HGAnnotate' - " Perform annotation of the version indicated by the current line. - let caption = matchstr(getline('.'),'\v^\s+\zs\d+') - let options = ' -r' . caption - else - let caption = '' - let options = '' - endif - elseif len(a:argList) == 1 && a:argList[0] !~ '^-' - let caption = a:argList[0] - let options = ' -r' . caption - else - let caption = join(a:argList, ' ') - let options = ' ' . caption - endif - - let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {}) - if resultBuffer > 0 - set filetype=HGAnnotate - endif - return resultBuffer -endfunction - -" Function: s:hgFunctions.Commit(argList) {{{2 -function! s:hgFunctions.Commit(argList) - let resultBuffer = s:DoCommand('commit -l "' . a:argList[0] . '"', 'commit', '', {}) - if resultBuffer == 0 - echomsg 'No commit needed.' - endif -endfunction - -" Function: s:hgFunctions.Delete() {{{2 -function! s:hgFunctions.Delete(argList) - return s:DoCommand(join(['remove'] + a:argList, ' '), 'remove', join(a:argList, ' '), {}) -endfunction - -" Function: s:hgFunctions.Diff(argList) {{{2 -function! s:hgFunctions.Diff(argList) - if len(a:argList) == 0 - let revOptions = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let revOptions = ['-r' . join(a:argList, ':')] - let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')' - else - " Pass-through - let caption = join(a:argList, ' ') - let revOptions = a:argList - endif - - let hgDiffExt = VCSCommandGetOption('VCSCommandHGDiffExt', '') - if hgDiffExt == '' - let diffExt = [] - else - let diffExt = ['--diff-cmd ' . hgDiffExt] - endif - - let hgDiffOpt = VCSCommandGetOption('VCSCommandHGDiffOpt', '') - if hgDiffOpt == '' - let diffOptions = [] - else - let diffOptions = ['-x -' . hgDiffOpt] - endif - - let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {}) - if resultBuffer > 0 - set filetype=diff - else - if hgDiffExt == '' - echomsg 'No differences found' - endif - endif - return resultBuffer -endfunction - -" Function: s:hgFunctions.Info(argList) {{{2 -function! s:hgFunctions.Info(argList) - return s:DoCommand(join(['log --limit 1'] + a:argList, ' '), 'log', join(a:argList, ' '), {}) -endfunction - -" Function: s:hgFunctions.GetBufferInfo() {{{2 -" Provides version control details for the current file. Current version -" number and current repository version number are required to be returned by -" the vcscommand plugin. -" Returns: List of results: [revision, repository, branch] - -function! s:hgFunctions.GetBufferInfo() - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let fileName = bufname(originalBuffer) - let statusText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' status "' . fileName . '"') - if(v:shell_error) - return [] - endif - - " File not under HG control. - if statusText =~ '^?' - return ['Unknown'] - endif - - let parentsText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' parents "' . fileName . '"') - let [revision] = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1] - - let logText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' log "' . fileName . '"') - let [repository] = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1] - - if revision == '' - " Error - return ['Unknown'] - elseif statusText =~ '^A' - return ['New', 'New'] - else - return [revision, repository] - endif -endfunction - -" Function: s:hgFunctions.Log(argList) {{{2 -function! s:hgFunctions.Log(argList) - if len(a:argList) == 0 - let options = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let options = ['-r' . join(a:argList, ':')] - let caption = options[0] - else - " Pass-through - let options = a:argList - let caption = join(a:argList, ' ') - endif - - let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {}) - return resultBuffer -endfunction - -" Function: s:hgFunctions.Revert(argList) {{{2 -function! s:hgFunctions.Revert(argList) - return s:DoCommand('revert', 'revert', '', {}) -endfunction - -" Function: s:hgFunctions.Review(argList) {{{2 -function! s:hgFunctions.Review(argList) - if len(a:argList) == 0 - let versiontag = '(current)' - let versionOption = '' - else - let versiontag = a:argList[0] - let versionOption = ' -r ' . versiontag . ' ' - endif - -" let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {}) - let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {}) - if resultBuffer > 0 - let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer -endfunction - -" Function: s:hgFunctions.Status(argList) {{{2 -function! s:hgFunctions.Status(argList) - let options = ['-u', '-v'] - if len(a:argList) == 0 - let options = a:argList - endif - return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {}) -endfunction - -" Function: s:hgFunctions.Update(argList) {{{2 -function! s:hgFunctions.Update(argList) - return s:DoCommand('update', 'update', '', {}) -endfunction - -" Section: Plugin Registration {{{1 -call VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, []) - -let &cpo = s:save_cpo diff --git a/.vim/plugin/vcssvk.vim b/.vim/plugin/vcssvk.vim deleted file mode 100644 index f79f578..0000000 --- a/.vim/plugin/vcssvk.vim +++ /dev/null @@ -1,262 +0,0 @@ -" vim600: set foldmethod=marker: -" -" SVK extension for VCSCommand. -" -" Version: VCS development -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Options documentation: {{{2 -" -" VCSCommandSVKExec -" This variable specifies the SVK executable. If not set, it defaults to -" 'svk' executed from the user's executable path. - -" Section: Plugin header {{{1 - -if exists('VCSCommandDisableAll') - finish -endif - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -runtime plugin/vcscommand.vim - -if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk')) - " SVK is not installed - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -" Section: Variable initialization {{{1 - -let s:svkFunctions = {} - -" Section: Utility functions {{{1 - -" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 -" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the -" command argument. -function! s:DoCommand(cmd, cmdName, statusText, options) - if VCSCommandGetVCSType(expand('%')) == 'SVK' - let fullCmd = VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) - else - throw 'SVK VCSCommand plugin called on non-SVK item.' - endif -endfunction - -" Section: VCS function implementations {{{1 - -" Function: s:svkFunctions.Identify(buffer) {{{2 -function! s:svkFunctions.Identify(buffer) - let fileName = resolve(bufname(a:buffer)) - if isdirectory(fileName) - let directoryName = fileName - else - let directoryName = fnamemodify(fileName, ':p:h') - endif - let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' info "' . directoryName . '"') - if(v:shell_error) - return 0 - else - return 1 - endif -endfunction - -" Function: s:svkFunctions.Add() {{{2 -function! s:svkFunctions.Add(argList) - return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {}) -endfunction - -" Function: s:svkFunctions.Annotate(argList) {{{2 -function! s:svkFunctions.Annotate(argList) - if len(a:argList) == 0 - if &filetype == 'SVKAnnotate' - " Perform annotation of the version indicated by the current line. - let caption = matchstr(getline('.'),'\v^\s+\zs\d+') - let options = ' -r' . caption - else - let caption = '' - let options = '' - endif - elseif len(a:argList) == 1 && a:argList[0] !~ '^-' - let caption = a:argList[0] - let options = ' -r' . caption - else - let caption = join(a:argList, ' ') - let options = ' ' . caption - endif - - let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {}) - if resultBuffer > 0 - normal 1G2dd - set filetype=SVKAnnotate - endif - return resultBuffer -endfunction - -" Function: s:svkFunctions.Commit(argList) {{{2 -function! s:svkFunctions.Commit(argList) - let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {}) - if resultBuffer == 0 - echomsg 'No commit needed.' - endif -endfunction - -" Function: s:svkFunctions.Delete() {{{2 -function! s:svkFunctions.Delete(argList) - return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '), {}) -endfunction - -" Function: s:svkFunctions.Diff(argList) {{{2 -function! s:svkFunctions.Diff(argList) - if len(a:argList) == 0 - let revOptions = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let revOptions = ['-r' . join(a:argList, ':')] - let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')' - else - " Pass-through - let caption = join(a:argList, ' ') - let revOptions = a:argList - endif - - let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {}) - if resultBuffer > 0 - set filetype=diff - else - echomsg 'No differences found' - endif - return resultBuffer -endfunction - -" Function: s:svkFunctions.GetBufferInfo() {{{2 -" Provides version control details for the current file. Current version -" number and current repository version number are required to be returned by -" the vcscommand plugin. -" Returns: List of results: [revision, repository] - -function! s:svkFunctions.GetBufferInfo() - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let fileName = resolve(bufname(originalBuffer)) - let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' status -v "' . fileName . '"') - if(v:shell_error) - return [] - endif - - " File not under SVK control. - if statusText =~ '^?' - return ['Unknown'] - endif - - let [flags, revision, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3] - if revision == '' - " Error - return ['Unknown'] - elseif flags =~ '^A' - return ['New', 'New'] - else - return [revision, repository] - endif -endfunction - -" Function: s:svkFunctions.Info(argList) {{{2 -function! s:svkFunctions.Info(argList) - return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '), {}) -endfunction - -" Function: s:svkFunctions.Lock(argList) {{{2 -function! s:svkFunctions.Lock(argList) - return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '), {}) -endfunction - -" Function: s:svkFunctions.Log() {{{2 -function! s:svkFunctions.Log(argList) - if len(a:argList) == 0 - let options = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let options = ['-r' . join(a:argList, ':')] - let caption = options[0] - else - " Pass-through - let options = a:argList - let caption = join(a:argList, ' ') - endif - - let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {}) - return resultBuffer -endfunction - -" Function: s:svkFunctions.Revert(argList) {{{2 -function! s:svkFunctions.Revert(argList) - return s:DoCommand('revert', 'revert', '', {}) -endfunction - -" Function: s:svkFunctions.Review(argList) {{{2 -function! s:svkFunctions.Review(argList) - if len(a:argList) == 0 - let versiontag = '(current)' - let versionOption = '' - else - let versiontag = a:argList[0] - let versionOption = ' -r ' . versiontag . ' ' - endif - - let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {}) - if resultBuffer > 0 - let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer -endfunction - -" Function: s:svkFunctions.Status(argList) {{{2 -function! s:svkFunctions.Status(argList) - let options = ['-v'] - if len(a:argList) == 0 - let options = a:argList - endif - return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {}) -endfunction - -" Function: s:svkFunctions.Unlock(argList) {{{2 -function! s:svkFunctions.Unlock(argList) - return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {}) -endfunction -" Function: s:svkFunctions.Update(argList) {{{2 -function! s:svkFunctions.Update(argList) - return s:DoCommand('update', 'update', '', {}) -endfunction - -" Section: Plugin Registration {{{1 -call VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, []) - -let &cpo = s:save_cpo diff --git a/.vim/plugin/vcssvn.vim b/.vim/plugin/vcssvn.vim deleted file mode 100644 index 90d2158..0000000 --- a/.vim/plugin/vcssvn.vim +++ /dev/null @@ -1,292 +0,0 @@ -" vim600: set foldmethod=marker: -" -" SVN extension for VCSCommand. -" -" Version: VCS development -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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. -" -" Section: Documentation {{{1 -" -" Options documentation: {{{2 -" -" VCSCommandSVNExec -" This variable specifies the SVN executable. If not set, it defaults to -" 'svn' executed from the user's executable path. -" -" VCSCommandSVNDiffExt -" This variable, if set, sets the external diff program used by Subversion. -" -" VCSCommandSVNDiffOpt -" This variable, if set, determines the options passed to the svn diff -" command (such as 'u', 'w', or 'b'). - -" Section: Plugin header {{{1 - -if exists('VCSCommandDisableAll') - finish -endif - -if v:version < 700 - echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None - finish -endif - -runtime plugin/vcscommand.vim - -if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn')) - " SVN is not installed - finish -endif - -let s:save_cpo=&cpo -set cpo&vim - -" Section: Variable initialization {{{1 - -let s:svnFunctions = {} - -" Section: Utility functions {{{1 - -" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 -" Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the -" command argument. -function! s:DoCommand(cmd, cmdName, statusText, options) - if VCSCommandGetVCSType(expand('%')) == 'SVN' - let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) - else - throw 'SVN VCSCommand plugin called on non-SVN item.' - endif -endfunction - -" Section: VCS function implementations {{{1 - -" Function: s:svnFunctions.Identify(buffer) {{{2 -function! s:svnFunctions.Identify(buffer) - let fileName = resolve(bufname(a:buffer)) - if isdirectory(fileName) - let directoryName = fileName - else - let directoryName = fnamemodify(fileName, ':h') - endif - if strlen(directoryName) > 0 - let svnDir = directoryName . '/.svn' - else - let svnDir = '.svn' - endif - if isdirectory(svnDir) - return 1 - else - return 0 - endif -endfunction - -" Function: s:svnFunctions.Add() {{{2 -function! s:svnFunctions.Add(argList) - return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {}) -endfunction - -" Function: s:svnFunctions.Annotate(argList) {{{2 -function! s:svnFunctions.Annotate(argList) - if len(a:argList) == 0 - if &filetype == 'SVNAnnotate' - " Perform annotation of the version indicated by the current line. - let caption = matchstr(getline('.'),'\v^\s+\zs\d+') - let options = ' -r' . caption - else - let caption = '' - let options = '' - endif - elseif len(a:argList) == 1 && a:argList[0] !~ '^-' - let caption = a:argList[0] - let options = ' -r' . caption - else - let caption = join(a:argList, ' ') - let options = ' ' . caption - endif - - let resultBuffer = s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {}) - if resultBuffer > 0 - set filetype=SVNAnnotate - endif - return resultBuffer -endfunction - -" Function: s:svnFunctions.Commit(argList) {{{2 -function! s:svnFunctions.Commit(argList) - let resultBuffer = s:DoCommand('commit --non-interactive -F "' . a:argList[0] . '"', 'commit', '', {}) - if resultBuffer == 0 - echomsg 'No commit needed.' - endif -endfunction - -" Function: s:svnFunctions.Delete() {{{2 -function! s:svnFunctions.Delete(argList) - return s:DoCommand(join(['delete --non-interactive'] + a:argList, ' '), 'delete', join(a:argList, ' '), {}) -endfunction - -" Function: s:svnFunctions.Diff(argList) {{{2 -function! s:svnFunctions.Diff(argList) - if len(a:argList) == 0 - let revOptions = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let revOptions = ['-r' . join(a:argList, ':')] - let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')' - else - " Pass-through - let caption = join(a:argList, ' ') - let revOptions = a:argList - endif - - let svnDiffExt = VCSCommandGetOption('VCSCommandSVNDiffExt', '') - if svnDiffExt == '' - let diffExt = [] - else - let diffExt = ['--diff-cmd ' . svnDiffExt] - endif - - let svnDiffOpt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '') - if svnDiffOpt == '' - let diffOptions = [] - else - let diffOptions = ['-x -' . svnDiffOpt] - endif - - let resultBuffer = s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {}) - if resultBuffer > 0 - set filetype=diff - else - if svnDiffExt == '' - echomsg 'No differences found' - endif - endif - return resultBuffer -endfunction - -" Function: s:svnFunctions.GetBufferInfo() {{{2 -" Provides version control details for the current file. Current version -" number and current repository version number are required to be returned by -" the vcscommand plugin. -" Returns: List of results: [revision, repository, branch] - -function! s:svnFunctions.GetBufferInfo() - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let fileName = bufname(originalBuffer) - let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status --non-interactive -vu "' . fileName . '"') - if(v:shell_error) - return [] - endif - - " File not under SVN control. - if statusText =~ '^?' - return ['Unknown'] - endif - - let [flags, revision, repository] = matchlist(statusText, '^\(.\{8}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3] - if revision == '' - " Error - return ['Unknown'] - elseif flags =~ '^A' - return ['New', 'New'] - else - return [revision, repository] - endif -endfunction - -" Function: s:svnFunctions.Info(argList) {{{2 -function! s:svnFunctions.Info(argList) - return s:DoCommand(join(['info --non-interactive'] + a:argList, ' '), 'info', join(a:argList, ' '), {}) -endfunction - -" Function: s:svnFunctions.Lock(argList) {{{2 -function! s:svnFunctions.Lock(argList) - return s:DoCommand(join(['lock --non-interactive'] + a:argList, ' '), 'lock', join(a:argList, ' '), {}) -endfunction - -" Function: s:svnFunctions.Log(argList) {{{2 -function! s:svnFunctions.Log(argList) - if len(a:argList) == 0 - let options = [] - let caption = '' - elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1 - let options = ['-r' . join(a:argList, ':')] - let caption = options[0] - else - " Pass-through - let options = a:argList - let caption = join(a:argList, ' ') - endif - - let resultBuffer = s:DoCommand(join(['log --non-interactive', '-v'] + options), 'log', caption, {}) - return resultBuffer -endfunction - -" Function: s:svnFunctions.Revert(argList) {{{2 -function! s:svnFunctions.Revert(argList) - return s:DoCommand('revert', 'revert', '', {}) -endfunction - -" Function: s:svnFunctions.Review(argList) {{{2 -function! s:svnFunctions.Review(argList) - if len(a:argList) == 0 - let versiontag = '(current)' - let versionOption = '' - else - let versiontag = a:argList[0] - let versionOption = ' -r ' . versiontag . ' ' - endif - - let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {}) - if resultBuffer > 0 - let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer -endfunction - -" Function: s:svnFunctions.Status(argList) {{{2 -function! s:svnFunctions.Status(argList) - let options = ['-u', '-v'] - if len(a:argList) == 0 - let options = a:argList - endif - return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {}) -endfunction - -" Function: s:svnFunctions.Unlock(argList) {{{2 -function! s:svnFunctions.Unlock(argList) - return s:DoCommand(join(['unlock --non-interactive'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {}) -endfunction - -" Function: s:svnFunctions.Update(argList) {{{2 -function! s:svnFunctions.Update(argList) - return s:DoCommand('update --non-interactive', 'update', '', {}) -endfunction - -" Annotate setting {{{2 -let s:svnFunctions.AnnotateSplitRegex = '\s\+\S\+\s\+\S\+ ' - -" Section: Plugin Registration {{{1 -call VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, []) - -let &cpo = s:save_cpo diff --git a/.vim/syntax/CVSAnnotate.vim b/.vim/syntax/CVSAnnotate.vim deleted file mode 100644 index 4af5809..0000000 --- a/.vim/syntax/CVSAnnotate.vim +++ /dev/null @@ -1,45 +0,0 @@ -" Vim syntax file -" Language: CVS annotate output -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" Remark: Used by the cvscommand plugin. Originally written by Mathieu -" Clabaut -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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 version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -syn match cvsDate /\d\d-...-\d\d/ contained -syn match cvsName /(\S* /hs=s+1,he=e-1 contained nextgroup=cvsDate -syn match cvsVer /^\d\+\(\.\d\+\)\+/ contained nextgroup=cvsName -syn region cvsHead start="^\d\+\.\d\+" end="):" contains=cvsVer,cvsName,cvsDate - -if !exists("did_cvsannotate_syntax_inits") - let did_cvsannotate_syntax_inits = 1 - hi link cvsDate Comment - hi link cvsName Type - hi link cvsVer Statement -endif - -let b:current_syntax="CVSAnnotate" diff --git a/.vim/syntax/SVKAnnotate.vim b/.vim/syntax/SVKAnnotate.vim deleted file mode 100644 index 3c53c3c..0000000 --- a/.vim/syntax/SVKAnnotate.vim +++ /dev/null @@ -1,42 +0,0 @@ -" Vim syntax file -" Language: SVK annotate output -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" Remark: Used by the vcscommand plugin. -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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("b:current_syntax") - finish -endif - -syn match svkDate /\d\{4}-\d\{1,2}-\d\{1,2}/ skipwhite contained -syn match svkName /(\s*\zs\S\+/ contained nextgroup=svkDate skipwhite -syn match svkVer /^\s*\d\+/ contained nextgroup=svkName skipwhite -syn region svkHead start=/^/ end="):" contains=svkVer,svkName,svkDate oneline - -if !exists("did_svkannotate_syntax_inits") - let did_svkannotate_syntax_inits = 1 - hi link svkName Type - hi link svkDate Comment - hi link svkVer Statement -endif - -let b:current_syntax="svkAnnotate" diff --git a/.vim/syntax/SVNAnnotate.vim b/.vim/syntax/SVNAnnotate.vim deleted file mode 100644 index d46f771..0000000 --- a/.vim/syntax/SVNAnnotate.vim +++ /dev/null @@ -1,40 +0,0 @@ -" Vim syntax file -" Language: SVN annotate output -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" Remark: Used by the vcscommand plugin. -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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("b:current_syntax") - finish -endif - -syn match svnName /\S\+/ contained -syn match svnVer /^\s\+\zs\d\+/ contained nextgroup=svnName skipwhite -syn match svnHead /^\s\+\d\+\s\+\S\+/ contains=svnVer,svnName - -if !exists("did_svnannotate_syntax_inits") - let did_svnannotate_syntax_inits = 1 - hi link svnName Type - hi link svnVer Statement -endif - -let b:current_syntax="svnAnnotate" diff --git a/.vim/syntax/cobra.vim b/.vim/syntax/cobra.vim deleted file mode 100644 index b84158e..0000000 --- a/.vim/syntax/cobra.vim +++ /dev/null @@ -1,169 +0,0 @@ -" Vim syntax file -" Language: Cobra -" Maintainer: -" Updated: 2008-10-11 -" -" -" Options to control Cobra syntax highlighting: -" -" For highlighted numbers: -" -" let cobra_highlight_numbers = 1 -" -" For highlighted builtin functions: -" -" let cobra_highlight_builtins = 1 -" -" For highlighted standard exceptions: -" -" let cobra_highlight_exceptions = 1 -" -" Highlight erroneous whitespace: -" -" let cobra_highlight_space_errors = 1 -" -" If you want all possible Cobra highlighting (the same as setting the -" preceding options): -" -" let cobra_highlight_all = 1 -" - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -syn keyword cobraStatement abstract all any as -syn keyword cobraStatement assembly assert base be body -syn keyword cobraStatement bool branch break callable catch -syn keyword cobraStatement char class continue ct_trace cue -syn keyword cobraStatement decimal def Dictionary dynamic -syn keyword cobraStatement ensure enum event expect extend -syn keyword cobraStatement extern fake false finally float -syn keyword cobraStatement float32 float64 get -syn keyword cobraStatement has ignore implements implies -syn keyword cobraStatement inherits init inlined inout -syn keyword cobraStatement int int16 int32 int64 int8 -syn keyword cobraStatement interface internal invariant List -syn keyword cobraStatement listen must namespace new nil -syn keyword cobraStatement nonvirtual number of off -syn keyword cobraStatement old on out override -syn keyword cobraStatement partial pass passthrough print -syn keyword cobraStatement private pro protected public raise -syn keyword cobraStatement ref require result return set -syn keyword cobraStatement Set shared sig stop String -syn keyword cobraStatement struct success test this throw -syn keyword cobraStatement to to? trace true try -syn keyword cobraStatement Type uint uint16 uint32 uint64 -syn keyword cobraStatement uint8 using value var -syn keyword cobraStatement vari virtual where yield - -syn match cobraFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained -syn keyword cobraRepeat for while post -syn keyword cobraConditional if else -syn keyword cobraOperator and in is not or -syn keyword cobraPreCondit use from import -syn match cobraComment "#.*$" contains=cobraTodo,@Spell -syn keyword cobraTodo TODO FIXME XXX contained - -" strings -syn region cobraString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=cobraEscape,@Spell -syn region cobraString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=cobraEscape,@Spell -syn region cobraString matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=cobraEscape,@Spell -syn region cobraString matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=cobraEscape,@Spell -syn region cobraRawString matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+ contains=@Spell -syn region cobraRawString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell -syn region cobraRawString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+ contains=@Spell -syn region cobraRawString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+ contains=@Spell -syn match cobraEscape +\\[abfnrtv'"\\]+ contained -syn match cobraEscape "\\\o\{1,3}" contained -syn match cobraEscape "\\x\x\{2}" contained -syn match cobraEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained -syn match cobraEscape "\\$" - -if exists("cobra_highlight_all") - let cobra_highlight_numbers = 1 - let cobra_highlight_builtins = 1 - let cobra_highlight_exceptions = 1 - let cobra_highlight_space_errors = 1 -endif - -if exists("cobra_highlight_numbers") - " numbers (including longs and complex) - syn match cobraNumber "\<0x\x\+[Ll]\=\>" - syn match cobraNumber "\<\d\+[LljJ]\=\>" - syn match cobraNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" - syn match cobraNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>" - syn match cobraNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" -endif - -if exists("cobra_highlight_builtins") - " builtin functions, types and objects, not really part of the syntax - syn keyword cobraBuiltin True False bool -endif - -if exists("cobra_highlight_exceptions") - " builtin exceptions and warnings - syn keyword cobraException Exception -endif - -if exists("cobra_highlight_space_errors") - " trailing whitespace - syn match cobraSpaceError display excludenl "\S\s\+$"ms=s+1 - " mixed tabs and spaces - syn match cobraSpaceError display " \+\t" - syn match cobraSpaceError display "\t\+ " -endif - -" This is fast but code inside triple quoted strings screws it up. It -" is impossible to fix because the only way to know if you are inside a -" triple quoted string is to start from the beginning of the file. If -" you have a fast machine you can try uncommenting the "sync minlines" -" and commenting out the rest. -syn sync match cobraSync grouphere NONE "):$" -syn sync maxlines=200 -"syn sync minlines=2000 - -if version >= 508 || !exists("did_cobra_syn_inits") - if version <= 508 - let did_cobra_syn_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - - " The default methods for highlighting. Can be overridden later - HiLink cobraStatement Statement - HiLink cobraFunction Function - HiLink cobraConditional Conditional - HiLink cobraRepeat Repeat - HiLink cobraString String - HiLink cobraRawString String - HiLink cobraEscape Special - HiLink cobraOperator Operator - HiLink cobraPreCondit PreCondit - HiLink cobraComment Comment - HiLink cobraTodo Todo - HiLink cobraDecorator Define - if exists("cobra_highlight_numbers") - HiLink cobraNumber Number - endif - if exists("cobra_highlight_builtins") - HiLink cobraBuiltin Function - endif - if exists("cobra_highlight_exceptions") - HiLink cobraException Exception - endif - if exists("cobra_highlight_space_errors") - HiLink cobraSpaceError Error - endif - - delcommand HiLink -endif - -let b:current_syntax = "cobra" - -" vim: ts=8 diff --git a/.vim/syntax/gitAnnotate.vim b/.vim/syntax/gitAnnotate.vim deleted file mode 100644 index fdc0bd1..0000000 --- a/.vim/syntax/gitAnnotate.vim +++ /dev/null @@ -1,44 +0,0 @@ -" Vim syntax file -" Language: git annotate output -" Maintainer: Bob Hiestand <bob.hiestand@gmail.com> -" Remark: Used by the vcscommand plugin. -" License: -" Copyright (c) 2009 Bob Hiestand -" -" 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("b:current_syntax") - finish -endif - -syn region gitName start="(\@<=" end="\( \d\d\d\d-\)\@=" contained -syn match gitCommit /^\x\+/ contained -syn match gitDate /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d [+-]\d\d\d\d/ contained -syn match gitLineNumber /\d\+)\@=/ contained -syn region gitAnnotation start="^" end=") " oneline keepend contains=gitCommit,gitLineNumber,gitDate,gitName - -if !exists("did_gitannotate_syntax_inits") - let did_gitannotate_syntax_inits = 1 - hi link gitName Type - hi link gitCommit Statement - hi link gitDate Comment - hi link gitLineNumber Label -endif - -let b:current_syntax="gitAnnotate" diff --git a/.vim/syntax/lighttpd.vim b/.vim/syntax/lighttpd.vim deleted file mode 100644 index 92c7baf..0000000 --- a/.vim/syntax/lighttpd.vim +++ /dev/null @@ -1,245 +0,0 @@ -" Vim syntax file -" Language: lighttpd config, http://www.lighttpd.net/ -" URL: http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/vim-syntax-lighttpd/lighttpd.vim -" Version Info: $Revision: 1.16 $ -" Maintainer: Elan Ruusamäe <glen@pld-linux.org> -" Last Change: $Date: 2009/11/09 12:52:16 $ UTC - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -syn case match - -if version < 600 - set iskeyword+=.,- -else - setlocal iskeyword+=.,- -endif - -" define the lighttpd syntax -" see also http://redmine.lighttpd.net/wiki/lighttpd/Docs:Configuration -syn match lighttpdDelimiter "[{}()\[\];,]" -syn match lighttpdOperator "[~!=|&\*\+\<\>]" -syn match lighttpdComment "\(#.*\)" -syn match lighttpdNumber "[-+]\=\<\d\+\(\.\d*\)\=\>" -syn region lighttpdString start=+"+ skip=+\\"+ end=+"+ -syn keyword lighttpdConditional else -syn match lighttpdServerVar /\$\(HTTP\|SERVER\|PHYSICAL\)\>/ -syn match lighttpdFunction /"\(cookie\|host\|useragent\|referer\|url\|querystring\|remoteip\|scheme\|socket\|path\|existing-path\)"/ - -" internal keywords -syn keyword lighttpdKeyword include include_shell - -syn match lighttpdSpecial /"\(dis\|en\)able"/ - -" module options -syn match lighttpdOption /var\.[A-Za-z][_A-Za-z0-9]*/ -syn keyword lighttpdOption - \ accesslog.filename - \ accesslog.format - \ accesslog.use-syslog - \ alias.url - \ auth.backend - \ auth.backend.htdigest.userfile - \ auth.backend.htpasswd.userfile - \ auth.backend.ldap.allow-empty-pw - \ auth.backend.ldap.base-dn - \ auth.backend.ldap.bind-dn - \ auth.backend.ldap.bind-pw - \ auth.backend.ldap.ca-file - \ auth.backend.ldap.filter - \ auth.backend.ldap.hostname - \ auth.backend.ldap.starttls - \ auth.backend.plain.groupfile - \ auth.backend.plain.userfile - \ auth.debug - \ auth.require - \ cgi.assign - \ cgi.execute-x-only - \ cml.extension - \ cml.memcache-hosts - \ cml.memcache-namespace - \ cml.power-magnet - \ compress.allowed-encodings - \ compress.cache-dir - \ compress.filetype - \ compress.max-filesize - \ connection.kbytes-per-second - \ debug.log-condition-handling - \ debug.log-file-not-found - \ debug.log-request-handling - \ debug.log-request-header - \ debug.log-request-header-on-error - \ debug.log-response-header - \ debug.log-ssl-noise - \ debug.log-state-handling - \ debug.log-timeouts - \ dir-listing.activate - \ dir-listing.auto-layout - \ dir-listing.encode-header - \ dir-listing.encode-readme - \ dir-listing.encoding - \ dir-listing.exclude - \ dir-listing.external-css - \ dir-listing.hide-dotfiles - \ dir-listing.hide-header-file - \ dir-listing.hide-readme-file - \ dir-listing.set-footer - \ dir-listing.show-header - \ dir-listing.show-readme - \ etag.use-inode - \ etag.use-mtime - \ etag.use-size - \ evasive.http-status-code - \ evasive.max-conns-per-ip - \ evasive.retry-after - \ evasive.silent - \ evhost.path-pattern - \ expire.url - \ extforward.forwarder - \ extforward.headers - \ fastcgi.debug - \ fastcgi.map-extensions - \ fastcgi.server - \ flv-streaming.extensions - \ h264-streaming.extensions - \ index-file.names - \ mimetype.assign - \ mimetype.use-xattr - \ proxy.balance - \ proxy.debug - \ proxy.server - \ rrdtool.binary - \ rrdtool.db-name - \ scgi.debug - \ scgi.server - \ secdownload.document-root - \ secdownload.secret - \ secdownload.timeout - \ secdownload.uri-prefix - \ server.bind - \ server.breakagelog - \ server.chroot - \ server.core-files - \ server.defer-accept - \ server.dir-listing - \ server.document-root - \ server.errorfile-prefix - \ server.error-handler-404 - \ server.errorlog - \ server.errorlog-use-syslog - \ server.event-handler - \ server.follow-symlink - \ server.force-lowercase-filenames - \ server.groupname - \ server.indexfiles - \ server.kbytes-per-second - \ server.max-connections - \ server.max-fds - \ server.max-keep-alive-idle - \ server.max-keep-alive-requests - \ server.max-read-idle - \ server.max-request-size - \ server.max-worker - \ server.max-write-idle - \ server.modules - \ server.name - \ server.network-backend - \ server.pid-file - \ server.port - \ server.protocol-http11 - \ server.range-requests - \ server.reject-expect-100-with-417 - \ server.stat-cache-engine - \ server.tag - \ server.upload-dirs - \ server.use-ipv6 - \ server.username - \ setenv.add-environment - \ setenv.add-request-header - \ setenv.add-response-header - \ simple-vhost.debug - \ simple-vhost.default-host - \ simple-vhost.document-root - \ simple-vhost.server-root - \ ssi.content-type - \ ssi.extension - \ ssl.ca-file - \ ssl.cipher-list - \ ssl.engine - \ ssl.pemfile - \ ssl.use-sslv2 - \ ssl.verifyclient.activate - \ ssl.verifyclient.depth - \ ssl.verifyclient.enforce - \ ssl.verifyclient.exportcert - \ ssl.verifyclient.username - \ static-file.etags - \ static-file.exclude-extensions - \ status.config-url - \ status.enable-sort - \ status.statistics-url - \ status.status-url - \ trigger-before-download.debug - \ trigger-before-download.deny-url - \ trigger-before-download.download-url - \ trigger-before-download.gdbm-filename - \ trigger-before-download.memcache-hosts - \ trigger-before-download.memcache-namespace - \ trigger-before-download.trigger-timeout - \ trigger-before-download.trigger-url - \ url.access-deny - \ url.redirect - \ url.rewrite - \ url.rewrite-final - \ url.rewrite-if-not-file - \ url.rewrite-once - \ url.rewrite-repeat - \ url.rewrite-repeat-if-not-file - \ userdir.basepath - \ userdir.exclude-user - \ userdir.include-user - \ userdir.letterhomes - \ userdir.path - \ usertrack.cookie-domain - \ usertrack.cookie-max-age - \ usertrack.cookie-name - \ webdav.activate - \ webdav.is-readonly - \ webdav.log-xml - \ webdav.sqlite-db-name - -" Define the default highlighting. -" For version 5.7 and earlier: only when not done already -" For version 5.8 and later: only when an item doesn't have highlighting yet -if version >= 508 || !exists("did_lighttpd_syntax_inits") - if version < 508 - let did_lighttpd_syntax_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - - HiLink lighttpdDelimiter Delimiter - HiLink lighttpdOperator Operator - HiLink lighttpdComment Comment - HiLink lighttpdNumber Number - HiLink lighttpdFunction Function - HiLink lighttpdKeyword Keyword - HiLink lighttpdOption Identifier - HiLink lighttpdSpecial Special - HiLink lighttpdConditional Conditional - HiLink lighttpdString String - HiLink lighttpdServerVar Identifier - - delcommand HiLink -endif - -let b:current_syntax = "lighttpd" - -" vim: ts=4 diff --git a/.vim/syntax/palmos.vim b/.vim/syntax/palmos.vim deleted file mode 100755 index 2fd60cc..0000000 --- a/.vim/syntax/palmos.vim +++ /dev/null @@ -1,41 +0,0 @@ -" Vim syntax file -" Language: PalmOS -" Maintainer: René Neumann aka Necoro <necoro@zakarum.de> -" Last Change: 2004 May 29 - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -"if version < 600 -" syntax clear -"elseif exists("b:current_syntax") -" finish -"endif - -" Read the C++ syntax to start with -if version < 600 - so <sfile>:p:h/cpp.vim -else - runtime! syntax/cpp.vim - unlet b:current_syntax -endif - - -" PalmOS extentions -syn keyword palmGenType UInt8 UInt16 UInt32 Int8 Int16 Int32 Boolean Char MemHandle MemPtr DmOpenRef WChar Err -syn keyword palmUsefulTypes ListType ControlType FormType FieldType ScrollBarType TableType DateType DateTimeType RectangleType EventType -syn keyword palmUsefulPtrs ListPtr ControlPtr FormPtr FieldPtr ScrollBarPtr TablePtr DatePtr DateTimePtr RectanglePtr EventPtr -syn keyword palmNetTypes NetSocketRef NetSocketAddrType NetSocketAddrINType NetHostInfoBufType -syn keyword palmNoDeleteNew delete new -syn keyword palmExceptions ErrThrow ErrCatch ErrEndCatch ErrTry - -command -nargs=+ HiLink hi def link <args> - - HiLink palmExceptions Exception - HiLink palmNoDeleteNew ErrorMsg - HiLink palmGenType Type - HiLink palmUsefulTypes Type - HiLink palmUsefulPtrs Type - HiLink palmNetTypes Type - delcommand HiLink - -let b:current_syntax = "palmos" diff --git a/.vim/syntax/scons.vim b/.vim/syntax/scons.vim deleted file mode 100644 index 0b63f9c..0000000 --- a/.vim/syntax/scons.vim +++ /dev/null @@ -1,75 +0,0 @@ -" Vim syntax file -" Language: SConscript -" Maintainer: Xi Wang <xi.wang@gmail.com> -" Last Change: 2006 Nov 15 - -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" Read the Python syntax to start with -if version < 600 - so <sfile>:p:h/python.vim -else - runtime! syntax/python.vim - unlet b:current_syntax -endif - -" SConscript extentions -syn keyword sconsTarget CFile CXXFile DVI Jar Java JavaH -syn keyword sconsTarget Library LoadableModule M4 Moc -syn keyword sconsTarget MSVSProject MSVSSolution Object -syn keyword sconsTarget PCH PDF PostScript Program -syn keyword sconsTarget RES RMIC RPCGenClient RPCGenHeader -syn keyword sconsTarget RPCGenService RPCGenXDR -syn keyword sconsTarget SharedLibrary SharedObject -syn keyword sconsTarget StaticLibrary StaticObject -syn keyword sconsTarget Tar TypeLibrary Uic Zip -syn keyword sconsEnv Action AddPostAction AddPreAction -syn keyword sconsEnv Alias AlwaysBuild Append AppendENVPath -syn keyword sconsEnv AppendUnique BitKeeper -syn keyword sconsEnv BuildDir Builder CacheDir Clean -syn keyword sconsEnv Command Configure Clone Copy CVS -syn keyword sconsEnv Default DefaultEnvironment -syn keyword sconsEnv Depends Dictionary Dir Dump -syn keyword sconsEnv EnsurePythonVersion EnsureSConsVersion -syn keyword sconsEnv Environment Execute Exit Export -syn keyword sconsEnv File FindFile Flatten -syn keyword sconsEnv GetBuildPath GetLaunchDir GetOption -syn keyword sconsEnv Help Ignore Import Install InstallAs -syn keyword sconsEnv Literal Local MergeFlags NoClean -syn keyword sconsEnv ParseConfig ParseDepends ParseFlags -syn keyword sconsEnv Preforce Platform Precious -syn keyword sconsEnv Prepend PrependENVPath PrependUnique -syn keyword sconsEnv RCS Replace Repository Return -syn keyword sconsEnv Scanner SCCS SConscript SConscriptChdir -syn keyword sconsEnv SConsignFile SetDefault SetOption -syn keyword sconsEnv SideEffect SourceCode SourceSignatures -syn keyword sconsEnv Split TargetSignatures Tool -syn keyword sconsEnv Value WhereIs -syn keyword sconsConf Configure Finish -syn keyword sconsConf CheckCHeader CheckCXXHeader CheckFun -syn keyword sconsConf CheckLib CheckLibWithHeader CheckType -syn keyword sconsOpt Options -syn match sconsVar /\<[A-Z_][A-Z0-9_]\+\>/ - -" Default highlighting -if version >= 508 || !exists("did_scons_syntax_inits") - if version < 508 - let did_scons_syntax_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - HiLink sconsTarget Keyword - HiLink sconsEnv Function - HiLink sconsConf Function - HiLink sconsOpt Function - HiLink sconsVar Special - delcommand HiLink -endif - -let b:current_syntax = "scons" -" vim: ts=8 diff --git a/.vim/syntax/swig.vim b/.vim/syntax/swig.vim deleted file mode 100644 index 90666c8..0000000 --- a/.vim/syntax/swig.vim +++ /dev/null @@ -1,44 +0,0 @@ -" Vim syntax file -" Language: SWIG -" Maintainer: Roman Stanchak (rstanchak@yahoo.com) -" Last Change: 2006 July 25 - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" Read the C++ syntax to start with -if version < 600 - so <sfile>:p:h/cpp.vim -else - runtime! syntax/cpp.vim - unlet b:current_syntax -endif - -" SWIG extentions -syn keyword swigDirective %typemap %define %apply %fragment %include %enddef %extend %newobject %name -syn keyword swigDirective %rename %ignore %keyword %typemap %define %apply %fragment %include -syn keyword swigDirective %enddef %extend %newobject %name %rename %ignore %template %module %constant -syn match swigDirective "%\({\|}\)" -syn match swigUserDef "%[-_a-zA-Z0-9]\+" - -" Default highlighting -if version >= 508 || !exists("did_swig_syntax_inits") - if version < 508 - let did_cpp_syntax_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - HiLink swigDirective Exception - HiLink swigUserDef PreProc - delcommand HiLink -endif - -let b:current_syntax = "swig" - -" vim: ts=8 diff --git a/.vim/syntax/vala.vim b/.vim/syntax/vala.vim deleted file mode 100644 index a24a8e6..0000000 --- a/.vim/syntax/vala.vim +++ /dev/null @@ -1,172 +0,0 @@ -" Vim syntax file -" Language: Vala -" Maintainers: Emmanuele Bassi <ebassi@gnome.org> -" Hans Vercammen <hveso3@gmail.com> -" Last Change: 2008-12-07 -" Filenames: *.vala *.vapi -" -" REFERENCES: -" [1] http://live.gnome.org/Vala -" -" TODO: Possibly when reaching vala 1.0 release -" - validate code attributes -" - better error checking for known errors -" - full support for valadoc - -if exists("b:current_syntax") - finish -endif - -let s:vala_cpo_save = &cpo -set cpo&vim - -" Types -syn keyword valaType bool char constpointer double float size_t ssize_t string unichar void -syn keyword valaType int int8 int16 int32 int64 long short -syn keyword valaType uint uint8 uint16 uint32 uint64 ulong ushort -" Storage keywords -syn keyword valaStorage class delegate enum errordomain interface namespace struct -" repeat / condition / label -syn keyword valaRepeat break continue do for foreach return while -syn keyword valaConditional else if switch -" User Labels -syn keyword valaLabel case default - -" Modifiers -syn keyword valaModifier abstract const dynamic ensures extern inline internal override -syn keyword valaModifier private protected public requires signal static virtual volatile weak -" Constants -syn keyword valaConstant false null true -" Exceptions -syn keyword valaException try catch finally throw -" Unspecified Statements -syn keyword valaUnspecifiedStatement as base construct delete get in is lock new out params ref sizeof set this throws typeof using value var yield yields - -" Comments -syn cluster valaCommentGroup contains=valaTodo -syn keyword valaTodo contained TODO FIXME XXX NOTE - -" valadoc Comments (ported from javadoc comments in java.vim) -" TODO: need to verify valadoc syntax -if !exists("vala_ignore_valadoc") - syn cluster valaDocCommentGroup contains=valaDocTags,valaDocSeeTag - syn region valaDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}" - syn match valaDocTags contained "@\(param\|exception\|throws\|since\)\s\+\S\+" contains=valaDocParam - syn match valaDocParam contained "\s\S\+" - syn match valaDocTags contained "@\(author\|brief\|version\|return\|deprecated\)\>" - syn region valaDocSeeTag contained matchgroup=valaDocTags start="@see\s\+" matchgroup=NONE end="\_."re=e-1 contains=valaDocSeeTagParam - syn match valaDocSeeTagParam contained @"\_[^"]\+"\|<a\s\+\_.\{-}</a>\|\(\k\|\.\)*\(#\k\+\((\_[^)]\+)\)\=\)\=@ extend -endif - -" Comment Strings (ported from c.vim) -if exists("vala_comment_strings") - syn match valaCommentSkip contained "^\s*\*\($\|\s\+\)" - syn region valaCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=valaSpecialChar,valaCommentSkip - syn region valaComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=valaSpecialChar - syn cluster valaCommentStringGroup contains=valaCommentString,valaCharacter,valaNumber - - syn region valaCommentL start="//" end="$" keepend contains=@valaCommentGroup,valaComment2String,valaCharacter,valaNumber,valaSpaceError,@Spell - syn region valaComment matchgroup=valaCommentStart start="/\*" end="\*/" contains=@valaCommentGroup,@valaCommentStringGroup,valaCommentStartError,valaSpaceError,@Spell extend - if !exists("vala_ignore_valadoc") - syn region valaDocComment matchgroup=valaCommentStart start="/\*\*" end="\*/" keepend contains=@valaCommentGroup,@valaDocCommentGroup,@valaCommentStringGroup,valaCommentStartError,valaSpaceError,@Spell - endif -else - syn region valaCommentL start="//" end="$" keepend contains=@valaCommentGroup,valaSpaceError,@Spell - syn region valaComment matchgroup=valaCommentStart start="/\*" end="\*/" contains=@valaCommentGroup,valaCommentStartError,valaSpaceError,@Spell - if !exists("vala_ignore_valadoc") - syn region valaDocComment matchgroup=valaCommentStart start="/\*\*" end="\*/" keepend contains=@valaCommentGroup,@valaDocCommentGroup,valaCommentStartError,valaSpaceError,@Spell - endif -endif -" match comment errors -syntax match valaCommentError display "\*/" -syntax match valaCommentStartError display "/\*"me=e-1 contained -" match the special comment /**/ -syn match valaComment "/\*\*/" - -" Vala Code Attributes -syn region valaAttribute start="^\s*\[" end="\]$" contains=valaComment,valaString keepend -syn region valaAttribute start="\[CCode" end="\]" contains=valaComment,valaString - -" Avoid escaped keyword matching -syn match valaUserContent display "@\I*" - -" Strings and constants -syn match valaSpecialError contained "\\." -syn match valaSpecialCharError contained "[^']" -syn match valaSpecialChar contained +\\["\\'0abfnrtvx]+ -syn region valaString start=+"+ end=+"+ end=+$+ contains=valaSpecialChar,valaSpecialError,valaUnicodeNumber,@Spell -syn region valaVerbatimString start=+"""+ end=+"""+ contains=@Spell -syn match valaUnicodeNumber +\\\(u\x\{4}\|U\x\{8}\)+ contained contains=valaUnicodeSpecifier -syn match valaUnicodeSpecifier +\\[uU]+ contained -syn match valaCharacter "'[^']*'" contains=valaSpecialChar,valaSpecialCharError -syn match valaCharacter "'\\''" contains=valaSpecialChar -syn match valaCharacter "'[^\\]'" -syn match valaNumber display "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" -syn match valaNumber display "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" -syn match valaNumber display "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" -syn match valaNumber display "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" - -" when wanted, highlight trailing white space -if exists("vala_space_errors") - if !exists("vala_no_trail_space_error") - syn match valaSpaceError display excludenl "\s\+$" - endif - if !exists("vala_no_tab_space_error") - syn match valaSpaceError display " \+\t"me=e-1 - endif -endif - -" when wanted, set minimum lines for comment syntax syncing -if exists("vala_minlines") - let b:vala_minlines = vala_minlines -else - let b:vala_minlines = 50 -endif -exec "syn sync ccomment valaComment minlines=" . b:vala_minlines - -" The default highlighting. -hi def link valaType Type -hi def link valaStorage StorageClass -hi def link valaRepeat Repeat -hi def link valaConditional Conditional -hi def link valaLabel Label -hi def link valaModifier StorageClass -hi def link valaConstant Constant -hi def link valaException Exception -hi def link valaUnspecifiedStatement Statement -hi def link valaUnspecifiedKeyword Keyword -hi def link valaContextualStatement Statement - -hi def link valaCommentError Error -hi def link valaCommentStartError Error -hi def link valaSpecialError Error -hi def link valaSpecialCharError Error -hi def link valaSpaceError Error - -hi def link valaTodo Todo -hi def link valaCommentL valaComment -hi def link valaCommentStart valaComment -hi def link valaCommentSkip valaComment -hi def link valaComment Comment -hi def link valaDocComment Comment -hi def link valaDocTags Special -hi def link valaDocParam Function -hi def link valaDocSeeTagParam Function -hi def link valaAttribute PreCondit - -hi def link valaCommentString valaString -hi def link valaComment2String valaString -hi def link valaString String -hi def link valaVerbatimString String -hi def link valaCharacter Character -hi def link valaSpecialChar SpecialChar -hi def link valaNumber Number -hi def link valaUnicodeNumber SpecialChar -hi def link valaUnicodeSpecifier SpecialChar - -let b:current_syntax = "vala" - -let &cpo = s:vala_cpo_save -unlet s:vala_cpo_save - -" vim: ts=8 diff --git a/.vim/syntax/vcscommit.vim b/.vim/syntax/vcscommit.vim deleted file mode 100644 index 0cd4c5e..0000000 --- a/.vim/syntax/vcscommit.vim +++ /dev/null @@ -1,31 +0,0 @@ -" Vim syntax file -" Language: VCS commit file -" Maintainer: Bob Hiestand (bob.hiestand@gmail.com) -" License: -" Copyright (c) 2007 Bob Hiestand -" -" 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("b:current_syntax") - finish -endif - -syntax region vcsComment start="^VCS: " end="$" -highlight link vcsComment Comment -let b:current_syntax = "vcscommit" @@ -2,17 +2,12 @@ " GENERAL " ======================================================= -" load the pathogen-style plugins -call pathogen#runtime_append_all_bundles() -call pathogen#helptags() +" load the bundles +source ~/.vim/bundles.vim " Colorscheme colorscheme desert -" Filetype -filetype indent on -filetype plugin on - " More general stuff set nu set fenc=utf-8 @@ -39,26 +34,6 @@ set laststatus=2 " always show line set statusline=%-3.3n\ %f\ %r%w[%{strlen(&ft)?&ft:'none'},%{strlen(&fenc)?&fenc:&enc.'\ (G)'},%{&fileformat}]%m%=%-14.(%l,%c%V%)%<%P " ======================================================= -" COMPLETION -" ======================================================= - -" Omnicomplete -autocmd FileType python set omnifunc=pythoncomplete#Complete -" nothing set for C/C++ -- done by the autoload feature -set completeopt=longest,menu,preview -set tags+=~/.vim/tags - -for tag in split(glob("~/.vim/tags.d/*"), "\n") - let &tags .= "," . tag -endfor - -" Allow Return to select a match -inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" - -" pydiction -let g:pydiction_location = '~/.vim/pydiction/complete-dict' - -" ======================================================= " COMPLETION FOR CMDLINE " ======================================================= @@ -88,10 +63,6 @@ map <F10> :make<CR> " Makes more sense and is similar to D map Y y$ -" Haskell GHCi stuff -autocmd FileType haskell nmap <LocalLeader>gi :GHCi -autocmd FileType haskell nmap <LocalLeader>gr :GHCReload - " ======================================================= " PLUGINS AND LANGUAGES " ======================================================= @@ -121,11 +92,6 @@ let g:tex_flavor = "latex" " do not do concealment in .tex files -- just too slow (and ugly) let g:tex_conceal = "" -" haskell stuff -au BufEnter *.hs compiler ghc -let g:haddock_browser = "/home/necoro/bin/openlink" -let g:haddock_indexfiledir = "/home/necoro/.cache/vim/" - " ======================================================= " FINAL " ======================================================= |