Vim wrong syntax highlighting in Groovy

南楼画角 提交于 2019-12-23 09:50:28

问题


when I do the single slash (/) when typing some arithmetic expression (like val1 / val2), my vim treats it as a comment for multiple lines (/*). The result looks like:

I now I can escape it by typing ;/ at the end of that line (which closes the comment), but it is still annoying and I'd like for my vim to behave properly :).

I've tried using another vim syntax highlighting package for groovy, I've tried :filetype plugin off in my .vimrc, I've tried purging vim with my settings and reinstalling it and the problem is still there.


回答1:


SOLUTION:

As pointed out by @cfrick, vim (my version: 7.4) treats '/' as beginning of regular expression in groovy. The solution is to edit

/usr/share/vim/vim74/syntax/groovy.vim

And around line 260-261 there is

syn region groovyString           start='/[^/]'  end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr

Just change the start to

start='/[^*/]'

Edit: changed space in regexp to * as @calid suggested in comment below

start='/[^ /]'

(that is add the space there.)

And now it looks much better. On the other hand it will now not highlight regexps starting with space, but for me it's okay. At least it's much better than what it was.

This helped mi a lot with finding my solution: Groovy syntax highlighting in Vim 7.4



来源:https://stackoverflow.com/questions/26518938/vim-wrong-syntax-highlighting-in-groovy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!