A Language Server Protocol (LSP) implementation for Comline, providing intelligent code editing features for .ids schema files.
- Diagnostics - Real-time syntax error detection and reporting
- Document Symbols - Hierarchical outline view of structs, enums, protocols, and constants
- Hover Information - Rich tooltips showing full type definitions and signatures
- Go to Definition - Jump from type references to their declarations
- Find References - Locate all usages of a symbol (with include/exclude declaration option)
- Auto-Completion - Context-aware code suggestions:
- Keywords with snippets (
struct,enum,protocol,const,use,import) - Primitive types (i8-i64, u8-u64, f32/f64, string, bool)
- User-defined types (all structs, enums, protocols from current file)
- Context detection (type position, top-level, struct body)
- Keywords with snippets (
- Find References - Locate all usages of a symbol
- Auto-Completion - Context-aware code completion
- Rename Symbol - Safe refactoring across files
- Code Formatting - Automatic code formatting
- Semantic Tokens - Enhanced syntax highlighting
cd language-server
cargo build --releaseThe LSP server binary will be available at target/release/comline-lsp.
- Install a generic LSP client extension (e.g.,
vscode-languageclient) - Configure the server in your settings:
{
"comline.server": {
"command": "/path/to/comline-lsp",
"args": [],
"transport": "stdio"
}
}Using nvim-lspconfig:
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
-- Define Comline LSP
if not configs.comline_ls then
configs.comline_ls = {
default_config = {
cmd = {'/path/to/comline-lsp'},
filetypes = {'comline'},
root_dir = lspconfig.util.root_pattern('.git', 'config.idp'),
settings = {},
},
}
end
-- Setup Comline LSP
lspconfig.comline_ls.setup{}
-- Associate .ids files with comline filetype
vim.filetype.add({
extension = {
ids = 'comline',
},
})Add to your languages.toml:
[[language]]
name = "comline"
scope = "source.comline"
file-types = ["ids"]
roots = ["config.idp", ".git"]
language-servers = ["comline-ls"]
[language-server.comline-ls]
command = "/path/to/comline-lsp"(add-to-list 'lsp-language-id-configuration '(comline-mode . "comline"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection "/path/to/comline-lsp")
:major-modes '(comline-mode)
:server-id 'comline-ls))Once integrated with your editor, the LSP server provides:
Syntax errors are highlighted as you type:
struct User {
name string // ← Error: Missing colon
age: i32
}
Navigate your schema using the document symbols panel:
📦 User (3 fields)
├─ 📄 name
├─ 📄 age
└─ 📄 email
🔌 UserService (2 functions)
├─ ⚡ getUser
└─ ⚡ createUser
Hover over any symbol to see its definition:
struct User {
name: string
age: i32
optional email: string
}
3 fields
Ctrl/Cmd + Click on any type reference to jump to its definition:
struct User { ... }
struct Request {
user: User // ← Click jumps to User definition
}
src/
├── main.rs # Entry point
├── backend.rs # LSP protocol implementation
├── document.rs # Document management
├── parser.rs # Comline parser integration
├── util.rs # Utility functions
├── analysis/ # Semantic analysis
│ ├── diagnostics.rs # Error reporting
│ ├── symbols.rs # Symbol extraction
│ ├── types.rs # Type resolution
│ └── imports.rs # Import resolution
└── handlers/ # LSP feature handlers
├── completion.rs
├── definition.rs
├── formatting.rs
├── hover.rs
├── references.rs
├── rename.rs
└── symbols.rs
cargo testAll tests should pass:
- Parser tests
- Diagnostic tests
- Symbol extraction tests
- Handler tests
- Integration tests
Set the RUST_LOG environment variable for debugging:
RUST_LOG=debug /path/to/comline-lspLogs are written to stderr and won't interfere with the LSP protocol communication over stdio.
The server advertises the following capabilities:
- Text Document Sync - Full document synchronization
- Hover Provider - Type information on hover
- Completion Provider - Trigger characters:
.,: - Definition Provider - Go to definition support
- References Provider - Find all references (planned)
- Document Symbol Provider - Outline view
- Workspace Symbol Provider - Global symbol search (planned)
- Document Formatting - Auto-formatting (planned)
- Rename Provider - Symbol renaming (planned)
- Semantic Tokens - Enhanced highlighting (planned)
- tower-lsp - LSP protocol framework
- comline-core - Comline parser and AST
- rust-sitter - Parser infrastructure
- tokio - Async runtime
- dashmap - Concurrent hashmap for document storage
- tracing - Structured logging
Contributions are welcome! Areas for improvement:
- Find References - Implement reference finding across files
- Auto-Completion - Add intelligent completion suggestions
- Import Resolution - Cross-file type resolution
- Code Actions - Quick fixes and refactorings
- Formatting - Implement Comline code formatter
See the main Comline project for licensing information.
Built using: