-
Notifications
You must be signed in to change notification settings - Fork 1.3k
syntax: add Gleam language support #4045
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
Changes from 3 commits
e19c021
992f30c
aa2c965
b6657ad
5f594d1
c733704
6357c79
4367c87
3338524
fefa5d9
da797ea
0700b34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||||||
| filetype: gleam | ||||||||||
|
|
||||||||||
| detect: | ||||||||||
| filename: "\\.gleam$" | ||||||||||
|
|
||||||||||
| rules: | ||||||||||
| # 1. Base Identifier Rule (Must be first so specific types below overwrite it) | ||||||||||
| - identifier: "\\b[A-Z][a-zA-Z0-9_]*\\b" | ||||||||||
|
|
||||||||||
| # 2. Built-in Types (Overwrites the identifier rule for these exact matches; Nil removed) | ||||||||||
| - type: "\\b(Int|Float|String|Bool|List|Option|Result|BitArray)\\b" | ||||||||||
|
|
||||||||||
| # 3. Constants (Nil safely kept here) | ||||||||||
| - constant: "\\b(True|False|Nil)\\b" | ||||||||||
|
|
||||||||||
| # 4. Keywords | ||||||||||
| - statement: "\\b(fn|let|case|if|use|import|pub|type|opaque|const|as|assert|panic|todo|echo)\\b" | ||||||||||
|
|
||||||||||
| # 5. Attributes / Decorators (Added for @external, @deprecated, etc.) | ||||||||||
| - preproc: "@[a-zA-Z0-9_]+" | ||||||||||
|
|
||||||||||
| # 6. Operators (Moved to 'statement' for red highlighting; arithmetic, float math, and assignment added) | ||||||||||
| - statement: "(\\|>|->|<-|\\.\\.|<>|==|!=|<=|>=|&&|\\|\\||\\+\\.|-\\.|\\*\\.|/\\.|\\+|-|\\*|/|%|=|<|>)" | ||||||||||
|
|
||||||||||
| # 7. Numbers (Copied directly from Python's robust micro syntax as the maintainer requested) | ||||||||||
| - constant.number: "\\b0b[01]+\\b" | ||||||||||
| - constant.number: "\\b0o[0-7]+\\b" | ||||||||||
| - constant.number: "\\b0x[0-9a-fA-F]+\\b" | ||||||||||
| - constant.number: "\\b[0-9]+\\.[0-9]*([eE][+-]?[0-9]+)?\\b" | ||||||||||
| - constant.number: "\\b[0-9]+\\b" | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Contrary to what the comment claims these are not copied from Python, they're missing support for underscores. |
||||||||||
|
|
||||||||||
| # 8. Strings | ||||||||||
| - constant.string: | ||||||||||
| start: '"' | ||||||||||
| end: '"' | ||||||||||
| skip: "\\\\." | ||||||||||
|
|
||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @Andriamanitra, thanks again for the detailed feedback! I've made all the suggested changes:
HiwarkhedePrasad marked this conversation as resolved.
Outdated
|
||||||||||
| # 9. Comments | ||||||||||
| - comment: | ||||||||||
| start: "//" | ||||||||||
| end: "$" | ||||||||||
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.
I think this is too permissive. I'm not sure if Gleam even has anything besides
@externaland@deprecatedright now but if we follow vim's example we should only allow lowercase here: 1Footnotes
https://github.com/vim/vim/blob/e21c4a649a830716599eadebad04ddf2393230bc/runtime/syntax/gleam.vim#L65 ↩