Commit b59d39e
committed
fix: use vtsls for TypeScript completions with proper document lifecycle
Problem:
Completions popup showed global/project symbols instead of context-appropriate
completions (e.g., typing `x.` on a string showed `arguments`, `config` instead
of `charAt`, `toLowerCase`).
Root Cause:
The extension sent `textDocument/didOpen` every time `getHints()` was called,
violating LSP protocol and causing the server to reset its analysis state.
Changes:
1. Switch to vtsls language server (@vtsls/language-server)
- Same LSP server that Zed editor uses by default
- Wraps VS Code's TypeScript extension directly
- Better server-side fuzzy matching and completion performance
2. Fix LSP document lifecycle (VS Code pattern)
- Send `textDocument/didOpen` only once per document
- Send `textDocument/didChange` for subsequent content updates
- Track open documents in `openDocuments` Set
- Track document versions in `documentVersions` Map
3. Add proper state cleanup
- Clear tracking state on server restart (projectOpen)
- Clear tracking state on shutdown
- Clear tracking state on server exit
- Send `textDocument/didClose` when documents are refreshed
4. Add vtsls-specific initialization options
- Enable server-side fuzzy matching
- Set completion entries limit to 5000
- Enable auto-use of workspace TypeScript SDK1 parent 275d074 commit b59d39e
3 files changed
Lines changed: 297 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | | - | |
| 32 | + | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
0 commit comments