feat: add Gleam language support via the Gleam compiler's bundled gleam lsp (#1765)

This commit is contained in:
weiconghe authored and GitHub committed 2026-08-08 19:44:27 +02:00
1 parent 8c1f3bcc98
commit 1d44e9cfab
17 files changed
+463 -3

No files matched your search

@@ -0,0 +1 @@
build/
@@ -0,0 +1,5 @@
name = "test_repo"
version = "1.0.0"
[dependencies]
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
@@ -0,0 +1,14 @@
# Do not manually edit this file, it is managed by Gleam.
#
# This file locks the dependency versions used, to make your build
# deterministic and to prevent unexpected versions from being included
# in your application.
#
# You should check this file into your source control repository.
packages = [
{ name = "gleam_stdlib", version = "1.0.3", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1F543AFBA5D33DA493E6087F4E4C4F20D899411343512686C98A8ABB2963CF22" },
]
[requirements]
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
@@ -0,0 +1,37 @@
import utils
/// A simple calculator type.
pub type Calculator {
Calculator(name: String)
}
/// Adds two integers and returns the result.
pub fn add(a: Int, b: Int) -> Int {
a + b
}
/// Subtracts b from a.
pub fn subtract(a: Int, b: Int) -> Int {
a - b
}
/// Multiplies two integers.
pub fn multiply(a: Int, b: Int) -> Int {
a * b
}
/// Formats the result of an operation using the utils module (cross-file reference).
pub fn format_result(label: String, value: Int) -> String {
utils.format_output(label, value)
}
/// Returns the description of a calculator.
pub fn describe(calc: Calculator) -> String {
"Calculator: " <> calc.name
}
/// Demonstrates calling add (same-file reference) and format_output (cross-file reference).
pub fn demo() -> String {
let sum = add(7, 8)
utils.format_output("sum", sum)
}
@@ -0,0 +1,5 @@
// This file intentionally contains a semantic error: `undefined_symbol` is not
// defined anywhere, so the Gleam language server reports a diagnostic for it.
pub fn broken() -> Int {
undefined_symbol
}
@@ -0,0 +1,12 @@
import gleam/int
import gleam/string
/// Formats a label and integer value into a human-readable string.
pub fn format_output(label: String, value: Int) -> String {
label <> ": " <> int.to_string(value)
}
/// Checks whether a string is non-empty.
pub fn is_non_empty(s: String) -> Bool {
!string.is_empty(s)
}