Closed iamgodot closed 5 months ago
same question
I found it
call wilder#set_option('noselect', 0)
my config, it works fine
local M = {}
M.wilderFunc = function()
local wilder = try_require("wilder")
if wilder == nil then
return
end
wilder.event = "CmdlineEnter" -- 懒加载:首次进入cmdline时载入
wilder.setup({
modes = { ":", "/", "?" },
next_key = 0,
previous_key = 0,
reject_key = 0,
accept_key = 0,
})
vim.api.nvim_command("silent! UpdateRemotePlugins") -- 需要载入一次py依赖 不然模糊过滤等失效
-- 设置source
wilder.set_option("pipeline", {
wilder.branch(
-- 当默认无输入时 展示15条历史记录
{
wilder.check(function(_, x)
return vim.fn.empty(x)
end),
wilder.history(10),
},
-- 当输入时 展示所有匹配项(模糊匹配)
wilder.cmdline_pipeline({
fuzzy = 1,
fuzzy_filter = wilder.vim_fuzzy_filter(),
}),
-- pipeline for search
wilder.search_pipeline()
),
})
-- 设置样式
wilder.set_option(
"renderer",
wilder.popupmenu_renderer(wilder.popupmenu_border_theme({
-- 设置特定高亮
highlights = {
accent = "WilderAccent",
selected_accent = "WilderSelectedAccent",
},
highlighter = wilder.basic_highlighter(),
left = { " ", wilder.popupmenu_devicons() }, -- 左侧加入icon
right = { " ", wilder.popupmenu_scrollbar() }, -- 右侧加入滚动条
border = "rounded",
max_height = 17, -- 最大高度限制 因为要计算上下 所以17支持最多15个选项
pumblend = 0,
}))
)
-- 设置快捷键
vim.api.nvim_set_keymap(
"c",
"<tab>",
-- [[wilder#in_context() ? wilder#next() : '<tab>']],
[['<tab>']],
{ noremap = true, expr = true }
)
vim.api.nvim_set_keymap(
"c",
"<Down>",
[[wilder#in_context() ? wilder#next() : '<down>']],
{ noremap = true, expr = true }
)
vim.api.nvim_set_keymap(
"c",
"<up>",
[[wilder#in_context() ? wilder#previous() : '<up>']],
{ noremap = true, expr = true }
)
vim.api.nvim_set_keymap("c", "0", "0", {}) -- 不清楚原因导致0无法使用 强制覆盖
-- 设置高亮
vim.api.nvim_set_hl(0, "WilderAccent", { fg = "#FF4500" })
vim.api.nvim_set_hl(0, "WilderSelectedAccent", { fg = "#FF4500", bg = "#4e4e4e" })
vim.cmd("call wilder#set_option('noselect', 0)")
end
return M
@edte Thanks, I can see the first item is being selected(highlighted actually), but when I hit the Enter key, it doesn't executed the selection but rather what I typed. For example, when I typed :lsp
, the first suggested item LspInfo
is selected, but when I hit Enter, it's the lsp
that got executed instead of LspInfo
. Do you have the same issue?
@edte Thanks, I can see the first item is being selected(highlighted actually), but when I hit the Enter key, it doesn't executed the selection but rather what I typed. For example, when I typed
:lsp
, the first suggested itemLspInfo
is selected, but when I hit Enter, it's thelsp
that got executed instead ofLspInfo
. Do you have the same issue?
Actually, I have the same problem, i just set right arrow
to tab
,sometimes useful
vim.api.nvim_set_keymap("c", "<Right>", [['<tab>']], { noremap = true, expr = true })
@edte I guess that's the closest we can get, but thanks anyway
I found when a list of items show up, I have to press to select. How do I select the first item by simply press the Return key? Thank you.