Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: 0fa7a11745
...
compare: e1f12ec338
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 155 files changed
  • 0 commit comments
  • 1 contributor
Showing with 484 additions and 21,938 deletions.
  1. +9 −7 .vimrc
  2. +0 −112 autoload/erlangcomplete.vim
  3. +381 −248 autoload/tagbar.vim
  4. +0 −55 autoload/togglebg.vim
  5. +0 −1  backup/create_me
  6. BIN  bitmaps/togglebg.png
  7. +0 −72 colors/adaryn.vim
  8. +0 −97 colors/adrian.vim
  9. +0 −37 colors/aiseered.vim
  10. +0 −108 colors/anotherdark.vim
  11. +0 −44 colors/aqua.vim
  12. +0 −164 colors/astronaut.vim
  13. +0 −59 colors/asu1dark.vim
  14. +0 −69 colors/autumn.vim
  15. +0 −88 colors/autumn2.vim
  16. +0 −154 colors/autumnleaf.vim
  17. +0 −319 colors/baycomb.vim
  18. +0 −67 colors/bclear.vim
  19. +0 −115 colors/biogoo.vim
  20. +0 −37 colors/blacksea.vim
  21. +0 −50 colors/bluegreen.vim
  22. +0 −60 colors/borland.vim
  23. +0 −70 colors/breeze.vim
  24. +0 −83 colors/brookstream.vim
  25. +0 −59 colors/buttercream.vim
  26. +0 −247 colors/calmar256-dark.vim
  27. +0 −247 colors/calmar256-light.vim
  28. +0 −76 colors/camo.vim
  29. +0 −78 colors/candy.vim
  30. +0 −174 colors/candycode.vim
  31. +0 −110 colors/chela_light.vim
  32. +0 −36 colors/chocolateliquor.vim
  33. +0 −52 colors/clarity.vim
  34. +0 −81 colors/cleanphp.vim
  35. +0 −79 colors/colorer.vim
  36. +0 −83 colors/dante.vim
  37. +0 −91 colors/darkZ.vim
  38. +0 −105 colors/darkblue2.vim
  39. +0 −102 colors/darkbone.vim
  40. +0 −117 colors/darkslategray.vim
  41. +0 −130 colors/darkspectrum.vim
  42. +0 −78 colors/dawn.vim
  43. +0 −141 colors/denim.vim
  44. +0 −338 colors/desert256.vim
  45. +0 −98 colors/desertEx.vim
  46. +0 −71 colors/dusk.vim
  47. +0 −66 colors/dw_blue.vim
  48. +0 −66 colors/dw_cyan.vim
  49. +0 −66 colors/dw_green.vim
  50. +0 −66 colors/dw_orange.vim
  51. +0 −66 colors/dw_purple.vim
  52. +0 −66 colors/dw_red.vim
  53. +0 −66 colors/dw_yellow.vim
  54. +0 −159 colors/earendel.vim
  55. +0 −92 colors/eclipse.vim
  56. +0 −105 colors/ekvoli.vim
  57. +0 −71 colors/fine_blue.vim
  58. +0 −71 colors/fine_blue2.vim
  59. +0 −67 colors/fnaqevan.vim
  60. +0 −170 colors/fog.vim
  61. +0 −79 colors/freya.vim
  62. +0 −69 colors/fruit.vim
  63. +0 −147 colors/fruity.vim
  64. +0 −70 colors/golden.vim
  65. +0 −103 colors/guardian.vim
  66. +0 −138 colors/habilight.vim
  67. +0 −385 colors/herald.vim
  68. +0 −66 colors/impact.vim
  69. +0 −133 colors/ironman.vim
  70. +0 −111 colors/jammy.vim
  71. +0 −410 colors/jellybeans.vim
  72. +0 −236 colors/kellys.vim
  73. +0 −150 colors/leo.vim
  74. +0 −215 colors/lettuce.vim
  75. +0 −346 colors/lucius.vim
  76. +0 −47 colors/manxome.vim
  77. +0 −174 colors/marklar.vim
  78. +0 −594 colors/maroloccio.vim
  79. +0 −397 colors/martin_krischik.vim
  80. +0 −80 colors/matrix.vim
  81. +0 −136 colors/metacosm.vim
  82. +0 −211 colors/molokai.vim
  83. +0 −247 colors/moria.vim
  84. +0 −109 colors/moss.vim
  85. +0 −66 colors/motus.vim
  86. +0 −57 colors/mustang.vim
  87. +0 −119 colors/navajo-night.vim
  88. +0 −65 colors/navajo.vim
  89. +0 −70 colors/neon.vim
  90. +0 −141 colors/neverness.vim
  91. +0 −70 colors/night.vim
  92. +0 −111 colors/nightshimmer.vim
  93. +0 −134 colors/no_quarter.vim
  94. +0 −149 colors/northland.vim
  95. +0 −107 colors/nuvola.vim
  96. +0 −115 colors/oceanblack.vim
  97. +0 −140 colors/oceandeep.vim
  98. +0 −105 colors/oceanlight.vim
  99. +0 −119 colors/olive.vim
  100. +0 −31 colors/papayawhip.vim
  101. +0 −597 colors/peaksea.vim
  102. +0 −65 colors/print_bw.vim
  103. +0 −92 colors/pyte.vim
  104. +0 −124 colors/railscasts.vim
  105. +0 −124 colors/railscasts2.vim
  106. +0 −159 colors/rdark.vim
  107. +0 −112 colors/relaxedgreen.vim
  108. +0 −103 colors/robinhood.vim
  109. +0 −98 colors/rootwater.vim
  110. +0 −47 colors/satori.vim
  111. +0 −69 colors/sea.vim
  112. +0 −53 colors/settlemyer.vim
  113. +0 −150 colors/sienna.vim
  114. +0 −116 colors/silent.vim
  115. +0 −65 colors/simpleandfriendly.vim
  116. +0 −45 colors/softblue.vim
  117. +0 −1,117 colors/solarized.vim
  118. +0 −67 colors/soso.vim
  119. +0 −71 colors/spring.vim
  120. +0 −322 colors/summerfruit256.vim
  121. +0 −81 colors/synic.vim
  122. +0 −698 colors/tabula.vim
  123. +0 −78 colors/tango.vim
  124. +0 −62 colors/tango2.vim
  125. +0 −84 colors/taqua.vim
  126. +0 −83 colors/tcsoft.vim
  127. +0 −130 colors/tir_black.vim
  128. +0 −43 colors/tolerable.vim
  129. +0 −51 colors/torte.vim
  130. +0 −114 colors/twilight.vim
  131. +0 −101 colors/two2tango.vim
  132. +0 −24 colors/vc.vim
  133. +0 −68 colors/vibrantink.vim
  134. +0 −172 colors/vividchalk.vim
  135. +0 −81 colors/vylight.vim
  136. +0 −87 colors/winter.vim
  137. +0 −51 colors/wombat.vim
  138. +0 −302 colors/wombat256.vim
  139. +0 −39 colors/wood.vim
  140. +0 −82 colors/wuye.vim
  141. +0 −46 colors/xemacs.vim
  142. +0 −94 colors/xoria256.vim
  143. +0 −351 colors/zenburn.vim
  144. +0 −59 colors/zmrok.vim
  145. +0 −48 compiler/erlang.vim
  146. +2 −2 doc/l9.txt
  147. +0 −254 doc/solarized.txt
  148. +89 −41 doc/tagbar.txt
  149. +0 −199 ftplugin/erlang.vim
  150. +0 −148 indent/erlang.vim
  151. +0 −2,041 plugin/fugitive.vim
  152. +2 −5 plugin/tagbar.vim
  153. +0 −463 syntax/erlang.vim
  154. +1 −1  syntax/tagbar.vim
  155. +0 −1  temp/create_me
View
16 .vimrc
@@ -7,10 +7,10 @@
" http://robertmelton.com (many forms of communication)
" }}}
" Startup {{{
-let s:running_windows = has("win16") || has("win32") || has("win64")
-let s:colorful_term = (&term =~ "xterm") || (&term =~ "screen")
-let g:erlangHighlightBif = 1
-let g:erlangHighLightOperators = 1
+ let s:running_windows = has("win16") || has("win32") || has("win64")
+ let s:colorful_term = (&term =~ "xterm") || (&term =~ "screen")
+ let g:erlangHighlightBif = 1
+ let g:erlangHighLightOperators = 1
" }}}
" Basics {{{
set nocompatible " explicitly get out of vi-compatible mode
@@ -31,6 +31,8 @@ let g:erlangHighLightOperators = 1
let g:skip_loading_mswin=1 " Just in case :)
" }}}
" Newish {{{
+ set history=9999 " big old history
+ set timeoutlen=200 " super low delay
set formatoptions+=n " Recognize numbered lists
set formatlistpat=^\\s*\\(\\d\\\|[-*]\\)\\+[\\]:.)}\\t\ ]\\s* "and bullets, too
set viminfo+=! " Store upper-case registers in viminfo
@@ -235,7 +237,7 @@ if s:colorful_term
endif
" }}}
" Odds n Ends {{{
-hi Folded ctermbg=black guibg=black
-match ErrorMsg '\%>80v.\+'
-set ttymouse=xterm2 " makes it work in
+ hi Folded ctermbg=black guibg=black
+ set ttymouse=xterm2 " makes it work in everything
+ " match ErrorMsg '\%>150v.\+'
" }}}
View
112 autoload/erlangcomplete.vim
@@ -1,112 +0,0 @@
-" ------------------------------------------------------------------------------
-" Vim omni-completion script
-" Author: Oscar Hellström
-" Email: oscar@oscarh.net
-" Version: 2006-06-23
-" ------------------------------------------------------------------------------
-
-" Patterns for completions {{{1
-let s:erlangLocalFuncBeg = '\(\<[0-9A-Za-z_-]*\|\s*\)$'
-let s:erlangExternalFuncBeg = '\<[0-9A-Za-z_-]\+:[0-9A-Za-z_-]*$'
-let s:ErlangBlankLine = '^\s*\(%.*\)\?$'
-
-" Main function for completion {{{1
-function! erlangcomplete#Complete(findstart, base)
- " 0) Init {{{2
- let lnum = line('.')
- let column = col('.')
- let line = strpart(getline('.'), 0, column - 1)
-
- " 1) First, check if completion is impossible {{{2
- if line =~ '[^~\\]%'
- return -1
- endif
-
- "echo "line[col - 1]:" . line[column - 1] . " line[col - 2]:" . line[column - 2] . "\n" . line . "\n"
-
- " 2) Check if the char to the left of us are part of a function call {{{2
- "
- " Nothing interesting is written at the char just before the cursor
- " This means _anything_ could be started here
- " In this case, keyword completion should probably be used,
- " for now we'll only try and complete local functions.
- " TODO: Examine if we can stare Identifiers end complete on them
- " Is this worth it? Is /completion/ of a "blank" wanted? Can we consider (
- " interesting and check if we are in a function call etc.?
- if line[column - 2] !~ '[0-9A-Za-z:_-]'
- if a:findstart
- return column
- else
- return s:erlangFindLocalFunc(a:base)
- endif
- endif
-
-
- " 3) Function in external module {{{2
- if line =~ s:erlangExternalFuncBeg
- let delimiter = match(line, ':[0-9A-Za-z_-]*$') + 1
- if a:findstart
- return delimiter
- else
- let module = matchstr(line, '\(\<\)\@<=[0-9A-Za-z_-]\+:\@=')
- return s:erlangFindExternalFunc(module, a:base)
- endif
- endif
-
- " 4) Local function {{{2
- if line =~ s:erlangLocalFuncBeg
- let funcstart = match(line, ':\@<![0-9A-Za-z_-]*$')
- if a:findstart
- return funcstart
- else
- return s:erlangFindLocalFunc(a:base)
- endif
- endif
-
- " 5) Unhandled situation {{{2
- if a:findstart
- return -1
- else
- return []
- endif
-endfunction
-
-" Auxiliary functions for completion {{{1
-" Find the next non-blank line {{{2
-function s:erlangFindNextNonBlank(lnum)
- let lnum = nextnonblank(a:lnum + 1)
- let line = getline(lnum)
- while line =~ s:ErlangBlankLine && 0 != lnum
- let lnum = nextnonblank(lnum + 1)
- let line = getline(lnum)
- endwhile
- return lnum
-endfunction
-
-" vim: foldmethod=marker:
-" Find external function names {{{2
-function s:erlangFindExternalFunc(module, base)
- let functions = []
- return functions
-endfunction
-
-" Find local function names {{{2
-function s:erlangFindLocalFunc(base)
- " begin at line 1
- let lnum = s:erlangFindNextNonBlank(1)
- if "" == a:base
- let base = '\w' " used to match against word symbol
- else
- let base = a:base
- endif
- while 0 != lnum && !complete_check()
- let line = getline(lnum)
- let function_name = matchstr(line, '^' . base . '[0-9A-Za-z_-]\+(\@=')
- if function_name != ""
- call complete_add(function_name)
- endif
- let lnum = s:erlangFindNextNonBlank(lnum)
- endwhile
- return []
-endfunction
-
View
629 autoload/tagbar.vim
@@ -4,7 +4,7 @@
" Author: Jan Larres <jan@majutsushi.net>
" Licence: Vim licence
" Website: http://majutsushi.github.com/tagbar/
-" Version: 2.3
+" Version: 2.4.1
" Note: This plugin was heavily inspired by the 'Taglist' plugin by
" Yegappan Lakshmanan and uses a small amount of code from it.
"
@@ -22,46 +22,14 @@ scriptencoding utf-8
" Initialization {{{1
-" Basic init {{{2
-
-if !exists('g:tagbar_ctags_bin')
- let ctagsbins = []
- let ctagsbins += ['ctags-exuberant'] " Debian
- let ctagsbins += ['exuberant-ctags']
- let ctagsbins += ['exctags'] " FreeBSD, NetBSD
- let ctagsbins += ['/usr/local/bin/ctags'] " Homebrew
- let ctagsbins += ['/opt/local/bin/ctags'] " Macports
- let ctagsbins += ['ectags'] " OpenBSD
- let ctagsbins += ['ctags']
- let ctagsbins += ['ctags.exe']
- let ctagsbins += ['tags']
- for ctags in ctagsbins
- if executable(ctags)
- let g:tagbar_ctags_bin = ctags
- break
- endif
- endfor
- if !exists('g:tagbar_ctags_bin')
- echomsg 'Tagbar: Exuberant ctags not found, skipping plugin'
- finish
- endif
-else
- " reset 'wildignore' temporarily in case *.exe is included in it
- let wildignore_save = &wildignore
- set wildignore&
-
- let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin)
-
- let &wildignore = wildignore_save
-
- if !executable(g:tagbar_ctags_bin)
- echomsg "Tagbar: Exuberant ctags not found at " .
- \ "'" . g:tagbar_ctags_bin . "', " .
- \ "skipping plugin"
- finish
- endif
+" If another plugin calls an autoloaded Tagbar function on startup before the
+" plugin/tagbar.vim file got loaded, load it explicitly
+if exists(':Tagbar') == 0
+ runtime plugin/tagbar.vim
endif
+" Basic init {{{2
+
redir => s:ftype_out
silent filetype
redir END
@@ -77,6 +45,7 @@ let s:icon_open = g:tagbar_iconchars[1]
let s:type_init_done = 0
let s:autocommands_done = 0
+" 0: not checked yet; 1: checked and found; 2: checked and not found
let s:checked_ctags = 0
let s:checked_ctags_types = 0
let s:ctags_types = {}
@@ -96,9 +65,11 @@ let s:debug = 0
let s:debug_file = ''
" s:Init() {{{2
-function! s:Init()
- if !s:checked_ctags
- if !s:CheckForExCtags()
+function! s:Init(silent) abort
+ if s:checked_ctags == 2 && a:silent
+ return 0
+ elseif s:checked_ctags != 1
+ if !s:CheckForExCtags(a:silent)
return 0
endif
endif
@@ -113,13 +84,14 @@ function! s:Init()
if !s:autocommands_done
call s:CreateAutocommands()
+ doautocmd CursorHold
endif
return 1
endfunction
" s:InitTypes() {{{2
-function! s:InitTypes()
+function! s:InitTypes() abort
call s:LogDebugMessage('Initializing types')
let s:known_types = {}
@@ -333,9 +305,9 @@ function! s:InitTypes()
" guesses and probably requires
" http://www.vim.org/scripts/script.php?script_id=2909
" Improvements welcome!
- let type_mxml = s:TypeInfo.New()
- let type_mxml.ctagstype = 'flex'
- let type_mxml.kinds = [
+ let type_as = s:TypeInfo.New()
+ let type_as.ctagstype = 'flex'
+ let type_as.kinds = [
\ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0},
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
@@ -343,14 +315,15 @@ function! s:InitTypes()
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0}
\ ]
- let type_mxml.sro = '.'
- let type_mxml.kind2scope = {
+ let type_as.sro = '.'
+ let type_as.kind2scope = {
\ 'c' : 'class'
\ }
- let type_mxml.scope2kind = {
+ let type_as.scope2kind = {
\ 'class' : 'c'
\ }
- let s:known_types.mxml = type_mxml
+ let s:known_types.mxml = type_as
+ let s:known_types.actionscript = type_as
" Fortran {{{3
let type_fortran = s:TypeInfo.New()
let type_fortran.ctagstype = 'fortran'
@@ -625,6 +598,7 @@ function! s:InitTypes()
let type_sql.ctagstype = 'sql'
let type_sql.kinds = [
\ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1},
+ \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1},
\ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1},
@@ -642,7 +616,8 @@ function! s:InitTypes()
\ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1},
\ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1},
\ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1},
- \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}
+ \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1},
+ \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1}
\ ]
let s:known_types.sql = type_sql
" Tcl {{{3
@@ -786,6 +761,7 @@ function! s:InitTypes()
let type_vim = s:TypeInfo.New()
let type_vim.ctagstype = 'vim'
let type_vim.kinds = [
+ \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1},
\ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1},
@@ -812,7 +788,7 @@ function! s:InitTypes()
endfunction
" s:LoadUserTypeDefs() {{{2
-function! s:LoadUserTypeDefs(...)
+function! s:LoadUserTypeDefs(...) abort
if a:0 > 0
let type = a:1
@@ -879,7 +855,7 @@ function! s:LoadUserTypeDefs(...)
endfunction
" s:CreateTypeKinddict() {{{2
-function! s:CreateTypeKinddict(type)
+function! s:CreateTypeKinddict(type) abort
" Create a dictionary of the kind order for fast access in sorting
" functions
let i = 0
@@ -891,7 +867,7 @@ endfunction
" s:RestoreSession() {{{2
" Properly restore Tagbar after a session got loaded
-function! s:RestoreSession()
+function! s:RestoreSession() abort
call s:LogDebugMessage('Restoring session')
let curfile = fnamemodify(bufname('%'), ':p')
@@ -908,11 +884,13 @@ function! s:RestoreSession()
endif
endif
- call s:Init()
+ let s:last_autofocus = 0
+
+ call s:Init(0)
call s:InitWindow(g:tagbar_autoclose)
- call s:AutoUpdate(curfile)
+ call s:AutoUpdate(curfile, 0)
if !in_tagbar
call s:winexec('wincmd p')
@@ -920,7 +898,7 @@ function! s:RestoreSession()
endfunction
" s:MapKeys() {{{2
-function! s:MapKeys()
+function! s:MapKeys() abort
call s:LogDebugMessage('Mapping keys')
nnoremap <script> <silent> <buffer> <2-LeftMouse>
@@ -965,7 +943,7 @@ function! s:MapKeys()
endfunction
" s:CreateAutocommands() {{{2
-function! s:CreateAutocommands()
+function! s:CreateAutocommands() abort
call s:LogDebugMessage('Creating autocommands')
augroup TagbarAutoCmds
@@ -973,12 +951,10 @@ function! s:CreateAutocommands()
autocmd BufEnter __Tagbar__ nested call s:QuitIfOnlyWindow()
autocmd CursorHold __Tagbar__ call s:ShowPrototype()
- autocmd BufWritePost *
- \ if line('$') < g:tagbar_updateonsave_maxlines |
- \ call s:AutoUpdate(fnamemodify(expand('<afile>'), ':p')) |
- \ endif
+ autocmd BufWritePost * call
+ \ s:AutoUpdate(fnamemodify(expand('<afile>'), ':p'), 1)
autocmd BufEnter,CursorHold,FileType * call
- \ s:AutoUpdate(fnamemodify(expand('<afile>'), ':p'))
+ \ s:AutoUpdate(fnamemodify(expand('<afile>'), ':p'), 0)
autocmd BufDelete,BufUnload,BufWipeout * call
\ s:known_files.rm(fnamemodify(expand('<afile>'), ':p'))
@@ -991,41 +967,95 @@ endfunction
" s:CheckForExCtags() {{{2
" Test whether the ctags binary is actually Exuberant Ctags and not GNU ctags
" (or something else)
-function! s:CheckForExCtags()
+function! s:CheckForExCtags(silent) abort
call s:LogDebugMessage('Checking for Exuberant Ctags')
+ if !exists('g:tagbar_ctags_bin')
+ let ctagsbins = []
+ let ctagsbins += ['ctags-exuberant'] " Debian
+ let ctagsbins += ['exuberant-ctags']
+ let ctagsbins += ['exctags'] " FreeBSD, NetBSD
+ let ctagsbins += ['/usr/local/bin/ctags'] " Homebrew
+ let ctagsbins += ['/opt/local/bin/ctags'] " Macports
+ let ctagsbins += ['ectags'] " OpenBSD
+ let ctagsbins += ['ctags']
+ let ctagsbins += ['ctags.exe']
+ let ctagsbins += ['tags']
+ for ctags in ctagsbins
+ if executable(ctags)
+ let g:tagbar_ctags_bin = ctags
+ break
+ endif
+ endfor
+ if !exists('g:tagbar_ctags_bin')
+ if !a:silent
+ echoerr 'Tagbar: Exuberant ctags not found!'
+ echomsg 'Please download Exuberant Ctags from ctags.sourceforge.net'
+ \ 'and install it in a directory in your $PATH'
+ \ 'or set g:tagbar_ctags_bin.'
+ endif
+ let s:checked_ctags = 2
+ return 0
+ endif
+ else
+ " reset 'wildignore' temporarily in case *.exe is included in it
+ let wildignore_save = &wildignore
+ set wildignore&
+
+ let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin)
+
+ let &wildignore = wildignore_save
+
+ if !executable(g:tagbar_ctags_bin)
+ if !a:silent
+ echoerr "Tagbar: Exuberant ctags not found at " .
+ \ "'" . g:tagbar_ctags_bin . "'!"
+ echomsg 'Please check your g:tagbar_ctags_bin setting.'
+ endif
+ let s:checked_ctags = 2
+ return 0
+ endif
+ endif
+
let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--version')
if ctags_cmd == ''
- return
+ let s:checked_ctags = 2
+ return 0
endif
let ctags_output = s:ExecuteCtags(ctags_cmd)
if v:shell_error || ctags_output !~# 'Exuberant Ctags'
- echoerr 'Tagbar: Ctags doesn''t seem to be Exuberant Ctags!'
- echomsg 'GNU ctags will NOT WORK.'
- \ 'Please download Exuberant Ctags from ctags.sourceforge.net'
- \ 'and install it in a directory in your $PATH'
- \ 'or set g:tagbar_ctags_bin.'
- echomsg 'Executed command: "' . ctags_cmd . '"'
- if !empty(ctags_output)
- echomsg 'Command output:'
- for line in split(ctags_output, '\n')
- echomsg line
- endfor
+ if !a:silent
+ echoerr 'Tagbar: Ctags doesn''t seem to be Exuberant Ctags!'
+ echomsg 'GNU ctags will NOT WORK.'
+ \ 'Please download Exuberant Ctags from ctags.sourceforge.net'
+ \ 'and install it in a directory in your $PATH'
+ \ 'or set g:tagbar_ctags_bin.'
+ echomsg 'Executed command: "' . ctags_cmd . '"'
+ if !empty(ctags_output)
+ echomsg 'Command output:'
+ for line in split(ctags_output, '\n')
+ echomsg line
+ endfor
+ endif
endif
+ let s:checked_ctags = 2
return 0
elseif !s:CheckExCtagsVersion(ctags_output)
- echoerr 'Tagbar: Exuberant Ctags is too old!'
- echomsg 'You need at least version 5.5 for Tagbar to work.'
- \ 'Please download a newer version from ctags.sourceforge.net.'
- echomsg 'Executed command: "' . ctags_cmd . '"'
- if !empty(ctags_output)
- echomsg 'Command output:'
- for line in split(ctags_output, '\n')
- echomsg line
- endfor
+ if !a:silent
+ echoerr 'Tagbar: Exuberant Ctags is too old!'
+ echomsg 'You need at least version 5.5 for Tagbar to work.'
+ \ 'Please download a newer version from ctags.sourceforge.net.'
+ echomsg 'Executed command: "' . ctags_cmd . '"'
+ if !empty(ctags_output)
+ echomsg 'Command output:'
+ for line in split(ctags_output, '\n')
+ echomsg line
+ endfor
+ endif
endif
+ let s:checked_ctags = 2
return 0
else
let s:checked_ctags = 1
@@ -1034,7 +1064,7 @@ function! s:CheckForExCtags()
endfunction
" s:CheckExCtagsVersion() {{{2
-function! s:CheckExCtagsVersion(output)
+function! s:CheckExCtagsVersion(output) abort
call s:LogDebugMessage('Checking Exuberant Ctags version')
if a:output =~ 'Exuberant Ctags Development'
@@ -1049,7 +1079,7 @@ function! s:CheckExCtagsVersion(output)
endfunction
" s:CheckFTCtags() {{{2
-function! s:CheckFTCtags(bin, ftype)
+function! s:CheckFTCtags(bin, ftype) abort
if executable(a:bin)
return a:bin
endif
@@ -1067,7 +1097,7 @@ function! s:CheckFTCtags(bin, ftype)
endfunction
" s:GetSupportedFiletypes() {{{2
-function! s:GetSupportedFiletypes()
+function! s:GetSupportedFiletypes() abort
call s:LogDebugMessage('Getting filetypes sypported by Exuberant Ctags')
let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--list-languages')
@@ -1097,7 +1127,7 @@ endfunction
let s:BaseTag = {}
" s:BaseTag.New() {{{3
-function! s:BaseTag.New(name) dict
+function! s:BaseTag.New(name) abort dict
let newobj = copy(self)
call newobj._init(a:name)
@@ -1106,7 +1136,7 @@ function! s:BaseTag.New(name) dict
endfunction
" s:BaseTag._init() {{{3
-function! s:BaseTag._init(name) dict
+function! s:BaseTag._init(name) abort dict
let self.name = a:name
let self.fields = {}
let self.fields.line = 0
@@ -1117,30 +1147,31 @@ function! s:BaseTag._init(name) dict
let self.parent = {}
let self.tline = -1
let self.fileinfo = {}
+ let self.typeinfo = {}
endfunction
" s:BaseTag.isNormalTag() {{{3
-function! s:BaseTag.isNormalTag() dict
+function! s:BaseTag.isNormalTag() abort dict
return 0
endfunction
" s:BaseTag.isPseudoTag() {{{3
-function! s:BaseTag.isPseudoTag() dict
+function! s:BaseTag.isPseudoTag() abort dict
return 0
endfunction
" s:BaseTag.isKindheader() {{{3
-function! s:BaseTag.isKindheader() dict
+function! s:BaseTag.isKindheader() abort dict
return 0
endfunction
" s:BaseTag.getPrototype() {{{3
-function! s:BaseTag.getPrototype() dict
+function! s:BaseTag.getPrototype() abort dict
return ''
endfunction
" s:BaseTag._getPrefix() {{{3
-function! s:BaseTag._getPrefix() dict
+function! s:BaseTag._getPrefix() abort dict
let fileinfo = self.fileinfo
if has_key(self, 'children') && !empty(self.children)
@@ -1162,7 +1193,7 @@ function! s:BaseTag._getPrefix() dict
endfunction
" s:BaseTag.initFoldState() {{{3
-function! s:BaseTag.initFoldState() dict
+function! s:BaseTag.initFoldState() abort dict
let fileinfo = self.fileinfo
if s:known_files.has(fileinfo.fpath) &&
@@ -1180,41 +1211,46 @@ function! s:BaseTag.initFoldState() dict
endfunction
" s:BaseTag.getClosedParentTline() {{{3
-function! s:BaseTag.getClosedParentTline() dict
- let tagline = self.tline
+function! s:BaseTag.getClosedParentTline() abort dict
+ let tagline = self.tline
let fileinfo = self.fileinfo
- let parent = self.parent
- while !empty(parent)
+ " Find the first closed parent, starting from the top of the hierarchy.
+ let parents = []
+ let curparent = self.parent
+ while !empty(curparent)
+ call add(parents, curparent)
+ let curparent = curparent.parent
+ endwhile
+ for parent in reverse(parents)
if parent.isFolded()
let tagline = parent.tline
break
endif
- let parent = parent.parent
- endwhile
+ endfor
return tagline
endfunction
" s:BaseTag.isFoldable() {{{3
-function! s:BaseTag.isFoldable() dict
+function! s:BaseTag.isFoldable() abort dict
return has_key(self, 'children') && !empty(self.children)
endfunction
" s:BaseTag.isFolded() {{{3
-function! s:BaseTag.isFolded() dict
+function! s:BaseTag.isFolded() abort dict
return self.fileinfo.tagfolds[self.fields.kind][self.fullpath]
endfunction
" s:BaseTag.openFold() {{{3
-function! s:BaseTag.openFold() dict
+function! s:BaseTag.openFold() abort dict
if self.isFoldable()
let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 0
endif
endfunction
" s:BaseTag.closeFold() {{{3
-function! s:BaseTag.closeFold() dict
+function! s:BaseTag.closeFold() abort dict
let newline = line('.')
if !empty(self.parent) && self.parent.isKindheader()
@@ -1236,12 +1272,12 @@ function! s:BaseTag.closeFold() dict
endfunction
" s:BaseTag.setFolded() {{{3
-function! s:BaseTag.setFolded(folded) dict
+function! s:BaseTag.setFolded(folded) abort dict
let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = a:folded
endfunction
" s:BaseTag.openParents() {{{3
-function! s:BaseTag.openParents() dict
+function! s:BaseTag.openParents() abort dict
let parent = self.parent
while !empty(parent)
@@ -1254,14 +1290,14 @@ endfunction
let s:NormalTag = copy(s:BaseTag)
" s:NormalTag.isNormalTag() {{{3
-function! s:NormalTag.isNormalTag() dict
+function! s:NormalTag.isNormalTag() abort dict
return 1
endfunction
-" s:NormalTag.str() {{{3
-function! s:NormalTag.str() dict
+" s:NormalTag.strfmt() {{{3
+function! s:NormalTag.strfmt() abort dict
let fileinfo = self.fileinfo
- let typeinfo = s:known_types[fileinfo.ftype]
+ let typeinfo = self.typeinfo
let suffix = get(self.fields, 'signature', '')
if has_key(self.fields, 'type')
@@ -1274,9 +1310,13 @@ function! s:NormalTag.str() dict
return self._getPrefix() . self.name . suffix . "\n"
endfunction
-" s:NormalTag.strshort() {{{3
-function! s:NormalTag.strshort(longsig) dict
- let str = self.name
+" s:NormalTag.str() {{{3
+function! s:NormalTag.str(longsig, full) abort dict
+ if a:full && self.path != ''
+ let str = self.path . self.typeinfo.sro . self.name
+ else
+ let str = self.name
+ endif
if has_key(self.fields, 'signature')
if a:longsig
@@ -1290,7 +1330,7 @@ function! s:NormalTag.strshort(longsig) dict
endfunction
" s:NormalTag.getPrototype() {{{3
-function! s:NormalTag.getPrototype() dict
+function! s:NormalTag.getPrototype() abort dict
return self.prototype
endfunction
@@ -1298,14 +1338,14 @@ endfunction
let s:PseudoTag = copy(s:BaseTag)
" s:PseudoTag.isPseudoTag() {{{3
-function! s:PseudoTag.isPseudoTag() dict
+function! s:PseudoTag.isPseudoTag() abort dict
return 1
endfunction
-" s:PseudoTag.str() {{{3
-function! s:PseudoTag.str() dict
+" s:PseudoTag.strfmt() {{{3
+function! s:PseudoTag.strfmt() abort dict
let fileinfo = self.fileinfo
- let typeinfo = s:known_types[fileinfo.ftype]
+ let typeinfo = self.typeinfo
let suffix = get(self.fields, 'signature', '')
if has_key(typeinfo.kind2scope, self.fields.kind)
@@ -1319,39 +1359,39 @@ endfunction
let s:KindheaderTag = copy(s:BaseTag)
" s:KindheaderTag.isKindheader() {{{3
-function! s:KindheaderTag.isKindheader() dict
+function! s:KindheaderTag.isKindheader() abort dict
return 1
endfunction
" s:KindheaderTag.getPrototype() {{{3
-function! s:KindheaderTag.getPrototype() dict
+function! s:KindheaderTag.getPrototype() abort dict
return self.name . ': ' .
\ self.numtags . ' ' . (self.numtags > 1 ? 'tags' : 'tag')
endfunction
" s:KindheaderTag.isFoldable() {{{3
-function! s:KindheaderTag.isFoldable() dict
+function! s:KindheaderTag.isFoldable() abort dict
return 1
endfunction
" s:KindheaderTag.isFolded() {{{3
-function! s:KindheaderTag.isFolded() dict
+function! s:KindheaderTag.isFolded() abort dict
return self.fileinfo.kindfolds[self.short]
endfunction
" s:KindheaderTag.openFold() {{{3
-function! s:KindheaderTag.openFold() dict
+function! s:KindheaderTag.openFold() abort dict
let self.fileinfo.kindfolds[self.short] = 0
endfunction
" s:KindheaderTag.closeFold() {{{3
-function! s:KindheaderTag.closeFold() dict
+function! s:KindheaderTag.closeFold() abort dict
let self.fileinfo.kindfolds[self.short] = 1
return line('.')
endfunction
" s:KindheaderTag.toggleFold() {{{3
-function! s:KindheaderTag.toggleFold() dict
+function! s:KindheaderTag.toggleFold() abort dict
let fileinfo = s:known_files.getCurrent()
let fileinfo.kindfolds[self.short] = !fileinfo.kindfolds[self.short]
@@ -1361,7 +1401,7 @@ endfunction
let s:TypeInfo = {}
" s:TypeInfo.New() {{{3
-function! s:TypeInfo.New(...) dict
+function! s:TypeInfo.New(...) abort dict
let newobj = copy(self)
let newobj.kinddict = {}
@@ -1374,7 +1414,7 @@ function! s:TypeInfo.New(...) dict
endfunction
" s:TypeInfo.getKind() {{{3
-function! s:TypeInfo.getKind(kind) dict
+function! s:TypeInfo.getKind(kind) abort dict
let idx = self.kinddict[a:kind]
return self.kinds[idx]
endfunction
@@ -1383,12 +1423,14 @@ endfunction
let s:FileInfo = {}
" s:FileInfo.New() {{{3
-function! s:FileInfo.New(fname, ftype) dict
+function! s:FileInfo.New(fname, ftype) abort dict
let newobj = copy(self)
" The complete file path
let newobj.fpath = a:fname
+ let newobj.bufnr = bufnr(a:fname)
+
" File modification time
let newobj.mtime = getftime(a:fname)
@@ -1408,6 +1450,7 @@ function! s:FileInfo.New(fname, ftype) dict
" Dictionary of the folding state of 'kind's, indexed by short name
let newobj.kindfolds = {}
let typeinfo = s:known_types[a:ftype]
+ let newobj.typeinfo = typeinfo
" copy the default fold state from the type info
for kind in typeinfo.kinds
let newobj.kindfolds[kind.short] =
@@ -1430,7 +1473,7 @@ endfunction
" s:FileInfo.reset() {{{3
" Reset stuff that gets regenerated while processing a file and save the old
" tag folds
-function! s:FileInfo.reset() dict
+function! s:FileInfo.reset() abort dict
let self.mtime = getftime(self.fpath)
let self.tags = []
let self.fline = {}
@@ -1446,14 +1489,14 @@ function! s:FileInfo.reset() dict
endfunction
" s:FileInfo.clearOldFolds() {{{3
-function! s:FileInfo.clearOldFolds() dict
+function! s:FileInfo.clearOldFolds() abort dict
if exists('self._tagfolds_old')
unlet self._tagfolds_old
endif
endfunction
" s:FileInfo.sortTags() {{{3
-function! s:FileInfo.sortTags() dict
+function! s:FileInfo.sortTags() abort dict
if has_key(s:compare_typeinfo, 'sort')
if s:compare_typeinfo.sort
call s:SortTags(self.tags, 's:CompareByKind')
@@ -1468,12 +1511,12 @@ function! s:FileInfo.sortTags() dict
endfunction
" s:FileInfo.openKindFold() {{{3
-function! s:FileInfo.openKindFold(kind) dict
+function! s:FileInfo.openKindFold(kind) abort dict
let self.kindfolds[a:kind.short] = 0
endfunction
" s:FileInfo.closeKindFold() {{{3
-function! s:FileInfo.closeKindFold(kind) dict
+function! s:FileInfo.closeKindFold(kind) abort dict
let self.kindfolds[a:kind.short] = 1
endfunction
@@ -1484,23 +1527,23 @@ let s:known_files = {
\ }
" s:known_files.getCurrent() {{{3
-function! s:known_files.getCurrent() dict
+function! s:known_files.getCurrent() abort dict
return self._current
endfunction
" s:known_files.setCurrent() {{{3
-function! s:known_files.setCurrent(fileinfo) dict
+function! s:known_files.setCurrent(fileinfo) abort dict
let self._current = a:fileinfo
endfunction
" s:known_files.get() {{{3
-function! s:known_files.get(fname) dict
+function! s:known_files.get(fname) abort dict
return get(self._files, a:fname, {})
endfunction
" s:known_files.put() {{{3
" Optional second argument is the filename
-function! s:known_files.put(fileinfo, ...) dict
+function! s:known_files.put(fileinfo, ...) abort dict
if a:0 == 1
let self._files[a:1] = a:fileinfo
else
@@ -1510,12 +1553,12 @@ function! s:known_files.put(fileinfo, ...) dict
endfunction
" s:known_files.has() {{{3
-function! s:known_files.has(fname) dict
+function! s:known_files.has(fname) abort dict
return has_key(self._files, a:fname)
endfunction
" s:known_files.rm() {{{3
-function! s:known_files.rm(fname) dict
+function! s:known_files.rm(fname) abort dict
if s:known_files.has(a:fname)
call remove(self._files, a:fname)
endif
@@ -1523,7 +1566,7 @@ endfunction
" Window management {{{1
" s:ToggleWindow() {{{2
-function! s:ToggleWindow()
+function! s:ToggleWindow() abort
call s:LogDebugMessage('ToggleWindow called')
let tagbarwinnr = bufwinnr("__Tagbar__")
@@ -1538,7 +1581,7 @@ function! s:ToggleWindow()
endfunction
" s:OpenWindow() {{{2
-function! s:OpenWindow(flags)
+function! s:OpenWindow(flags) abort
call s:LogDebugMessage("OpenWindow called with flags: '" . a:flags . "'")
let autofocus = a:flags =~# 'f'
@@ -1546,6 +1589,7 @@ function! s:OpenWindow(flags)
let autoclose = a:flags =~# 'c'
let curfile = fnamemodify(bufname('%'), ':p')
+ let curline = line('.')
" If the tagbar window is already open check jump flag
" Also set the autoclose flag if requested
@@ -1556,6 +1600,7 @@ function! s:OpenWindow(flags)
if autoclose
let w:autoclose = autoclose
endif
+ call s:HighlightTag(1, curline)
endif
call s:LogDebugMessage("OpenWindow finished, Tagbar already open")
return
@@ -1564,7 +1609,7 @@ function! s:OpenWindow(flags)
" This is only needed for the CorrectFocusOnStartup() function
let s:last_autofocus = autofocus
- if !s:Init()
+ if !s:Init(0)
return 0
endif
@@ -1584,7 +1629,8 @@ function! s:OpenWindow(flags)
call s:InitWindow(autoclose)
- call s:AutoUpdate(curfile)
+ call s:AutoUpdate(curfile, 0)
+ call s:HighlightTag(1, curline)
if !(g:tagbar_autoclose || autofocus || g:tagbar_autofocus)
call s:winexec('wincmd p')
@@ -1594,16 +1640,17 @@ function! s:OpenWindow(flags)
endfunction
" s:InitWindow() {{{2
-function! s:InitWindow(autoclose)
+function! s:InitWindow(autoclose) abort
call s:LogDebugMessage('InitWindow called with autoclose: ' . a:autoclose)
+ setlocal filetype=tagbar
+
setlocal noreadonly " in case the "view" mode is used
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
setlocal nobuflisted
setlocal nomodifiable
- setlocal filetype=tagbar
setlocal nolist
setlocal nonumber
setlocal nowrap
@@ -1611,6 +1658,7 @@ function! s:InitWindow(autoclose)
setlocal textwidth=0
setlocal nocursorline
setlocal nocursorcolumn
+ setlocal nospell
if exists('+relativenumber')
setlocal norelativenumber
@@ -1659,7 +1707,7 @@ function! s:InitWindow(autoclose)
endfunction
" s:CloseWindow() {{{2
-function! s:CloseWindow()
+function! s:CloseWindow() abort
call s:LogDebugMessage('CloseWindow called')
let tagbarwinnr = bufwinnr('__Tagbar__')
@@ -1723,7 +1771,7 @@ function! s:CloseWindow()
endfunction
" s:ZoomWindow() {{{2
-function! s:ZoomWindow()
+function! s:ZoomWindow() abort
if s:is_maximized
execute 'vert resize ' . g:tagbar_width
let s:is_maximized = 0
@@ -1738,7 +1786,7 @@ endfunction
" tagbar#autoopen is used with a FileType autocommand on startup and
" g:tagbar_left is set. This should work around it by jumping to the window of
" the current file after startup.
-function! s:CorrectFocusOnStartup()
+function! s:CorrectFocusOnStartup() abort
if bufwinnr('__Tagbar__') != -1 && !g:tagbar_autofocus && !s:last_autofocus
let curfile = s:known_files.getCurrent()
if !empty(curfile) && curfile.fpath != fnamemodify(bufname('%'), ':p')
@@ -1753,7 +1801,7 @@ endfunction
" Tag processing {{{1
" s:ProcessFile() {{{2
" Execute ctags and put the information into a 'FileInfo' object
-function! s:ProcessFile(fname, ftype)
+function! s:ProcessFile(fname, ftype) abort
call s:LogDebugMessage('ProcessFile called on ' . a:fname)
if !s:IsValidFile(a:fname, a:ftype)
@@ -1761,32 +1809,39 @@ function! s:ProcessFile(fname, ftype)
return
endif
- let ctags_output = s:ExecuteCtagsOnFile(a:fname, a:ftype)
+ " If the file has only been updated preserve the fold states, otherwise
+ " create a new entry
+ if s:known_files.has(a:fname)
+ let fileinfo = s:known_files.get(a:fname)
+ call fileinfo.reset()
+ else
+ let fileinfo = s:FileInfo.New(a:fname, a:ftype)
+ endif
+
+ let tempfile = tempname()
+
+ call writefile(getbufline(fileinfo.bufnr, 1, '$'), tempfile)
+ let fileinfo.mtime = getftime(tempfile)
+
+ let ctags_output = s:ExecuteCtagsOnFile(tempfile, a:ftype)
+
+ call delete(tempfile)
if ctags_output == -1
call s:LogDebugMessage('Ctags error when processing file')
- " put an empty entry into known_files so the error message is only
+ " Put an empty entry into known_files so the error message is only
" shown once
call s:known_files.put({}, a:fname)
return
elseif ctags_output == ''
call s:LogDebugMessage('Ctags output empty')
" No need to go through the tag processing if there are no tags, and
- " preserving the old fold state also isn't necessary
+ " preserving the old fold state isn't necessary either
call s:known_files.put(s:FileInfo.New(a:fname, a:ftype), a:fname)
return
endif
- " If the file has only been updated preserve the fold states, otherwise
- " create a new entry
- if s:known_files.has(a:fname)
- let fileinfo = s:known_files.get(a:fname)
- call fileinfo.reset()
- else
- let fileinfo = s:FileInfo.New(a:fname, a:ftype)
- endif
-
- let typeinfo = s:known_types[a:ftype]
+ let typeinfo = fileinfo.typeinfo
" Parse the ctags output lines
call s:LogDebugMessage('Parsing ctags output')
@@ -1864,7 +1919,7 @@ function! s:ProcessFile(fname, ftype)
endfunction
" s:ExecuteCtagsOnFile() {{{2
-function! s:ExecuteCtagsOnFile(fname, ftype)
+function! s:ExecuteCtagsOnFile(fname, ftype) abort
call s:LogDebugMessage('ExecuteCtagsOnFile called on ' . a:fname)
let typeinfo = s:known_types[a:ftype]
@@ -1935,7 +1990,7 @@ endfunction
" tagname<TAB>filename<TAB>expattern;"fields
" fields: <TAB>name:value
" fields that are always present: kind, line
-function! s:ParseTagline(part1, part2, typeinfo, fileinfo)
+function! s:ParseTagline(part1, part2, typeinfo, fileinfo) abort
let basic_info = split(a:part1, '\t')
let taginfo = s:NormalTag.New(basic_info[0])
@@ -1990,6 +2045,7 @@ function! s:ParseTagline(part1, part2, typeinfo, fileinfo)
endif
let taginfo.fileinfo = a:fileinfo
+ let taginfo.typeinfo = a:typeinfo
" Needed for folding
try
@@ -2013,7 +2069,7 @@ endfunction
" Tagbar. Properly parsing them is quite tricky, so try not to think about it
" too much.
function! s:AddScopedTags(tags, processedtags, parent, depth,
- \ typeinfo, fileinfo)
+ \ typeinfo, fileinfo) abort
if !empty(a:parent)
let curpath = a:parent.fullpath
let pscope = a:typeinfo.kind2scope[a:parent.fields.kind]
@@ -2101,7 +2157,7 @@ function! s:AddScopedTags(tags, processedtags, parent, depth,
endfunction
" s:ProcessPseudoTag() {{{2
-function! s:ProcessPseudoTag(curtags, tag, parent, typeinfo, fileinfo)
+function! s:ProcessPseudoTag(curtags, tag, parent, typeinfo, fileinfo) abort
let curpath = !empty(a:parent) ? a:parent.fullpath : ''
let pseudoname = substitute(a:tag.path, curpath, '', '')
@@ -2122,7 +2178,7 @@ function! s:ProcessPseudoTag(curtags, tag, parent, typeinfo, fileinfo)
endfunction
" s:ProcessPseudoChildren() {{{2
-function! s:ProcessPseudoChildren(tags, tag, depth, typeinfo, fileinfo)
+function! s:ProcessPseudoChildren(tags, tag, depth, typeinfo, fileinfo) abort
for childtag in a:tag.children
let childtag.parent = a:tag
@@ -2148,7 +2204,7 @@ function! s:ProcessPseudoChildren(tags, tag, depth, typeinfo, fileinfo)
endfunction
" s:CreatePseudoTag() {{{2
-function! s:CreatePseudoTag(name, parent, scope, typeinfo, fileinfo)
+function! s:CreatePseudoTag(name, parent, scope, typeinfo, fileinfo) abort
if !empty(a:parent)
let curpath = a:parent.fullpath
let pscope = a:typeinfo.kind2scope[a:parent.fields.kind]
@@ -2176,6 +2232,7 @@ function! s:CreatePseudoTag(name, parent, scope, typeinfo, fileinfo)
let pseudotag.parent = a:parent
let pseudotag.fileinfo = a:fileinfo
+ let pseudotag.typeinfo = a:typeinfo
call pseudotag.initFoldState()
@@ -2184,7 +2241,7 @@ endfunction
" Sorting {{{1
" s:SortTags() {{{2
-function! s:SortTags(tags, comparemethod)
+function! s:SortTags(tags, comparemethod) abort
call sort(a:tags, a:comparemethod)
for tag in a:tags
@@ -2195,7 +2252,7 @@ function! s:SortTags(tags, comparemethod)
endfunction
" s:CompareByKind() {{{2
-function! s:CompareByKind(tag1, tag2)
+function! s:CompareByKind(tag1, tag2) abort
let typeinfo = s:compare_typeinfo
if typeinfo.kinddict[a:tag1.fields.kind] <#
@@ -2227,12 +2284,12 @@ function! s:CompareByKind(tag1, tag2)
endfunction
" s:CompareByLine() {{{2
-function! s:CompareByLine(tag1, tag2)
+function! s:CompareByLine(tag1, tag2) abort
return a:tag1.fields.line - a:tag2.fields.line
endfunction
" s:ToggleSort() {{{2
-function! s:ToggleSort()
+function! s:ToggleSort() abort
let fileinfo = s:known_files.getCurrent()
if empty(fileinfo)
return
@@ -2259,7 +2316,7 @@ endfunction
" Display {{{1
" s:RenderContent() {{{2
-function! s:RenderContent(...)
+function! s:RenderContent(...) abort
call s:LogDebugMessage('RenderContent called')
let s:new_window = 0
@@ -2304,7 +2361,7 @@ function! s:RenderContent(...)
call s:PrintHelp()
- let typeinfo = s:known_types[fileinfo.ftype]
+ let typeinfo = fileinfo.typeinfo
" Print tags
call s:PrintKinds(typeinfo, fileinfo)
@@ -2349,7 +2406,7 @@ function! s:RenderContent(...)
endfunction
" s:PrintKinds() {{{2
-function! s:PrintKinds(typeinfo, fileinfo)
+function! s:PrintKinds(typeinfo, fileinfo) abort
call s:LogDebugMessage('PrintKinds called')
let first_tag = 1
@@ -2369,9 +2426,9 @@ function! s:PrintKinds(typeinfo, fileinfo)
" Scoped tags
for tag in curtags
if g:tagbar_compact && first_tag && s:short_help
- silent 0put =tag.str()
+ silent 0put =tag.strfmt()
else
- silent put =tag.str()
+ silent put =tag.strfmt()
endif
" Save the current tagbar line in the tag for easy
@@ -2434,7 +2491,7 @@ function! s:PrintKinds(typeinfo, fileinfo)
if !kindtag.isFolded()
for tag in curtags
- let str = tag.str()
+ let str = tag.strfmt()
silent put =' ' . str
" Save the current tagbar line in the tag for easy
@@ -2456,9 +2513,9 @@ function! s:PrintKinds(typeinfo, fileinfo)
endfunction
" s:PrintTag() {{{2
-function! s:PrintTag(tag, depth, fileinfo, typeinfo)
+function! s:PrintTag(tag, depth, fileinfo, typeinfo) abort
" Print tag indented according to depth
- silent put =repeat(' ', a:depth * 2) . a:tag.str()
+ silent put =repeat(' ', a:depth * 2) . a:tag.strfmt()
" Save the current tagbar line in the tag for easy
" highlighting access
@@ -2494,7 +2551,7 @@ function! s:PrintTag(tag, depth, fileinfo, typeinfo)
endfunction
" s:PrintHelp() {{{2
-function! s:PrintHelp()
+function! s:PrintHelp() abort
if !g:tagbar_compact && s:short_help
silent 0put ='\" Press <F1> for help'
silent put _
@@ -2527,7 +2584,7 @@ endfunction
" s:RenderKeepView() {{{2
" The gist of this function was taken from NERDTree by Martin Grenfell.
-function! s:RenderKeepView(...)
+function! s:RenderKeepView(...) abort
if a:0 == 1
let line = a:1
else
@@ -2553,10 +2610,14 @@ endfunction
" User actions {{{1
" s:HighlightTag() {{{2
-function! s:HighlightTag()
+function! s:HighlightTag(openfolds, ...) abort
let tagline = 0
- let tag = s:GetNearbyTag(1)
+ if a:0 > 0
+ let tag = s:GetNearbyTag(1, a:1)
+ else
+ let tag = s:GetNearbyTag(1)
+ endif
if !empty(tag)
let tagline = tag.tline
endif
@@ -2586,7 +2647,7 @@ function! s:HighlightTag()
return
endif
- if g:tagbar_autoshowtag
+ if g:tagbar_autoshowtag || a:openfolds
call s:OpenParents(tag)
endif
@@ -2602,15 +2663,18 @@ function! s:HighlightTag()
let foldpat = '[' . s:icon_open . s:icon_closed . ' ]'
let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\zs[^( ]\+\ze/'
+ call s:LogDebugMessage("Highlight pattern: '" . pattern . "'")
execute 'match TagbarHighlight ' . pattern
- call s:winexec(prevwinnr . 'wincmd w')
+ if a:0 == 0 " no line explicitly given, so assume we were in the file window
+ call s:winexec(prevwinnr . 'wincmd w')
+ endif
redraw
endfunction
" s:JumpToTag() {{{2
-function! s:JumpToTag(stay_in_tagbar)
+function! s:JumpToTag(stay_in_tagbar) abort
let taginfo = s:GetTagInfo(line('.'), 1)
let autoclose = w:autoclose
@@ -2689,17 +2753,17 @@ function! s:JumpToTag(stay_in_tagbar)
redraw
if a:stay_in_tagbar
- call s:HighlightTag()
+ call s:HighlightTag(0)
call s:winexec(tagbarwinnr . 'wincmd w')
elseif g:tagbar_autoclose || autoclose
call s:CloseWindow()
else
- call s:HighlightTag()
+ call s:HighlightTag(0)
endif
endfunction
" s:ShowPrototype() {{{2
-function! s:ShowPrototype()
+function! s:ShowPrototype() abort
let taginfo = s:GetTagInfo(line('.'), 1)
if empty(taginfo)
@@ -2710,7 +2774,7 @@ function! s:ShowPrototype()
endfunction
" s:ToggleHelp() {{{2
-function! s:ToggleHelp()
+function! s:ToggleHelp() abort
let s:short_help = !s:short_help
" Prevent highlighting from being off after adding/removing the help text
@@ -2723,7 +2787,7 @@ function! s:ToggleHelp()
endfunction
" s:GotoNextToplevelTag() {{{2
-function! s:GotoNextToplevelTag(direction)
+function! s:GotoNextToplevelTag(direction) abort
let curlinenr = line('.')
let newlinenr = line('.')
@@ -2754,7 +2818,7 @@ endfunction
" Folding {{{1
" s:OpenFold() {{{2
-function! s:OpenFold()
+function! s:OpenFold() abort
let fileinfo = s:known_files.getCurrent()
if empty(fileinfo)
return
@@ -2773,7 +2837,7 @@ function! s:OpenFold()
endfunction
" s:CloseFold() {{{2
-function! s:CloseFold()
+function! s:CloseFold() abort
let fileinfo = s:known_files.getCurrent()
if empty(fileinfo)
return
@@ -2794,7 +2858,7 @@ function! s:CloseFold()
endfunction
" s:ToggleFold() {{{2
-function! s:ToggleFold()
+function! s:ToggleFold() abort
let fileinfo = s:known_files.getCurrent()
if empty(fileinfo)
return
@@ -2825,7 +2889,7 @@ function! s:ToggleFold()
endfunction
" s:SetFoldLevel() {{{2
-function! s:SetFoldLevel(level, force)
+function! s:SetFoldLevel(level, force) abort
if a:level < 0
echoerr 'Foldlevel can''t be negative'
return
@@ -2838,7 +2902,7 @@ function! s:SetFoldLevel(level, force)
call s:SetFoldLevelRecursive(fileinfo, fileinfo.tags, a:level)
- let typeinfo = s:known_types[fileinfo.ftype]
+ let typeinfo = fileinfo.typeinfo
" Apply foldlevel to 'kind's
if a:level == 0
@@ -2860,7 +2924,7 @@ endfunction
" s:SetFoldLevelRecursive() {{{2
" Apply foldlevel to normal tags
-function! s:SetFoldLevelRecursive(fileinfo, tags, level)
+function! s:SetFoldLevelRecursive(fileinfo, tags, level) abort
for tag in a:tags
if tag.depth >= a:level
call tag.setFolded(1)
@@ -2875,7 +2939,7 @@ function! s:SetFoldLevelRecursive(fileinfo, tags, level)
endfunction
" s:OpenParents() {{{2
-function! s:OpenParents(...)
+function! s:OpenParents(...) abort
let tagline = 0
if a:0 == 1
@@ -2891,7 +2955,7 @@ endfunction
" Helper functions {{{1
" s:AutoUpdate() {{{2
-function! s:AutoUpdate(fname)
+function! s:AutoUpdate(fname, force) abort
call s:LogDebugMessage('AutoUpdate called on ' . a:fname)
" Get the filetype of the file we're about to process
@@ -2917,14 +2981,22 @@ function! s:AutoUpdate(fname)
let updated = 0
- " Process the file if it's unknown or the information is outdated
+ " Process the file if it's unknown or the information is outdated.
" Also test for entries that exist but are empty, which will be the case
- " if there was an error during the ctags execution
+ " if there was an error during the ctags execution.
+ " Testing the mtime of the file is necessary in case it got changed
+ " outside of Vim, for example by checking out a different version from a
+ " VCS.
if s:known_files.has(a:fname) && !empty(s:known_files.get(a:fname))
- if s:known_files.get(a:fname).mtime != getftime(a:fname)
+ let curfile = s:known_files.get(a:fname)
+ " if a:force || getbufvar(curfile.bufnr, '&modified') ||
+ if a:force ||
+ \ (filereadable(a:fname) && getftime(a:fname) > curfile.mtime)
call s:LogDebugMessage('File data outdated, updating ' . a:fname)
call s:ProcessFile(a:fname, sftype)
let updated = 1
+ else
+ call s:LogDebugMessage('File data seems up to date: ' . a:fname)
endif
elseif !s:known_files.has(a:fname)
call s:LogDebugMessage('New file, processing ' . a:fname)
@@ -2949,18 +3021,18 @@ function! s:AutoUpdate(fname)
endif
" Call setCurrent after rendering so RenderContent can check whether the
- " same file is redisplayed
+ " same file is being redisplayed
if !empty(fileinfo)
call s:LogDebugMessage('Setting current file to ' . a:fname)
call s:known_files.setCurrent(fileinfo)
endif
- call s:HighlightTag()
+ call s:HighlightTag(0)
call s:LogDebugMessage('AutoUpdate finished successfully')
endfunction
" s:CheckMouseClick() {{{2
-function! s:CheckMouseClick()
+function! s:CheckMouseClick() abort
let line = getline('.')
let curcol = col('.')
@@ -2974,7 +3046,7 @@ function! s:CheckMouseClick()
endfunction
" s:DetectFiletype() {{{2
-function! s:DetectFiletype(bufnr)
+function! s:DetectFiletype(bufnr) abort
" Filetype has already been detected for loaded buffers, but not
" necessarily for unloaded ones
let ftype = getbufvar(a:bufnr, '&filetype')
@@ -3008,7 +3080,7 @@ endfunction
" Assemble the ctags command line in a way that all problematic characters are
" properly escaped and converted to the system's encoding
" Optional third parameter is a file name to run ctags on
-function! s:EscapeCtagsCmd(ctags_bin, args, ...)
+function! s:EscapeCtagsCmd(ctags_bin, args, ...) abort
call s:LogDebugMessage('EscapeCtagsCmd called')
call s:LogDebugMessage('ctags_bin: ' . a:ctags_bin)
call s:LogDebugMessage('ctags_args: ' . a:args)
@@ -3026,16 +3098,23 @@ function! s:EscapeCtagsCmd(ctags_bin, args, ...)
let ctags_cmd = shellescape(a:ctags_bin) . ' ' . a:args . ' ' . fname
+ " Stupid cmd.exe quoting
+ if &shell =~ 'cmd\.exe'
+ let ctags_cmd = substitute(ctags_cmd, '\(&\|\^\)', '^\0', 'g')
+ endif
+
if exists('+shellslash')
let &shellslash = shellslash_save
endif
" Needed for cases where 'encoding' is different from the system's
" encoding
- if g:tagbar_systemenc != &encoding
- let ctags_cmd = iconv(ctags_cmd, &encoding, g:tagbar_systemenc)
- elseif $LANG != ''
- let ctags_cmd = iconv(ctags_cmd, &encoding, $LANG)
+ if has('multi_byte')
+ if g:tagbar_systemenc != &encoding
+ let ctags_cmd = iconv(ctags_cmd, &encoding, g:tagbar_systemenc)
+ elseif $LANG != ''
+ let ctags_cmd = iconv(ctags_cmd, &encoding, $LANG)
+ endif
endif
call s:LogDebugMessage('Escaped ctags command: ' . ctags_cmd)
@@ -3043,7 +3122,7 @@ function! s:EscapeCtagsCmd(ctags_bin, args, ...)
if ctags_cmd == ''
echoerr 'Tagbar: Encoding conversion failed!'
\ 'Please make sure your system is set up correctly'
- \ 'and that Vim is compiled with the "iconv" feature.'
+ \ 'and that Vim is compiled with the "+iconv" feature.'
endif
return ctags_cmd
@@ -3053,7 +3132,7 @@ endfunction
" Execute ctags with necessary shell settings
" Partially based on the discussion at
" http://vim.1045645.n5.nabble.com/bad-default-shellxquote-in-Widows-td1208284.html
-function! s:ExecuteCtags(ctags_cmd)
+function! s:ExecuteCtags(ctags_cmd) abort
if exists('+shellslash')
let shellslash_save = &shellslash
set noshellslash
@@ -3082,14 +3161,18 @@ endfunction
" s:GetNearbyTag() {{{2
" Get the tag info for a file near the cursor in the current file
-function! s:GetNearbyTag(all)
+function! s:GetNearbyTag(all, ...) abort
let fileinfo = s:known_files.getCurrent()
if empty(fileinfo)
- return
+ return {}
endif
- let typeinfo = s:known_types[fileinfo.ftype]
- let curline = line('.')
+ let typeinfo = fileinfo.typeinfo
+ if a:0 > 0
+ let curline = a:1
+ else
+ let curline = line('.')
+ endif
let tag = {}
" If a tag appears in a file more than once (for example namespaces in
@@ -3099,8 +3182,9 @@ function! s:GetNearbyTag(all)
" highlighting isn't /that/ important ignore it for now.
for line in range(curline, 1, -1)
if has_key(fileinfo.fline, line)
- let tag = fileinfo.fline[line]
- if a:all || typeinfo.getKind(tag.fields.kind).stl
+ let curtag = fileinfo.fline[line]
+ if a:all || typeinfo.getKind(curtag.fields.kind).stl
+ let tag = curtag
break
endif
endif
@@ -3113,7 +3197,7 @@ endfunction
" Return the info dictionary of the tag on the specified line. If the line
" does not contain a valid tag (for example because it is empty or only
" contains a pseudo-tag) return an empty dictionary.
-function! s:GetTagInfo(linenr, ignorepseudo)
+function! s:GetTagInfo(linenr, ignorepseudo) abort
let fileinfo = s:known_files.getCurrent()
if empty(fileinfo)
@@ -3142,7 +3226,7 @@ function! s:GetTagInfo(linenr, ignorepseudo)
endfunction
" s:IsValidFile() {{{2
-function! s:IsValidFile(fname, ftype)
+function! s:IsValidFile(fname, ftype) abort
call s:LogDebugMessage('Checking if file is valid: ' . a:fname)
if a:fname == '' || a:ftype == ''
@@ -3150,7 +3234,7 @@ function! s:IsValidFile(fname, ftype)
return 0
endif
- if !filereadable(a:fname)
+ if !filereadable(a:fname) && getbufvar(a:fname, 'netrw_tmpfile') == ''
call s:LogDebugMessage('File not readable')
return 0
endif
@@ -3170,7 +3254,7 @@ function! s:IsValidFile(fname, ftype)
endfunction
" s:QuitIfOnlyWindow() {{{2
-function! s:QuitIfOnlyWindow()
+function! s:QuitIfOnlyWindow() abort
" Check if there is more than window
if winbufnr(2) == -1
" Check if there is more than one tab page
@@ -3186,7 +3270,7 @@ function! s:QuitIfOnlyWindow()
endfunction
" s:winexec() {{{2
-function! s:winexec(cmd)
+function! s:winexec(cmd) abort
call s:LogDebugMessage("Executing without autocommands: " . a:cmd)
let eventignore_save = &eventignore
@@ -3198,7 +3282,7 @@ function! s:winexec(cmd)
endfunction
" TagbarBalloonExpr() {{{2
-function! TagbarBalloonExpr()
+function! TagbarBalloonExpr() abort
let taginfo = s:GetTagInfo(v:beval_lnum, 1)
if empty(taginfo)
@@ -3209,7 +3293,7 @@ function! TagbarBalloonExpr()
endfunction
" TagbarGenerateStatusline() {{{2
-function! TagbarGenerateStatusline()
+function! TagbarGenerateStatusline() abort
if g:tagbar_sort
let text = '[Name]'
else
@@ -3226,7 +3310,7 @@ endfunction
" Debugging {{{1
" s:StartDebug() {{{2
-function! s:StartDebug(filename)
+function! s:StartDebug(filename) abort
if empty(a:filename)
let s:debug_file = 'tagbardebug.log'
else
@@ -3248,13 +3332,13 @@ function! s:StartDebug(filename)
endfunction
" s:StopDebug() {{{2
-function! s:StopDebug()
+function! s:StopDebug() abort
let s:debug = 0
let s:debug_file = ''
endfunction
" s:LogDebugMessage() {{{2
-function! s:LogDebugMessage(msg)
+function! s:LogDebugMessage(msg) abort
if s:debug
exe 'redir >> ' . s:debug_file
silent echon strftime('%H:%M:%S') . ': ' . a:msg . "\n"
@@ -3263,42 +3347,45 @@ function! s:LogDebugMessage(msg)
endfunction
" Autoload functions {{{1
-function! tagbar#ToggleWindow()
+
+" Wrappers {{{2
+function! tagbar#ToggleWindow() abort
call s:ToggleWindow()
endfunction
-function! tagbar#OpenWindow(...)
+function! tagbar#OpenWindow(...) abort
let flags = a:0 > 0 ? a:1 : ''
call s:OpenWindow(flags)
endfunction
-function! tagbar#CloseWindow()
+function! tagbar#CloseWindow() abort
call s:CloseWindow()
endfunction
-function! tagbar#SetFoldLevel(level, force)
+function! tagbar#SetFoldLevel(level, force) abort
call s:SetFoldLevel(a:level, a:force)
endfunction
-function! tagbar#OpenParents()
+function! tagbar#OpenParents() abort
call s:OpenParents()
endfunction
-function! tagbar#StartDebug(...)
+function! tagbar#StartDebug(...) abort
let filename = a:0 > 0 ? a:1 : ''
call s:StartDebug(filename)
endfunction
-function! tagbar#StopDebug()
+function! tagbar#StopDebug() abort
call s:StopDebug()
endfunction
-function! tagbar#RestoreSession()
+function! tagbar#RestoreSession() abort
call s:RestoreSession()
endfunction
+" }}}2
" tagbar#getusertypes() {{{2
-function! tagbar#getusertypes()
+function! tagbar#getusertypes() abort
redir => defs
silent execute 'let g:'
redir END
@@ -3316,13 +3403,14 @@ function! tagbar#getusertypes()
return defdict
endfunction
+" tagbar#autoopen() {{{2
" Automatically open Tagbar if one of the open buffers contains a supported
" file
-function! tagbar#autoopen(...)
+function! tagbar#autoopen(...) abort
call s:LogDebugMessage('tagbar#autoopen called on ' . bufname('%'))
let always = a:0 > 0 ? a:1 : 1
- call s:Init()
+ call s:Init(0)
for bufnr in range(1, bufnr('$'))
if buflisted(bufnr) && (always || bufwinnr(bufnr) != -1)
@@ -3340,21 +3428,66 @@ function! tagbar#autoopen(...)
\ 'without finding valid file')
endfunction
-function! tagbar#currenttag(fmt, default, ...)
- let longsig = a:0 > 0 ? a:1 : 0
+" tagbar#currenttag() {{{2
+function! tagbar#currenttag(fmt, default, ...) abort
+ if a:0 > 0
+ " also test for non-zero value for backwards compatibility
+ let longsig = a:1 =~# 's' || (type(a:1) == type(0) && a:1 != 0)
+ let fullpath = a:1 =~# 'f'
+ else
+ let longsig = 0
+ let fullpath = 0
+ endif
- if !s:Init()
- return ''
+ if !s:Init(1)
+ return a:default
endif
let tag = s:GetNearbyTag(0)
if !empty(tag)
- return printf(a:fmt, tag.strshort(longsig))
+ return printf(a:fmt, tag.str(longsig, fullpath))
else
return a:default
endif
endfunction
+" tagbar#gettypeconfig() {{{2
+function! tagbar#gettypeconfig(type) abort
+ if !s:Init(1)
+ return ''
+ endif
+
+ let typeinfo = get(s:known_types, a:type, {})
+
+ if empty(typeinfo)
+ echoerr 'Unknown type ' . a:type . '!'
+ return
+ endif
+
+ let output = "let g:tagbar_type_" . a:type . " = {\n"
+
+ let output .= " \\ 'kinds' : [\n"
+ for kind in typeinfo.kinds
+ let output .= " \\ '" . kind.short . ":" . kind.long
+ if kind.fold || !kind.stl
+ if kind.fold
+ let output .= ":1"
+ else
+ let output .= ":0"
+ endif
+ endif
+ if !kind.stl
+ let output .= ":0"
+ endif
+ let output .= "',\n"
+ endfor
+ let output .= " \\ ],\n"
+
+ let output .= "\\ }"
+
+ silent put =output
+endfunction
+
" Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
View
55 autoload/togglebg.vim