aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lsp/flow.lua12
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' },