-
This commit is contained in:
108
docs/plans/2026-01-29-slint-lsp-integration-design.md
Normal file
108
docs/plans/2026-01-29-slint-lsp-integration-design.md
Normal file
@@ -0,0 +1,108 @@
|
||||
# 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
|
||||
|
||||
1. **File Type System**
|
||||
- `SlintLanguage`: Language definition
|
||||
- `SlintFileType`: File type definition with .slint extension
|
||||
- File icon and description
|
||||
|
||||
2. **LSP Server Integration**
|
||||
- `SlintLspServerSupportProvider`: LSP entry point (exists, needs refinement)
|
||||
- `SlintLspServerDescriptor`: Server configuration (rename from FooLspServerDescriptor)
|
||||
- Automatic capability negotiation via LSP initialize handshake
|
||||
|
||||
3. **Syntax Highlighting**
|
||||
- Use TextMate grammar from official Slint VSCode extension
|
||||
- `SlintTextMateProvider`: TextMate bundle provider
|
||||
|
||||
4. **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.kt`
|
||||
- `src/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 == SlintFileType` instead of string comparison
|
||||
|
||||
### 3. Syntax Highlighting
|
||||
|
||||
**Resources to add:**
|
||||
- Download `slint.tmLanguage.json` from 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
|
||||
Reference in New Issue
Block a user