minimal extui fuzzy finder for neovim

feat(builtins): add `base_dir` option for `files()` and `grep()`

fix https://github.com/comfysage/artio.nvim/issues/16

+16 -12
+16 -12
lua/artio/builtins.lua
··· 34 34 ) 35 35 end 36 36 37 + ---@class artio.picker.generic.fs.Props : artio.Picker.config 38 + ---@field base_dir? string 39 + 37 40 local findprg = vim.fn.executable("fd") == 1 and "fd -H -p -a -t f --color=never --" 38 41 or "find . -type f -iregex '.*$*.*'" 39 42 40 - ---@class artio.picker.files.Props : artio.Picker.config 43 + ---@class artio.picker.files.Props : artio.picker.generic.fs.Props 41 44 ---@field findprg? string 42 45 43 46 ---@param props? artio.picker.files.Props ··· 45 48 props = props or {} 46 49 props.findprg = props.findprg or findprg 47 50 48 - local base_dir = vim.fn.getcwd(0) 51 + local base_dir = props.base_dir or vim.fn.getcwd(0) 49 52 local lst = utils.make_cmd(props.findprg, { 50 53 cwd = base_dir, 51 54 })() ··· 81 84 ) 82 85 end 83 86 84 - ---@class artio.picker.grep.Props : artio.Picker.config 87 + ---@class artio.picker.grep.Props : artio.picker.generic.fs.Props 85 88 ---@field grepprg? string 86 89 87 90 ---@param props? artio.picker.grep.Props ··· 89 92 props = props or {} 90 93 props.grepprg = props.grepprg or vim.o.grepprg 91 94 92 - local base_dir = vim.fn.getcwd(0) 95 + local base_dir = props.base_dir or vim.fn.getcwd(0) 93 96 local ui2 = require("vim._core.ui2") 94 97 local grepcmd = utils.make_cmd(props.grepprg, { 95 98 cwd = base_dir, ··· 273 276 end) 274 277 end, 275 278 preview_item = function(tag) 276 - return vim.api.nvim_create_buf(false, true), function(w) 277 - local buf = vim.api.nvim_win_get_buf(w) 278 - vim.bo[buf].bufhidden = "wipe" 279 - vim.bo[buf].buftype = "help" 279 + return vim.api.nvim_create_buf(false, true), 280 + function(w) 281 + local buf = vim.api.nvim_win_get_buf(w) 282 + vim.bo[buf].bufhidden = "wipe" 283 + vim.bo[buf].buftype = "help" 280 284 281 - vim._with({ buf = buf }, function() 282 - vim.cmd.help(tag) 283 - end) 284 - end 285 + vim._with({ buf = buf }, function() 286 + vim.cmd.help(tag) 287 + end) 288 + end 285 289 end, 286 290 }, props) 287 291 )