nucleic / enaml

Declarative User Interfaces for Python
http://enaml.readthedocs.io/en/latest/
Other
1.53k stars 130 forks source link

Minor fixes to vim syntax highlighting #439

Closed adigitoleo closed 3 years ago

adigitoleo commented 3 years ago

This fixes spurrious highlighting of characters immediately preceding or following an enamlOperator. Also, the case of the notification operator :: followed by and EOL is now handled correctly. Lastly, the attr keyword is highlighted using the Define group (like python decorators, etc.)

codecov-io commented 3 years ago

Codecov Report

Merging #439 (918b111) into main (0c16693) will decrease coverage by 3.65%. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #439      +/-   ##
==========================================
- Coverage   73.44%   69.78%   -3.66%     
==========================================
  Files         313      313              
  Lines       23976    23713     -263     
==========================================
- Hits        17609    16548    -1061     
- Misses       6367     7165     +798     
MatthieuDartiailh commented 3 years ago

Could you share screenshots of the higlighting before and after the change ? I do not use vim personally and it would help me see if this patch makes vim highlighting closer to the other ones.

adigitoleo commented 3 years ago

Before

Default neovim colorscheme: 2021-02-06_225914_497970831

My colorscheme: 2021-02-06_225933_829690538


After

Default neovim colorscheme: 2021-02-06_230018_827965024

My colorscheme: 2021-02-06_230055_983403806


This code doesn't work: the syntax at the second button is broken. That is to show the "spurrious" highlighting with the current syntax file, which is something I discovered by accident. Mainly I'm just sharing this for the fix to the :: operator which can be followed by a newline (the original regex didn't check for this).

I thought I would add a definition for attr while I am at it. Now I realise that func could also deserve special treatment... Or I can forgo these if it's inconsistent with the other editor tools.

adigitoleo commented 3 years ago

In the new commit I have made attr and func use the same definition as enamldef, which looks consistent with python's class and def keywords, let me know what you think: 2021-02-06_233211_489622518

MatthieuDartiailh commented 3 years ago

That is looking good. Note that alias could use the same treatment as attr and func. Just for you to know here is how it looks for me under VS Code which is based on the Sublime text syntax highlighting. image

adigitoleo commented 3 years ago

Thanks for your time and help, I've added alias as a special keyword also.

There are other improvements that could be made (making special groups for the word after alias or attr as in the VScode example) but I'm not confident at adding it this time (I'd need to understand vim syntax highlighting files a bit more). If you want, we can wait for that, or just add these corrections first.

MatthieuDartiailh commented 3 years ago

The improvements you made are already quite nice so I will merge those now. And you are obviously welcome to make another PR later. Thanks for your contribution !