Skip to content

Commit b59d39e

Browse files
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 SDK
1 parent 275d074 commit b59d39e

3 files changed

Lines changed: 297 additions & 38 deletions

File tree

src-node/package-lock.json

Lines changed: 153 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-node/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
},
2020
"IMPORTANT!!": "Adding things here will bloat up the package size",
2121
"dependencies": {
22+
"@expo/sudo-prompt": "^9.3.2",
2223
"@phcode/fs": "^3.0.1",
23-
"open": "^10.1.0",
24-
"npm": "10.1.0",
25-
"ws": "^8.17.1",
24+
"@vtsls/language-server": "^0.3.0",
25+
"cross-spawn": "^7.0.6",
2626
"lmdb": "^2.9.2",
2727
"mime-types": "^2.1.35",
28-
"cross-spawn": "^7.0.6",
28+
"npm": "10.1.0",
29+
"open": "^10.1.0",
30+
"typescript": "^5.3.3",
2931
"which": "^2.0.1",
30-
"@expo/sudo-prompt": "^9.3.2"
32+
"ws": "^8.17.1"
3133
}
32-
}
34+
}

0 commit comments

Comments
 (0)