chrisbra/vim-zsh

Incorrect highlighting of commented out function definitions

Closed this issue · 3 comments

Hi,

The following is currently highlighted as a function definition rather than a comment.

#foo() {}

Thanks,
Doug

Hm, this comes from the fact that # is part of syn iskeyword setting. I don't know what pattern \k matches, so not sure how to remove # from the \k.

This patch fixes it and should work, but not sure whether this breaks anything else (and I do not use zsh syntax scripts that much to notice myself):

diff --git a/syntax/zsh.vim b/syntax/zsh.vim
index ddb19b5..7efacbd 100644
--- a/syntax/zsh.vim
+++ b/syntax/zsh.vim
@@ -78,7 +78,7 @@ syn keyword zshException        always
 syn keyword zshKeyword          function nextgroup=zshKSHFunction skipwhite

 syn match   zshKSHFunction      contained '\w\S\+'
-syn match   zshFunction         '^\s*\k\+\ze\s*()'
+syn match   zshFunction         '^\s*[^#]\+\k\+\ze\s*()'

 syn match   zshOperator         '||\|&&\|;\|&!\='

Hopefully this does not break anything.

fixed by 9bc3d31