问题复现
首先确定有 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
安装之后就能使用了。