Add Gleam syntax highlighting

This commit is contained in:
Wesley Moore 2024-02-20 20:46:22 +10:00
parent c5f5be6abe
commit c191d6efd9
No known key found for this signature in database
4 changed files with 44 additions and 3 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "v2/syntaxes/gleam"]
path = v2/syntaxes/gleam
url = https://github.com/digitalcora/sublime-text-gleam.git

View file

@ -19,6 +19,7 @@ build_search_index = false
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = true highlight_code = true
smart_punctuation = true smart_punctuation = true
extra_syntaxes_and_themes = ["syntaxes/gleam"]
[extra] [extra]
author = "Wesley Moore" author = "Wesley Moore"

View file

@ -35,10 +35,46 @@ maintained Elm without the restrictions on interop with existing JavaScript
code. code.
To get started here's some Gleam code that demonstrates a decent chunk of the To get started here's some Gleam code that demonstrates a decent chunk of the
language. My blog doesn't highlight Gleam code at the moment so what's shown language:
below is a picture. See [example.gleam](example.gleam) for the source file:
<img src="gleam-example.png" width="378" alt=""> ```gleam
import gleam/io
import gleam/list
import gleam/int
pub type Temperature {
F(Float)
C(Float)
}
pub type Celcius {
Celcius(Float)
}
pub fn main() {
let temps = [C(22.0), C(-5.0), F(0.0), C(0.0), F(32.0)]
io.debug(avg(temps))
}
pub fn avg(measurements: List(Temperature)) -> Celcius {
let sum =
list.fold(measurements, 0.0, fn(sum, val) {
let Celcius(c) = to_c(val)
sum +. c
})
let length =
list.length(measurements)
|> int.to_float
Celcius(sum /. length)
}
fn to_c(temp: Temperature) -> Celcius {
case temp {
C(c) -> Celcius(c)
F(f) -> Celcius({ f -. 32.0 } /. 1.8)
}
}
```
When run it outputs: When run it outputs:

1
v2/syntaxes/gleam Submodule

@ -0,0 +1 @@
Subproject commit 6c2080bf6039aa4c844086953d5aca49a7cd5ab6