diff --git a/lua/artio/builtins.lua b/lua/artio/builtins.lua index dffda5d..e35f1a8 100644 --- a/lua/artio/builtins.lua +++ b/lua/artio/builtins.lua @@ -16,7 +16,7 @@ end local builtins = {} -local findprg = "fd -H -p -t f --color=never" +local findprg = "fd -H -p -a -t f --color=never" ---@class artio.picker.files.Props : artio.Picker.config ---@field findprg? string @@ -26,7 +26,10 @@ builtins.files = function(props) props = props or {} props.findprg = props.findprg or findprg - local lst = utils.make_cmd(props.findprg)() + local base_dir = vim.fn.getcwd(0) + local lst = utils.make_cmd(props.findprg, { + cwd = base_dir, + })() return artio.generic( lst, @@ -37,6 +40,9 @@ builtins.files = function(props) vim.cmd.edit(text) end) end, + format_item = function(item) + return vim.fs.relpath(base_dir, item) or item + end, get_icon = config.get().opts.use_icons and function(item) return require("mini.icons").get("file", item.v) end or nil, @@ -288,7 +294,10 @@ builtins.smart = function(props) currentfile = vim.fs.abspath(currentfile) props.findprg = props.findprg or findprg - local lst = utils.make_cmd(props.findprg)() + local base_dir = vim.fn.getcwd(0) + local lst = utils.make_cmd(props.findprg, { + cwd = base_dir, + })() local pwd = vim.fn.getcwd() local recentlst = vim @@ -330,6 +339,9 @@ builtins.smart = function(props) vim.cmd.edit(text) end) end, + format_item = function(item) + return vim.fs.relpath(base_dir, item) or item + end, get_icon = config.get().opts.use_icons and function(item) return require("mini.icons").get("file", item.v) end or nil, diff --git a/lua/artio/utils.lua b/lua/artio/utils.lua index 7498211..f14912f 100644 --- a/lua/artio/utils.lua +++ b/lua/artio/utils.lua @@ -11,8 +11,9 @@ local function cmd_callback(o) end ---@param prg? string +---@param opts? table ---@return fun(arg?: string): string[] -function utils.make_cmd(prg) +function utils.make_cmd(prg, opts) return function(arg) if not prg then return {} @@ -23,9 +24,12 @@ function utils.make_cmd(prg) cmd = ("%s %s"):format(prg, arg) end return cmd_callback(vim - .system({ vim.o.shell, "-c", cmd }, { - text = true, - }) + .system( + { vim.o.shell, "-c", cmd }, + vim.tbl_extend("force", { + text = true, + }, opts or {}) + ) :wait()) end end