Open aslilac opened 1 year ago
Here's a quick WIP I whipped up:
Prism.languages.gleam = {
doc: {
pattern: /\/\/\/\/?.*/,
greedy: true,
},
comment: {
pattern: /\/\/.*/,
greedy: true,
},
keyword:
/\b(use|case|if|external|fn|import|let|assert|try|pub|type|opaque|const|todo)\b/,
operator: {
pattern:
/(<-|->|\|>|<>|\.\.|<=\.?|>=\.?|==\.?|!=\.?|<\.?|>\.?|&&|\|\||\+\.?|-\.?|\/\.?|\*\.?|%\.?|=)/,
greedy: true,
},
string: {
pattern: /"(?:\\(?:\r\n|[\s\S])|(?!")[^\\\r\n])*"/,
greedy: true,
inside: {
punctuation: /\\./,
},
},
punctuation: /[.\\:,]/,
number:
/\b(?:0b[0-1]+|0o[0-7]+|[[:digit:]][[:digit:]_]*(\\.[[:digit:]]*)?|0x[[:xdigit:]]+)\b/,
boolean: /\b(?:True|False)\b/,
};
I'll need to test on some fuller Gleam example, though.
Here is an updated version of the grammar, though it accepts uppercase characters in function names which Gleam doesn't (need to fix): pastebin.
I see PrismJS isn't accepting PRs at the moment. I'll still fix this up and use it on my pastebin at https://nicd.gitlab.io/t/ in the meantime, so it'll be easy to take into use once v2 is out and it's accepting PRs again.
Language
Gleam is a statically typed programming language that can compile to JavaScript and Erlang
Additional resources
Website: https://gleam.run Source: https://github.com/gleam-lang/gleam Tree sitter grammar: https://github.com/gleam-lang/tree-sitter-gleam VSCode extension (w/ TextMate grammar): https://github.com/gleam-lang/vscode-gleam
It's also supported by Github's linguist (which just uses the VSCode/TextMate grammar)