From 8e5ce3a3e59dca55e6ba5e841ded67120bbb0819 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 22 Dec 2011 18:06:48 +1300 Subject: [PATCH] Replace usearrows with iconchars --- autoload/tagbar.vim | 13 ++--------- doc/tagbar.txt | 25 +++++++++++---------- plugin/tagbar.vim | 9 ++++++-- syntax/tagbar.vim | 53 +++++++++++++++++++++------------------------ 4 files changed, 47 insertions(+), 53 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index a8512c3..5014f8d 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -73,17 +73,8 @@ if s:ftype_out !~# 'detection:ON' endif unlet s:ftype_out -if has('multi_byte') && has('unix') && &encoding == 'utf-8' && - \ (empty(&termencoding) || &termencoding == 'utf-8') - let s:icon_closed = '▶' - let s:icon_open = '▼' -elseif has('multi_byte') && (has('win32') || has('win64')) && g:tagbar_usearrows - let s:icon_closed = '▷' - let s:icon_open = '◢' -else - let s:icon_closed = '+' - let s:icon_open = '-' -endif +let s:icon_closed = g:tagbar_iconchars[0] +let s:icon_open = g:tagbar_iconchars[1] let s:type_init_done = 0 let s:autocommands_done = 0 diff --git a/doc/tagbar.txt b/doc/tagbar.txt index ae33cb6..e459bee 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -421,21 +421,22 @@ Example: let g:tagbar_foldlevel = 2 < - *g:tagbar_usearrows* -g:tagbar_usearrows~ -{Windows only} -Default: 0 + *g:tagbar_iconchars* +g:tagbar_iconchars~ -Tagbar can display nice Unicode arrows instead of +/- characters as fold icons. -However, Windows doesn't seem to be able to substitute in characters from -other fonts if the current font doesn't support them. This means that you have -to use a font that supports those arrows. Unfortunately there is no way to -detect whether specific characters are supported in the current font. So if -your font supports those arrows you have to set this option to make it work. +Since the display of the icons used to indicate open or closed folds depends +on the actual font used, different characters may be optimal for different +fonts. With this variable you can set the icons to characters of your liking. +The first character in the list specifies the icon to use for a closed fold, +and the second one for an open fold. -Example: +Examples (don't worry if some the characters aren't displayed correctly, just +choose other characters in that case): > - let g:tagbar_usearrows = 1 + let g:tagbar_iconchars = ['▶', '▼'] (default on Linux and Mac OS X) + let g:tagbar_iconchars = ['▾', '▸'] + let g:tagbar_iconchars = ['▷', '◢'] + let g:tagbar_iconchars = ['+', '-'] (default on Windows) < *g:tagbar_autoshowtag* diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 35b3bac..5704d93 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -78,8 +78,13 @@ if !exists('g:tagbar_foldlevel') let g:tagbar_foldlevel = 99 endif -if !exists('g:tagbar_usearrows') - let g:tagbar_usearrows = 0 +if !exists('g:tagbar_iconchars') + if has('multi_byte') && has('unix') && &encoding == 'utf-8' && + \ (empty(&termencoding) || &termencoding == 'utf-8') + let g:tagbar_iconchars = ['▶', '▼'] + else + let g:tagbar_iconchars = ['+', '-'] + endif endif if !exists('g:tagbar_autoshowtag') diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index 89458fd..2c76280 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -11,35 +11,32 @@ if exists("b:current_syntax") finish endif -if has('multi_byte') && has('unix') && &encoding == 'utf-8' && - \ (empty(&termencoding) || &termencoding == 'utf-8') - syntax match TagbarKind '\([▶▼] \)\@<=[^-+: ]\+[^:]\+$' - syntax match TagbarScope '\([▶▼][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@=' - - syntax match TagbarFoldIcon '[▶▼]\([-+# ]\)\@=' - - syntax match TagbarAccessPublic '\([▶▼ ]\)\@<=+\([^-+# ]\)\@=' - syntax match TagbarAccessProtected '\([▶▼ ]\)\@<=#\([^-+# ]\)\@=' - syntax match TagbarAccessPrivate '\([▶▼ ]\)\@<=-\([^-+# ]\)\@=' -elseif has('multi_byte') && (has('win32') || has('win64')) && g:tagbar_usearrows - syntax match TagbarKind '\([▷◢] \)\@<=[^-+: ]\+[^:]\+$' - syntax match TagbarScope '\([▷◢][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@=' - - syntax match TagbarFoldIcon '[▷◢]\([-+# ]\)\@=' - - syntax match TagbarAccessPublic '\([▷◢ ]\)\@<=+\([^-+# ]\)\@=' - syntax match TagbarAccessProtected '\([▷◢ ]\)\@<=#\([^-+# ]\)\@=' - syntax match TagbarAccessPrivate '\([▷◢ ]\)\@<=-\([^-+# ]\)\@=' -else - syntax match TagbarKind '\([-+] \)\@<=[^-+: ]\+[^:]\+$' - syntax match TagbarScope '\([-+][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@=' - - syntax match TagbarFoldIcon '[-+]\([-+# ]\)\@=' - - syntax match TagbarAccessPublic '\([-+ ]\)\@<=+\([^-+# ]\)\@=' - syntax match TagbarAccessProtected '\([-+ ]\)\@<=#\([^-+# ]\)\@=' - syntax match TagbarAccessPrivate '\([-+ ]\)\@<=-\([^-+# ]\)\@=' +let s:ic = g:tagbar_iconchars[0] +if s:ic =~ '[]^\\-]' + let s:ic = '\' . s:ic endif +let s:io = g:tagbar_iconchars[1] +if s:io =~ '[]^\\-]' + let s:io = '\' . s:io +endif + +let s:pattern = '\([' . s:ic . s:io . '] \)\@<=[^-+: ]\+[^:]\+$' +execute "syntax match TagbarKind '" . s:pattern . "'" + +let s:pattern = '\([' . s:ic . s:io . '][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@=' +execute "syntax match TagbarScope '" . s:pattern . "'" + +let s:pattern = '[' . s:ic . s:io . ']\([-+# ]\)\@=' +execute "syntax match TagbarFoldIcon '" . s:pattern . "'" + +let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=+\([^-+# ]\)\@=' +execute "syntax match TagbarAccessPublic '" . s:pattern . "'" +let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=#\([^-+# ]\)\@=' +execute "syntax match TagbarAccessProtected '" . s:pattern . "'" +let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=-\([^-+# ]\)\@=' +execute "syntax match TagbarAccessPrivate '" . s:pattern . "'" + +unlet s:pattern syntax match TagbarNestedKind '^\s\+\[[^]]\+\]$' syntax match TagbarComment '^".*'