From 9d8238cef09d8cb7c270b616ec56a335e0ac0854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Neumann?= Date: Tue, 4 Sep 2012 16:20:28 +0200 Subject: Move to bundles in vim -- also remove old craft --- .vim/after/ftplugin/c.vim | 2 - .vim/after/ftplugin/cpp.vim | 2 - .vim/autoload/haskellmode.vim | 191 - .vim/autoload/omni/common/debug.vim | 32 - .vim/autoload/omni/common/utils.vim | 67 - .vim/autoload/omni/cpp/complete.vim | 569 --- .vim/autoload/omni/cpp/includes.vim | 126 - .vim/autoload/omni/cpp/items.vim | 660 --- .vim/autoload/omni/cpp/maycomplete.vim | 82 - .vim/autoload/omni/cpp/namespaces.vim | 838 ---- .vim/autoload/omni/cpp/settings.vim | 96 - .vim/autoload/omni/cpp/tokenizer.vim | 93 - .vim/autoload/omni/cpp/utils.vim | 587 --- .vim/autoload/pathogen.vim | 139 - .vim/bundle/gundo.vim/.hg/00changelog.i | Bin 57 -> 0 bytes .vim/bundle/gundo.vim/.hg/branch | 1 - .vim/bundle/gundo.vim/.hg/branchheads.cache | 2 - .vim/bundle/gundo.vim/.hg/dirstate | Bin 185 -> 0 bytes .vim/bundle/gundo.vim/.hg/hgrc | 2 - .vim/bundle/gundo.vim/.hg/requires | 3 - .vim/bundle/gundo.vim/.hg/store/00changelog.i | Bin 6899 -> 0 bytes .vim/bundle/gundo.vim/.hg/store/00manifest.i | Bin 5751 -> 0 bytes .vim/bundle/gundo.vim/.hg/store/data/.hgignore.i | Bin 171 -> 0 bytes .vim/bundle/gundo.vim/.hg/store/data/.hgtags.i | Bin 237 -> 0 bytes .../.hg/store/data/_r_e_a_d_m_e.markdown.i | Bin 1447 -> 0 bytes .../gundo.vim/.hg/store/data/doc/gundo.txt.i | Bin 2698 -> 0 bytes .../gundo.vim/.hg/store/data/plugin/gundo.vim.i | Bin 15222 -> 0 bytes .vim/bundle/gundo.vim/.hg/store/fncache | 5 - .vim/bundle/gundo.vim/.hg/store/undo | Bin 141 -> 0 bytes .vim/bundle/gundo.vim/.hg/tags.cache | 4 - .vim/bundle/gundo.vim/.hg/undo.branch | 1 - .vim/bundle/gundo.vim/.hg/undo.dirstate | 0 .vim/bundle/gundo.vim/.hgignore | 5 - .vim/bundle/gundo.vim/.hgtags | 2 - .vim/bundle/gundo.vim/README.markdown | 50 - .vim/bundle/gundo.vim/doc/gundo.txt | 128 - .vim/bundle/gundo.vim/doc/tags | 8 - .vim/bundle/gundo.vim/plugin/gundo.vim | 795 ---- .vim/bundles.vim | 40 + .vim/colors/desert.vim | 109 - .vim/compiler/ghc.vim | 536 --- .vim/doc/NERD_tree.txt | 961 ----- .vim/doc/haskellmode.txt | 465 -- .vim/doc/omnicppcomplete.txt | 1078 ----- .vim/doc/surround.txt | 184 - .vim/doc/taglist.txt | 1501 ------- .vim/doc/tags | 290 -- .vim/doc/vcscommand.txt | 819 ---- .vim/filetype.vim | 3 - .vim/ftplugin/haskell.vim | 14 - .vim/ftplugin/haskell_doc.vim | 881 ---- .vim/ftplugin/haskell_hpaste.vim | 79 - .vim/ftplugin/java/CTree.vim | 240 -- .vim/ftplugin/java/java.vim | 84 - .vim/ftplugin/java/java_getset.vim | 871 ---- .vim/indent/haskell.vim | 85 - .vim/plugin/NERD_tree.vim | 3917 ----------------- .vim/plugin/a.vim | 840 ---- .vim/plugin/autotag.vim | 150 - .vim/plugin/scmCloseParens.vim | 58 - .vim/plugin/surround.vim | 727 ---- .vim/plugin/tEchoPair.vim | 369 -- .vim/plugin/taglist.vim | 4546 -------------------- .vim/plugin/toggle_words.vim | 67 - .vim/plugin/vcsbzr.vim | 254 -- .vim/plugin/vcscommand.vim | 1344 ------ .vim/plugin/vcscvs.vim | 453 -- .vim/plugin/vcsgit.vim | 260 -- .vim/plugin/vcshg.vim | 275 -- .vim/plugin/vcssvk.vim | 262 -- .vim/plugin/vcssvn.vim | 292 -- .vim/syntax/CVSAnnotate.vim | 45 - .vim/syntax/SVKAnnotate.vim | 42 - .vim/syntax/SVNAnnotate.vim | 40 - .vim/syntax/cobra.vim | 169 - .vim/syntax/gitAnnotate.vim | 44 - .vim/syntax/lighttpd.vim | 245 -- .vim/syntax/palmos.vim | 41 - .vim/syntax/scons.vim | 75 - .vim/syntax/swig.vim | 44 - .vim/syntax/vala.vim | 172 - .vim/syntax/vcscommit.vim | 31 - 82 files changed, 40 insertions(+), 27452 deletions(-) delete mode 100644 .vim/after/ftplugin/c.vim delete mode 100644 .vim/after/ftplugin/cpp.vim delete mode 100644 .vim/autoload/haskellmode.vim delete mode 100644 .vim/autoload/omni/common/debug.vim delete mode 100644 .vim/autoload/omni/common/utils.vim delete mode 100644 .vim/autoload/omni/cpp/complete.vim delete mode 100644 .vim/autoload/omni/cpp/includes.vim delete mode 100644 .vim/autoload/omni/cpp/items.vim delete mode 100644 .vim/autoload/omni/cpp/maycomplete.vim delete mode 100644 .vim/autoload/omni/cpp/namespaces.vim delete mode 100644 .vim/autoload/omni/cpp/settings.vim delete mode 100644 .vim/autoload/omni/cpp/tokenizer.vim delete mode 100644 .vim/autoload/omni/cpp/utils.vim delete mode 100644 .vim/autoload/pathogen.vim delete mode 100644 .vim/bundle/gundo.vim/.hg/00changelog.i delete mode 100644 .vim/bundle/gundo.vim/.hg/branch delete mode 100644 .vim/bundle/gundo.vim/.hg/branchheads.cache delete mode 100644 .vim/bundle/gundo.vim/.hg/dirstate delete mode 100644 .vim/bundle/gundo.vim/.hg/hgrc delete mode 100644 .vim/bundle/gundo.vim/.hg/requires delete mode 100644 .vim/bundle/gundo.vim/.hg/store/00changelog.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/00manifest.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/data/.hgignore.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/data/.hgtags.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/data/_r_e_a_d_m_e.markdown.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/data/doc/gundo.txt.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/data/plugin/gundo.vim.i delete mode 100644 .vim/bundle/gundo.vim/.hg/store/fncache delete mode 100644 .vim/bundle/gundo.vim/.hg/store/undo delete mode 100644 .vim/bundle/gundo.vim/.hg/tags.cache delete mode 100644 .vim/bundle/gundo.vim/.hg/undo.branch delete mode 100644 .vim/bundle/gundo.vim/.hg/undo.dirstate delete mode 100644 .vim/bundle/gundo.vim/.hgignore delete mode 100644 .vim/bundle/gundo.vim/.hgtags delete mode 100644 .vim/bundle/gundo.vim/README.markdown delete mode 100644 .vim/bundle/gundo.vim/doc/gundo.txt delete mode 100644 .vim/bundle/gundo.vim/doc/tags delete mode 100644 .vim/bundle/gundo.vim/plugin/gundo.vim create mode 100644 .vim/bundles.vim delete mode 100644 .vim/colors/desert.vim delete mode 100644 .vim/compiler/ghc.vim delete mode 100644 .vim/doc/NERD_tree.txt delete mode 100644 .vim/doc/haskellmode.txt delete mode 100644 .vim/doc/omnicppcomplete.txt delete mode 100644 .vim/doc/surround.txt delete mode 100755 .vim/doc/taglist.txt delete mode 100644 .vim/doc/tags delete mode 100644 .vim/doc/vcscommand.txt delete mode 100644 .vim/ftplugin/haskell.vim delete mode 100644 .vim/ftplugin/haskell_doc.vim delete mode 100644 .vim/ftplugin/haskell_hpaste.vim delete mode 100644 .vim/ftplugin/java/CTree.vim delete mode 100644 .vim/ftplugin/java/java.vim delete mode 100644 .vim/ftplugin/java/java_getset.vim delete mode 100644 .vim/indent/haskell.vim delete mode 100644 .vim/plugin/NERD_tree.vim delete mode 100644 .vim/plugin/a.vim delete mode 100644 .vim/plugin/autotag.vim delete mode 100644 .vim/plugin/scmCloseParens.vim delete mode 100644 .vim/plugin/surround.vim delete mode 100644 .vim/plugin/tEchoPair.vim delete mode 100644 .vim/plugin/taglist.vim delete mode 100644 .vim/plugin/toggle_words.vim delete mode 100644 .vim/plugin/vcsbzr.vim delete mode 100644 .vim/plugin/vcscommand.vim delete mode 100644 .vim/plugin/vcscvs.vim delete mode 100644 .vim/plugin/vcsgit.vim delete mode 100755 .vim/plugin/vcshg.vim delete mode 100644 .vim/plugin/vcssvk.vim delete mode 100644 .vim/plugin/vcssvn.vim delete mode 100644 .vim/syntax/CVSAnnotate.vim delete mode 100644 .vim/syntax/SVKAnnotate.vim delete mode 100644 .vim/syntax/SVNAnnotate.vim delete mode 100644 .vim/syntax/cobra.vim delete mode 100644 .vim/syntax/gitAnnotate.vim delete mode 100644 .vim/syntax/lighttpd.vim delete mode 100755 .vim/syntax/palmos.vim delete mode 100644 .vim/syntax/scons.vim delete mode 100644 .vim/syntax/swig.vim delete mode 100644 .vim/syntax/vala.vim delete mode 100644 .vim/syntax/vcscommit.vim (limited to '.vim') 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 - - - -" 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 omni#cpp#maycomplete#Complete() - inoremap . omni#cpp#maycomplete#Dot() - inoremap > omni#cpp#maycomplete#Arrow() - inoremap : 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...) -