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
Add custom exe path, icons, and improve syntax highlighting #30
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! This is brilliant, thank you. And thanks for waiting while I have been on holiday.
Ive left one question in line
Hi @myleslinder , shall I pick this PR up from you? |
@lpil sorry for the radio silence, I can get this over the finish line this week. Are there any other changes you need aside from not styling the prelude types differently? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @myleslinder ! Slow for the slow reply, I quit my job and then immediately fell unwell 😷
That sounds great to me!
@lpil made the changes you requested and added the |
} | ||
}, | ||
{ | ||
"match": "(?:{| |, |\\/|\\.|\\[|\\()(\\.\\.)*(?!\\bas\\b|\\blet\\b|\\bfn\\b|\\buse\\b|\\bconst\\b|\\bcase\\b|\\btry\\b|\\bassert\\b|\\bif\\b|\\bopaque\\b|\\bexternal\\b|\\btype\\b|\\b_+\\w*\\b|\\blet _+\\w*\\b)(\\w+\\()*([a-z_]+)(?!\\/|\\(|:)\\b", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since try
is no longer a keyword:
"match": "(?:{| |, |\\/|\\.|\\[|\\()(\\.\\.)*(?!\\bas\\b|\\blet\\b|\\bfn\\b|\\buse\\b|\\bconst\\b|\\bcase\\b|\\btry\\b|\\bassert\\b|\\bif\\b|\\bopaque\\b|\\bexternal\\b|\\btype\\b|\\b_+\\w*\\b|\\blet _+\\w*\\b)(\\w+\\()*([a-z_]+)(?!\\/|\\(|:)\\b", | |
"match": "(?:{| |, |\\/|\\.|\\[|\\()(\\.\\.)*(?!\\bas\\b|\\blet\\b|\\bfn\\b|\\buse\\b|\\bconst\\b|\\bcase\\b|\\bassert\\b|\\bif\\b|\\bopaque\\b|\\bexternal\\b|\\btype\\b|\\b_+\\w*\\b|\\blet _+\\w*\\b)(\\w+\\()*([a-z_]+)(?!\\/|\\(|:)\\b", |
}, | ||
{ | ||
"name": "keyword.control.trycatch.gleam", | ||
"match": "\\b(try|assert)\\b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since try
is no longer a language keyword:
"match": "\\b(try|assert)\\b" | |
"match": "\\b(assert)\\b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call it assertion
or something rather than trycatch
?
} | ||
}, | ||
{ | ||
"match": "(\"\\w+(?:\\/*\\w+\\.{1}(?:js|mjs|cjs)+)*\") (\"\\w+\")", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
}, | ||
{ | ||
"name": "keyword.control.trycatch.gleam", | ||
"match": "\\b(try|assert)\\b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call it assertion
or something rather than trycatch
?
Could the custom PATH changes be perhaps pulled into a separate PR to make it easier to review? I'm particularly interested in this feature. Let me know if I could pick that up, if that'd be interesting. |
Love your work on the language so far. I had some syntax highlighting issues with my theme so took a stab at making some updates and tried to address some open issues in the process. Let me know if there's any issues or you need any updates.
Custom Path
Should close #26
Added a setting to change the path to the Gleam executable. By default, it looks for it in the PATH, but if the setting has a value it will use the path specified instead.
I've set the scope to
machine
as it seems to be what is recommended in the configuration schema docsIf an executable can't be found at the path an error dialog is shown to the user.
Default Formatter
I've set the default formatter in the configuration so users won't have to set that themselves.
Language Icons
I added these icons before I noticed that PR #29 already exists so apologies for the duplication. The icons are svgs and using the black for light themes and pink for dark themes.
Syntax Highlighting
This may close #24 as if the variable name starts with an
_
I've set it to besource.ignore
which is a scope themes often target and even if they don't it will be stylized differently than regular variables. As far as I could see there's no way to accomplish the reduced opacity in the grammar and other languages I checked out (Go and TS) both don't have reduced opacity when the unused variable is ignored with the_
prefix.I set up a number of new matches for different parts of the grammar and split out most of the keywords into their own patterns to the most accurate scope that themes are likely to target. I ran into some issues with proper scope assignment on the outer function names in the case of multiple nested function calls that are the formatter doesn't split across multiple lines and that don't use the pipe operator (e.g.
f(f(x))
).High level overview of the changes:
todo
is identified as a system provided function.
, and,
are indicated as punctuation scopesas
,#
,:
Nil
is scoped as anull
import
keyword, a name if applicable (e.g. in gleam/io, gleam is scoped as the import name), and variables for the usable values. The entire import statement is scoped as well.case
, function calls, etc