feat(file_selector): support customized filepaths resolver (#1294)
This commit is contained in:
18
README.md
18
README.md
@@ -417,6 +417,24 @@ To create a customized file_selector, you can specify a customized function to l
|
||||
end
|
||||
})
|
||||
end,
|
||||
---below is optional
|
||||
provider_opts = {
|
||||
---@param params avante.file_selector.opts.IGetFilepathsParams
|
||||
get_filepaths = function(params)
|
||||
local cwd = params.cwd ---@type string
|
||||
local selected_filepaths = params.selected_filepaths ---@type string[]
|
||||
local cmd = string.format("fd --base-directory '%s' --hidden", vim.fn.fnameescape(cwd))
|
||||
local output = vim.fn.system(cmd)
|
||||
local filepaths = vim.split(output, "\n", { trimempty = true })
|
||||
return vim
|
||||
.iter(filepaths)
|
||||
:filter(function(filepath)
|
||||
return not vim.tbl_contains(selected_filepaths, filepath)
|
||||
end)
|
||||
:totable()
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user