From 5c304966ea9da98ec07d09a5d346a24374113ccd Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 11 Apr 2010 20:49:43 +0200 Subject: [PATCH] =?UTF-8?q?Zmiany,=20zmiany,=20zmiany.=20Wywalony=20taglis?= =?UTF-8?q?t,=20w=20zamian=20dodany=20taglisttoo=20z=20projektu=20eclim.?= =?UTF-8?q?=20Wywalone=20funckje=20PyLint,=20na=20rzecz=20kompilera,=20fun?= =?UTF-8?q?kcja=20generuj=C2=BFca=20bufor=20z=20outputem=20z=20pylint=20zo?= =?UTF-8?q?sta=C2=BFa=20wrzucona=20do=20.vimrc=20(inne=20podej=C2=BFcie=20?= =?UTF-8?q?-=20banalnie=20proste=20i=20skuteczne).=20Uzupe=C5=82niona=20li?= =?UTF-8?q?sta=20GetLatestVimScripts,=20stosowne=20zmiany=20w=20.vimrc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vimrc | 68 +- GetLatest/GetLatestVimScripts.dat | 4 +- compiler/pylint.vim | 127 + filetype.vim | 9 - ftplugin/python/eclim_py.vim | 28 - .../python/pyflakes/pyflakes/__init__.pyc | Bin 148 -> 0 bytes ftplugin/python/pyflakes/pyflakes/ast.pyc | Bin 14028 -> 0 bytes ftplugin/python/pyflakes/pyflakes/checker.pyc | Bin 15889 -> 0 bytes .../python/pyflakes/pyflakes/messages.pyc | Bin 5385 -> 0 bytes plugin/{eclim_py.vim => eclim_tools.vim} | 518 +- plugin/taglist.vim | 4546 ----------------- plugin/taglisttoo.vim | 2224 ++++++++ syntax/mkd.vim | 104 - 13 files changed, 2447 insertions(+), 5181 deletions(-) create mode 100644 compiler/pylint.vim delete mode 100644 filetype.vim delete mode 100644 ftplugin/python/eclim_py.vim delete mode 100644 ftplugin/python/pyflakes/pyflakes/__init__.pyc delete mode 100644 ftplugin/python/pyflakes/pyflakes/ast.pyc delete mode 100644 ftplugin/python/pyflakes/pyflakes/checker.pyc delete mode 100644 ftplugin/python/pyflakes/pyflakes/messages.pyc rename plugin/{eclim_py.vim => eclim_tools.vim} (73%) delete mode 100644 plugin/taglist.vim create mode 100644 plugin/taglisttoo.vim delete mode 100644 syntax/mkd.vim diff --git a/.vimrc b/.vimrc index 8c92811..128b418 100644 --- a/.vimrc +++ b/.vimrc @@ -85,6 +85,8 @@ autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,exce autocmd FileType python set foldmethod=indent|set foldlevel=100|set list|set textwidth=78|set cinkeys-=0# autocmd FileType python set indentkeys-=0#|inoremap # X# autocmd FileType python set ofu=syntaxcomplete#Complete +autocmd FileType python compiler pylint +let g:pylint_onwrite = 0 " I don't want to run pylint on every save "autocmd FileType python setlocal omnifunc=pysmell#Complete let python_highlight_all=1 @@ -95,9 +97,6 @@ autocmd FileType sql set nolist|set nosmartindent|set autoindent|set foldmethod= autocmd FileType vim set nolist|set nosmartindent|set autoindent|set foldmethod=manual autocmd FileType snippet set nolist|set tabstop=4|set autoindent|set foldmethod=manual|set noexpandtab|set shiftwidth=4 autocmd FileType snippets set noexpandtab, nolist -augroup mkd - autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:> -augroup END autocmd FileType rst set spf=/home/gryf/.vim/pol.utf8.add|set textwidth=80 "}}} @@ -120,9 +119,9 @@ if $TERM == 'linux' endif "}}} "PLUGINS: {{{ -"getscriptPlugin +"getscriptPlugin {{{2 "let g:GetLatestVimScripts_allowautoinstall=1 "allow autoinstall scripts - +"}}} "TagList{{{2 let Tlist_Use_Right_Window = 1 "show menu in gvim. usefull to pop it up from kbd @@ -137,24 +136,27 @@ let Tlist_Sort_Type = "name" let Tlist_Exit_OnlyWindow = 1 let Tlist_WinWidth = 40 "}}} - -"NERDTree +"NERDTree {{{2 let NERDTreeWinSize = 40 - -"VimWIKI +" }}} +"VimWIKI {{{2 let g:vimwiki_list = [{'html_header': '~/vimwiki/vimwiki_head.tpl', \ 'html_footer': '~/vimwiki/vimwiki_foot.tpl'}] - -"ShowMarks +" }}} +"ShowMarks {{{2 let g:showmarks_ignore_type = "hqprm" let g:showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - -"jsbeautify +"}}} +"jsbeautify {{{3 nnoremap ff :call g:Jsbeautify():retab! - -" pydiction +"}}} +" pydiction {{{2 let g:pydiction_location = '/home/gryf/.vim/after/ftplugin/pytdiction/complete-dict' "}}} +"TagListToo {{{2 +let g:VerticalToolWindowSide = 'right' +"}}} +"}}} "KEYS: User definied keyboard shortcuts {{{ "set =^[[11^ @@ -175,8 +177,8 @@ if $TERM == 'rxvt-unicode' map :tabp endif -map :PyLint -map :call PyLintBuf() +map :call runPyLint() +map :call PyLintBuf() "map ctags plugin to show popup menu in gvim "map :popup Tags @@ -228,18 +230,26 @@ map :FufFile **/ " endif "endfunction -"function PyLint() -" :make -" let l:mbe = 0 -" if bufwinnr(bufnr('-MiniBufExplorer-')) != -1 -" let l:mbe = 1 -" :CMiniBufExplorer -" endif -" :cwindow -" if l:mbe == 1 -" :MiniBufExplorer -" endif -"endfunction +function runPyLint() + echohl Statement + echo "Running pylint (ctrl-c to cancel) ..." + echohl Normal + :Pylint +endfunction +function PyLintBuf() + echohl Statement + echo "Running pylint (ctrl-c to cancel) ..." + echohl Normal + let file = expand('%:p') + let cmd = 'pylint --reports=n --output-format=text "' . file . '"' + + if has('win32') || has('win64') + let command = 'cmd /c "' . command . '"' + endif + + exec "bel silent new " . file . ".lint" + exec "silent! read! " . cmd +endfunction function! StripTrailingWhitespaces() " Preparation: save last search, and cursor position. diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat index 655672b..a650cab 100644 --- a/GetLatest/GetLatestVimScripts.dat +++ b/GetLatest/GetLatestVimScripts.dat @@ -13,7 +13,7 @@ ScriptID SourceID Filename 2421 9423 pysmell.vim 152 3342 showmarks.vim 2540 11006 snipMate.vim -273 7701 taglist.vim +#273 7701 taglist.vim # exchanged with taglisttoo 2607 10388 tasklist.vim 90 12743 vcscommand.vim 2226 12476 vimwiki.vim @@ -23,6 +23,8 @@ ScriptID SourceID Filename 2536 12154 lucius.vim 1165 3741 tolerable.vim 2465 11352 wombat256.vim +# compiler +891 10365 pylint.vim # ftplugin 2441 12763 pyflakes.vim 30 9196 python_fn.vim diff --git a/compiler/pylint.vim b/compiler/pylint.vim new file mode 100644 index 0000000..662e7d7 --- /dev/null +++ b/compiler/pylint.vim @@ -0,0 +1,127 @@ +" Vim compiler file for Python +" Compiler: Style checking tool for Python +" Maintainer: Oleksandr Tymoshenko +" Last Change: 2009 Apr 19 +" Version: 0.5 +" Contributors: +" Artur Wroblewski +" Menno +" +" Installation: +" Drop pylint.vim in ~/.vim/compiler directory. Ensure that your PATH +" environment variable includes the path to 'pylint' executable. +" +" Add the following line to the autocmd section of .vimrc +" +" autocmd FileType python compiler pylint +" +" Usage: +" Pylint is called after a buffer with Python code is saved. QuickFix +" window is opened to show errors, warnings and hints provided by Pylint. +" Code rate calculated by Pylint is displayed at the bottom of the +" window. +" +" Above is realized with :Pylint command. To disable calling Pylint every +" time a buffer is saved put into .vimrc file +" +" let g:pylint_onwrite = 0 +" +" Displaying code rate calculated by Pylint can be avoided by setting +" +" let g:pylint_show_rate = 0 +" +" Openning of QuickFix window can be disabled with +" +" let g:pylint_cwindow = 0 +" +" Of course, standard :make command can be used as in case of every +" other compiler. +" + + +if exists('current_compiler') + finish +endif +let current_compiler = 'pylint' + +if !exists('g:pylint_onwrite') + let g:pylint_onwrite = 1 +endif + +if !exists('g:pylint_show_rate') + let g:pylint_show_rate = 1 +endif + +if !exists('g:pylint_cwindow') + let g:pylint_cwindow = 1 +endif + +if exists(':Pylint') != 2 + command Pylint :call Pylint(0) +endif + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +" We should echo filename because pylint truncates .py +" If someone know better way - let me know :) +CompilerSet makeprg=(echo\ '[%]';\ pylint\ -r\ y\ %) + +" We could omit end of file-entry, there is only one file +" %+I... - include code rating information +" %-G... - remove all remaining report lines from quickfix buffer +CompilerSet efm=%+P[%f],%t:\ %#%l:%m,%Z,%+IYour\ code%m,%Z,%-G%.%# + +if g:pylint_onwrite + augroup python + au! + au BufWritePost * call Pylint(1) + augroup end +endif + +function! Pylint(writing) + if !a:writing && &modified + " Save before running + write + endif + + if has('win32') || has('win16') || has('win95') || has('win64') + setlocal sp=>%s + else + setlocal sp=>%s\ 2>&1 + endif + + " If check is executed by buffer write - do not jump to first error + if !a:writing + silent make + else + silent make! + endif + + if g:pylint_cwindow + cwindow + endif + + call PylintEvaluation() + + if g:pylint_show_rate + echon 'code rate: ' b:pylint_rate ', prev: ' b:pylint_prev_rate + endif +endfunction + +function! PylintEvaluation() + let l:list = getqflist() + let b:pylint_rate = '0.00' + let b:pylint_prev_rate = '0.00' + for l:item in l:list + if l:item.type == 'I' && l:item.text =~ 'Your code has been rated' + let l:re_rate = '\(-\?[0-9]\{1,2\}\.[0-9]\{2\}\)/' + let b:pylint_rate = substitute(l:item.text, '.*rated at '.l:re_rate.'.*', '\1', 'g') + " Only if there is information about previous run + if l:item.text =~ 'previous run: ' + let b:pylint_prev_rate = substitute(l:item.text, '.*previous run: '.l:re_rate.'.*', '\1', 'g') + endif + endif + endfor +endfunction diff --git a/filetype.vim b/filetype.vim deleted file mode 100644 index 363ec0b..0000000 --- a/filetype.vim +++ /dev/null @@ -1,9 +0,0 @@ -" markdown filetype file -if exists("did\_load\_filetypes") - finish -endif - -augroup markdown - au! BufRead,BufNewFile *.mkd setfiletype mkd -augroup END - diff --git a/ftplugin/python/eclim_py.vim b/ftplugin/python/eclim_py.vim deleted file mode 100644 index 4966061..0000000 --- a/ftplugin/python/eclim_py.vim +++ /dev/null @@ -1,28 +0,0 @@ -" ftplugin for python. -" See: eclim_py plugin in plugins dir -" Global Variables {{{ - -if !exists("g:EclimPythonValidate") - let g:EclimPythonValidate = 1 -endif - -" }}} - -" Autocmds {{{ - -if g:EclimPythonValidate - augroup eclim_python_validate - autocmd! BufWritePost - autocmd BufWritePost call Validate(1) - augroup END -endif - -" }}} - -if !exists(":Validate") - command -nargs=0 -buffer Validate :call Validate(0) -endif -if !exists(":PyLint") - command -nargs=0 -buffer PyLint :call PyLint() -endif - diff --git a/ftplugin/python/pyflakes/pyflakes/__init__.pyc b/ftplugin/python/pyflakes/pyflakes/__init__.pyc deleted file mode 100644 index bb3ff8acd904611c70e870ce09d0a8d27edd8120..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 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 IPA!)I7r!D-I{*Lx diff --git a/ftplugin/python/pyflakes/pyflakes/messages.pyc b/ftplugin/python/pyflakes/pyflakes/messages.pyc deleted file mode 100644 index 746f6aedaecaddda126a1276ca47bf53e6244d99..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5385 zcmds5-EQ1O6dvzxew(yuQ^L;;M%7ZMf`$u(L<1060#h7ym9f`k!Q9j zQt!e&FTo`*!yE7nJOST#{Ig_<)M&d&Bz85kGsoj|X3jU?nKS$6->b{N|MA#cNI#kbY2_YM|m7f}76 zjR^<3bwdZTM<`|!6@0*DqsB73Y9GtO8sHK~?PJ;ssZeCz1g9v1vbvhZhZ#*Ja+4RaqO zIFTSo^V9|b=V4eWX9?ek^JSq(7WoqzSYaw#=jDKHSuP$^(vx~lZ6rOl zvFpH(ljFuCx)>oY;v#p}pj3Vf+w(VamH`oMMW^43Gu9 z;QlllsQRUw%KJKY4@TAt->dINUfYitXqWLCwx-NP_0e$nxxWBfijtwpYp@|4+Qv}#Em^%jcyup_m&th(M_7?Gl1YvHJtHAXZ?9yvvTp5=48b|NI z&r`t4-EtZ%2HFNH{$4y>5@=`6zpchs%DGhj@o4{A+RAE}}4-0;uOulJVU( zS~9MB4b9Tr)p?W^Cd~(~iHalb;wY^T&P}(}i7qjK`H)VEQoErs=^!8K+(u0GSY~^y zN&+biJ$-Euv?b(9CMstuuNs&@6@+JWuzmr3HBT=!S>k2y^TxK|PmVnv9c5`0TK!!) z7>U;*l+XDy+fOh)ZuGdgM~EVB1E8Ob@<`Gr*%6XS{V!D(XzgGn=Ggm{?u9g*`-VEbNfz{P| z?K}%Ws<(U~Dc8*7=`(1)ig@}y>^^O56U7~mcQX06syKLwY_qzPGaK@GtMM6ceWpu3 q&tjhe*(aTSZU~?H#?Fz}+n+dclzmnGjq*(w77XogT;EtY{rv}BayU5v diff --git a/plugin/eclim_py.vim b/plugin/eclim_tools.vim similarity index 73% rename from plugin/eclim_py.vim rename to plugin/eclim_tools.vim index d1af92f..71eb972 100644 --- a/plugin/eclim_py.vim +++ b/plugin/eclim_tools.vim @@ -18,29 +18,23 @@ " License along with this program. If not, see " . " ============================================================================ -let s:Eclim_ver = '1.5.4' +let s:Eclim_ver = '1.5.6' " Further Description: {{{1 -" @gryf: Python and editor helpers taken over from Eclim project. There are +" @gryf: taglist and editor helpers taken over from Eclim project. There are " couple of nice tools, which I want to have separately from Eclim project. -" Just for my conviniece and because I mainly work with Python files, I'll -" put all of necessary thing into this one file. +" Just for my conviniece, I've puted all of necessary things into this one file. " " Added: " :Buffers " :Sign " :Signs -" :PyLint -" :Validate (pyflakes) " :QuickFixClear " :LocationListClear " TODO: -" :Validate (rope) [this one is not crucial. at least for now.] +" :taglisttoo " :SignClearUser " :SignClearAll -" (w daleszej kolejnoĊ›ci) -" :PythonRegex -" :LocateFile (do silnego przerobienia) " " }}} @@ -103,7 +97,7 @@ endif " Command Declarations {{{2 if !exists(":Buffers") - command Buffers :call Buffers() + command Buffers :call s:Buffers() endif if has('signs') @@ -122,10 +116,10 @@ if has('signs') endif if !exists(":QuickFixClear") - command QuickFixClear :call setqflist([]) | call SignsUpdate() + command QuickFixClear :call setqflist([]) | call s:SignsUpdate() endif if !exists(":LocationListClear") - command LocationListClear :call setloclist(0, []) | call SignsUpdate() + command LocationListClear :call setloclist(0, []) | call s:SignsUpdate() endif " }}} @@ -134,10 +128,10 @@ endif if g:EclimSignLevel augroup eclim_qf - autocmd QuickFixCmdPost *make* call SignsShow('', 'qf') - autocmd QuickFixCmdPost grep*,vimgrep* call SignsShow('i', 'qf') - autocmd QuickFixCmdPost lgrep*,lvimgrep* call SignsShow('i', 'loc') - autocmd BufWinEnter * call SignsUpdate() + autocmd QuickFixCmdPost *make* call s:SignsShow('', 'qf') + autocmd QuickFixCmdPost grep*,vimgrep* call s:SignsShow('i', 'qf') + autocmd QuickFixCmdPost lgrep*,lvimgrep* call s:SignsShow('i', 'loc') + autocmd BufWinEnter * call s:SignsUpdate() augroup END endif @@ -177,7 +171,7 @@ endif " Buffers() eclim/autoload/eclim/common/buffers.vim {{{2 " Like, :buffers, but opens a temporary buffer. -function! Buffers() +function! s:Buffers() redir => list silent exec 'buffers' redir END @@ -367,9 +361,13 @@ function! DelayedCommand(command, ...) exec 'augroup END' endfunction " }}} -" EchoTrace(message) eclim/autoload/eclim/util.vim {{{2 -function! EchoTrace(message) - call s:EchoLevel(a:message, 6, g:EclimTraceHighlight) +" EchoTrace(message, [time_elapsed]) eclim/autoload/eclim/util.vim {{{2 +function! EchoTrace(message, ...) + if a:0 > 0 + call s:EchoLevel('(' . a:1 . 's) ' . a:message, 6, g:EclimTraceHighlight) + else + call s:EchoLevel(a:message, 6, g:EclimTraceHighlight) + endif endfunction " }}} " EchoWarning(message) eclim/autoload/eclim/util.vim {{{2 @@ -414,7 +412,12 @@ endfunction " }}} " Escapes the supplied buffer name so that it can be safely used by buf* " functions. function! EscapeBufferName(name) - let name = escape(a:name, ' ') + let name = a:name + " escaping the space in cygwin could lead to the dos path error message that + " cygwin throws when a dos path is referenced. + if !has('win32unix') + let name = escape(a:name, ' ') + endif return substitute(name, '\(.\{-}\)\[\(.\{-}\)\]\(.\{-}\)', '\1[[]\2[]]\3', 'g') endfunction " }}} @@ -489,7 +492,14 @@ function! GoToBufferWindowOrOpen(name, cmd) exec winnr . "winc w" call DelayedCommand('doautocmd WinEnter') else - silent exec a:cmd . ' ' . escape(Simplify(a:name), ' ') + let cmd = a:cmd + " if splitting and the buffer is a unamed empty buffer, then switch to an + " edit. + if cmd == 'split' && expand('%') == '' && + \ !&modified && line('$') == 1 && getline(1) == '' + let cmd = 'edit' + endif + silent exec cmd . ' ' . escape(Simplify(a:name), ' ') endif endfunction " }}} @@ -535,7 +545,7 @@ function! SetLocationList(list, ...) if g:EclimShowCurrentError && len(loclist) > 0 call DelayedCommand('call ShowCurrentError()') endif - call SignsUpdate() + call s:SignsUpdate() endfunction " }}} " ClearLocationList([namespace, namespace, ...]) eclim/autoload/eclim/util.vim {{{2 @@ -566,7 +576,7 @@ function! ClearLocationList(...) else call setloclist(0, [], 'r') endif - call SignsUpdate() + call s:SignsUpdate() endfunction " }}} " SetQuickfixList(list, [action]) eclim/autoload/eclim/util.vim {{{2 @@ -599,7 +609,7 @@ function! SetQuickfixList(list, ...) if g:EclimShowCurrentError && len(qflist) > 0 call DelayedCommand('call ShowCurrentError()') endif - call SignsUpdate() + call s:SignsUpdate() endfunction " }}} " ShowCurrentError() eclim/autoload/eclim/util.vim {{{2 @@ -688,11 +698,19 @@ function! System(cmd, ...) if len(a:000) > 0 && a:000[0] let result = '' - call EchoTrace('exec: ' . a:cmd) - exec a:cmd + let begin = localtime() + try + exec a:cmd + finally + call EchoTrace('exec: ' . a:cmd, localtime() - begin) + endtry else - call EchoTrace('system: ' . a:cmd) - let result = system(a:cmd) + let begin = localtime() + try + let result = system(a:cmd) + finally + call EchoTrace('system: ' . a:cmd, localtime() - begin) + endtry endif let &shell = saveshell @@ -757,8 +775,8 @@ function! TempWindow(name, lines, ...) exec bufwinnr(name) . "winc w" endif - set modifiable - set noreadonly + setlocal modifiable + setlocal noreadonly call append(1, a:lines) retab silent 1,1delete _ @@ -769,7 +787,7 @@ function! TempWindow(name, lines, ...) setlocal readonly endif - doautocmd BufEnter + silent doautocmd BufEnter " Store filename and window number so that plugins can use it if necessary. if filename != expand('%:p') @@ -1006,7 +1024,7 @@ endfunction " }}} " This function supports a severity level by examining the 'type' key of the " dictionaries in the location or quickfix list. It supports 'i' (info), 'w' " (warning), and 'e' (error). -function! SignsUpdate() +function! s:SignsUpdate() if !has('signs') || !g:EclimSignLevel return endif @@ -1103,7 +1121,7 @@ function! SignsShow(type, list) endif endif - call SignsUpdate() + call s:SignsUpdate() redraw! endfunction " }}} @@ -1152,249 +1170,6 @@ endif " }}} " End Display Signs: }}} -" Python Django: {{{1 - -" GetProjectPath([path]) eclim/autoload/eclim/python/django/util.vim {{{2 -function! DjangoGetProjectPath(...) - let path = len(a:000) > 0 ? a:000[0] : escape(expand('%:p:h'), ' ') - let dir = findfile("manage.py", path . ';') - if dir != '' - let dir = substitute(fnamemodify(dir, ':p:h'), '\', '/', 'g') - " secondary check on the dir, if settings.py exists, then probably the - " right dir, otherwise, search again from the parent. - if !filereadable(dir . '/settings.py') - return DjangoGetProjectPath(path . '/..') - endif - endif - return dir -endfunction " }}} - -" }}} - -" Python Validate: {{{1 - -" Global Variables eclim/autoload/eclim/python/validate.vim {{{2 - " if the user has the pyflakes plugin from vim.org, then disable our - " validation since the two overlap and may result in errors - let s:pyflakes_enabled = 1 - if exists('g:pyflakes_builtins') - let s:pyflakes_enabled = 0 - endif - if !exists('g:EclimValidateBuffer') - let g:EclimValidateBuffer = 1 - endif -" }}} - -" Script Variables eclim/autoload/eclim/python/validate.vim {{{2 - let s:warnings = '\(' . join([ - \ 'imported but unused', - \ 'local variable .* assigned to but never used', - \ ], '\|') . '\)' -" }}} - -" Validate(on_save) eclim/autoload/eclim/python/validate.vim {{{2 -" Validates the current file. -function! Validate(on_save) - if g:EclimValidateBuffer == 0 - return - endif - - if WillWrittenBufferClose() - return - endif - - if &filetype != "python" - return - endif - - let results = [] - let syntax_error = ValidateSyntax() - - if syntax_error == '' - if s:pyflakes_enabled - if !executable('pyflakes') - if !exists('g:eclim_python_pyflakes_warn') - call EchoWarning("Unable to find 'pyflakes' command.") - let g:eclim_python_pyflakes_warn = 1 - endif - else - let command = 'pyflakes "' . expand('%:p') . '"' - let results = split(System(command), '\n') - if v:shell_error > 1 " pyflakes returns 1 if there where warnings. - call EchoError('Error running command: ' . command) - let results = [] - endif - endif - endif - - " rope validation - " currently too slow for running on every save. - " - " gryf: this stuff should be rewriten somehow. For now it is just to - " complicated. - " - "if eclim#project#util#IsCurrentFileInProject(0) && !a:on_save - " let project = eclim#project#util#GetCurrentProjectRoot() - " let filename = eclim#project#util#GetProjectRelativeFilePath(expand('%:p')) - " let rope_results = eclim#python#rope#Validate(project, filename) - " " currently rope gets confused with iterator var on list comprehensions - " let rope_results = filter(rope_results, "v:val !~ '^Unresolved variable'") - " let results += rope_results - "endif - endif - - if !empty(results) || syntax_error != '' - call filter(results, "v:val !~ 'unable to detect undefined names'") - - let errors = [] - if syntax_error != '' - let lnum = substitute(syntax_error, '.*(line \(\d\+\))', '\1', '') - let text = substitute(syntax_error, '\(.*\)\s\+(line .*', '\1', '') - if lnum == syntax_error - let lnum = 1 - let text .= ' (unknown line)' - endif - call add(errors, { - \ 'filename': Simplify(expand('%')), - \ 'lnum': lnum, - \ 'text': text, - \ 'type': 'e' - \ }) - endif - - if syntax_error == '' - for error in results - let file = substitute(error, '\(.\{-}\):[0-9]\+:.*', '\1', '') - let line = substitute(error, '.\{-}:\([0-9]\+\):.*', '\1', '') - let message = substitute(error, '.\{-}:[0-9]\+:\(.*\)', '\1', '') - let dict = { - \ 'filename': Simplify(file), - \ 'lnum': line, - \ 'text': message, - \ 'type': message =~ s:warnings ? 'w' : 'e', - \ } - - call add(errors, dict) - endfor - endif - - call SetLocationList(errors) - if g:EclimOpenQFLists - :lopen - endif - else - call ClearLocationList() - endif -endfunction " }}} - -" ValidateSyntax() eclim/autoload/eclim/python/validate.vim {{{2 -function ValidateSyntax() - let syntax_error = '' - - if has('python') - -python << EOF -import re, vim -from compiler import parseFile -try: - parseFile(vim.eval('expand("%:p")')) -except SyntaxError, se: - vim.command("let syntax_error = \"%s\"" % re.sub(r'"', r'\"', str(se))) -except IndentationError, ie: - vim.command("let syntax_error = \"%s (line %s)\"" % ( - re.sub(r'"', r'\"', ie.msg), ie.lineno) - ) -EOF - - endif - - return syntax_error -endfunction " }}} - -" PyLint() eclim/autoload/eclim/python/validate.vim {{{2 -function! PyLint() - - if &filetype != "python" - return - endif - - let file = expand('%:p') - - if !executable('pylint') - call EchoError("Unable to find 'pylint' command.") - return - endif - - let pylint_env = '' - if exists('g:EclimPyLintEnv') - let pylint_env = g:EclimPyLintEnv - else - let paths = [] - - let django_dir = DjangoGetProjectPath() - if django_dir != '' - call add(paths, fnamemodify(django_dir, ':h')) - let settings = fnamemodify(django_dir, ':t') - if has('win32') || has('win64') - let pylint_env = - \ 'set DJANGO_SETTINGS_MODULE='. settings . '.settings && ' - else - let pylint_env = - \ 'DJANGO_SETTINGS_MODULE="'. settings . '.settings" ' - endif - endif - - if !empty(paths) - if has('win32') || has('win64') - let pylint_env .= 'set "PYTHONPATH=' . join(paths, ';') . '" && ' - else - let pylint_env .= 'PYTHONPATH="$PYTHONPATH:' . join(paths, ':') . '"' - endif - endif - endif - - " TODO: switch to 'parseable' output format. - let command = pylint_env . - \ ' pylint --reports=n --output-format=text "' . file . '"' - if has('win32') || has('win64') - let command = 'cmd /c "' . command . '"' - endif - - call Echo('Running pylint (ctrl-c to cancel) ...') - let result = System(command) - call Echo(' ') - if v:shell_error == 1 - call EchoError('Error running command: ' . command) - return - endif - - if result =~ ':' - let errors = [] - for error in split(result, '\n') - if error =~ '^[CWERF]\(: \)\?[0-9]' - let line = substitute(error, '.\{-}:\s*\([0-9]\+\):.*', '\1', '') - let message = substitute(error, '.\{-}:\s*[0-9]\+:\(.*\)', '\1', '') - let dict = { - \ 'filename': Simplify(file), - \ 'lnum': line, - \ 'text': message, - \ 'type': error =~ '^E' ? 'e' : 'w', - \ } - - call add(errors, dict) - endif - endfor - call SetQuickfixList(errors) - if g:EclimOpenQFLists - :copen - endif - else - call SetQuickfixList([], 'r') - endif -endfunction " }}} - -" }}} - " Eclim Help: {{{1 " BufferHelp(lines, orientation, size) eclim/autoload/eclim/help.vim {{{ @@ -1423,7 +1198,7 @@ function! BufferHelp(lines, orientation, size) setlocal buftype=nofile bufhidden=delete nnoremap ? :bd - set modifiable noreadonly + setlocal modifiable noreadonly silent 1,$delete _ call append(1, a:lines) retab @@ -1482,58 +1257,6 @@ function! GetAllBuffers() echo buffers return buffers - - "let buffers = [] - "let filelength = 0 - "for entry in split(list, '\n') - " let buffer = {} - " let buffer.status = substitute(entry, '\s*[0-9]\+\s\+\(.\{-}\)\s\+".*', '\1', '') - " let buffer.path = substitute(entry, '.\{-}"\(.\{-}\)".*', '\1', '') - " let buffer.path = fnamemodify(buffer.path, ':p') - " let buffer.file = fnamemodify(buffer.path, ':p:t') - " let buffer.dir = fnamemodify(buffer.path, ':p:h') - " exec 'let buffer.bufnr = ' . substitute(entry, '\s*\([0-9]\+\).*', '\1', '') - " exec 'let buffer.lnum = ' . - " \ substitute(entry, '.*"\s\+line\s\+\([0-9]\+\).*', '\1', '') - " call add(buffers, buffer) - - " if len(buffer.file) > filelength - " let filelength = len(buffer.file) - " endif - "endfor - - "if g:EclimBuffersSort != '' - " call sort(buffers, 'BufferCompare') - "endif - - "let lines = [] - "for buffer in buffers - " call add(lines, s:BufferEntryToLine(buffer, filelength)) - "endfor - - "call TempWindow('[buffers]', lines) - "let b:eclim_buffers = buffers - - "" syntax - "set ft=eclim_buffers - "hi link BufferActive Special - "hi link BufferHidden Comment - "syntax match BufferActive /+\?active\s\+\(\[RO\]\)\?/ - "syntax match BufferHidden /+\?hidden\s\+\(\[RO\]\)\?/ - - "" mappings - "nnoremap :call BufferOpen(g:EclimBuffersDefaultAction) - "nnoremap E :call BufferOpen('edit') - "nnoremap S :call BufferOpen('split') - "nnoremap T :call BufferOpen('tablast \| tabnew') - "nnoremap D :call BufferDelete() - - "augroup eclim_buffers - " autocmd! - " autocmd BufAdd,BufWinEnter,BufDelete,BufWinLeave * - " \ call eclim#common#buffers#BuffersUpdate() - " autocmd BufUnload autocmd! eclim_buffers - "augroup END endfunction " }}} " ViewAllSigns(name) {{{2 @@ -1564,23 +1287,6 @@ function! SignsViewAllSigns(name) augroup END endif endfor - - "let filename = expand('%:p') - "let signs = SignsGetExisting(a:name) - "call sort(signs, 's:CompareSigns') - "let content = map(signs, "v:val.line . '|' . getline(v:val.line)") - - "call TempWindow('[Sign List]', content) - - "set ft=qf - "nnoremap :call JumpToSign() - - "" Store filename so that plugins can use it if necessary. - "let b:filename = filename - "augroup temp_window - " autocmd! BufWinLeave - " call GoToBufferWindowRegister(filename) - "augroup END endfunction " }}} " TODO: remove this @@ -1622,122 +1328,6 @@ function! SignsGetAllExisting(buffernr, mark_name) return existing endfunction " }}} -" PyLintBuf() create pylint-output buffer {{{2 -function! PyLintBuf() - - if &filetype != "python" - return - endif - - let file = expand('%:p') - - if !executable('pylint') - call EchoError("Unable to find 'pylint' command.") - return - endif - - let pylint_env = '' - if exists('g:EclimPyLintEnv') - let pylint_env = g:EclimPyLintEnv - else - let paths = [] - - if !empty(paths) - if has('win32') || has('win64') - let pylint_env .= 'set "PYTHONPATH=' . join(paths, ';') . '" && ' - else - let pylint_env .= 'PYTHONPATH="$PYTHONPATH:' . join(paths, ':') . '"' - endif - endif - endif - - " TODO: switch to 'parseable' output format. - let command = pylint_env . - \ ' pylint --reports=n --output-format=text "' . file . '"' - if has('win32') || has('win64') - let command = 'cmd /c "' . command . '"' - endif - - call Echo('Running pylint (ctrl-c to cancel) ...') - let result = System(command) - call Echo(' ') - if v:shell_error == 1 - call EchoError('Error running command: ' . command) - return - endif - - exec "bel silent new " . file . ".lint" - - for i in split(result, "\n") - call append("$", i) - endfor - - "remove first empty line - exec "delete 1" -endfunction " }}} - -" Marks() {{{2 -" Like, :marks, but opens a temporary buffer. -function! Marks() - redir => list - silent exec 'marks' - redir END - - let marks = [] - let filelength = 0 - for entry in split(list, '\n') - echo entry - let buffer = {} - let buffer.status = substitute(entry, '\s*[0-9]\+\s\+\(.\{-}\)\s\+".*', '\1', '') - let buffer.path = substitute(entry, '.\{-}"\(.\{-}\)".*', '\1', '') - let buffer.path = fnamemodify(buffer.path, ':p') - let buffer.file = fnamemodify(buffer.path, ':p:t') - let buffer.dir = fnamemodify(buffer.path, ':p:h') - exec 'let buffer.bufnr = ' . substitute(entry, '\s*\([0-9]\+\).*', '\1', '') - exec 'let buffer.lnum = ' . - \ substitute(entry, '.*"\s\+line\s\+\([0-9]\+\).*', '\1', '') - call add(marks, buffer) - - if len(buffer.file) > filelength - let filelength = len(buffer.file) - endif - endfor - - if g:EclimBuffersSort != '' - call sort(buffers, 'BufferCompare') - endif - - let lines = [] - for buffer in buffers - call add(lines, s:BufferEntryToLine(buffer, filelength)) - endfor - - call TempWindow('[marks]', lines) - let b:eclim_buffers = buffers - - " syntax - set ft=eclim_buffers - hi link BufferActive Special - hi link BufferHidden Comment - syntax match BufferActive /+\?active\s\+\(\[RO\]\)\?/ - syntax match BufferHidden /+\?hidden\s\+\(\[RO\]\)\?/ - - " mappings - nnoremap :call BufferOpen(g:EclimBuffersDefaultAction) - nnoremap E :call BufferOpen('edit') - nnoremap S :call BufferOpen('split') - nnoremap T :call BufferOpen('tablast \| tabnew') - nnoremap D :call BufferDelete() - - "augroup eclim_buffers - " autocmd! - " autocmd BufAdd,BufWinEnter,BufDelete,BufWinLeave * - " \ call eclim#common#buffers#BuffersUpdate() - " autocmd BufUnload autocmd! eclim_buffers - "augroup END -endfunction " }}} -command Marks :call Marks() - " s:BufferOpen2(cmd) {{{2 function! s:BufferOpen2(cmd) let line = line('.') diff --git a/plugin/taglist.vim b/plugin/taglist.vim deleted file mode 100644 index 59901f6..0000000 --- a/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() - command! -nargs=+ -complete=dir TlistAddFilesRecursive - \ call s:Tlist_Add_Files_Recursive() - 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() - command! -nargs=* -complete=buffer TlistShowTag - \ echo Tlist_Get_Tagname_By_Line() - command! -nargs=* -complete=file TlistSessionLoad - \ call s:Tlist_Session_Load() - command! -nargs=* -complete=file TlistSessionSave - \ call s:Tlist_Session_Save() - 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() - 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 xx xx - let s:tlist_sid = substitute(maparg('xx'), '\(\d\+_\)xx$', - \ '\1', '') - unmap xx - - exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_* source ' . - \ escape(expand(''), ' ') - exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Window_* source ' . - \ escape(expand(''), ' ') - exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Menu_* source ' . - \ escape(expand(''), ' ') - exe 'autocmd FuncUndefined Tlist_* source ' . - \ escape(expand(''), ' ') - exe 'autocmd FuncUndefined TagList_* source ' . - \ escape(expand(''), ' ') - - 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 - 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 to display help text') - else - " Add the extensive help - call append(0, '" : 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, '" : 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, '" : 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: - " - " ;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 - \ :call Tlist_Window_Jump_To_Tag('useopen') - nnoremap o - \ :call Tlist_Window_Jump_To_Tag('newwin') - nnoremap p - \ :call Tlist_Window_Jump_To_Tag('preview') - nnoremap P - \ :call Tlist_Window_Jump_To_Tag('prevwin') - if v:version >= 700 - nnoremap t - \ :call Tlist_Window_Jump_To_Tag('checktab') - nnoremap - \ :call Tlist_Window_Jump_To_Tag('newtab') - endif - nnoremap <2-LeftMouse> - \ :call Tlist_Window_Jump_To_Tag('useopen') - nnoremap s - \ :call Tlist_Change_Sort('cmd', 'toggle', '') - nnoremap + :silent! foldopen - nnoremap - :silent! foldclose - nnoremap * :silent! %foldopen! - nnoremap = :silent! %foldclose - nnoremap :silent! foldopen - nnoremap :silent! foldclose - nnoremap :silent! %foldopen! - nnoremap :call Tlist_Window_Show_Info() - nnoremap u :call Tlist_Window_Update_File() - nnoremap d :call Tlist_Remove_File(-1, 1) - nnoremap x :call Tlist_Window_Zoom() - nnoremap [[ :call Tlist_Window_Move_To_File(-1) - nnoremap :call Tlist_Window_Move_To_File(-1) - nnoremap ]] :call Tlist_Window_Move_To_File(1) - nnoremap :call Tlist_Window_Move_To_File(1) - nnoremap :call Tlist_Window_Toggle_Help_Text() - nnoremap q :close - - " Insert mode mappings - inoremap - \ :call Tlist_Window_Jump_To_Tag('useopen') - " Windows needs return - inoremap - \ :call Tlist_Window_Jump_To_Tag('useopen') - inoremap o - \ :call Tlist_Window_Jump_To_Tag('newwin') - inoremap p - \ :call Tlist_Window_Jump_To_Tag('preview') - inoremap P - \ :call Tlist_Window_Jump_To_Tag('prevwin') - if v:version >= 700 - inoremap t - \ :call Tlist_Window_Jump_To_Tag('checktab') - inoremap - \ :call Tlist_Window_Jump_To_Tag('newtab') - endif - inoremap <2-LeftMouse> - \ :call Tlist_Window_Jump_To_Tag('useopen') - inoremap s - \ :call Tlist_Change_Sort('cmd', 'toggle', '') - inoremap + :silent! foldopen - inoremap - :silent! foldclose - inoremap * :silent! %foldopen! - inoremap = :silent! %foldclose - inoremap :silent! foldopen - inoremap :silent! foldclose - inoremap :silent! %foldopen! - inoremap :call - \ Tlist_Window_Show_Info() - inoremap u - \ :call Tlist_Window_Update_File() - inoremap d :call Tlist_Remove_File(-1, 1) - inoremap x :call Tlist_Window_Zoom() - inoremap [[ :call Tlist_Window_Move_To_File(-1) - inoremap :call Tlist_Window_Move_To_File(-1) - inoremap ]] :call Tlist_Window_Move_To_File(1) - inoremap :call Tlist_Window_Move_To_File(1) - inoremap :call Tlist_Window_Toggle_Help_Text() - inoremap q :close - - " 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 ... however vim does - " not fire the when you use the mouse - " to enter a buffer. - let clickmap = ':if bufname("%") =~ "__Tag_List__" ' . - \ 'call Tlist_Window_Jump_To_Tag("useopen") ' . - \ ' endif ' - if maparg('', 'n') == '' - " no mapping for leftmouse - exe ':nnoremap ' . clickmap - else - " we have a mapping - let mapcmd = ':nnoremap ' - let mapcmd = mapcmd . substitute(substitute( - \ maparg('', 'n'), '|', '', 'g'), - \ '\c^', '', '') - 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('')) - 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('') - nunmap - 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_namefile_nameex_cmd;"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:\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:\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 ' . - \ '' - 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 ' - 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 ') - 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 ') - 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(':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 T&ags.Refresh\ menu :call Tlist_Menu_Refresh() - anoremenu T&ags.Sort\ menu\ by.Name - \ :call Tlist_Change_Sort('menu', 'set', 'name') - anoremenu T&ags.Sort\ menu\ by.Order - \ :call Tlist_Change_Sort('menu', 'set', 'order') - anoremenu T&ags.-SEP1- : - - if &mousemodel =~ 'popup' - anoremenu PopUp.T&ags.Refresh\ menu - \ :call Tlist_Menu_Refresh() - anoremenu PopUp.T&ags.Sort\ menu\ by.Name - \ :call Tlist_Change_Sort('menu', 'set', 'name') - anoremenu PopUp.T&ags.Sort\ menu\ by.Order - \ :call Tlist_Change_Sort('menu', 'set', 'order') - 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 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 Tlist_Menu_Jump_To_Tag(' . - \ tidx . ')|' - - 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 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 Tlist_Menu_Jump_To_Tag(' . tidx - \ . ')|' - - 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 . ' ' - 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/plugin/taglisttoo.vim b/plugin/taglisttoo.vim new file mode 100644 index 0000000..9535762 --- /dev/null +++ b/plugin/taglisttoo.vim @@ -0,0 +1,2224 @@ +" Author: Eric Van Dewoestine +" +" Description: {{{ +" see http://eclim.org/vim/taglist.html +" +" License: +" +" Copyright (C) 2005 - 2010 Eric Van Dewoestine +" +" This program is free software: you can redistribute it and/or modify +" it under the terms of the GNU General Public License as published by +" the Free Software Foundation, either version 3 of the License, or +" (at your option) any later version. +" +" This program is distributed in the hope that it will be useful, +" but WITHOUT ANY WARRANTY; without even the implied warranty of +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +" GNU General Public License for more details. +" +" You should have received a copy of the GNU General Public License +" along with this program. If not, see . +" +" }}} + +"if exists('g:taglisttoo_loaded') || +" \ (exists('g:taglisttoo_disabled') && g:taglisttoo_disabled) +" finish +"endif +"let g:taglisttoo_loaded = 1 + +" Global Variables {{{ + +if !exists("g:TaglistEnabled") + let g:TaglistEnabled = 1 +endif + +if !exists('g:Tlist_Ctags_Cmd') + if executable('exuberant-ctags') + let g:Tlist_Ctags_Cmd = 'exuberant-ctags' + elseif executable('ctags') + let g:Tlist_Ctags_Cmd = 'ctags' + elseif executable('ctags.exe') + let g:Tlist_Ctags_Cmd = 'ctags.exe' + elseif executable('tags') + let g:Tlist_Ctags_Cmd = 'tags' + endif +endif + +" always set the taglist title since eclim references it in a few places. +if !exists('g:TagList_title') + let g:TagList_title = "__Tag_List__" +endif + +" no ctags found, no need to continue. +if !exists('g:Tlist_Ctags_Cmd') + finish +endif + +let g:Tlist_Ctags_Cmd_Ctags = g:Tlist_Ctags_Cmd + +" don't conflict with original taglist if that is what the user is using. +if !exists('loaded_taglist') + " Automatically open the taglist window on Vim startup + if !exists('g:Tlist_Auto_Open') + let g:Tlist_Auto_Open = 0 + endif + + if g:Tlist_Auto_Open && !exists('g:Tlist_Temp_Disable') + augroup taglisttoo_autoopen + autocmd! + autocmd VimEnter * nested call s:AutoOpen() + augroup END + + " Auto open on new tabs as well. + if v:version >= 700 + autocmd taglisttoo_autoopen BufWinEnter * + \ if tabpagenr() > 1 && + \ !exists('t:Tlist_Auto_Opened') && + \ !exists('g:SessionLoad') | + \ call s:AutoOpen() | + \ let t:Tlist_Auto_Opened = 1 | + \ endif + endif + endif + + augroup taglisttoo_file_session + autocmd! + autocmd SessionLoadPost * call s:Restore() + augroup END +endif +" }}} + +" Command Declarations {{{ +if !exists(":Tlist") && !exists(":TlistToo") + command TlistToo :call s:Taglist() +endif +" }}} + +" Util: {{{1 + +" Script Variables eclim/autoload/eclim/util.vim {{{2 + let s:buffer_write_closing_commands = '^\s*\(' . + \ 'wq\|xa\|' . + \ '\d*w[nN]\|\d*wp\|' . + \ 'ZZ' . + \ '\)' + + let s:bourne_shells = ['sh', 'bash', 'dash', 'ksh', 'zsh'] + let s:c_shells = ['csh', 'tcsh'] + + let s:show_current_error_displaying = 0 +" }}} + +" Balloon(message) eclim/autoload/eclim/util.vim {{{2 +" Function for use as a vim balloonexpr expression. +function! Balloon(message) + let message = a:message + if !has('balloon_multiline') + " remove any new lines + let message = substitute(message, '\n', ' ', 'g') + endif + return message +endfunction " }}} + +" DelayedCommand(command, [delay]) eclim/autoload/eclim/util.vim {{{2 +" Executes a delayed command. Useful in cases where one would expect an +" autocommand event (WinEnter, etc) to fire, but doesn't, or you need a +" command to execute after other autocommands have finished. +" Note: Nesting is not supported. A delayed command cannot be invoke off +" another delayed command. +function! DelayedCommand(command, ...) + let uid = fnamemodify(tempname(), ':t:r') + if &updatetime > 1 + exec 'let g:eclim_updatetime_save' . uid . ' = &updatetime' + endif + exec 'let g:eclim_delayed_command' . uid . ' = a:command' + let &updatetime = len(a:000) ? a:000[0] : 1 + exec 'augroup delayed_command' . uid + exec 'autocmd CursorHold * ' . + \ ' if exists("g:eclim_updatetime_save' . uid . '") | ' . + \ ' let &updatetime = g:eclim_updatetime_save' . uid . ' | ' . + \ ' unlet g:eclim_updatetime_save' . uid . ' | ' . + \ ' endif | ' . + \ ' exec g:eclim_delayed_command' . uid . ' | ' . + \ ' unlet g:eclim_delayed_command' . uid . ' | ' . + \ ' autocmd! delayed_command' . uid + exec 'augroup END' +endfunction " }}} + +" EchoTrace(message, [time_elapsed]) eclim/autoload/eclim/util.vim {{{2 +function! EchoTrace(message, ...) + if a:0 > 0 + call s:EchoLevel('(' . a:1 . 's) ' . a:message, 6, g:EclimTraceHighlight) + else + call s:EchoLevel(a:message, 6, g:EclimTraceHighlight) + endif +endfunction " }}} + +" EchoWarning(message) eclim/autoload/eclim/util.vim {{{2 +function! EchoWarning(message) + call s:EchoLevel(a:message, 3, g:EclimWarningHighlight) +endfunction " }}} + +" EchoError(message) eclim/autoload/eclim/util.vim {{{2 +function! EchoError(message) + call s:EchoLevel(a:message, 2, g:EclimErrorHighlight) +endfunction " }}} + +" s:EchoLevel(message) eclim/autoload/eclim/util.vim {{{2 +" Echos the supplied message at the supplied level with the specified +" highlight. +function! s:EchoLevel(message, level, highlight) + " only echo if the result is not 0, which signals that ExecuteEclim failed. + if a:message != "0" && g:EclimLogLevel >= a:level + exec "echohl " . a:highlight + redraw + for line in split(a:message, '\n') + echom line + endfor + echohl None + endif +endfunction " }}} + +" Echo(message) eclim/autoload/eclim/util.vim {{{2 +" Echos a message using the info highlight regardless of what log level is set. +function! Echo(message) + if a:message != "0" && g:EclimLogLevel > 0 + exec "echohl " . g:EclimInfoHighlight + redraw + for line in split(a:message, '\n') + echom line + endfor + echohl None + endif +endfunction " }}} + +" EscapeBufferName(name) eclim/autoload/eclim/util.vim {{{2 +" Escapes the supplied buffer name so that it can be safely used by buf* +" functions. +function! EscapeBufferName(name) + let name = a:name + " escaping the space in cygwin could lead to the dos path error message that + " cygwin throws when a dos path is referenced. + if !has('win32unix') + let name = escape(a:name, ' ') + endif + return substitute(name, '\(.\{-}\)\[\(.\{-}\)\]\(.\{-}\)', '\1[[]\2[]]\3', 'g') +endfunction " }}} + +" ExecWithoutAutocmds(cmd, [events]) eclim/autoload/eclim/util.vim {{{2 +" Execute a command after disabling all autocommands (borrowed from taglist.vim) +function! ExecWithoutAutocmds(cmd, ...) + let save_opt = &eventignore + let events = len(a:000) == 0 ? 'all' : a:000[0] + exec 'set eventignore=' . events + try + exec a:cmd + finally + let &eventignore = save_opt + endtry +endfunction " }}} + +" GetLineError(line) eclim/autoload/eclim/util.vim {{{2 +" Gets the error (or message) for the supplie line number if one. +function! GetLineError(line) + let line = line('.') + let col = col('.') + + let errornum = 0 + let errorcol = 0 + let index = 0 + + let locerrors = getloclist(0) + let qferrors = getqflist() + let bufname = expand('%') + let lastline = line('$') + for error in qferrors + locerrors + let index += 1 + if bufname(error.bufnr) == bufname && + \ (error.lnum == line || (error.lnum > lastline && line == lastline)) + if errornum == 0 || (col >= error.col && error.col != errorcol) + let errornum = index + let errorcol = error.col + endif + endif + endfor + + if errornum > 0 + let src = 'qf' + let cnt = len(qferrors) + let errors = qferrors + if errornum > cnt + let errornum -= cnt + let src = 'loc' + let cnt = len(locerrors) + let errors = locerrors + endif + + let message = src . ' - (' . errornum . ' of ' . cnt . '): ' + \ . substitute(errors[errornum - 1].text, '^\s\+', '', '') + return message + endif + return '' +endfunction " }}} + +" GoToBufferWindow(buf) eclim/autoload/eclim/util.vim {{{2 +" Focuses the window containing the supplied buffer name or buffer number. +" Returns 1 if the window was found, 0 otherwise. +function! GoToBufferWindow(buf) + if type(a:buf) == 0 + let winnr = bufwinnr(a:buf) + else + let name = EscapeBufferName(a:buf) + let winnr = bufwinnr(bufnr('^' . name)) + endif + if winnr != -1 + exec winnr . "winc w" + call DelayedCommand('doautocmd WinEnter') + return 1 + endif + return 0 +endfunction " }}} + +" GoToBufferWindowOrOpen(name, cmd) eclim/autoload/eclim/util.vim {{{2 +" Gives focus to the window containing the buffer for the supplied file, or if +" none, opens the file using the supplied command. +function! GoToBufferWindowOrOpen(name, cmd) + let name = EscapeBufferName(a:name) + let winnr = bufwinnr(bufnr('^' . name)) + if winnr != -1 + exec winnr . "winc w" + call DelayedCommand('doautocmd WinEnter') + else + let cmd = a:cmd + " if splitting and the buffer is a unamed empty buffer, then switch to an + " edit. + if cmd == 'split' && expand('%') == '' && + \ !&modified && line('$') == 1 && getline(1) == '' + let cmd = 'edit' + endif + silent exec cmd . ' ' . escape(Simplify(a:name), ' ') + endif +endfunction " }}} + +" GoToBufferWindowRegister(buf) eclim/autoload/eclim/util.vim {{{2 +" Registers the autocmd for returning the user to the supplied buffer when the +" current buffer is closed. +function! GoToBufferWindowRegister(buf) + exec 'autocmd BufWinLeave ' . + \ 'call GoToBufferWindow("' . escape(a:buf, '\') . '") | ' . + \ 'doautocmd BufEnter' +endfunction " }}} + +" SetLocationList(list, [action]) eclim/autoload/eclim/util.vim {{{2 +" Sets the contents of the location list for the current window. +function! SetLocationList(list, ...) + let loclist = a:list + + " filter the list if the current buffer defines a list of filters. + if exists('b:EclimLocationListFilter') + let newlist = [] + for item in loclist + let addit = 1 + + for filter in b:EclimLocationListFilter + if item.text =~ filter + let addit = 0 + break + endif + endfor + + if addit + call add(newlist, item) + endif + endfor + let loclist = newlist + endif + + if a:0 == 0 + call setloclist(0, loclist) + else + call setloclist(0, loclist, a:1) + endif + if g:EclimShowCurrentError && len(loclist) > 0 + call DelayedCommand('call ShowCurrentError()') + endif + call s:SignsUpdate() +endfunction " }}} + +" ClearLocationList([namespace, namespace, ...]) eclim/autoload/eclim/util.vim {{{2 +" Clears the current location list. Optionally 'namespace' arguments can be +" supplied which will only clear items with text prefixed with '[namespace]'. +" Also the special namespace 'global' may be supplied which will only remove +" items with no namepace prefix. +function! ClearLocationList(...) + if a:0 > 0 + let loclist = getloclist(0) + if len(loclist) > 0 + let pattern = '' + for ns in a:000 + if pattern != '' + let pattern .= '\|' + endif + if ns == 'global' + let pattern .= '\(\[\w\+\]\)\@!' + else + let pattern .= '\[' . ns . '\]' + endif + endfor + let pattern = '^\(' . pattern . '\)' + + call filter(loclist, 'v:val.text !~ pattern') + call setloclist(0, loclist, 'r') + endif + else + call setloclist(0, [], 'r') + endif + call s:SignsUpdate() +endfunction " }}} + +" SetQuickfixList(list, [action]) eclim/autoload/eclim/util.vim {{{2 +" Sets the contents of the quickfix list. +function! SetQuickfixList(list, ...) + let qflist = a:list + if exists('b:EclimQuickfixFilter') + let newlist = [] + for item in qflist + let addit = 1 + + for filter in b:EclimQuickfixFilter + if item.text =~ filter + let addit = 0 + break + endif + endfor + + if addit + call add(newlist, item) + endif + endfor + let qflist = newlist + endif + if a:0 == 0 + call setqflist(qflist) + else + call setqflist(qflist, a:1) + endif + if g:EclimShowCurrentError && len(qflist) > 0 + call DelayedCommand('call ShowCurrentError()') + endif + call s:SignsUpdate() +endfunction " }}} + +" ShowCurrentError() eclim/autoload/eclim/util.vim {{{2 +" Shows the error on the cursor line if one. +function! ShowCurrentError() + let message = GetLineError(line('.')) + if message != '' + " remove any new lines + let message = substitute(message, '\n', ' ', 'g') + + if len(message) > (&columns - 1) + let message = strpart(message, 0, &columns - 4) . '...' + endif + + call WideMessage('echo', message) + let s:show_current_error_displaying = 1 + else + " clear the message if one of our error messages was displaying + if s:show_current_error_displaying + call WideMessage('echo', message) + let s:show_current_error_displaying = 0 + endif + endif +endfunction " }}} + +" Simplify(file) eclim/autoload/eclim/util.vim {{{2 +" Simply the supplied file to the shortest valid name. +function! Simplify(file) + let file = a:file + + " Don't run simplify on url files, it will screw them up. + if file !~ '://' + let file = simplify(file) + endif + + " replace all '\' chars with '/' except those escaping spaces. + let file = substitute(file, '\\\([^[:space:]]\)', '/\1', 'g') + let cwd = substitute(getcwd(), '\', '/', 'g') + if cwd !~ '/$' + let cwd .= '/' + endif + + if file =~ '^' . cwd + let file = substitute(file, '^' . cwd, '', '') + endif + + return file +endfunction " }}} + +" System(cmd, [exec]) eclim/autoload/eclim/util.vim {{{2 +" Executes system() accounting for possibly disruptive vim options. +function! System(cmd, ...) + let saveshell = &shell + let saveshellcmdflag = &shellcmdflag + let saveshellpipe = &shellpipe + let saveshellquote = &shellquote + let saveshellredir = &shellredir + let saveshellslash = &shellslash + let saveshelltemp = &shelltemp + let saveshellxquote = &shellxquote + + if has("win32") || has("win64") + set shell=cmd.exe + set shellcmdflag=/c + set shellpipe=>%s\ 2>&1 + set shellquote= + set shellredir=>%s\ 2>&1 + set noshellslash + set shelltemp + set shellxquote= + else + if executable('/bin/bash') + set shell=/bin/bash + else + set shell=/bin/sh + endif + set shell=/bin/sh + set shellcmdflag=-c + set shellpipe=2>&1\|\ tee + set shellquote= + set shellredir=>%s\ 2>&1 + set noshellslash + set shelltemp + set shellxquote= + endif + + if len(a:000) > 0 && a:000[0] + let result = '' + let begin = localtime() + try + exec a:cmd + finally + call EchoTrace('exec: ' . a:cmd, localtime() - begin) + endtry + else + let begin = localtime() + try + let result = system(a:cmd) + finally + call EchoTrace('system: ' . a:cmd, localtime() - begin) + endtry + endif + + let &shell = saveshell + let &shellcmdflag = saveshellcmdflag + let &shellquote = saveshellquote + let &shellslash = saveshellslash + let &shelltemp = saveshelltemp + let &shellxquote = saveshellxquote + + " If a System call is executed at startup, it appears to interfere with + " vim's setting of 'shellpipe' and 'shellredir' to their shell specific + " values. So, if we detect that the values we are restoring look like + " uninitialized defaults, then attempt to mimic vim's documented + " (:h 'shellpipe' :h 'shellredir') logic for setting the proper values based + " on the shell. + " Note: still doesn't handle more obscure shells + if saveshellredir == '>' + if index(s:bourne_shells, fnamemodify(&shell, ':t')) != -1 + set shellpipe=2>&1\|\ tee + set shellredir=>%s\ 2>&1 + elseif index(s:c_shells, fnamemodify(&shell, ':t')) != -1 + set shellpipe=\|&\ tee + set shellredir=>& + else + let &shellpipe = saveshellpipe + let &shellredir = saveshellredir + endif + else + let &shellpipe = saveshellpipe + let &shellredir = saveshellredir + endif + + return result +endfunction " }}} + +" TempWindow(name, lines, [readonly]) eclim/autoload/eclim/util.vim {{{2 +" Opens a temp window w/ the given name and contents which is readonly unless +" specified otherwise. +function! TempWindow(name, lines, ...) + let filename = expand('%:p') + let winnr = winnr() + + call TempWindowClear(a:name) + let name = EscapeBufferName(a:name) + + if bufwinnr(name) == -1 + silent! noautocmd exec "botright 10sview " . escape(a:name, ' ') + let b:eclim_temp_window = 1 + + " play nice with maximize.vim + "if eclim#display#maximize#GetMaximizedWindow() + " call eclim#display#maximize#AdjustFixedWindow(10, 1) + "endif + + setlocal nowrap + setlocal winfixheight + setlocal noswapfile + setlocal nobuflisted + setlocal buftype=nofile + setlocal bufhidden=delete + else + exec bufwinnr(name) . "winc w" + endif + + setlocal modifiable + setlocal noreadonly + call append(1, a:lines) + retab + silent 1,1delete _ + + if len(a:000) == 0 || a:000[0] + setlocal nomodified + setlocal nomodifiable + setlocal readonly + endif + + silent doautocmd BufEnter + + " Store filename and window number so that plugins can use it if necessary. + if filename != expand('%:p') + let b:filename = filename + let b:winnr = winnr + + augroup eclim_temp_window + autocmd! BufWinLeave + call GoToBufferWindowRegister(b:filename) + augroup END + endif +endfunction " }}} + +" TempWindowClear(name) eclim/autoload/eclim/util.vim {{{2 +" Clears the contents of the temp window with the given name. +function! TempWindowClear(name) + let name = EscapeBufferName(a:name) + if bufwinnr(name) != -1 + let curwinnr = winnr() + exec bufwinnr(name) . "winc w" + setlocal modifiable + setlocal noreadonly + silent 1,$delete _ + exec curwinnr . "winc w" + endif +endfunction " }}} + +" WideMessage(command, message) eclim/autoload/eclim/util.vim {{{2 +" Executes the supplied echo command and forces vim to display as much as +" possible without the "Press Enter" prompt. +" Thanks to vimtip #1289 +function! WideMessage(command, message) + let saved_ruler = &ruler + let saved_showcmd = &showcmd + + let message = substitute(a:message, '^\s\+', '', '') + + set noruler noshowcmd + redraw + exec a:command . ' "' . escape(message, '"\') . '"' + + let &ruler = saved_ruler + let &showcmd = saved_showcmd +endfunction " }}} + +" WillWrittenBufferClose() eclim/autoload/eclim/util.vim {{{2 +" Returns 1 if the current buffer is to be hidden/closed/deleted after it is +" written, or 0 otherwise. This function is useful during a post write auto +" command for determining whether or not to perform some operation based on +" whether the buffer will still be visible to the user once the current +" command has finished. +" Note: This function only detects command typed by the user at the +" command (:) prompt, not any normal mappings which may hide/close/delete the +" buffer. +function! WillWrittenBufferClose() + return histget("cmd") =~ s:buffer_write_closing_commands +endfunction " }}} + +" End Util: }}} + +" TagListToo: {{{1 + +" Global Variables eclim/autoload/eclim/taglist/taglisttoo.vim {{{ +let g:TagListToo = 1 + +" Tag listing sort type - 'name' or 'order' +if !exists('Tlist_Sort_Type') + let Tlist_Sort_Type = 'order' +endif + +" }}} + +" Script Variables eclim/autoload/eclim/taglist/taglisttoo.vim {{{ + let s:taglisttoo_ignore = g:TagList_title . '\|ProjectTree' + + " used to prefer one window over another if a buffer is open in more than + " one window. + let s:taglisttoo_prevwinnr = 0 +" }}} + +" Language Settings eclim/autoload/eclim/taglist/taglisttoo.vim {{{ +" assembly language +let s:tlist_def_asm_settings = { + \ 'lang': 'asm', 'tags': { + \ 'd': 'define', + \ 'l': 'label', + \ 'm': 'macro', + \ 't': 'type' + \ } + \ } + +" aspperl language +let s:tlist_def_aspperl_settings = { + \ 'lang': 'asp', 'tags': { + \ 'f': 'function', + \ 's': 'sub', + \ 'v': 'variable' + \ } + \ } + +" aspvbs language +let s:tlist_def_aspvbs_settings = { + \ 'lang': 'asp', 'tags': { + \ 'f': 'function', + \ 's': 'sub', + \ 'v': 'variable' + \ } + \ } + +" awk language +let s:tlist_def_awk_settings = {'lang': 'awk', 'tags': {'f': 'function'}} + +" beta language +let s:tlist_def_beta_settings = { + \ 'lang': 'beta', 'tags': { + \ 'f': 'fragment', + \ 's': 'slot', + \ 'v': 'pattern' + \ } + \ } + +" c language +let s:tlist_def_c_settings = { + \ 'lang': 'c', 'tags': { + \ 'd': 'macro', + \ 'g': 'enum', + \ 's': 'struct', + \ 'u': 'union', + \ 't': 'typedef', + \ 'v': 'variable', + \ 'f': 'function' + \ } + \ } + +" c++ language +let s:tlist_def_cpp_settings = { + \ 'lang': 'c++', 'tags': { + \ '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 = { + \ 'lang': 'c#', 'tags': { + \ '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 = { + \ 'lang': 'cobol', 'tags': { + \ 'd': 'data', + \ 'f': 'file', + \ 'g': 'group', + \ 'p': 'paragraph', + \ 'P': 'program', + \ 's': 'section' + \ } + \ } + +" eiffel language +let s:tlist_def_eiffel_settings = { + \ 'lang': 'eiffel', 'tags': { + \ 'c': 'class', + \ 'f': 'feature' + \ } + \ } + +" erlang language +let s:tlist_def_erlang_settings = { + \ 'lang': 'erlang', 'tags': { + \ 'd': 'macro', + \ 'r': 'record', + \ 'm': 'module', + \ 'f': 'function' + \ } + \ } + +" expect (same as tcl) language +let s:tlist_def_expect_settings = { + \ 'lang': 'tcl', 'tags': { + \ 'c': 'class', + \ 'f': 'method', + \ 'p': 'procedure' + \ } + \ } + +" fortran language +let s:tlist_def_fortran_settings = { + \ 'lang': 'fortran', 'tags': { + \ '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 = { + \ 'lang': 'html', 'tags': { + \ 'a': 'anchor', + \ 'f': 'javascript function' + \ } + \ } + +let s:tlist_format_javascript = 'FormatJavascript' +let s:tlist_def_javascript_settings = { + \ 'lang': 'javascript', 'tags': { + \ 'o': 'object', + \ 'm': 'member', + \ 'f': 'function', + \ } + \ } + +" lisp language +let s:tlist_def_lisp_settings = {'lang': 'lisp', 'tags': {'f': 'function'}} + +" lua language +let s:tlist_def_lua_settings = {'lang': 'lua', 'tags': {'f': 'function'}} + +" makefiles +let s:tlist_def_make_settings = {'lang': 'make', 'tags': {'m': 'macro'}} + +" pascal language +let s:tlist_def_pascal_settings = { + \ 'lang': 'pascal', 'tags': { + \ 'f': 'function', + \ 'p': 'procedure' + \ } + \ } + +" perl language +let s:tlist_def_perl_settings = { + \ 'lang': 'perl', 'tags': { + \ 'c': 'constant', + \ 'l': 'label', + \ 'p': 'package', + \ 's': 'subroutine' + \ } + \ } + +" php language +let s:tlist_format_php = 'FormatPhp' +let s:tlist_def_php_settings = { + \ 'lang': 'php', 'tags': { + \ 'c': 'class', + \ 'd': 'constant', + \ 'v': 'variable', + \ 'f': 'function' + \ } + \ } + +" python language +let s:tlist_format_python = 'FormatPython' +let s:tlist_def_python_settings = { + \ 'lang': 'python', 'tags': { + \ 'c': 'class', + \ 'm': 'member', + \ 'f': 'function' + \ } + \ } + +" rexx language +let s:tlist_def_rexx_settings = {'lang': 'rexx', 'tags': {'s': 'subroutine'}} + +" ruby language +let s:tlist_def_ruby_settings = { + \ 'lang': 'ruby', 'tags': { + \ 'c': 'class', + \ 'f': 'method', + \ 'F': 'function', + \ 'm': 'singleton method' + \ } + \ } + +" scheme language +let s:tlist_def_scheme_settings = { + \ 'lang': 'scheme', 'tags': { + \ 's': 'set', + \ 'f': 'function' + \ } + \ } + +" shell language +let s:tlist_def_sh_settings = {'lang': 'sh', 'tags': {'f': 'function'}} + +" C shell language +let s:tlist_def_csh_settings = {'lang': 'sh', 'tags': {'f': 'function'}} + +" Z shell language +let s:tlist_def_zsh_settings = {'lang': 'sh', 'tags': {'f': 'function'}} + +" slang language +let s:tlist_def_slang_settings = { + \ 'lang': 'slang', 'tags': { + \ 'n': 'namespace', + \ 'f': 'function' + \ } + \ } + +" sml language +let s:tlist_def_sml_settings = { + \ 'lang': 'sml', 'tags': { + \ 'e': 'exception', + \ 'c': 'functor', + \ 's': 'signature', + \ 'r': 'structure', + \ 't': 'type', + \ 'v': 'value', + \ 'f': 'function' + \ } + \ } + +" sql language +let s:tlist_def_sql_settings = { + \ 'lang': 'sql', 'tags': { + \ '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 = { + \ 'lang': 'tcl', 'tags': { + \ 'c': 'class', + \ 'f': 'method', + \ 'm': 'method', + \ 'p': 'procedure' + \ } + \ } + +" vera language +let s:tlist_def_vera_settings = { + \ 'lang': 'vera', 'tags': { + \ '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 = { + \ 'lang': 'verilog', 'tags': { + \ '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 = { + \ 'lang': 'vim', 'tags': { + \ 'a': 'autocmds', + \ 'v': 'variable', + \ 'f': 'function' + \ } + \ } + +" yacc language +let s:tlist_def_yacc_settings = {'lang': 'yacc', 'tags': {'l': 'label'}} +" }}} + +" AutoOpen() eclim/autoload/eclim/taglist/taglisttoo.vim {{{ +function! s:AutoOpen() + let open_window = 0 + + let i = 1 + let buf_num = winbufnr(i) + while buf_num != -1 + let filename = fnamemodify(bufname(buf_num), ':p') + if s:FileSupported(filename, getbufvar(buf_num, '&filetype')) + let open_window = 1 + break + endif + let i = i + 1 + let buf_num = winbufnr(i) + endwhile + + if open_window + call s:TaglistToo() + endif +endfunction " }}} + +" Taglist([action]) eclim/autoload/eclim/taglist/taglisttoo.vim {{{ +" action +" - not supplied (or -1): toggle +" - 1: open +" - 0: close +function! s:Taglist(...) + if !exists('g:Tlist_Ctags_Cmd') + call EchoError('Unable to find a version of ctags installed.') + return + endif + + if bufname('%') == g:TagList_title + call s:CloseTaglist() + return + endif + + let action = len(a:000) ? a:000[0] : -1 + + if action == -1 || action == 0 + let winnum = bufwinnr(g:TagList_title) + if winnum != -1 + let prevbuf = bufnr('%') + exe winnum . 'wincmd w' + call s:CloseTaglist() + exec bufwinnr(prevbuf) . 'wincmd w' + return + endif + endif + + if action == -1 || action == 1 + call s:ProcessTags() + call s:StartAutocmds() + + augroup taglisttoo + autocmd! + autocmd BufUnload __Tag_List__ call s:Cleanup() + autocmd CursorHold * call s:ShowCurrentTag() + augroup END + endif +endfunction " }}} + +" Restore() eclim/autoload/eclim/taglist/taglisttoo.vim {{{ +" Restore the taglist, typically after loading from a session file. +function! s:Restore() + if exists('t:taglistoo_restoring') + return + endif + let t:taglistoo_restoring = 1 + + " prevent auto open from firing after session is loaded. + augroup taglisttoo_autoopen + autocmd! + augroup END + + call DelayedCommand( + \ 'let winnum = bufwinnr(g:TagList_title) | ' . + \ 'if winnum != -1 | ' . + \ ' exec "TlistToo" | ' . + \ ' exec "TlistToo" | ' . + \ ' unlet t:taglistoo_restoring | ' . + \ 'endif') +endfunction " }}} + +" s:StartAutocmds() {{{ +function! s:StartAutocmds() + augroup taglisttoo_file + autocmd! + autocmd BufEnter,BufWritePost * + \ if bufwinnr(g:TagList_title) != -1 | + \ call s:ProcessTags() | + \ endif + " bit of a hack to re-process tags if the filetype changes after the tags + " have been processed. + autocmd FileType * + \ if exists('b:ft') | + \ if b:ft != &ft | + \ if bufwinnr(g:TagList_title) != -1 | + \ call s:ProcessTags() | + \ endif | + \ endif | + \ else | + \ let b:ft = &ft | + \ endif + autocmd WinLeave * + \ if bufwinnr(g:TagList_title) != -1 | + \ let s:taglisttoo_prevwinnr = winnr() | + \ endif + augroup END +endfunction " }}} + +" s:StopAutocmds() {{{ +function! s:StopAutocmds() + augroup taglisttoo_file + autocmd! + augroup END +endfunction " }}} + +" s:ProcessTags() {{{ +function! s:ProcessTags() + " on insert completion prevent vim's jumping back and forth from the + " completion preview window from triggering a re-processing of tags + if pumvisible() + return + endif + + let filename = expand('%:p') + if filename =~ s:taglisttoo_ignore || filename == '' + return + endif + let filewin = winnr() + + let tags = [] + if s:FileSupported(expand('%:p'), &ft) + if exists('g:tlist_{&ft}_settings') + let settings = g:tlist_{&ft}_settings + let types = join(keys(settings.tags), '') + else + let settings = s:tlist_def_{&ft}_settings + let types = join(keys(settings.tags), '') + endif + + let file = substitute(expand('%:p'), '\', '/', 'g') + + " support generated file contents (like viewing a .class file via jad) + let tempfile = '' + if !filereadable(file) || &buftype == 'nofile' + let tempfile = g:EclimTempDir . '/' . fnamemodify(file, ':t') + if tolower(file) != tolower(tempfile) + let tempfile = escape(tempfile, ' ') + exec 'write! ' . tempfile + let file = tempfile + endif + endif + + try + let command = g:Tlist_Ctags_Cmd_Ctags + "if eclim#EclimAvailable() && !exists('g:EclimDisabled') + " let port = eclim#client#nailgun#GetNgPort() + " let command = substitute(g:Tlist_Ctags_Cmd_Eclim, '', port, '') + "endif + + let command .= ' -f - --format=2 --excmd=pattern ' . + \ '--fields=nks --sort=no --language-force= ' . + \ '---types= ""' + let command = substitute(command, '', settings.lang, 'g') + let command = substitute(command, '', types, 'g') + let command = substitute(command, '', file, '') + + if (has('win32') || has('win64')) && command =~ '^"' + let command .= ' "' + endif + + let response = System(command) + finally + if tempfile != '' + call delete(tempfile) + endif + endtry + + if v:shell_error + call EchoError('taglist failed with error code: ' . v:shell_error) + return + endif + + let results = split(response, '\n') + if len(response) == 1 && response[0] == '0' + return + endif + + while len(results) && results[0] =~ 'ctags.*: Warning:' + call remove(results, 0) + endwhile + + let truncated = 0 + if len(results) + " for some reason, vim may truncate the output of system, leading to only + " a partial taglist. + let values = s:ParseOutputLine(results[-1]) + if len(values) < 5 + let truncated = 1 + endif + + if g:Tlist_Sort_Type == 'name' + call sort(results) + endif + + for result in results + let values = s:ParseOutputLine(result) + + " filter false positives found in comments. + if values[-1] =~ 'line:[0-9]\+' + exec 'let lnum = ' . substitute(values[-1], 'line:\([0-9]\+\).*', '\1', '') + let line = getline(lnum) + let col = len(line) - len(substitute(line, '^\s*', '', '')) + 1 + if synIDattr(synID(lnum, col, 1), "name") =~ '\([Cc]omment\|[Ss]tring\)' + continue + endif + endif + + " exit if we run into apparent bug in vim that truncates the response + " from system() + if len(values) < 5 + break + endif + + call add(tags, values) + endfor + endif + + if exists('s:tlist_format_{&ft}') + exec 'call s:Window(settings.tags, tags, ' . + \ s:tlist_format_{&ft} . '(settings.tags, tags))' + else + call s:Window(settings.tags, tags, s:FormatDefault(settings.tags, tags)) + endif + + " if vim truncated the output, then add a note in the taglist indicating + " the the list has been truncated. + if truncated + setlocal modifiable + call append(line('$'), '') + call append(line('$'), 'Warning: taglist truncated.') + setlocal nomodifiable + endif + + " if the file buffer is no longer in the same window it was, then find its + " new location. Occurs when taglist first opens. + if winbufnr(filewin) != bufnr(filename) + let filewin = bufwinnr(filename) + endif + + if filewin != -1 + exec filewin . 'winc w' + endif + else + " if the file isn't supported, then don't open the taglist window if it + " isn't open already. + let winnum = bufwinnr(g:TagList_title) + if winnum != -1 + call s:Window({}, tags, [[],[]]) + winc p + endif + endif + + call s:ShowCurrentTag() +endfunction " }}} + +" s:CloseTaglist() {{{ +function! s:CloseTaglist() + close + call s:Cleanup() +endfunction " }}} + +" s:Cleanup() {{{ +function! s:Cleanup() + augroup taglisttoo_file + autocmd! + augroup END + + augroup taglisttoo + autocmd! + augroup END +endfunction " }}} + +" s:ProcessTags() {{{ +function! s:ProcessTags() + " on insert completion prevent vim's jumping back and forth from the + " completion preview window from triggering a re-processing of tags + if pumvisible() + return + endif + + let filename = expand('%:p') + if filename =~ s:taglisttoo_ignore || filename == '' + return + endif + let filewin = winnr() + + let tags = [] + if s:FileSupported(expand('%:p'), &ft) + if exists('g:tlist_{&ft}_settings') + let settings = g:tlist_{&ft}_settings + let types = join(keys(settings.tags), '') + else + let settings = s:tlist_def_{&ft}_settings + let types = join(keys(settings.tags), '') + endif + + let file = substitute(expand('%:p'), '\', '/', 'g') + + " support generated file contents (like viewing a .class file via jad) + let tempfile = '' + if !filereadable(file) || &buftype == 'nofile' + let tempfile = g:EclimTempDir . '/' . fnamemodify(file, ':t') + if tolower(file) != tolower(tempfile) + let tempfile = escape(tempfile, ' ') + exec 'write! ' . tempfile + let file = tempfile + endif + endif + + try + let command = g:Tlist_Ctags_Cmd_Ctags + "if eclim#EclimAvailable() && !exists('g:EclimDisabled') + " let port = eclim#client#nailgun#GetNgPort() + " let command = substitute(g:Tlist_Ctags_Cmd_Eclim, '', port, '') + "endif + + let command .= ' -f - --format=2 --excmd=pattern ' . + \ '--fields=nks --sort=no --language-force= ' . + \ '---types= ""' + let command = substitute(command, '', settings.lang, 'g') + let command = substitute(command, '', types, 'g') + let command = substitute(command, '', file, '') + + if (has('win32') || has('win64')) && command =~ '^"' + let command .= ' "' + endif + + let response = System(command) + finally + if tempfile != '' + call delete(tempfile) + endif + endtry + + if v:shell_error + call EchoError('taglist failed with error code: ' . v:shell_error) + return + endif + + let results = split(response, '\n') + if len(response) == 1 && response[0] == '0' + return + endif + + while len(results) && results[0] =~ 'ctags.*: Warning:' + call remove(results, 0) + endwhile + + let truncated = 0 + if len(results) + " for some reason, vim may truncate the output of system, leading to only + " a partial taglist. + let values = s:ParseOutputLine(results[-1]) + if len(values) < 5 + let truncated = 1 + endif + + if g:Tlist_Sort_Type == 'name' + call sort(results) + endif + + for result in results + let values = s:ParseOutputLine(result) + + " filter false positives found in comments. + if values[-1] =~ 'line:[0-9]\+' + exec 'let lnum = ' . substitute(values[-1], 'line:\([0-9]\+\).*', '\1', '') + let line = getline(lnum) + let col = len(line) - len(substitute(line, '^\s*', '', '')) + 1 + if synIDattr(synID(lnum, col, 1), "name") =~ '\([Cc]omment\|[Ss]tring\)' + continue + endif + endif + + " exit if we run into apparent bug in vim that truncates the response + " from system() + if len(values) < 5 + break + endif + + call add(tags, values) + endfor + endif + + if exists('s:tlist_format_{&ft}') + exec 'call s:Window(settings.tags, tags, ' . + \ s:tlist_format_{&ft} . '(settings.tags, tags))' + else + call s:Window(settings.tags, tags, s:FormatDefault(settings.tags, tags)) + endif + + " if vim truncated the output, then add a note in the taglist indicating + " the the list has been truncated. + if truncated + setlocal modifiable + call append(line('$'), '') + call append(line('$'), 'Warning: taglist truncated.') + setlocal nomodifiable + endif + + " if the file buffer is no longer in the same window it was, then find its + " new location. Occurs when taglist first opens. + if winbufnr(filewin) != bufnr(filename) + let filewin = bufwinnr(filename) + endif + + if filewin != -1 + exec filewin . 'winc w' + endif + else + " if the file isn't supported, then don't open the taglist window if it + " isn't open already. + let winnum = bufwinnr(g:TagList_title) + if winnum != -1 + call s:Window({}, tags, [[],[]]) + winc p + endif + endif + + call s:ShowCurrentTag() +endfunction " }}} + +" s:ParseOutputLine(line) {{{ +function! s:ParseOutputLine(line) + let pre = substitute(a:line, '\(.\{-}\)\t\/\^.*', '\1', '') + let pattern = substitute(a:line, '.\{-}\(\/\^.*\$\/;"\).*', '\1', '') + let post = substitute(a:line, '.*\$\/;"\t', '', '') + return split(pre, '\t') + [pattern] + split(post, '\t') +endfunction " }}} + +" s:FormatDefault(types, tags) {{{ +" All format functions must return a two element list containing: +" result[0] - A list of length len(result[1]) where each value specifies the +" tag index such that result[0][line('.') - 1] == tag index for +" the current line. +" For content lines that do no map to a tag, use -1 as the value. +" result[1] - A list of lines to be inserted as content into the taglist +" window. +function! s:FormatDefault(types, tags) + let lines = [] + let content = [] + + call add(content, expand('%:t')) + call add(lines, -1) + + for key in keys(a:types) + let values = filter(copy(a:tags), 'len(v:val) > 3 && v:val[3] == key') + call s:FormatType(a:tags, a:types[key], values, lines, content, "\t") + endfor + + return [lines, content] +endfunction " }}} + +" s:JumpToTag() {{{ +function! s:JumpToTag() + if line('.') > len(b:taglisttoo_content[0]) + return + endif + + let index = b:taglisttoo_content[0][line('.') - 1] + if index == -1 + return + endif + + let tag_info = b:taglisttoo_tags[index] + + call s:StopAutocmds() + + " handle case of buffer open in multiple windows. + if s:taglisttoo_prevwinnr && + \ winbufnr(s:taglisttoo_prevwinnr) == b:taglisttoo_file_bufnr + exec s:taglisttoo_prevwinnr . 'winc w' + else + exec bufwinnr(b:taglisttoo_file_bufnr) . 'winc w' + endif + + call s:StartAutocmds() + + let lnum = s:GetTagLineNumber(tag_info) + let pattern = s:GetTagPattern(tag_info) + + " account for my plugin which removes trailing spaces from the file + let pattern = escape(pattern, '.~*[]') + let pattern = substitute(pattern, '\s\+\$$', '\s*$', '') + + if getline(lnum) =~ pattern + mark ' + call cursor(lnum, 1) + call s:ShowCurrentTag() + else + let pos = getpos('.') + + call cursor(lnum, 1) + + let up = search(pattern, 'bcnW') + let down = search(pattern, 'cnW') + + " pattern found below recorded line + if !up && down + let line = down + + " pattern found above recorded line + elseif !down && up + let line = up + + " pattern found above and below recorded line + elseif up && down + " use the closest match to the recorded line + if (lnum - up) < (down - lnum) + let line = up + else + let line = down + endif + + " pattern not found. + else + let line = 0 + endif + + call setpos('.', pos) + if line + mark ' + call cursor(line, 1) + call s:ShowCurrentTag() + endif + endif +endfunction " }}} + +" s:Window(types, tags, content) {{{ +function! s:Window(types, tags, content) + let filename = expand('%:t') + let file_bufnr = bufnr('%') + + let winnum = bufwinnr(g:TagList_title) + if winnum != -1 + exe winnum . 'wincmd w' + else + call VerticalToolWindowOpen(g:TagList_title, 10) + + setlocal filetype=taglist + setlocal buftype=nofile + setlocal bufhidden=delete + setlocal noswapfile + setlocal nobuflisted + setlocal nowrap + setlocal tabstop=2 + + syn match TagListFileName "^.*\%1l.*" + hi link TagListFileName Identifier + hi link TagListKeyword Statement + hi TagListCurrentTag term=bold,underline cterm=bold,underline gui=bold,underline + + nnoremap :call JumpToTag() + endif + + let pos = [0, 1, 1, 0] + " if we are updating the taglist for the same file, then preserve the + " cursor position. + if len(a:content[1]) > 0 && getline(1) == a:content[1][0] + let pos = getpos('.') + endif + + setlocal modifiable + silent 1,$delete _ + call append(1, a:content[1]) + silent retab + silent 1,1delete _ + setlocal nomodifiable + + call setpos('.', pos) + + " if the entire taglist can fit in the window, then reposition the content + " just in case the previous contents result in the current contents being + " scrolled up a bit. + if len(a:content[1]) < winheight(winnr()) + normal! zb + endif + + silent! syn clear TagListKeyword + for value in values(a:types) + exec 'syn keyword TagListKeyword ' . value + endfor + syn match TagListKeyword /^Warning:/ + + let b:taglisttoo_content = a:content + let b:taglisttoo_tags = a:tags + let b:taglisttoo_file_bufnr = file_bufnr +endfunction " }}} + +" s:ShowCurrentTag() {{{ +function! s:ShowCurrentTag() + if s:FileSupported(expand('%:p'), &ft) && bufwinnr(g:TagList_title) != -1 + let tags = getbufvar(g:TagList_title, 'taglisttoo_tags') + let content = getbufvar(g:TagList_title, 'taglisttoo_content') + + let clnum = line('.') + let tlnum = 0 + let tindex = -1 + + let index = 0 + for tag in tags + let lnum = s:GetTagLineNumber(tag) + let diff = clnum - lnum + if diff >= 0 && (diff < (clnum - tlnum)) + let tlnum = lnum + let current = tag + let tindex = index + endif + let index += 1 + endfor + + if exists('current') + let cwinnum = winnr() + let twinnum = bufwinnr(g:TagList_title) + + call ExecWithoutAutocmds(twinnum . 'winc w') + + let index = index(content[0], tindex) + 1 + syn clear TagListCurrentTag + exec 'syn match TagListCurrentTag "\S*\%' . index . 'l\S*"' + if index != line('.') + call cursor(index, 0) + call winline() + endif + + call ExecWithoutAutocmds(cwinnum . 'winc w') + endif + endif +endfunction " }}} + +" s:FileSupported(filename, ftype) {{{ +" Check whether tag listing is supported for the specified file +function! s:FileSupported(filename, ftype) + " Skip buffers with no names, buffers with filetype not set, and vimballs + if a:filename == '' || a:ftype == '' || expand('%:e') == 'vba' + return 0 + 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 0 + endif + endif + + " Skip files which are not readable or files which are not yet stored + " to the disk + if !filereadable(a:filename) + return 0 + endif + + return 1 +endfunction " }}} + +" s:GetTagLineNumber(tag) {{{ +function! s:GetTagLineNumber(tag) + if len(a:tag) > 4 + return substitute(a:tag[4], '.*:\(.*\)', '\1', '') + endif + return 0 +endfunction " }}} + + +" FormatJavascript(types, tags) eclim/autoload/eclim/taglist/lang/javascript.vim {{{ +function! FormatJavascript(types, tags) + let pos = getpos('.') + + let lines = [] + let content = [] + + call add(content, expand('%:t')) + call add(lines, -1) + + let object_contents = [] + + let objects = filter(copy(a:tags), 'v:val[3] == "o"') + let members = filter(copy(a:tags), 'v:val[3] == "m"') + let functions = filter(copy(a:tags), + \ 'v:val[3] == "f" && v:val[2] =~ "\\"') + let object_bounds = {} + for object in objects + exec 'let object_start = ' . split(object[4], ':')[1] + call cursor(object_start, 1) + while search('{', 'W') && s:SkipComments() + " no op + endwhile + let object_end = searchpair('{', '', '}', 'W', 's:SkipComments()') + + let methods = [] + for fct in members + if len(fct) > 3 + exec 'let fct_line = ' . split(fct[4], ':')[1] + if fct_line > object_start && fct_line < object_end + call add(methods, fct) + endif + endif + endfor + + let indexes = [] + let index = 0 + for fct in functions + if len(fct) > 3 + exec 'let fct_line = ' . split(fct[4], ':')[1] + if fct_line > object_start && fct_line < object_end + call add(methods, fct) + call add(indexes, index) + elseif fct_line == object_start + call add(indexes, index) + endif + endif + let index += 1 + endfor + call reverse(indexes) + for i in indexes + call remove(functions, i) + endfor + + if len(methods) > 0 + let parent_object = s:GetParentObject( + \ object_contents, object_bounds, object_start, object_end) + " remove methods from the parent if necessary + if len(parent_object) + call filter(parent_object.methods, 'index(methods, v:val) == -1') + endif + let object_bounds[string(object)] = [object_start, object_end] + call sort(methods) + call add(object_contents, {'object': object, 'methods': methods}) + endif + endfor + + if len(functions) > 0 + call add(content, "") + call add(lines, -1) + call s:FormatType( + \ a:tags, a:types['f'], functions, lines, content, "\t") + endif + + for object_content in object_contents + call add(content, "") + call add(lines, -1) + call add(content, "\t" . a:types['o'] . ' ' . object_content.object[0]) + call add(lines, index(a:tags, object_content.object)) + + call s:FormatType( + \ a:tags, a:types['f'], object_content.methods, lines, content, "\t\t") + endfor + + call setpos('.', pos) + + return [lines, content] +endfunction " }}} + +" s:SkipComments() eclim/autoload/eclim/taglist/lang/javascript.vim {{{ +function! s:SkipComments() + let synname = synIDattr(synID(line('.'), col('.'), 1), "name") + return synname =~ '\([Cc]omment\|[Ss]tring\)' +endfunction " }}} + +" s:GetParentObject(objects, bounds, start, end) eclim/autoload/eclim/taglist/lang/javascript.vim {{{ +function! s:GetParentObject(objects, bounds, start, end) + for key in keys(a:bounds) + let range = a:bounds[key] + if range[0] < a:start && range[1] > a:end + for object_content in a:objects + if string(object_content.object) == key + return object_content + endif + endfor + break + endif + endfor + return {} +endfunction " }}} + +" FormatType(tags, type, values, lines, content, indent) eclim/autoload/eclim/taglist/util.vim {{{ +" tags: The list of tag results from eclim/ctags. +" type: The display name of the tag type we are formatting. +" values: List of tag results for the type. +" lines: The list representing the mapping of content entries to tag info. +" content: The list representing the display that we will add to. +" indent: The indentation to use on the display (string). +function! s:FormatType(tags, type, values, lines, content, indent) + if len(a:values) > 0 + call add(a:content, a:indent . a:type) + call add(a:lines, -1) + + for value in a:values + let visibility = s:GetVisibility(value) + call add(a:content, "\t" . a:indent . visibility . value[0]) + call add(a:lines, index(a:tags, value)) + endfor + endif +endfunction " }}} + +" GetTagPattern(tag) eclim/autoload/eclim/taglist/util.vim {{{ +function! s:GetTagPattern(tag) + return strpart(a:tag[2], 1, len(a:tag[2]) - 4) +endfunction " }}} + +" GetVisibility(tag) eclim/autoload/eclim/taglist/util.vim {{{ +" Gets the visibility string for the supplied tag. +function! s:GetVisibility(tag) + let pattern = s:GetTagPattern(a:tag) + if pattern =~ '\' + if pattern =~ '\' + return '*' + endif + return '+' + elseif pattern =~ '\' + return '#' + elseif pattern =~ '\' + return '-' + endif + return '' +endfunction " }}} + +" FormatPhp(types, tags) eclim/autoload/eclim/taglist/lang/php.vim {{{ +function! FormatPhp(types, tags) + let pos = getpos('.') + + let lines = [] + let content = [] + + call add(content, expand('%:t')) + call add(lines, -1) + + let top_functions = filter(copy(a:tags), 'v:val[3] == "f"') + + let class_contents = [] + let classes = filter(copy(a:tags), 'v:val[3] == "c"') + for class in classes + exec 'let object_start = ' . split(class[4], ':')[1] + call cursor(object_start, 1) + call search('{', 'W') + let object_end = searchpair('{', '', '}', 'W') + + let functions = [] + let indexes = [] + let index = 0 + for fct in top_functions + if len(fct) > 3 + exec 'let fct_line = ' . split(fct[4], ':')[1] + if fct_line > object_start && fct_line < object_end + call add(functions, fct) + call add(indexes, index) + endif + endif + let index += 1 + endfor + call reverse(indexes) + for i in indexes + call remove(top_functions, i) + endfor + + call add(class_contents, {'class': class, 'functions': functions}) + endfor + + let interface_contents = [] + let interfaces = filter(copy(a:tags), 'v:val[3] == "i"') + for interface in interfaces + exec 'let object_start = ' . split(interface[4], ':')[1] + call cursor(object_start, 1) + call search('{', 'W') + let object_end = searchpair('{', '', '}', 'W') + + let functions = [] + let indexes = [] + let index = 0 + for fct in top_functions + if len(fct) > 3 + exec 'let fct_line = ' . split(fct[4], ':')[1] + if fct_line > object_start && fct_line < object_end + call add(functions, fct) + call add(indexes, index) + endif + endif + let index += 1 + endfor + call reverse(indexes) + for i in indexes + call remove(top_functions, i) + endfor + + call add(interface_contents, {'interface': interface, 'functions': functions}) + endfor + + if len(top_functions) > 0 + call add(content, "") + call add(lines, -1) + call s:FormatType( + \ a:tags, a:types['f'], top_functions, lines, content, "\t") + endif + + for class_content in class_contents + call add(content, "") + call add(lines, -1) + call add(content, "\t" . a:types['c'] . ' ' . class_content.class[0]) + call add(lines, index(a:tags, class_content.class)) + + call s:FormatType( + \ a:tags, a:types['f'], class_content.functions, lines, content, "\t\t") + endfor + + for interface_content in interface_contents + call add(content, "") + call add(lines, -1) + call add(content, "\t" . a:types['i'] . ' ' . interface_content.interface[0]) + call add(lines, index(a:tags, interface_content.interface)) + + call s:FormatType( + \ a:tags, a:types['f'], interface_content.functions, lines, content, "\t\t") + endfor + + call setpos('.', pos) + + return [lines, content] +endfunction " }}} + +" FormatPython(types, tags) eclim/autoload/eclim/taglist/lang/python.vim {{{ +function! FormatPython(types, tags) + let lines = [] + let content = [] + + call add(content, expand('%:t')) + call add(lines, -1) + + let functions = filter(copy(a:tags), 'len(v:val) > 3 && v:val[3] == "f"') + call s:FormatType( + \ a:tags, a:types['f'], functions, lines, content, "\t") + + let classes = filter(copy(a:tags), 'len(v:val) > 3 && v:val[3] == "c"') + for class in classes + call add(content, "") + call add(lines, -1) + call add(content, "\t" . a:types['c'] . ' ' . class[0]) + call add(lines, index(a:tags, class)) + + let members = filter(copy(a:tags), + \ 'len(v:val) > 5 && v:val[3] == "m" && v:val[5] == "class:" . class[0]') + for member in members + call add(content, "\t\t" . member[0]) + call add(lines, index(a:tags, member)) + endfor + endfor + + return [lines, content] +endfunction " }}} + + +" GlobalVariables eclim/autoload/eclim/display/window.vim {{{ +let g:VerticalToolBuffers = {} + +if !exists('g:VerticalToolWindowSide') + let g:VerticalToolWindowSide = 'left' +endif + +if g:VerticalToolWindowSide == 'right' + let g:VerticalToolWindowPosition = 'botright vertical' +else + let g:VerticalToolWindowPosition = 'topleft vertical' +endif + +if !exists('g:VerticalToolWindowWidth') + let g:VerticalToolWindowWidth = 40 +endif +" }}} + +" VerticalToolWindowOpen(name, weight) eclim/autoload/eclim/display/window.vim {{{ +" Handles opening windows in the vertical tool window on the left (taglist, +" project tree, etc.) +function! VerticalToolWindowOpen(name, weight) + let taglist_window = exists('g:TagList_title') ? bufwinnr(g:TagList_title) : -1 + if exists('g:Tlist_Use_Horiz_Window') && g:Tlist_Use_Horiz_Window + let taglist_window = -1 + endif + + let relative_window = 0 + let relative_window_loc = 'below' + if taglist_window != -1 || len(g:VerticalToolBuffers) > 0 + if taglist_window != -1 + let relative_window = taglist_window + endif + for toolbuf in keys(g:VerticalToolBuffers) + exec 'let toolbuf = ' . toolbuf + if bufwinnr(toolbuf) != -1 + if relative_window == 0 + let relative_window = bufwinnr(toolbuf) + if getbufvar(toolbuf, 'weight') > a:weight + let relative_window_loc = 'below' + else + let relative_window_loc = 'above' + endif + elseif getbufvar(toolbuf, 'weight') > a:weight + let relative_window = bufwinnr(toolbuf) + let relative_window_loc = 'below' + endif + endif + endfor + endif + + if relative_window != 0 + let wincmd = relative_window . 'winc w | ' . relative_window_loc . ' ' + else + let wincmd = g:VerticalToolWindowPosition . ' ' . g:VerticalToolWindowWidth + endif + + let escaped = substitute( + \ a:name, '\(.\{-}\)\[\(.\{-}\)\]\(.\{-}\)', '\1[[]\2[]]\3', 'g') + let bufnum = bufnr(escaped) + let name = bufnum == -1 ? a:name : '+buffer' . bufnum + silent call ExecWithoutAutocmds(wincmd . ' split ' . name) + + setlocal winfixwidth + setlocal nonumber + + let b:weight = a:weight + let bufnum = bufnr('%') + let g:VerticalToolBuffers[bufnum] = a:name + augroup eclim_vertical_tool_windows + autocmd! + autocmd BufDelete * call s:PreventCloseOnBufferDelete() + autocmd BufEnter * nested call s:CloseIfLastWindow() + augroup END + if exists('g:TagList_title') && + \ !exists('g:TagListToo') && + \ (!exists('g:Tlist_Use_Horiz_Window') || !g:Tlist_Use_Horiz_Window) + augroup eclim_vertical_tool_windows_move + autocmd! + augroup END + exec 'autocmd BufWinEnter ' . g:TagList_title . + \ ' call s:MoveRelativeTo(g:TagList_title)' + endif + augroup eclim_vertical_tool_windows_buffer + exec 'autocmd BufWinLeave ' . + \ 'silent! call remove(g:VerticalToolBuffers, ' . bufnum . ') | ' . + \ 'autocmd! eclim_vertical_tool_windows_buffer * ' + augroup END +endfunction " }}} + +" GetWindowOptions(winnum) eclim/autoload/eclim/display/window.vim {{{ +" Gets a dictionary containing all the localy set options for the specified +" window. +function! GetWindowOptions(winnum) + let curwin = winnr() + try + exec a:winnum . 'winc w' + redir => list + silent exec 'setlocal' + redir END + finally + exec curwin . 'winc w' + endtry + + let list = substitute(list, '---.\{-}---', '', '') + let winopts = {} + for wopt in split(list, '\_s\+')[1:] + if wopt =~ '^[a-z]' + if wopt =~ '=' + let key = substitute(wopt, '\(.\{-}\)=.*', '\1', '') + let value = substitute(wopt, '.\{-}=\(.*\)', '\1', '') + let winopts[key] = value + else + let winopts[wopt] = '' + endif + endif + endfor + return winopts +endfunction " }}} + +" SetWindowOptions(winnum, options) eclim/autoload/eclim/display/window.vim {{{ +" Given a dictionary of options, sets each as local options for the specified +" window. +function! SetWindowOptions(winnum, options) + let curwin = winnr() + try + exec a:winnum . 'winc w' + for key in keys(a:options) + if key =~ '^no' + silent! exec 'setlocal ' . key + else + silent! exec 'setlocal ' . key . '=' . a:options[key] + endif + endfor + finally + exec curwin . 'winc w' + endtry +endfunction " }}} + +" s:CloseIfLastWindow() eclim/autoload/eclim/display/window.vim {{{ +function! s:CloseIfLastWindow() + if histget(':', -1) !~ '^bd' + let numtoolwindows = 0 + for toolbuf in keys(g:VerticalToolBuffers) + exec 'let toolbuf = ' . toolbuf + if bufwinnr(toolbuf) != -1 + let numtoolwindows += 1 + endif + endfor + if winnr('$') == numtoolwindows + if tabpagenr('$') > 1 + tabclose + else + quitall + endif + endif + endif +endfunction " }}} + +" s:MoveRelativeTo(name) eclim/autoload/eclim/display/window.vim {{{ +function! s:MoveRelativeTo(name) + for toolbuf in keys(g:VerticalToolBuffers) + exec 'let toolbuf = ' . toolbuf + if bufwinnr(toolbuf) != -1 + call setwinvar(bufwinnr(toolbuf), 'marked_for_removal', 1) + let winoptions = GetWindowOptions(bufwinnr(toolbuf)) + call remove(winoptions, 'filetype') + call remove(winoptions, 'syntax') + call VerticalToolWindowOpen( + \ g:VerticalToolBuffers[toolbuf], getbufvar(toolbuf, 'weight')) + call SetWindowOptions(winnr(), winoptions) + endif + endfor + + let winnum = 1 + while winnum <= winnr('$') + if getwinvar(winnum, 'marked_for_removal') == 1 + exec winnum . 'winc w' + close + else + let winnum += 1 + endif + endwhile + call VerticalToolWindowRestore() +endfunction " }}} + +" s:PreventCloseOnBufferDelete() eclim/autoload/eclim/display/window.vim {{{ +function! s:PreventCloseOnBufferDelete() + let numtoolwindows = 0 + for toolbuf in keys(g:VerticalToolBuffers) + exec 'let toolbuf = ' . toolbuf + if bufwinnr(toolbuf) != -1 + let numtoolwindows += 1 + endif + endfor + + if winnr('$') == numtoolwindows + let toolbuf = bufnr('%') + if g:VerticalToolWindowSide == 'right' + vertical topleft new + else + vertical botright new + endif + let winnum = winnr() + exec 'let bufnr = ' . expand('') + + redir => list + silent exec 'buffers' + redir END + + " build list of buffers open in other tabs to exclude + let tabbuffers = [] + let lasttab = tabpagenr('$') + let index = 1 + while index <= lasttab + if index != tabpagenr() + for bnum in tabpagebuflist(index) + call add(tabbuffers, bnum) + endfor + endif + let index += 1 + endwhile + + " build list of buffers not open in any window + let buffers = [] + for entry in split(list, '\n') + exec 'let bnum = ' . substitute(entry, '\s*\([0-9]\+\).*', '\1', '') + if bnum != bufnr && index(tabbuffers, bnum) == -1 && bufwinnr(bnum) == -1 + if bnum < bufnr + call insert(buffers, bnum) + else + call add(buffers, bnum) + endif + endif + endfor + + " we found a hidden buffer, so open it + if len(buffers) > 0 + exec 'buffer ' . buffers[0] + doautocmd BufEnter + doautocmd BufWinEnter + doautocmd BufReadPost + endif + + exec bufwinnr(toolbuf) . 'winc w' + exec 'vertical resize ' . g:VerticalToolWindowWidth + exec winnum . 'winc w' + endif +endfunction " }}} + + +" End TagListToo: }}} + + +" vim:ft=vim:fdm=marker diff --git a/syntax/mkd.vim b/syntax/mkd.vim deleted file mode 100644 index ee22365..0000000 --- a/syntax/mkd.vim +++ /dev/null @@ -1,104 +0,0 @@ -" Vim syntax file -" Language: Markdown -" Maintainer: Ben Williams -" URL: http://plasticboy.com/markdown-vim-mode/ -" Version: 9 -" Last Change: 2009 May 18 -" Remark: Uses HTML syntax file -" Remark: I don't do anything with angle brackets (<>) because that would too easily -" easily conflict with HTML syntax -" TODO: Handle stuff contained within stuff (e.g. headings within blockquotes) - - -" Read the HTML syntax to start with -if version < 600 - so :p:h/html.vim -else - runtime! syntax/html.vim - unlet b:current_syntax -endif - -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" don't use standard HiLink, it will not work with included syntax files -if version < 508 - command! -nargs=+ HtmlHiLink hi link -else - command! -nargs=+ HtmlHiLink hi def link -endif - -syn spell toplevel -syn case ignore -syn sync linebreaks=1 - -"additions to HTML groups -syn region htmlBold start=/\\\@) -syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite -syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline -syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained -syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained -syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained - -"define Markdown groups -syn match mkdLineContinue ".$" contained -syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/ -syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/ -syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/ -syn match mkdRule /^\s*-\{3,}$/ -syn match mkdRule /^\s*\*\{3,5}$/ -syn match mkdListItem "^\s*[-*+]\s\+" -syn match mkdListItem "^\s*\d\+\.\s\+" -syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ -syn match mkdLineBreak / \+$/ -syn region mkdCode start=/\\\@/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell -syn region mkdCode start="]*>" end="" -syn region mkdCode start="]*>" end="" - -"HTML headings -syn region htmlH1 start="^\s*#" end="\($\|#\+\)" contains=@Spell -syn region htmlH2 start="^\s*##" end="\($\|#\+\)" contains=@Spell -syn region htmlH3 start="^\s*###" end="\($\|#\+\)" contains=@Spell -syn region htmlH4 start="^\s*####" end="\($\|#\+\)" contains=@Spell -syn region htmlH5 start="^\s*#####" end="\($\|#\+\)" contains=@Spell -syn region htmlH6 start="^\s*######" end="\($\|#\+\)" contains=@Spell -syn match htmlH1 /^.\+\n=\+$/ contains=@Spell -syn match htmlH2 /^.\+\n-\+$/ contains=@Spell - -"highlighting for Markdown groups -HtmlHiLink mkdString String -HtmlHiLink mkdCode String -HtmlHiLink mkdBlockquote Comment -HtmlHiLink mkdLineContinue Comment -HtmlHiLink mkdListItem Identifier -HtmlHiLink mkdRule Identifier -HtmlHiLink mkdLineBreak Todo -HtmlHiLink mkdLink htmlLink -HtmlHiLink mkdURL htmlString -HtmlHiLink mkdID Identifier -HtmlHiLink mkdLinkDef mkdID -HtmlHiLink mkdLinkDefTarget mkdURL -HtmlHiLink mkdLinkTitle htmlString - -HtmlHiLink mkdDelimiter Delimiter - -let b:current_syntax = "mkd" - -delcommand HtmlHiLink -" vim: ts=8