You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is probably more of a Lua/programming question. Any ideas? I would think local actions = require("fzf-lua").actions in the config function passes actions to the opts table, but I get the errors:
["enter"] = actions.file_edit_or_qf, Undefined global `actions`.
["ctrl-s"] = actions.file_split, Undefined global `actions`.
["ctrl-v"] = actions.file_vsplit, Undefined global `actions`.
The full spec:
local paths_to_clipboard = function(selected, clipboard)
local list = {}
clipboard = clipboard or vim.o.clipboard
for i = 1, #selected do
table.insert(list, path.entry_to_file(selected[i], opts).stripped)
end
local filepaths = table.concat(list, "\n")
if clipboard == "unnamed" then
vim.fn.setreg([[*]], filepaths)
elseif clipboard == "unnamedplus" then
vim.fn.setreg([[+]], filepaths)
else
vim.fn.setreg([["]], filepaths)
end
vim.fn.setreg([[0]], filepaths)
end
return {
"ibhagwan/fzf-lua",
opts = {
actions = {
files = {
true,
["enter"] = actions.file_edit_or_qf,
["ctrl-s"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
["alt-Q"] = actions.file_sel_to_ll,
["alt-i"] = actions.toggle_ignore,
["alt-h"] = actions.toggle_hidden,
["alt-f"] = actions.toggle_follow,
},
},
},
config = function(_, opts)
local fzflua = require("fzf-lua")
local actions = require("fzf-lua")
vim.keymap.set("", "<C-s>", fzflua.grep_curbuf, { desc = "Fzf: grep buffer" })
vim.keymap.set("", "<leader>s", fzflua.live_grep, { desc = "Fzf: live_grep" })
vim.keymap.set("", "<leader>ss", function()
fzflua.live_grep({
rg_glob = true,
glob_separator = "",
rg_glob_fn = function(query, o)
local regex, flags = query:match("^(.-)%s%-%-(.*)$")
local function rebuild_regex(str)
local result = str:gsub("%s+", function(r)
if #r == 1 then
return ".*"
else
return r:match("%s(.*)")
end
end)
return result
end
if not regex then
return rebuild_regex(query), ""
end
return rebuild_regex(regex), flags
end,
})
end, { desc = "Fzf: live_grep" })
vim.keymap.set("n", "<leader>sw", fzflua.grep_cword, { desc = "[S]earch current [W]ord" })
vim.keymap.set("", "<leader>f", fzflua.files, { desc = "Fzf: files" })
vim.keymap.set("", "<leader>e", function()
fzflua.fzf_exec("e", {
previewer = "builtin",
actions = {
["default"] = actions.file_edit,
},
})
end, { desc = "freq files" })
end,
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a lazy.nvim spec and I'm having trouble getting
actions
defined as:in the config function to apply to the
opts
table so that it can be referenced as:instead of:
This is probably more of a Lua/programming question. Any ideas? I would think
local actions = require("fzf-lua").actions
in theconfig
function passesactions
to theopts
table, but I get the errors:The full spec:
Much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions