Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Syntax highlighting] Vim comments are not detected correctly whenever a line has 2 double quotes #11560

Closed
Melandel opened this issue Nov 16, 2022 · 5 comments

Comments

@Melandel
Copy link

Steps to reproduce

  1. open your vimrc file
  2. write the lines
" Desktop Integration:-----------------{{{
" Plugins" ----------------------------{{{
" Graphical Layout:--------------------{{{
" Colorscheme, Highlight groups" ------{{{
  1. observe that the syntax highlighting is off

Expected behaviour

The written lines are highlighted as comments/commentLines

Version of Vim

9.0 with patch 1-887

Environment

gvim 64bits on Windows 10

Logs and stack traces

No response

@Melandel Melandel added the bug label Nov 16, 2022
@brammool
Copy link
Contributor

This was discussed before: the double quotes make the text look like a string (which would be valid in Vim9 script, but we don't know in what type of script this is).
Just change those double quotes to colons and it looks OK. Any reason you don't want to do that?

@cecamp
Copy link
Collaborator

cecamp commented Nov 17, 2022

That's because the syntax highlighting sees "..." and interprets that as a string. Get rid of the double quote following the words Plugins and groups so they don't appear to be strings.

@brammool
Copy link
Contributor

brammool commented Nov 17, 2022 via email

@chdiza
Copy link

chdiza commented Nov 17, 2022

See #11307, where @dkearns sketched a fix.

I still haven't seen a good reason why that extra double quote was there

Maybe not in the OP's particular example, but there is at least one good reason for this kind of thing: trailing comments, which are a real thing.

call SomeFunc() "Must do this or else XYZ

Obviously one might want to comment out the whole line for a variety of reasons. And if one does, the line ought to be highlighted as a comment.

@dkearns
Copy link
Contributor

dkearns commented Nov 17, 2022

That's because the syntax highlighting sees "..." and interprets that as a string. Get rid of the double quote following the words Plugins and groups so they don't appear to be strings.

I find that this highlighting issue turns up all the time and isn't really practical to work around. E.g., in comments with quotes and any commented out code with quotes (strings, patterns etc).

I appear to have some sort of fix for this as I haven't noticed the problem in some time.

It seems that, much as you described, I'm using regions for legacy and compiled functions and testing for "vim9script" when the syntax file is loaded. We could poll for that statement with the appropriate autocommands and then reload the syntax file or just clear and add the appropriate syntax groups?

I'm currently testing a similar strategy in my Vim filetype plugin to change option settings for Vim9 and legacy script regions. It seems to work alright with CursorHold but I wasn't sure if that was too complicated to distribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants