Skip to content

Commit 53d412e

Browse files
committed
fix: is_thread
1 parent a4c449f commit 53d412e

5 files changed

Lines changed: 38 additions & 26 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: 11 additions & 6 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

@@ -204,12 +205,15 @@ 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+
require("fzf-lua.make_entry")
212+
print('e')
213+
-- print(vim.inspect(package.loaders))
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
@@ -218,6 +222,7 @@ M.spawn = function(opts, fn_transform, fn_done)
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))
220224
-- if trans then line = trans(line) end
225+
line = trans(line, {})
221226
if line then ret[#ret + 1] = line end
222227
start_idx = nl_idx + 1
223228
end
@@ -492,7 +497,7 @@ M.spawn_stdio = function(opts)
492497
local on_write = function(data, cb)
493498
if stdout then
494499
pipe_write(stdout, data, cb)
495-
else
500+
elseif data then
496501
-- on success: rc=true, err=nil
497502
-- on failure: rc=nil, err="Broken pipe"
498503
-- cb with an err ends the process

lua/fzf-lua/make_entry.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ local function load_config_section(s, datatype, optional)
3232
local val = utils.map_get(config, s)
3333
return type(val) == datatype and val or nil
3434
---@diagnostic disable-next-line: undefined-field
35+
elseif false then
3536
elseif _G._fzf_lua_server then
3637
-- load config from our running instance
3738
local is_bytecode = false

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)