Skip to content

Commit 2d0b58f

Browse files
committed
docs(lsp): update CLAUDE.md and create README.md
- Add Vue and Dart servers to supported servers list - Document new methods: definition, references, completion - Add LSPManager methods reference table - Create comprehensive README with API reference
1 parent f2c9bcd commit 2d0b58f

2 files changed

Lines changed: 158 additions & 1 deletion

File tree

packages/lsp/CLAUDE.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LSP (Language Server Protocol) client implementation for AI coding tools.
44

55
## Overview
66

7-
This package provides a unified interface for interacting with multiple language servers, enabling real-time diagnostics, hover information, and symbol navigation.
7+
This package provides a unified interface for interacting with multiple language servers, enabling real-time diagnostics, code navigation, completions, and symbol navigation.
88

99
## Architecture
1010

@@ -22,11 +22,13 @@ src/
2222
|--------|-----|------------|----------------|
2323
| TypeScript | `typescript` | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | package-lock.json, bun.lockb, bun.lock, yarn.lock, pnpm-lock.yaml |
2424
| Deno | `deno` | .ts, .tsx, .js, .jsx, .mjs | deno.json, deno.jsonc |
25+
| Vue | `vue` | .vue | package.json, package-lock.json, bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock |
2526
| Oxlint | `oxlint` | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue, .astro, .svelte | .oxlintrc.json, package-lock.json, bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock, package.json |
2627
| Pyright | `pyright` | .py, .pyi | pyproject.toml, setup.py, requirements.txt, pyrightconfig.json |
2728
| Gopls | `gopls` | .go | go.work, go.mod, go.sum |
2829
| Rust Analyzer | `rust-analyzer` | .rs | Cargo.toml, Cargo.lock |
2930
| Kotlin | `kotlin` | .kt, .kts | build.gradle.kts, build.gradle, settings.gradle.kts, settings.gradle, pom.xml |
31+
| Dart | `dart` | .dart | pubspec.yaml, pubspec.lock |
3032

3133
## Adding a New Server
3234

@@ -89,13 +91,39 @@ const diags = await manager.diagnostics()
8991
// Get hover info
9092
const hover = await manager.hover({ file, line, character })
9193

94+
// Go to definition
95+
const defs = await manager.definition({ file, line, character })
96+
97+
// Find all references
98+
const refs = await manager.references({ file, line, character, includeDeclaration: true })
99+
100+
// Get code completions
101+
const completions = await manager.completion({ file, line, character })
102+
92103
// Search symbols
93104
const symbols = await manager.workspaceSymbol('query')
94105

106+
// Get document symbols
107+
const docSymbols = await manager.documentSymbol(uri)
108+
95109
// Cleanup
96110
await manager.shutdown()
97111
```
98112

113+
### LSPManager Methods
114+
115+
| Method | LSP Request | Description |
116+
|--------|-------------|-------------|
117+
| `touchFile()` | `textDocument/didOpen` | Open file in LSP servers |
118+
| `diagnostics()` | `textDocument/publishDiagnostics` | Get all diagnostics |
119+
| `hover()` | `textDocument/hover` | Get hover information |
120+
| `definition()` | `textDocument/definition` | Go to definition |
121+
| `references()` | `textDocument/references` | Find all references |
122+
| `completion()` | `textDocument/completion` | Get code completions |
123+
| `workspaceSymbol()` | `workspace/symbol` | Search workspace symbols |
124+
| `documentSymbol()` | `textDocument/documentSymbol` | Get document symbols |
125+
| `shutdown()` | `shutdown` | Close all clients |
126+
99127
### Server Utilities
100128

101129
```typescript

packages/lsp/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# @pleaseai/code-lsp
2+
3+
LSP (Language Server Protocol) client implementation for AI coding tools.
4+
5+
## Installation
6+
7+
```bash
8+
bun add @pleaseai/code-lsp
9+
```
10+
11+
## Features
12+
13+
- Multi-server support with automatic lifecycle management
14+
- Code navigation (definition, references)
15+
- Code completions
16+
- Diagnostics and hover information
17+
- Symbol search (workspace and document)
18+
- Auto-download for Kotlin, Dart, and Vue language servers
19+
20+
## Quick Start
21+
22+
```typescript
23+
import { LSPManager } from '@pleaseai/code-lsp'
24+
25+
const manager = new LSPManager('/path/to/project')
26+
27+
// Open a file to initialize LSP
28+
await manager.touchFile('src/index.ts', true)
29+
30+
// Get diagnostics
31+
const diagnostics = await manager.diagnostics()
32+
33+
// Go to definition
34+
const definitions = await manager.definition({
35+
file: 'src/index.ts',
36+
line: 10,
37+
character: 5,
38+
})
39+
40+
// Find all references
41+
const references = await manager.references({
42+
file: 'src/index.ts',
43+
line: 10,
44+
character: 5,
45+
includeDeclaration: true,
46+
})
47+
48+
// Get completions
49+
const completions = await manager.completion({
50+
file: 'src/index.ts',
51+
line: 10,
52+
character: 5,
53+
})
54+
55+
// Cleanup
56+
await manager.shutdown()
57+
```
58+
59+
## Supported Language Servers
60+
61+
| Language | Server | Auto-download |
62+
|----------|--------|---------------|
63+
| TypeScript/JavaScript | typescript-language-server | No |
64+
| Deno | deno lsp | No |
65+
| Vue | @vue/language-server | Yes |
66+
| Python | pyright-langserver | No |
67+
| Go | gopls | No |
68+
| Rust | rust-analyzer | No |
69+
| Kotlin | JetBrains Kotlin LSP | Yes |
70+
| Dart | dart language-server | Yes |
71+
| Linting | oxlint | No |
72+
73+
## API Reference
74+
75+
### LSPManager
76+
77+
| Method | Description |
78+
|--------|-------------|
79+
| `touchFile(file, waitForDiagnostics?)` | Open file in LSP servers |
80+
| `diagnostics()` | Get all diagnostics |
81+
| `hover({ file, line, character })` | Get hover information |
82+
| `definition({ file, line, character })` | Go to definition |
83+
| `references({ file, line, character, includeDeclaration? })` | Find all references |
84+
| `completion({ file, line, character })` | Get code completions |
85+
| `workspaceSymbol(query)` | Search workspace symbols |
86+
| `documentSymbol(uri)` | Get document symbols |
87+
| `status()` | Get connected server status |
88+
| `shutdown()` | Close all clients |
89+
90+
### Types
91+
92+
```typescript
93+
import {
94+
// Position and Range
95+
Position,
96+
Range,
97+
Location,
98+
LocationLink,
99+
100+
// Symbols
101+
Symbol,
102+
DocumentSymbol,
103+
SymbolKind,
104+
105+
// Completions
106+
CompletionItem,
107+
CompletionList,
108+
CompletionItemKind,
109+
110+
// Diagnostics
111+
Diagnostic,
112+
} from '@pleaseai/code-lsp'
113+
```
114+
115+
## Server Utilities
116+
117+
```typescript
118+
import { getServerById, getServersForExtension } from '@pleaseai/code-lsp'
119+
120+
// Get server by ID
121+
const tsServer = getServerById('typescript')
122+
123+
// Get servers for file extension
124+
const servers = getServersForExtension('.ts')
125+
```
126+
127+
## License
128+
129+
MIT

0 commit comments

Comments
 (0)