Note
This repo uses l-lang, a simple statically-typed programming language with structs, functions, and expressions.
Tip
If you want a chumsky based language implementation, please check out the tag v1.0.0
struct Point {
x: int,
y: int,
}
struct Rectangle {
top_left: Point,
bottom_right: Point,
}
fn add_points(a: Point, b: Point) -> Point {
return Point { x: a.x + b.x, y: a.y + b.y };
}
fn main() {
let p1 = Point { x: 10, y: 20 };
let p2 = Point { x: 5, y: 15 };
let result = add_points(p1, p2);
let rect = Rectangle {
top_left: Point { x: 0, y: 100 },
bottom_right: Point { x: 100, y: 0 },
};
return result;
}L-lang is a statically-typed language that supports:
- Struct definitions with typed fields
- Functions with typed parameters and return types
- Variable bindings with type inference
- Arithmetic operations (+, -, *, /)
- Field access for structs
- Struct literals for instantiation
- Basic types:
int,bool,string
This repo is a template for building Language Server Protocol (LSP) implementations using tower-lsp, demonstrating how to create language servers with full IDE support.
pnpm icargo build- Open the project in VSCode:
code . - In VSCode, press F5 or change to the Debug panel and click Launch Client.
- In the newly launched VSCode instance, open the file
examples/test.lfrom this project. - If the LSP is working correctly you should see syntax highlighting and the features described below should work.
Note
If encountered errors like Cannot find module '/xxx/xxx/dist/extension.js'
please try run command tsc -b manually, you could refer #6 for more details
- Make sure all dependency are installed.
- Make sure the
l-language-serveris under yourPATH pnpm run packagecode --install-extension l-language-server-${version}.vsix, theversionyou could inspect in file system.- Restart the
VsCode, and write a minimalLfile, then inspect the effect.
For other editor, please refer the related manual, you could skip steps above.
This Language Server Protocol implementation for l-lang provides comprehensive IDE support with the following features:
Syntax highlighting based on semantic analysis. Functions, variables, parameters, structs, and fields are highlighted according to their semantic roles.
Make sure semantic highlighting is enabled in your editor settings:
{
"editor.semanticHighlighting.enabled": true
}Type annotations for variables.
inlay_hint_compressed.mp4
Real-time error reporting.
diagnostic_compressed.mp4
Context-aware suggestions for symbols.
completion_compressed.mp4
Navigate to symbol declarations.
definition_compressed.mp4
Locate all usages of a symbol.
reference_compressed.mp4
Rename symbols across the entire codebase.