Permalink
Browse files

Create temporary fix for Tagbar segment

This update adds a wrapper function that checks if Tagbar is loaded
before trying to call `tagbar#currenttag()`. Unfortunately this only
works *after* Tagbar has been opened, so the Tagbar/current tag segment
will be empty until Tagbar has been opened for the first time.

Refs #152.
Refs majutsushi/tagbar#77.
1 parent 40048d2 commit 5948dd5bc28cf4dda75d8532fe4e35b1722353c0 @Lokaltog committed Jun 22, 2012
Showing with 12 additions and 1 deletion.
  1. +11 −0 autoload/Powerline/Functions/tagbar.vim
  2. +1 −1 autoload/Powerline/Segments/tagbar.vim
@@ -0,0 +1,11 @@
+function! Powerline#Functions#tagbar#GetTag() " {{{
+ " Wrapper function that checks if Tagbar is loaded to avoid errors when
+ " Tagbar is loaded after Powerline
+ let ret = ''
+
+ if exists('g:loaded_tagbar') && g:loaded_tagbar == 1
+ let ret = tagbar#currenttag('%s', '')
+ endif
+
+ return ret
+endfunction " }}}
@@ -1,5 +1,5 @@
let g:Powerline#Segments#tagbar#segments = Pl#Segment#Init(['tagbar',
\ (exists(':Tagbar') > 0),
\
- \ Pl#Segment#Create('currenttag', '%{tagbar#currenttag("%s", "")}', Pl#Segment#Modes('!N'))
+ \ Pl#Segment#Create('currenttag', '%{Powerline#Functions#tagbar#GetTag()}', Pl#Segment#Modes('!N'))
\ ])

0 comments on commit 5948dd5

Please sign in to comment.