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

Improve tmlanguage #72

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Improve tmlanguage #72

wants to merge 8 commits into from

Conversation

u9g
Copy link

@u9g u9g commented Apr 22, 2024

Current Syntax Highlighting vs Syntax Highlighting with this PR

image
image

"name": "punctuation.gleam"
},
"3": {
"name": "entity.name.function.gleam"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be controversial to assume every Y in X.Y is a function, but we can do better if we can feed the data from ast into the syntax somehow like I believe rustanalyzer does, although I'm not sure

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the following:

let wibble = get_wibble() // <-- Wibble is blue
wibble.wobble             // <-- Wibble is green, wobble is yellow
wibble.wobble(wibble)     // <-- First wibble is green, second wibble is blue

(I see the GitHub highlighting has this same issue.)

This hints to the user that wibble is a module, which it is not, and that wobble is a function, which it might not be. I understand it's difficult if not impossible to make the distinction. But I fear that the variable changing colour when it is used could be confusing.

I might be the only one with this opinion so don't take it too strongly yet.

"include": "#dot_expressions"
},
{
"include": "#any_string_of_lowercase_text_with_underscore_and_number"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a better name for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Suggested change
"include": "#any_string_of_lowercase_text_with_underscore_and_number"
"include": "#lowercase_text_with_underscore_and_number"

@Nicd
Copy link

Nicd commented Apr 22, 2024

In the import lists, the final module name is blue, but in the body modules are green and variables are blue. Could the modules use the same colour?

@lpil
Copy link
Member

lpil commented Apr 24, 2024

Hello! Could you explain what improvements you're looking to implement here. Thank you

@u9g
Copy link
Author

u9g commented Apr 24, 2024

Hello! Could you explain what improvements you're looking to implement here. Thank you

Hi, absolutely.

  1. select base object that function is called on, so that in int.to_string(), int is also highlighted (as a class) ba074fd
  2. add syntax highlighting for entire import lines, so that not just import is highlighted, now actual gleam/int is also highlighted 9e7c42c
  3. add coloring to let statements, which means that we now highlight this: let [identifier is highlighted] = 2014e3f
  4. highlight any string of lowercase text with underscore and numbers, which removes a lot of white by highlighting variable references 8d94528
  5. add dot expression support player.get_name is now highlighted as player[type].get_name[function] (without knowing whether it's a function or not, it's just a nice default. This feels much more right since std.now() is highlighted the same way, but player.get_name wasn't being highlighted because it's not being called. b429ca8

@lpil
Copy link
Member

lpil commented Apr 25, 2024

Sorry, what I mean is what are you aiming to improve by adding these colours? To me now that most everything has colour nothing in particular stands out.

@u9g
Copy link
Author

u9g commented May 4, 2024

Sorry, what I mean is what are you aiming to improve by adding these colours? To me now that most everything has colour nothing in particular stands out.

For some people, having the color is instrumental in being able to at a glance understand what code is doing. I think this is a net improvement considering we already have some syntax highlighting and you can code without the extension if you think that adding colors distracts from the code.

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

Successfully merging this pull request may close these issues.

None yet

4 participants