3.2 KiB
3.2 KiB
Slint LSP Integration Design
Date: 2026-01-29 Status: Approved Phase: Phase 1 - Core LSP Features
Overview
Implement complete Slint LSP integration into IntelliJ IDEA, enabling standard LSP features (diagnostics, completion, goto definition, hover, formatting, etc.) through IntelliJ's built-in LSP framework.
Architecture
Component Structure
IntelliJ IDEA (LSP Client)
↓
SlintLspServerSupportProvider (Entry point)
↓
SlintLspServerDescriptor (Server configuration)
↓
Slint LSP Server (External process)
Core Components
-
File Type System
SlintLanguage: Language definitionSlintFileType: File type definition with .slint extension- File icon and description
-
LSP Server Integration
SlintLspServerSupportProvider: LSP entry point (exists, needs refinement)SlintLspServerDescriptor: Server configuration (rename from FooLspServerDescriptor)- Automatic capability negotiation via LSP initialize handshake
-
Syntax Highlighting
- Use TextMate grammar from official Slint VSCode extension
SlintTextMateProvider: TextMate bundle provider
-
LSP Feature Mapping (automatic via IntelliJ)
- Diagnostics → Error/warning annotations
- Completion → Code completion UI
- Goto Definition → Ctrl+Click navigation
- Hover → Quick documentation
- Formatting → Code formatting actions
- References → Find usages
- Rename → Refactor rename
Implementation Plan
1. File Type System
Files to create:
src/main/kotlin/me/zhouxi/slint/lang/SlintLanguage.ktsrc/main/kotlin/me/zhouxi/slint/lang/SlintFileType.kt
Changes to plugin.xml:
- Register
<fileType>extension
2. LSP Server Configuration
Files to modify:
src/main/kotlin/me/zhouxi/slint/lsp/SlintLspServerSupportProvider.kt- Rename
FooLspServerDescriptor→SlintLspServerDescriptor - Use
file.fileType == SlintFileTypeinstead of string comparison
- Rename
3. Syntax Highlighting
Resources to add:
- Download
slint.tmLanguage.jsonfrom Slint GitHub - Place in
src/main/resources/textmate/
Files to create:
src/main/kotlin/me/zhouxi/slint/lang/syntax/SlintTextMateProvider.kt
Changes to plugin.xml:
- Register
<textMate.bundleProvider>extension
4. Testing
Test files to create:
- Sample .slint files for manual testing
- Verify: diagnostics, completion, goto definition, hover, formatting
Design Decisions
- Use IntelliJ LSP Framework: Leverage built-in LSP client, no manual protocol implementation
- TextMate for Syntax: Use official grammar, zero maintenance
- Minimal Custom Code: Only implement required extension points
- Type-Safe File Detection: Use FileType comparison instead of string extension checks
Out of Scope (Phase 2)
- Live Preview integration (Slint-specific feature)
- Custom UI components
- Advanced project configuration
Success Criteria
- .slint files recognized by IntelliJ
- LSP server starts automatically when .slint file opened
- Syntax highlighting works
- Code completion provides suggestions
- Diagnostics show errors/warnings
- Goto definition navigates correctly
- Hover shows documentation
- Code formatting works