Skip to content

Commit 79c9d29

Browse files
committed
fix: is_thread
1 parent 220c80d commit 79c9d29

5 files changed

Lines changed: 41 additions & 30 deletions

File tree

lua/fzf-lua/defaults.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,8 @@ M.defaults.git = {
696696
FzfLua.git_hunks(o)
697697
end,
698698
header = "git hunks",
699-
reuse = #vim.api.nvim_list_uis() == 0,
700-
exec_silent = #vim.api.nvim_list_uis() > 0,
699+
-- reuse = #vim.api.nvim_list_uis() == 0,
700+
-- exec_silent = #vim.api.nvim_list_uis() > 0,
701701
field_index = "{} $FZF_POS",
702702
},
703703
["ctrl-q"] = {
@@ -766,8 +766,8 @@ M.defaults.git = {
766766
FzfLua.git_diff(o)
767767
end,
768768
header = "git diff",
769-
reuse = #vim.api.nvim_list_uis() == 0,
770-
exec_silent = #vim.api.nvim_list_uis() > 0,
769+
-- reuse = #vim.api.nvim_list_uis() == 0,
770+
-- exec_silent = #vim.api.nvim_list_uis() > 0,
771771
field_index = "{} $FZF_POS",
772772
},
773773
},
@@ -2017,7 +2017,7 @@ M.defaults.spell_suggest = {
20172017
---@class fzf-lua.config.Serverlist : fzf-lua.config.Base
20182018
---@field _screenshot string
20192019
M.defaults.serverlist = {
2020-
_screenshot = vim.fn.tempname(),
2020+
-- _screenshot = vim.fn.tempname(),
20212021
previewer = { _ctor = previewers.fzf.nvim_server },
20222022
_resume_reload = true, -- avoid list contain killed server unhide
20232023
actions = {

lua/fzf-lua/init.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---@diagnostic disable: duplicate-require
2-
local gen = _G.arg[0] == "lua/fzf-lua/init.lua"
2+
local gen = _G.arg and _G.arg[0] == "lua/fzf-lua/init.lua"
33
local currFile = assert(debug.getinfo(1, "S")).source:gsub("^@", "")
44
if gen then vim.opt.rtp:append(vim.fn.fnamemodify(currFile, ":h:h:h:p")) end
55

@@ -12,7 +12,7 @@ local config = require "fzf-lua.config"
1212
---@class fzf-lua
1313
local M = {}
1414

15-
do
15+
if not vim.is_thread() then
1616
local function source_vimL(path_parts)
1717
local vimL_file = path.join(path_parts)
1818
if uv.fs_stat(vimL_file) then
@@ -175,7 +175,9 @@ end
175175

176176
-- Setup highlights at least once on load in
177177
-- case the user decides not to call `setup()`
178-
M.setup_highlights()
178+
if not vim.is_thread() then
179+
M.setup_highlights()
180+
end
179181

180182
---@param opts? fzf-lua.profile|fzf-lua.Config|{}
181183
---@param do_not_reset_defaults? boolean

lua/fzf-lua/libuv.lua

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---@diagnostic disable-next-line: deprecated
22
local uv = vim.uv or vim.loop
33

4-
local _is_win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
4+
-- local _is_win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
5+
local _is_win = false
56

67
local M = {}
78

@@ -126,7 +127,7 @@ M.spawn = function(opts, fn_transform, fn_done)
126127

127128
---@diagnostic disable-next-line: redefined-local
128129
local finish = function(code, sig, from, pid)
129-
os.execute("notify-send " .. write_cb_count)
130+
-- os.execute("notify-send " .. write_cb_count)
130131
-- Uncomment to debug pipe closure timing issues (#1521)
131132
-- output_pipe:close(function() print("closed o") end)
132133
-- error_pipe:close(function() print("closed e") end)
@@ -204,20 +205,25 @@ M.spawn = function(opts, fn_transform, fn_done)
204205
local function split_lines(data)
205206
-- io.stderr:write("[DEBUG] worker init")
206207
if not _G.fzf_lua_worker_init then
208+
-- TODO: we can pass serialize opts to first queue...
209+
local __FILE__ = assert(debug.getinfo(1, "S")).source:gsub("^@", "")
210+
package.path = ("%s/?.lua;"):format(vim.fs.dirname(vim.fs.dirname(__FILE__))) .. package.path
211+
package.path = ("%s/?/init.lua;"):format(vim.fs.dirname(vim.fs.dirname(__FILE__))) ..
212+
package.path
213+
require("fzf-lua.make_entry")
207214
_G.fzf_lua_worker_init = true
208-
-- local __FILE__ = assert(debug.getinfo(1, "S")).source:gsub("^@", "")
209-
-- package.path = ("%s/?.lua;"):format(vim.fs.dirname(vim.fs.dirname(__FILE__))) .. package.path
210-
-- require("fzf-lua")
211-
-- pcall(require, "fzf-lua.make_entry")
212215
end
216+
local trans = require("fzf-lua.make_entry").file
213217
local ret = {}
214218
local start_idx = 1
215219
repeat
216220
local nl_idx = data:find(EOL_data or "\n", start_idx, true)
217221
if nl_idx then
218222
local cr = data:byte(nl_idx - 1, nl_idx - 1) == 13 -- \r
219223
local line = data:sub(start_idx, nl_idx - (cr and 2 or 1))
220-
-- if trans then line = trans(line) end
224+
if trans then
225+
line = trans(line)
226+
end
221227
if line then ret[#ret + 1] = line end
222228
start_idx = nl_idx + 1
223229
end
@@ -267,7 +273,7 @@ M.spawn = function(opts, fn_transform, fn_done)
267273
else -- EOF signalled, we can close the pipe
268274
output_pipe:close()
269275
end
270-
if #strbuf > 0 or output_pipe:is_closing() then
276+
if #strbuf > 100000 or output_pipe:is_closing() then
271277
assert(coroutine.resume(co))
272278
end
273279
end
@@ -492,7 +498,7 @@ M.spawn_stdio = function(opts)
492498
local on_write = function(data, cb)
493499
if stdout then
494500
pipe_write(stdout, data, cb)
495-
else
501+
elseif data then
496502
-- on success: rc=true, err=nil
497503
-- on failure: rc=nil, err="Broken pipe"
498504
-- cb with an err ends the process

lua/fzf-lua/make_entry.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
local M = {}
22

3-
-- do return { file = nil } end
43
---@diagnostic disable-next-line: deprecated
54
local uv = vim.uv or vim.loop
65
local path = require "fzf-lua.path"

lua/fzf-lua/utils.lua

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ local memoize = vim.func and vim.func._memoize
1212

1313
local M = {}
1414

15-
M.__HAS_NVIM_010 = vim.fn.has("nvim-0.10") == 1
16-
M.__HAS_NVIM_0102 = vim.fn.has("nvim-0.10.2") == 1
17-
M.__HAS_NVIM_011 = vim.fn.has("nvim-0.11") == 1
18-
M.__HAS_NVIM_0116 = vim.fn.has("nvim-0.11.6") == 1
19-
M.__HAS_NVIM_012 = vim.fn.has("nvim-0.12") == 1
20-
M.__IS_WINDOWS = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
21-
-- M.__HAS_NVIM_010 = true
22-
-- M.__HAS_NVIM_0102 = true
23-
-- M.__HAS_NVIM_011 = true
24-
-- M.__HAS_NVIM_0116 = true
25-
-- M.__HAS_NVIM_012 = true
26-
-- M.__IS_WINDOWS = false
15+
if vim.is_thread() then
16+
M.__HAS_NVIM_010 = true
17+
M.__HAS_NVIM_0102 = true
18+
M.__HAS_NVIM_011 = true
19+
M.__HAS_NVIM_0116 = true
20+
M.__HAS_NVIM_012 = true
21+
M.__IS_WINDOWS = false
22+
else
23+
M.__HAS_NVIM_010 = vim.fn.has("nvim-0.10") == 1
24+
M.__HAS_NVIM_0102 = vim.fn.has("nvim-0.10.2") == 1
25+
M.__HAS_NVIM_011 = vim.fn.has("nvim-0.11") == 1
26+
M.__HAS_NVIM_0116 = vim.fn.has("nvim-0.11.6") == 1
27+
M.__HAS_NVIM_012 = vim.fn.has("nvim-0.12") == 1
28+
M.__IS_WINDOWS = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
29+
end
30+
2731
-- `:help shellslash` (for more info see #1055)
2832
M.__WIN_HAS_SHELLSLASH = M.__IS_WINDOWS and vim.fn.exists("+shellslash") == 1
2933

0 commit comments

Comments
 (0)