feat: implement LSP server for IDE integration

Add a Language Server Protocol (LSP) server to enable IDE integration.
The server provides:

- Real-time diagnostics (parse errors and type errors)
- Basic hover information
- Keyword completions (fn, let, if, match, type, effect, etc.)
- Go-to-definition stub (ready for implementation)

Usage: lux --lsp

The LSP server can be integrated with any editor that supports LSP,
including VS Code, Neovim, Emacs, and others.

Dependencies added:
- lsp-server 0.7
- lsp-types 0.94
- serde with derive feature
- serde_json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 05:42:37 -05:00
parent 3206aad653
commit 20bf75a5f8
4 changed files with 722 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ mod diagnostics;
mod exhaustiveness;
mod interpreter;
mod lexer;
mod lsp;
mod modules;
mod parser;
mod schema;
@@ -67,8 +68,31 @@ fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 {
// Run a file
run_file(&args[1]);
match args[1].as_str() {
"--lsp" => {
// Run LSP server
if let Err(e) = lsp::LspServer::run() {
eprintln!("LSP server error: {}", e);
std::process::exit(1);
}
}
"--help" | "-h" => {
println!("Lux {} - A functional language with first-class effects", VERSION);
println!();
println!("Usage:");
println!(" lux Start the REPL");
println!(" lux <file.lux> Run a file");
println!(" lux --lsp Start LSP server (for IDE integration)");
println!(" lux --help Show this help");
}
"--version" | "-v" => {
println!("Lux {}", VERSION);
}
path => {
// Run a file
run_file(path);
}
}
} else {
// Start REPL
run_repl();