Skip to content

Commit

Permalink
fix: g:did_load_filetypes=1 only on nvim >= 0.10 (closes #1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Apr 30, 2024
1 parent a4bce02 commit cb208cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lua/fzf-lua/libuv.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local uv = vim.loop

local _has_nvim_010 = vim.fn.has("nvim-0.10") == 1
local _is_win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1

local M = {}
Expand Down Expand Up @@ -708,11 +709,11 @@ M.wrap_spawn_stdio = function(opts, fn_transform, fn_preprocess)
_is_win and [[set VIMRUNTIME=%s& ]] or "VIMRUNTIME=%s ",
_is_win and vim.fs.normalize(vim.env.VIMRUNTIME) or M.shellescape(vim.env.VIMRUNTIME)
)
local lua_cmd = ("lua vim.g.did_load_filetypes=1; loadfile([[%s]])().spawn_stdio(%s,%s,%s)")
:format(
_is_win and vim.fs.normalize(__FILE__) or __FILE__,
opts, fn_transform, fn_preprocess
)
local lua_cmd = ("lua %sloadfile([[%s]])().spawn_stdio(%s,%s,%s)"):format(
_has_nvim_010 and "vim.g.did_load_filetypes=1; " or "",
_is_win and vim.fs.normalize(__FILE__) or __FILE__,
opts, fn_transform, fn_preprocess
)
local cmd_str = ("%s%s -n --headless --clean --cmd %s"):format(
nvim_runtime,
M.shellescape(_is_win and vim.fs.normalize(nvim_bin) or nvim_bin),
Expand Down
7 changes: 5 additions & 2 deletions lua/fzf-lua/shell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ function M.raw_async_action(fn, fzf_field_expression, debug)
local action_cmd = ("%s%s -n --headless --clean --cmd %s -- %s"):format(
nvim_runtime,
libuv.shellescape(path.normalize(nvim_bin)),
libuv.shellescape(("lua vim.g.did_load_filetypes=1; loadfile([[%s]])().rpc_nvim_exec_lua({%s})")
:format(path.join { vim.g.fzf_lua_directory, "shell_helper.lua" }, call_args)),
libuv.shellescape(("lua %sloadfile([[%s]])().rpc_nvim_exec_lua({%s})"):format(
utils.__HAS_NVIM_010 and "vim.g.did_load_filetypes=1; " or "",
path.join { vim.g.fzf_lua_directory, "shell_helper.lua" },
call_args
)),
fzf_field_expression)

return action_cmd, id
Expand Down

0 comments on commit cb208cd

Please sign in to comment.