Rovo LSP
Language Server Protocol implementation for Rovo annotation validation and completion.
Features
- Annotation Parsing: Detects and parses Rovo annotations in doc comments
- Diagnostics: Real-time validation of annotation syntax (e.g., HTTP status codes must be 100-599)
- Completions: Intelligent completions for annotations, status codes, and security schemes
- Auto-completion for common HTTP status codes (200, 201, 204, 400, 401, 403, 404, 409, 422, 500, 503)
- Auto-completion for security schemes (bearer, basic, apiKey, oauth2)
- Filters as you type (e.g., typing "2" shows 200, 201, 204)
- Snippets: Smart snippet support for common annotation patterns
- Hover Documentation: Rich markdown documentation for annotations, status codes, and security schemes
- Code Actions: Quick fixes and refactorings
- Add missing annotations (@response, @tag, @security, @example, @id, @hidden)
- Add #[rovo] macro to functions
- Add JsonSchema derive to structs
- Go-to-Definition: Navigate to type definitions from annotations
- Find References: Find all references to a tag across the document
- Context-Aware: Features only activate near #[rovo] attributes
Supported Annotations
@response STATUS TYPE DESCRIPTION- Define an API response@tag NAME- Add an API tag@security SCHEME- Specify security scheme@example STATUS JSON- Add response example@id OPERATION_ID- Set operation ID@hidden- Hide from documentation
Installation
Or add to your Cargo.toml:
[]
= "0.1"
Usage
The LSP server runs as a standalone binary that communicates via stdin/stdout following the LSP protocol.
With Neovim
See editors/nvim/README.md for Neovim integration.
With VSCode
Support for VSCode and other editors coming soon.
Development
Running Tests
# Run all tests
# Run specific test suite
Manual Testing
-
Build the LSP server:
-
Test with a fixture file:
-
Try typing
/// @to see completions
Architecture
rovo-lsp/
├── src/
│ ├── main.rs # LSP server entry point
│ ├── backend.rs # LSP backend implementation
│ ├── handlers.rs # LSP request handlers (hover, completion, references)
│ ├── parser.rs # Annotation parser
│ ├── diagnostics.rs # Validation logic
│ ├── completion.rs # Completion provider with status codes and security schemes
│ ├── code_actions.rs # Code actions (add annotations, add #[rovo], add JsonSchema)
│ ├── type_resolver.rs # Type resolution and go-to-definition
│ └── docs.rs # Shared documentation for annotations
└── tests/
├── integration.rs # Parser integration tests
├── validation.rs # Validation tests
├── completion.rs # Completion tests
└── fixtures/ # Test Rust files
Contributing
Contributions are welcome! Please ensure all tests pass before submitting a PR:
License
MIT