Merge pull request #128 from Askhz/fix/lsp-windows-spawn-shell

fix: 修复 Windows 上 LSP 服务器启动 ENOENT 错误
This commit is contained in:
linkai0924 2026-05-19 11:59:49 +08:00 committed by GitHub
commit 0574a8e00e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import { type ChildProcess, spawn } from 'child_process'
import { platform } from 'os'
import {
createMessageConnection,
type MessageConnection,
@ -101,6 +102,11 @@ export function createLSPClient(
cwd: options?.cwd,
// Prevent visible console window on Windows (no-op on other platforms)
windowsHide: true,
// On Windows, npm-installed packages produce .cmd wrapper scripts.
// spawn() without shell uses CreateProcess, which only handles PE
// executables (.exe/.com) — .cmd/.bat files cause ENOENT. Enabling
// the shell lets cmd.exe resolve the wrapper.
shell: platform() === 'win32',
})
if (!process.stdout || !process.stdin) {