From 695fa76aefb69dc8fa3a694ed167db880eefdacb Mon Sep 17 00:00:00 2001 From: Arthur <82575487+arthur-mountain@users.noreply.github.com> Date: Fri, 29 May 2026 01:11:44 +0800 Subject: 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. --- lsp/flow.lua | 12 ++++++++---- 1 file 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' }, -- cgit v1.3.1