diff options
| author | Arthur <82575487+arthur-mountain@users.noreply.github.com> | 2026-05-29 01:11:44 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-28 13:11:44 -0400 |
| commit | 695fa76aefb69dc8fa3a694ed167db880eefdacb (patch) | |
| tree | 013160a9e7c16dddbe00a2b3c242c2f075d5a866 | |
| parent | docs: update generated annotations (diff) | |
| download | nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.tar nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.tar.gz nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.tar.bz2 nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.tar.lz nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.tar.xz nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.tar.zst nvim-lspconfig-695fa76aefb69dc8fa3a694ed167db880eefdacb.zip | |
fix(flow): resolve project-local binary before npx fallback #4431
When flow is not in global PATH, try node_modules/.bin/flow relative
to the project root before falling back to npx. This covers the common
case where flow-bin is a local devDependency.
| -rw-r--r-- | lsp/flow.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lsp/flow.lua b/lsp/flow.lua index 183606de..f526b94a 100644 --- a/lsp/flow.lua +++ b/lsp/flow.lua @@ -14,14 +14,18 @@ ---@type vim.lsp.Config return { - cmd = function(dispatchers) - local cmd = nil + cmd = function(dispatchers, config) + local cmd if vim.fn.executable('flow') == 1 then cmd = { 'flow', 'lsp' } else - cmd = { 'npx', '--no-install', 'flow', 'lsp' } + local flow_bin = (config or {}).root_dir and vim.fs.joinpath(config.root_dir, 'node_modules/.bin/flow') + if flow_bin and vim.fn.executable(flow_bin) == 1 then + cmd = { flow_bin, 'lsp' } + else + cmd = { 'npx', '--no-install', 'flow', 'lsp' } + end end - return vim.lsp.rpc.start(cmd, dispatchers) end, filetypes = { 'javascript', 'javascriptreact' }, |
