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