ganezdragon / tree-sitter-perl

a perl parser for javascript
MIT License
33 stars 9 forks source link

Syntax highlighting breaks with Mojolicious. #9

Closed marcelarie closed 1 year ago

marcelarie commented 3 years ago

The syntax breaks in multiple files. Here is the original issue I opened at nvim-treesitter Peek 2021-09-27 12-31

And the regex:

    $tx->res->dom =~ m!"changeLocation":\{"menu":\{"label":\["[^"]+","([0-9]+)"\]\}! && $1;

it happens the same with lines like this

    if ( my $variations_script = $dom->at( '#twisterJsInitializer_feature_div script' ) ) {

where the # breaks the syntax.

I use the last version of nvim nightly and Mojolicious to work with perl. It seems that the problems are related with the syntax of the library.

ganezdragon commented 3 years ago

@marcelarie Thanks for reporting. And yes, this is a issue with grammar. Let me try to fix it this week!

xse commented 2 years ago

Hey, might be the same issue where the commented # makes "username" blue there: 2021-11-21 23_35_33-OpenSSH SSH client

and without comment: 2021-11-21 23_36_34-OpenSSH SSH client

my %config = (
  "foo", {
    "url",  "http://foo.bar",
    "port", "8088", # 8080 default
    "api_key", "",
    "username", "",
    "password", "",
  },
);

have a good day!

marcelarie commented 2 years ago

The syntax breaks in multiple files. Here is the original issue I opened at nvim-treesitter Peek 2021-09-27 12-31

And the regex:

   $tx->res->dom =~ m!"changeLocation":\{"menu":\{"label":\["[^"]+","([0-9]+)"\]\}! && $1;

it happens the same with lines like this

    if ( my $variations_script = $dom->at( '#twisterJsInitializer_feature_div script' ) ) {

where the # breaks the syntax.

I use the last version of nvim nightly and Mojolicious to work with perl. It seems that the problems are related with the syntax of the library.

This still happens. but the # issue does not anymore. :)

ganezdragon commented 2 years ago

yea the # issue shouldn't happen, or atleast now!

But I'm still working on the regex based patterns in perl. Should release the version soon :)

marcelarie commented 2 years ago

Thanks for the work, I can't wait.

ganezdragon commented 2 years ago

I have publish version 0.3.0 . This should parse all these syntax properly. Let me know otherwise. :)

marcelarie commented 2 years ago

The m! syntax is fixed :) Now I realized of the qr// highlight error: qr-tsperl

if it's needed I can make a separate issue for that one.

ganezdragon commented 2 years ago

@marcelarie , could you paste the expression here ? I can take a look at what's failing.

marcelarie commented 2 years ago

@marcelarie , could you paste the expression here ? I can take a look at what's failing.

Of course, there you go:

  qr/^@{[ $self->merchant_name ]}$/i
# ^ q making the trouble (?)
  m!"changeLocation":\{"menu":\{"label":\["[^"]+","([0-9]+)"\]\}!
# ^ m making the trouble (?)
  $brand =~ s/^de //;
#           ^ s making the trouble (?)
ganezdragon commented 2 years ago

@marcelarie the above patter matcher syntax should be fixed in the latest commit. I will wait around and run some test before publishing the next npm version

marcelarie commented 2 years ago

@marcelarie the above patter matcher syntax should be fixed in the latest commit. I will wait around and run some test before publishing the next npm version

nice, thank you!!

brneor commented 2 years ago

split(/ *, */,$Var) also breaks syntax highlighting, among other patterns that I couldn't identify yet. Sometimes it only breaks partialy, changing colors only for a sub name, eg.

ganezdragon commented 1 year ago

split(/ *, */,$Var) works as expected. And I see the original issue reported here is also fixed. So closing this issue.