elixir-editors / elixir-sublime-syntax

The most powerful Elixir for the most Sublime experience.
MIT License
47 stars 6 forks source link

Couple of improvements and fixes #2

Closed azizk closed 5 years ago

azizk commented 5 years ago

Hi!

I'm using Elixir every moment at work and would love to see improvements to the syntax highlighting definition. That's why I'm contributing these changes.

I hope to add a syntax test file soon in order to ensure a better quality and to avoid possible regressions when we modify the regular expressions.

Besides, what do you think about adopting the style of other syntax definition files like the one for Python in the PythonImproved package? Maybe that's the path we should take to make ours better and more ideal?

princemaple commented 5 years ago

Besides, what do you think about adopting the style of other syntax definition files like the one for Python in the PythonImproved package? Maybe that's the path we should take to make ours better and more ideal?

What do you mean exactly? I'm not quite sure what PythonImproved does that you are referring to specifically. Some examples might help.

FYI I have no intention messing with tmLanguage in my lifetime 😆 . There is https://github.com/elixir-editors/elixir-tmbundle for that.

princemaple commented 5 years ago

Hey @azizk , looks like you did not tick the allow maintainer to modify your code checkbox. You will have to commit the suggestions yourself. They look good 👍 .

azizk commented 5 years ago

Thanks for the review! I added my suggestions.

Of course, I don't want any tmLanguage XML craziness either. The PythonImproved package uses YAML. It looks very extensive, complete and well thought out. I don't know Sublime's syntax file format fully yet, but one main difference to Elixir.sublime-syntax is that PythonImproved mainly uses beginCaptures and endCaptures which may enable Sublime to actually parse the text into a proper syntax tree for more accurate and contextful highlighting, which is better than just having some semi-tree structure with flat areas where regexes match blindly more or less. It's fine in the beginning but it can definitely be improved.

azizk commented 5 years ago

Oh, but I think I did tick the box to allow changes by you. Don't know why it's not working.

I'll take a look again tomorrow. Until then!

princemaple commented 5 years ago

I'll take a look again tomorrow. Until then!

Thank you very much!

Of course, I don't want any tmLanguage XML craziness either. The PythonImproved package uses YAML. It looks very extensive, complete and well thought out. I don't know Sublime's syntax file format fully yet, but one main difference to Elixir.sublime-syntax is that PythonImproved mainly uses beginCaptures and endCaptures which may enable Sublime to actually parse the text into a proper syntax tree for more accurate and contextful highlighting, which is better than just having some semi-tree structure with flat areas where regexes match blindly more or less. It's fine in the beginning but it can definitely be improved.

Looks like it's just a yaml version of tm language. They probably got sick of XML and decided to write yaml first and compile to tmLanguage. I believe sublime-syntax is more superior and does mostly everything tmLanguage does and more. If you intend to stick with Sublime for the foreseeable future like I do, we should just write sublime-syntax. The Elixir syntax is converted from the tmLanguage version, which is done by Sublime itself. The definition is not optimal, I already know and have made improvements to it. Let's make it better together!

azizk commented 5 years ago

The definition is not optimal, I already know and have made improvements to it. Let's make it better together!

Yeah, let's do so! :)

I added one commit to fix the issue of matching numbers in function names like def 123() do end for example. While I was at it, I added a variable which should make the regex clearer.

princemaple commented 5 years ago

Thanks @azizk ! Merged.