Skip to content

Commit

Permalink
fix: headless wrapper with custom runtime path (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Dec 12, 2023
1 parent 372b643 commit 209e940
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lua/fzf-lua/libuv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -473,14 +473,17 @@ M.wrap_spawn_stdio = function(opts, fn_transform, fn_preprocess)
assert(opts and type(opts) == "string")
assert(not fn_transform or type(fn_transform) == "string")
local nvim_bin = os.getenv("FZF_LUA_NVIM_BIN") or vim.v.progpath
local nvim_runtime = os.getenv("FZF_LUA_NVIM_BIN") and ""
or string.format("VIMRUNTIME=%s ", M.shellescape(vim.env.VIMRUNTIME))
local call_args = opts
for _, fn in ipairs({ fn_transform, fn_preprocess }) do
if type(fn) == "string" then
call_args = ("%s,[[%s]]"):format(call_args, fn)
end
end
local cmd_str = ("%s -n --headless --clean --cmd %s"):format(
vim.fn.shellescape(nvim_bin),
local cmd_str = ("%s%s -n --headless --clean --cmd %s"):format(
nvim_runtime,
M.shellescape(nvim_bin),
M.shellescape(("lua loadfile([[%s]])().spawn_stdio(%s)")
:format(__FILE__, call_args)))
return cmd_str
Expand Down
5 changes: 4 additions & 1 deletion lua/fzf-lua/shell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ function M.raw_async_action(fn, fzf_field_expression, debug)
-- this is for windows WSL and AppImage users, their nvim path isn't just
-- 'nvim', it can be something else
local nvim_bin = os.getenv("FZF_LUA_NVIM_BIN") or vim.v.progpath
local nvim_runtime = os.getenv("FZF_LUA_NVIM_BIN") and ""
or string.format("VIMRUNTIME=%s ", libuv.shellescape(vim.env.VIMRUNTIME))

local call_args = ("fzf_lua_server=[[%s]], fnc_id=%d %s"):format(
vim.g.fzf_lua_server, id, debug and ", debug=true" or "")
Expand All @@ -88,7 +90,8 @@ function M.raw_async_action(fn, fzf_field_expression, debug)
-- special shell chars ('+', '-', etc), exmaples where this can
-- happen are the `git status` command and git brances from diff
-- worktrees (#600)
local action_cmd = ("%s -n --headless --clean --cmd %s -- %s"):format(
local action_cmd = ("%s%s -n --headless --clean --cmd %s -- %s"):format(
nvim_runtime,
libuv.shellescape(nvim_bin),
libuv.shellescape(("lua loadfile([[%s]])().rpc_nvim_exec_lua({%s})")
:format(path.join { vim.g.fzf_lua_directory, "shell_helper.lua" }, call_args)),
Expand Down

0 comments on commit 209e940

Please sign in to comment.