Duso VSCode Extension
Language Server Protocol (LSP) support for Duso in VSCode.
Features
- Syntax Highlighting - Color coded syntax for Duso scripts
- Error Diagnostics - Real-time parse error detection
- Hover Documentation - View built-in function documentation
- Go to Definition - Jump to function and variable definitions (Ctrl+Click)
- Find References - Find all usages of variables and functions
Installation
From Source (Development)
cd vscode
npm install
code --extensionDevelopmentPath=. .
This opens a new VSCode window running the extension in development mode.
Prerequisites
Ensure the duso binary is in your PATH:
which duso
duso --version
If duso is not found, the extension will fail to start. Make sure you've run ./build.sh in the project root.
Quick Test
Create a file test.du:
print("Hello, Duso!")
function greet(name) do
print("Hello, " + name)
end
greet("World")
Open the file in VSCode - you should see syntax highlighting
Hover over print and greet to see documentation
Ctrl+Click on greet("World") to jump to the function definition
Create a syntax error to see diagnostics:
print(1 2) # Missing comma
Features
Error Diagnostics
- Syntax errors shown in real-time with red squiggles
- Error details in the Problems panel
Hover Documentation
- Hover over built-in functions (print, len, map, etc.) to see docs
- Shows function signatures and descriptions
Go to Definition
- Ctrl+Click on a function/variable to jump to its definition
- Works for same-file definitions in Phase 1
Find References
- Right-click → Find All References to find all usages
- Highlights all matching identifiers
Architecture
The extension launches duso -lsp which:
- Reads LSP messages from VSCode over stdin
- Parses documents and analyzes them
- Sends diagnostics, hover info, and definitions back to VSCode
No separate server needed - it's built into the duso binary!
Troubleshooting
If the server doesn't start:
- Check Output panel: View → Output → Duso Language Server
- Verify
duso is in PATH: which duso
- Rebuild:
./build.sh in project root
- Reload extension: Cmd+Shift+P → Developer: Reload Window
Phase 1 Implementation
Currently implemented:
- ✅ Syntax highlighting
- ✅ Error diagnostics
- ✅ Hover documentation
- ✅ Go to definition (same-file)
- ✅ Find references (same-file)
Coming in Phase 2:
- Code completion
- Document symbols (outline)
- Rename refactoring
- Cross-file definitions
| |