martinda/Jenkinsfile-vim-syntax

Incorrect comment higlighting inside sh block

ftorres16 opened this issue · 5 comments

When using a Jenkinsfile that includes an sh block in which the /* character combination is used the remaining of the file is highlighted as a comment instead of as actual code.

This particular snippet is valid Jenkins syntax but gets everything after mv reports-python/* considered a comment.

            post {
              always {
                sh '''
                echo "Tests generated"
                mv reports-python/* reports
                '''
              }
            }

@ftorres16 - which version of Vim are you using, and what's the output of :scriptnames when editing the Jenkinsfile in question? I pasted your example into a Jenkinsfile and it gets highlighted correctly. I'm wondering if there was either an update to the built-in groovy highlighting or if there's something configured weirdly on your system. It may be worth disabling all of your plugins except Jenkinsfile-vim-syntax and checking if the issue persists. There may be another plugin that interacts poorly with this one.

It works correctly on the latest version of macvim that can be currently installed with Homebrew...

$ mvim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 30 2019 23:05:43)
macOS version
Included patches: 1-2234
Compiled by Homebrew

...as well as on the version of vim that comes with macOS 10.14:

$ /usr/bin/vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 19 2019 19:08:44)
Included patches: 1-503, 505-680, 682-1283, 1365
Compiled by root@apple.com

:scriptnames yields:

  1: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/vimrc
  2: ~/.vimrc
  3: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/ftoff.vim
  4: ~/.vim/autoload/pathogen.vim
  5: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
  6: ~/.vim/bundle/Jenkinsfile-vim-syntax/ftdetect/Jenkinsfile.vim
  7: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/menu.vim
  8: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/autoload/paste.vim
  9: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/ftplugin.vim
 10: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/indent.vim
 11: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
 12: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/synload.vim
 13: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/syncolor.vim
 14: ~/.vim/plugin/cscope_maps.vim
 15: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/getscriptPlugin.vim
 16: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/gzip.vim
 17: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/logiPat.vim
 18: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/manpager.vim
 19: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
 20: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
 21: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/rrhelper.vim
 22: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/spellfile.vim
 23: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/tarPlugin.vim
 24: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/tohtml.vim
 25: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
 26: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/plugin/zipPlugin.vim
 27: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/gvimrc
 28: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/colors/macvim.vim
 29: ~/.gvimrc
 30: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/scripts.vim
 31: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/ftplugin/groovy.vim
 32: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/groovy.vim
 33: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/html.vim
 34: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/javascript.vim
 35: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/vb.vim
 36: /usr/local/Cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/syntax/css.vim
 37: ~/.vim/bundle/Jenkinsfile-vim-syntax/indent/Jenkinsfile.vim
 38: ~/.vim/bundle/Jenkinsfile-vim-syntax/syntax/Jenkinsfile.vim

The highlighting looks correct to me as well.

@mplough I am using this through sheerun/vim-polyglotvim-polyglot.

fabian@fabian-pc: ~ $ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov  7 2019 22:30:47)
Included patches: 1-2268
Compiled by Arch Linux

Also, the same issue happened on my work machine with vim8.1 and Ubuntu 18.04

When editing the file with vim, :scriptnames returns the following:

 1: /etc/vimrc
 2: /usr/share/vim/vimfiles/archlinux.vim
 3: ~/.vimrc
 4: /usr/share/vim/vim81/filetype.vim
 5: /usr/share/vim/vimfiles/ftdetect/PKGBUILD.vim
 6: /usr/share/vim/vim81/ftplugin.vim
 7: /usr/share/vim/vim81/indent.vim
 8: ~/.vim/autoload/plug.vim
 9: /usr/share/vim/vim81/ftoff.vim
10: ~/.vim/plugged/vim-polyglot/ftdetect/polyglot.vim
11: /usr/share/vim/vim81/syntax/syntax.vim
12: /usr/share/vim/vim81/syntax/synload.vim
13: /usr/share/vim/vim81/syntax/syncolor.vim
14: /usr/share/vim/vim81/syntax/nosyntax.vim
15: /usr/share/vim/vimfiles/plugin/fzf.vim
16: /usr/share/vim/vim81/plugin/getscriptPlugin.vim
17: /usr/share/vim/vim81/plugin/gzip.vim
18: /usr/share/vim/vim81/plugin/logiPat.vim
19: /usr/share/vim/vim81/plugin/manpager.vim
20: /usr/share/vim/vim81/plugin/matchparen.vim
21: /usr/share/vim/vim81/plugin/netrwPlugin.vim
22: /usr/share/vim/vim81/plugin/rrhelper.vim
23: /usr/share/vim/vim81/plugin/spellfile.vim
24: /usr/share/vim/vim81/plugin/tarPlugin.vim
25: /usr/share/vim/vim81/plugin/tohtml.vim
26: /usr/share/vim/vim81/plugin/vimballPlugin.vim
27: /usr/share/vim/vim81/plugin/zipPlugin.vim
28: /usr/share/vim/vim81/scripts.vim
29: ~/.vim/plugged/vim-polyglot/indent/Jenkinsfile.vim
30: ~/.vim/plugged/vim-polyglot/indent/groovy.vim
31: ~/.vim/plugged/vim-polyglot/syntax/Jenkinsfile.vim
32: ~/.vim/plugged/vim-polyglot/syntax/groovy.vim
33: ~/.vim/plugged/vim-polyglot/syntax/html.vim
34: /usr/share/vim/vim81/syntax/html.vim
35: ~/.vim/plugged/vim-polyglot/syntax/javascript.vim
36: /usr/share/vim/vim81/syntax/javascript.vim
37: ~/.vim/plugged/vim-polyglot/after/syntax/javascript.vim
38: ~/.vim/plugged/vim-polyglot/after/syntax/jsx_pretty.vim
39: /usr/share/vim/vim81/syntax/vb.vim
40: /usr/share/vim/vim81/syntax/css.vim
41: ~/.vim/plugged/vim-polyglot/after/syntax/html.vim

@ftorres16 I reproduced the bad highlighting behavior with vim-polyglot's current master, sheerun/vim-polyglot@e8454d6. Jenkinsfile-vim-syntax has no issue; the issue is with vim-polyglot's Groovy highlighting.

Your installation is using vim-polyglot's Groovy highlighting rather than Vim's built-in highlighting, as shown on line 32:

32: ~/.vim/plugged/vim-polyglot/syntax/groovy.vim

If you set filetype=groovy with vim-polyglot installed, the Jenkinsfile-vim-syntax plugin is not used at all and the bad highlighting persists.

There are a couple of options available:

  • Nuke vim-polyglot and install Jenkinsfile-vim-syntax directly. This will use Vim's the built-in Groovy highlighting and make the issue disappear.
  • File an issue with vim-polyglot. It's using https://github.com/vim-scripts/groovy.vim from 2004 for Groovy highlighting.

@martinda we've reproduced the issue and have shown that there is no problem with Jenkinsfile-vim-syntax. It may be worth making a note in the repo README that vim-polyglot's Groovy highlighting is broken and that using it isn't recommended.

Thanks!