fix(lsp): offer auto-imports from unopened files in projects without a tsconfig (#496)

Without a tsconfig.json or jsconfig.json, tsserver's inferred project holds only
open files and what they import, so completion never offered exports from other
files. Register the project's sources with tsserver as an external project,
using the options an inferred project assumes, so no file is written to disk.

Registration needs `typescript.tsserverRequest`. Projects with a configuration,
including one in a subfolder, stay as they were, and so do trees over 10,000
sources or 16 MiB of JavaScript, since tsserver disables its language service
past 20 MiB. Created and deleted files update the project, and unopened files
stay out of Problems.
This commit is contained in:
l0ng-ai
2026-10-31 01:49:00 +08:00
committed by GitHub
parent a3cd99db1f
commit 8fabf054ef
16 changed files with 393 additions and 1 deletions
+2
View File
@@ -9,6 +9,7 @@ tree-sitter = "javascript"
[[language-servers]]
name = "vtsls"
tsserver-project = true
command = "vtsls"
args = ["--stdio"]
root-markers = ["jsconfig.json", "tsconfig.json", "package.json"]
@@ -16,6 +17,7 @@ install-hint = "npm i -g @vtsls/language-server"
[[language-servers]]
name = "typescript-language-server"
tsserver-project = true
# Alternative: used only when the server above is not installed.
fallback = true
command = "typescript-language-server"