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

Comments not highlighting in some cases #26

Closed
BinaryMuse opened this issue Apr 13, 2015 · 1 comment
Closed

Comments not highlighting in some cases #26

BinaryMuse opened this issue Apr 13, 2015 · 1 comment

Comments

@BinaryMuse
Copy link

There are a few cases where comments do not highlight correctly. I'm not familiar enough with Vim syntax highlighting to really understand what's going on, but I was able to get my files highlighting with a couple small changes.

  1. Inside arrays

    let a = [
      1,
      2, // testing
      3, /* test */
      4
    ];

    index_jsx____minerva_schools_apps_student_enrollment_hub_client_prepare__-_vim

  2. Inside nested object literals where one of the values involves a function call with more than one dot. I found this when using React.PropTypes.shape({ ... }).

    let a = {
      b: a.b.c({
        key: "value" // test
      })
    };

    index_jsx____minerva_schools_apps_student_enrollment_hub_client_prepare__-_vim

    (Changing a.b.c to a.b makes this example work.)

  3. Inside the argument list to functions

    Math.floor(1, 2, /* test */ 3);
    Math.fllor(
      1,
      2, // test
      3
    );

    index_jsx____minerva_schools_apps_student_enrollment_hub_client_prepare__-_vim

I was able to fix 1. and 2. with the following changes, though I don't know if they're the correct changes:

diff --git a/syntax/javascript.vim b/syntax/javascript.vim
index ce42d24..a10628e 100644
--- a/syntax/javascript.vim
+++ b/syntax/javascript.vim
@@ -131,7 +131,7 @@ syntax match   javascriptTemplateSStringRB     /}/ contained
 syntax region  javascriptString                start=/\z(["']\)/  skip=/\\\\\|\\\z1\|\\\n/  end=/\z1\|$/ nextgroup=@javascriptSymbols skipwhite skipempty
 syntax region  javascriptTemplate              start=/`/  skip=/\\\\\|\\`\|\n/  end=/`\|$/ contains=javascriptTemplateSubstitution nextgroup=@javascriptSymbols skipwhite skipempty
 " syntax match   javascriptTemplateTag           /\k\+/ nextgroup=javascriptTemplate
-syntax region  javascriptArray                 matchgroup=javascriptBraces start=/\[/ end=/]/ contains=@javascriptValue,javascriptForComprehension nextgroup=@javascriptSymbols,@javascriptComments skipwhite skipempty
+syntax region  javascriptArray                 matchgroup=javascriptBraces start=/\[/ end=/]/ contains=@javascriptValue,javascriptForComprehension,@javascriptComments nextgroup=@javascriptSymbols,@javascriptComments skipwhite skipempty

 syntax match   javascriptNumber                /\<0[bB][01]\+\>/ nextgroup=@javascriptSymbols skipwhite skipempty
 syntax match   javascriptNumber                /\<0[oO][0-7]\+\>/ nextgroup=@javascriptSymbols skipwhite skipempty
@@ -249,7 +249,7 @@ syntax keyword javascriptExport                export module
 syntax region  javascriptBlock                 matchgroup=javascriptBraces start=/\([\^:]\s\*\)\=\zs{/ end=/}/ contains=@htmlJavaScript

 syntax region  javascriptMethodDef             contained start=/\(\(\(set\|get\)\_s\+\)\?\)[a-zA-Z_$]\k*\_s*(/ end=/)/ contains=javascriptMethodAccessor,javascriptMethodName,javascriptFuncArg nextgroup=javascriptBlock skipwhite keepend
-syntax region  javascriptMethodArgs            contained start=/(/ end=/)/ contains=javascriptFuncArg nextgroup=javascriptBlock skipwhite keepend
+syntax region  javascriptMethodArgs            contained start=/(/ end=/)/ contains=javascriptFuncArg,@javascriptComments nextgroup=javascriptBlock skipwhite keepend
 syntax keyword javascriptMethodAccessor        contained get set
 syntax match   javascriptMethodName            contained /[a-zA-Z_$]\k*/ nextgroup=javascriptMethodArgs skipwhite skipempty
 syntax region  javascriptMethodName            contained matchgroup=javascriptPropertyName start=/\[/ end=/]/ contains=@javascriptValue nextgroup=javascriptMethodArgs skipwhite skipempty
@othree othree closed this as completed in ed26082 Apr 14, 2015
@othree
Copy link
Owner

othree commented Apr 14, 2015

Thanks, there is a known issue about comment everywhere.
But these cases are critical cases.

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

No branches or pull requests

2 participants