From ca950017c647315ac8488975c3621bb74b0bde7e Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:35:47 +0000 Subject: fix(tsgo): prefer local node_modules binary over global #4258 Convert the cmd from a static array to a function that checks for a locally installed tsgo binary in node_modules/.bin/ before falling back to the global installation. This ensures projects using @typescript/native-preview as a local dependency will use the correct version, matching the pattern already used by biome. --- lsp/tsgo.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lsp/tsgo.lua b/lsp/tsgo.lua index d0394826..e51971dc 100644 --- a/lsp/tsgo.lua +++ b/lsp/tsgo.lua @@ -16,7 +16,14 @@ ---@type vim.lsp.Config return { - cmd = { 'tsgo', '--lsp', '--stdio' }, + cmd = function(dispatchers, config) + local cmd = 'tsgo' + local local_cmd = (config or {}).root_dir and config.root_dir .. '/node_modules/.bin/tsgo' + if local_cmd and vim.fn.executable(local_cmd) == 1 then + cmd = local_cmd + end + return vim.lsp.rpc.start({ cmd, '--lsp', '--stdio' }, dispatchers) + end, filetypes = { 'javascript', 'javascriptreact', -- cgit v1.2.3-70-g09d2