From 87d293206b0dbac7ef8b8e3a12c3698da6f7ad9c Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 12 Apr 2013 20:48:08 +0200 Subject: [PATCH 1/4] Simplify conversion of g:tagbar_iconchars into regexp. With join() and escape(), the steps can be simplified. --- syntax/tagbar.vim | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index df53682..34e2f69 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -11,29 +11,21 @@ if exists("b:current_syntax") finish endif -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 . '] \?\)\@<=[^-+: ]\+[^:]\+$' +let s:ics= escape(join(g:tagbar_iconchars, ''), ']^\-') +let s:pattern = '\([' . s:ics . '] \?\)\@<=[^-+: ]\+[^:]\+$' execute "syntax match TagbarKind '" . s:pattern . "'" -let s:pattern = '\([' . s:ic . s:io . '][-+# ]\?\)\@<=[^*(]\+\(\*\?\(([^)]\+)\)\? :\)\@=' +let s:pattern = '\([' . s:ics . '][-+# ]\?\)\@<=[^*(]\+\(\*\?\(([^)]\+)\)\? :\)\@=' execute "syntax match TagbarScope '" . s:pattern . "'" -let s:pattern = '[' . s:ic . s:io . ']\([-+# ]\?\)\@=' +let s:pattern = '[' . s:ics . ']\([-+# ]\?\)\@=' execute "syntax match TagbarFoldIcon '" . s:pattern . "'" -let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=+\([^-+# ]\)\@=' +let s:pattern = '\([' . s:ics . ' ]\)\@<=+\([^-+# ]\)\@=' execute "syntax match TagbarVisibilityPublic '" . s:pattern . "'" -let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=#\([^-+# ]\)\@=' +let s:pattern = '\([' . s:ics . ' ]\)\@<=#\([^-+# ]\)\@=' execute "syntax match TagbarVisibilityProtected '" . s:pattern . "'" -let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=-\([^-+# ]\)\@=' +let s:pattern = '\([' . s:ics . ' ]\)\@<=-\([^-+# ]\)\@=' execute "syntax match TagbarVisibilityPrivate '" . s:pattern . "'" unlet s:pattern From 32b5b15b525d5c0d6047f8d118c860217bbd4177 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 12 Apr 2013 21:14:23 +0200 Subject: [PATCH 2/4] FIX: Avoid that the sigils used for highlighting match inside a tag. When there's a tag e.g. "foo-bar", the "-bar" part is matched as TagbarKind. Add a zero-width condition to all sigil patterns that allow only whitespace characters before the sigil. --- syntax/tagbar.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index 34e2f69..58634b1 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -12,20 +12,20 @@ if exists("b:current_syntax") endif let s:ics= escape(join(g:tagbar_iconchars, ''), ']^\-') -let s:pattern = '\([' . s:ics . '] \?\)\@<=[^-+: ]\+[^:]\+$' +let s:pattern = '\(\S\@ Date: Fri, 12 Apr 2013 21:22:27 +0200 Subject: [PATCH 3/4] FIX: Avoid matching public / private methods as TagbarKind. When g:tagbar_iconchars = ['+', '-'] (default on Windows), and viewing a filetype (e.g. java) that has visibility information (i.e. the [-+#] sigils), the method is mistakenly highlighted as TagbarKind. Restrict its matches to when the sigil is at the beginning of the line to avoid the false matches at the indented method tags. --- syntax/tagbar.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index 58634b1..509453c 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -12,7 +12,7 @@ if exists("b:current_syntax") endif let s:ics= escape(join(g:tagbar_iconchars, ''), ']^\-') -let s:pattern = '\(\S\@ Date: Wed, 24 Apr 2013 11:33:30 +1200 Subject: [PATCH 4/4] Fix TagbarScope pattern --- syntax/tagbar.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index 509453c..ce5bf45 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -8,14 +8,14 @@ scriptencoding utf-8 if exists("b:current_syntax") - finish + finish endif -let s:ics= escape(join(g:tagbar_iconchars, ''), ']^\-') +let s:ics = escape(join(g:tagbar_iconchars, ''), ']^\-') let s:pattern = '\(^[' . s:ics . '] \?\)\@<=[^-+: ]\+[^:]\+$' execute "syntax match TagbarKind '" . s:pattern . "'" -let s:pattern = '\(\S\@