neovim在windwos11下snack.nvim的問題
問題復現
首先確定有 find 命令,在執行之后,會出現下面的問題:
Command failed:
- cmd: `find . -type f -not -path */.git/* -not -path */.*`
幾乎百分百。
查找原因
查閱之后得知,問題為調用了linux風格的find命令,語法匹配錯誤。
查閱源碼,在 lua/snacks/picker/source/files.lua 有下面的片段:
---@type {cmd:string[], args:string[], enabled?:boolean, available?:boolean|string}[]
local commands = {
{
cmd = { "fd", "fdfind" },
args = { "--type", "f", "--type", "l", "--color", "never", "-E", ".git" },
},
{
cmd = { "rg" },
args = { "--files", "--no-messages", "--color", "never", "-g", "!.git" },
},
{
cmd = { "find" },
args = { ".", "-type", "f", "-not", "-path", "*/.git/*" },
enabled = vim.fn.has("win-32") == 0, -- 問題在這里
},
}
可以看見有find指令,但有關鍵的 enabled = vim.fn.has("win-32") == 0,大概是這句出了問題
解決方案
本著盡量不動第三方插件源碼的原則,最好的辦法是安裝 fd。
winget install sharkdp.fd
安裝之后就能使用了。

浙公網安備 33010602011771號