aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorryoppippi <1560508+ryoppippi@users.noreply.github.com>2025-12-23 15:35:47 +0000
committerGitHub <noreply@github.com>2025-12-23 10:35:47 -0500
commitca950017c647315ac8488975c3621bb74b0bde7e (patch)
treed69075df0532184199c3b28f4ea8f9c956b064de
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.tar
nvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.tar.gz
nvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.tar.bz2
nvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.tar.lz
nvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.tar.xz
nvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.tar.zst
nvim-lspconfig-ca950017c647315ac8488975c3621bb74b0bde7e.zip
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.
-rw-r--r--lsp/tsgo.lua9
1 files changed, 8 insertions, 1 deletions
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',