···11# artio.nvim
2233-A minimal, nature-infused file picker for Neovim using the new extui window.
33+A minimal, nature-infused file picker for Neovim using ui2.
44Inspired by forest spirits and the calm intuition of hunting, Artio helps you gently select files without the weight of heavy fuzzy-finder dependencies.
5566
···991010Requires Neovim `>= 0.12`
11111212-- Lightweight picker window built on Neovim's extui
1212+- Lightweight picker window built on Neovim's ui2
1313- Prompt + list UI components - minimal and focused
1414- Fuzzy filtering using matchfuzzy (built-in)
1515- Icon support for common filetypes through [mini.icons](https://github.com/echasnovski/mini.nvim) _(optional)_
1616- No heavy dependencies - pure Lua
17171818-### extui
1818+### ui2
19192020-artio requires the extui to be enabled.
2020+artio requires ui2 to be enabled.
21212222an example of how to set this up is:
23232424```lua
2525-require("vim._extui").enable({ enable = true, msg = {
2525+require("vim._core.ui2").enable({ enable = true, msg = {
2626 target = "msg",
2727} })
2828```
+5-6
doc/artio.txt
···11-*artio.txt* a minimal, nature-infused file picker for neovim using the new
22- extui window
11+*artio.txt* a minimal, nature-infused file picker for neovim using ui2
3243==============================================================================
54···7687Requires Neovim `>= 0.12`
981010-- Lightweight picker window built on Neovim's extui
99+- Lightweight picker window built on Neovim's ui2
1110- Prompt + list UI components - minimal and focused
1211- Fuzzy filtering using matchfuzzy (built-in)
1312- Optional icon support for common filetypes through mini.icons
1413 (https://github.com/echasnovski/mini.nvim)
1514- No heavy dependencies - pure Lua
16151717-EXTUI
1616+UI2
18171919-artio requires the extui to be enabled.
1818+artio requires ui2 to be enabled.
20192120an example of how to set this up is:
22212322>lua
2424- require("vim._extui").enable({ enable = true, msg = {
2323+ require("vim._core.ui2").enable({ enable = true, msg = {
2524 target = "msg",
2625 } })
2726<
+3-3
lua/artio/builtins.lua
···9090 props.grepprg = props.grepprg or vim.o.grepprg
91919292 local base_dir = vim.fn.getcwd(0)
9393- local ext = require("vim._extui.shared")
9393+ local ui2 = require("vim._core.ui2")
9494 local grepcmd = utils.make_cmd(props.grepprg, {
9595 cwd = base_dir,
9696 })
···105105106106 local lines = grepcmd(input)
107107108108- vim.fn.setloclist(ext.wins.cmd, {}, " ", {
108108+ vim.fn.setloclist(ui2.wins.cmd, {}, " ", {
109109 title = "grep[" .. input .. "]",
110110 lines = lines,
111111 efm = vim.o.grepformat,
···113113 })
114114115115 return vim
116116- .iter(ipairs(vim.fn.getloclist(ext.wins.cmd)))
116116+ .iter(ipairs(vim.fn.getloclist(ui2.wins.cmd)))
117117 :map(function(i, locitem)
118118 local name = vim.fs.abspath(vim.fn.bufname(locitem.bufnr))
119119 return {
+2-2
lua/artio/health.lua
···77 vim.health.error("artio.nvim not loaded")
88 end
991010- if not vim.tbl_get(require("vim._extui.shared") or {}, "cfg", "enable") then
1111- vim.health.error("extui not enabled")
1010+ if not vim.tbl_get(require("vim._core.ui2") or {}, "cfg", "enable") then
1111+ vim.health.error("ui2 not enabled")
1212 end
13131414 if _G["MiniIcons"] then
+5-5
lua/artio/picker.lua
···169169end
170170171171function Picker:initkeymaps()
172172- local ext = require("vim._extui.shared")
172172+ local ui2 = require("vim._core.ui2")
173173174174 ---@type vim.keymap.set.Opts
175175- local opts = { buffer = ext.bufs.cmd }
175175+ local opts = { buffer = ui2.bufs.cmd }
176176177177 if self.actions then
178178 vim.iter(pairs(self.actions)):each(function(k, v)
···187187end
188188189189function Picker:delkeymaps()
190190- local ext = require("vim._extui.shared")
190190+ local ui2 = require("vim._core.ui2")
191191192192- local keymaps = vim.api.nvim_buf_get_keymap(ext.bufs.cmd, "i")
192192+ local keymaps = vim.api.nvim_buf_get_keymap(ui2.bufs.cmd, "i")
193193194194 vim.iter(ipairs(keymaps)):each(function(_, v)
195195 if v.lhs:match("^<Plug>(artio-action-") or (v.rhs and v.rhs:match("^<Plug>(artio-action-")) then
196196- vim.api.nvim_buf_del_keymap(ext.bufs.cmd, "i", v.lhs)
196196+ vim.api.nvim_buf_del_keymap(ui2.bufs.cmd, "i", v.lhs)
197197 end
198198 end)
199199end
+35-35
lua/artio/view.lua
···11-local cmdline = require("vim._extui.cmdline")
22-local ext = require("vim._extui.shared")
11+local cmdline = require("vim._core.ui2.cmdline")
22+local ui2 = require("vim._core.ui2")
3344local _log = {}
55local _loglevel = vim.log.levels.ERROR
···3838---@param hide boolean Whether to hide or show the window.
3939---@param height integer (Text)height of the cmdline window.
4040local function win_config(win, hide, height)
4141- if ext.cmdheight == 0 and vim.api.nvim_win_get_config(win).hide ~= hide then
4141+ if ui2.cmdheight == 0 and vim.api.nvim_win_get_config(win).hide ~= hide then
4242 vim.api.nvim_win_set_config(win, { hide = hide, height = not hide and height or nil })
4343 elseif vim.api.nvim_win_get_height(win) ~= height then
4444 vim.api.nvim_win_set_height(win, height)
···4949 vim._with({ noautocmd = true, o = { splitkeep = "screen" } }, function()
5050 vim.o.cmdheight = height
5151 end)
5252- ext.msg.set_pos()
5252+ ui2.msg.set_pos()
5353 end
5454end
5555···9292--- gets updated after changedtick event
9393local last_draw_tick = 0
9494local function get_changedtick()
9595- return vim.api.nvim_buf_get_changedtick(ext.bufs.cmd)
9595+ return vim.api.nvim_buf_get_changedtick(ui2.bufs.cmd)
9696end
97979898local cmdbuff = "" ---@type string Stored cmdline used to calculate translation offset.
···119119120120 self:promptpos()
121121 self:setlines(promptidx, promptidx + 1, lines)
122122- vim.fn.prompt_setprompt(ext.bufs.cmd, promptstr)
122122+ vim.fn.prompt_setprompt(ui2.bufs.cmd, promptstr)
123123 vim.schedule(function()
124124- local ok, result = pcall(vim.api.nvim_buf_set_mark, ext.bufs.cmd, ":", promptidx + 1, promptlen, {})
124124+ local ok, result = pcall(vim.api.nvim_buf_set_mark, ui2.bufs.cmd, ":", promptidx + 1, promptlen, {})
125125 if not ok then
126126 logerror(("Failed to set mark %d:%d\n\t%s"):format(promptidx, promptlen, result))
127127 return
···141141function View:show(content, pos, firstc, prompt, indent, level, hl_id)
142142 cmdline.level, cmdline.indent = level, indent
143143 if cmdline.highlighter and cmdline.highlighter.active then
144144- cmdline.highlighter.active[ext.bufs.cmd] = nil
144144+ cmdline.highlighter.active[ui2.bufs.cmd] = nil
145145 end
146146- if ext.msg.cmd.msg_row ~= -1 then
147147- ext.msg.msg_clear()
146146+ if ui2.msg.cmd.msg_row ~= -1 then
147147+ ui2.msg.msg_clear()
148148 end
149149- ext.msg.virt.last = { {}, {}, {}, {} }
149149+ ui2.msg.virt.last = { {}, {}, {}, {} }
150150151151 self:clear()
152152 prompthl_id = hl_id
···169169170170---@param predicted? integer The predicted height of the cmdline window
171171function View:updatewinheight(predicted)
172172- local height = math.max(1, predicted or vim.api.nvim_win_text_height(ext.wins.cmd, {}).all)
172172+ local height = math.max(1, predicted or vim.api.nvim_win_text_height(ui2.wins.cmd, {}).all)
173173 height = math.min(height, self.win.height)
174174- win_config(ext.wins.cmd, false, height)
174174+ win_config(ui2.wins.cmd, false, height)
175175end
176176177177function View:saveview()
···211211 self.opts[level] = self.opts[level] or {}
212212 local props = {
213213 scope = level == "g" and "global" or "local",
214214- buf = level == "buf" and ext.bufs.cmd or nil,
215215- win = level == "win" and ext.wins.cmd or nil,
214214+ buf = level == "buf" and ui2.bufs.cmd or nil,
215215+ win = level == "win" and ui2.wins.cmd or nil,
216216 }
217217218218 for name, value in pairs(o) do
···248248 _log = nil
249249 _log = {}
250250251251- ext.check_targets()
251251+ ui2.check_targets()
252252253253 vim.schedule(function()
254254 self.augroup = vim.api.nvim_create_augroup("artio:group", { clear = true })
···286286287287 vim.api.nvim_create_autocmd("TextChangedI", {
288288 group = self.augroup,
289289- buffer = ext.bufs.cmd,
289289+ buffer = ui2.bufs.cmd,
290290 callback = function()
291291 self:update()
292292 end,
···294294295295 vim.api.nvim_create_autocmd("CursorMovedI", {
296296 group = self.augroup,
297297- buffer = ext.bufs.cmd,
297297+ buffer = ui2.bufs.cmd,
298298 callback = function()
299299 self:updatecursor()
300300 end,
···312312 self:trigger_show()
313313314314 vim._with({ noautocmd = true }, function()
315315- vim.api.nvim_set_current_win(ext.wins.cmd)
315315+ vim.api.nvim_set_current_win(ui2.wins.cmd)
316316 end)
317317318318 self:setopts()
···325325326326 -- trigger after registering events
327327 vim.schedule(function()
328328- vim._with({ win = ext.wins.cmd, wo = { eventignorewin = "" } }, function()
328328+ vim._with({ win = ui2.wins.cmd, wo = { eventignorewin = "" } }, function()
329329 vim.api.nvim_exec_autocmds("WinEnter", {})
330330 end)
331331 end)
···338338 self:closepreview()
339339 vim.schedule(function()
340340 pcall(vim.api.nvim_del_augroup_by_id, self.augroup)
341341- pcall(vim.api.nvim_buf_detach, ext.bufs.cmd)
341341+ pcall(vim.api.nvim_buf_detach, ui2.bufs.cmd)
342342343343 vim.cmd.stopinsert()
344344···364364end
365365366366function View:hide()
367367- vim.fn.clearmatches(ext.wins.cmd) -- Clear matchparen highlights.
368368- vim.api.nvim_win_set_cursor(ext.wins.cmd, { 1, 0 })
369369- vim.api.nvim_buf_set_lines(ext.bufs.cmd, 0, -1, false, {})
367367+ vim.fn.clearmatches(ui2.wins.cmd) -- Clear matchparen highlights.
368368+ vim.api.nvim_win_set_cursor(ui2.wins.cmd, { 1, 0 })
369369+ vim.api.nvim_buf_set_lines(ui2.bufs.cmd, 0, -1, false, {})
370370371371 local clear = vim.schedule_wrap(function(was_prompt)
372372 -- Avoid clearing prompt window when it is re-entered before the next event
373373 -- loop iteration. E.g. when a non-choice confirm button is pressed.
374374 if was_prompt and not cmdline.prompt then
375375 pcall(function()
376376- vim.api.nvim_buf_set_lines(ext.bufs.cmd, 0, -1, false, {})
377377- vim.api.nvim_buf_set_lines(ext.bufs.dialog, 0, -1, false, {})
378378- vim.api.nvim_win_set_config(ext.wins.dialog, { hide = true })
379379- vim.on_key(nil, ext.msg.dialog_on_key)
376376+ vim.api.nvim_buf_set_lines(ui2.bufs.cmd, 0, -1, false, {})
377377+ vim.api.nvim_buf_set_lines(ui2.bufs.dialog, 0, -1, false, {})
378378+ vim.api.nvim_win_set_config(ui2.wins.dialog, { hide = true })
379379+ vim.on_key(nil, ui2.msg.dialog_on_key)
380380 end)
381381 end
382382 -- Messages emitted as a result of a typed command are treated specially:
···389389 clear(cmdline.prompt)
390390391391 cmdline.prompt, cmdline.level = false, 0
392392- win_config(ext.wins.cmd, true, ext.cmdheight)
392392+ win_config(ui2.wins.cmd, true, ui2.cmdheight)
393393end
394394395395function View:trigger_show()
···441441 self:promptpos()
442442443443 if not pos or pos < 0 then
444444- local cursorpos = vim.api.nvim_win_get_cursor(ext.wins.cmd)
444444+ local cursorpos = vim.api.nvim_win_get_cursor(ui2.wins.cmd)
445445 pos = cursorpos[2] - promptlen
446446 end
447447···459459 curpos[1], curpos[2] = promptidx + 1, promptlen + pos
460460461461 vim._with({ noautocmd = true }, function()
462462- local ok, _ = pcall(vim.api.nvim_win_set_cursor, ext.wins.cmd, curpos)
462462+ local ok, _ = pcall(vim.api.nvim_win_set_cursor, ui2.wins.cmd, curpos)
463463 if not ok then
464464 logerror(("Failed to set cursor %d:%d"):format(curpos[1], curpos[2]))
465465 end
···482482 -- update winheight to prevent wrong scroll when increasing from 1
483483 local diff = #lines - (posend - posstart)
484484 if diff ~= 0 then
485485- local height = vim.api.nvim_win_text_height(ext.wins.cmd, {}).all
485485+ local height = vim.api.nvim_win_text_height(ui2.wins.cmd, {}).all
486486 local predicted = height + diff
487487 self:updatewinheight(predicted)
488488 end
489489490490 before_draw_tick = get_changedtick()
491491- vim.api.nvim_buf_set_lines(ext.bufs.cmd, posstart, posend, false, lines)
491491+ vim.api.nvim_buf_set_lines(ui2.bufs.cmd, posstart, posend, false, lines)
492492 last_draw_tick = get_changedtick()
493493end
494494···511511function View:mark(id, line, col, opts)
512512 if id and self.marks[id] then
513513 vim._with({ noautocmd = true }, function()
514514- vim.api.nvim_buf_del_extmark(ext.bufs.cmd, view_ns, self.marks[id])
514514+ vim.api.nvim_buf_del_extmark(ui2.bufs.cmd, view_ns, self.marks[id])
515515 end)
516516 self.marks[id] = nil
517517 end
···521521522522 local ok, result
523523 vim._with({ noautocmd = true }, function()
524524- ok, result = pcall(vim.api.nvim_buf_set_extmark, ext.bufs.cmd, view_ns, line, col, opts)
524524+ ok, result = pcall(vim.api.nvim_buf_set_extmark, ui2.bufs.cmd, view_ns, line, col, opts)
525525 end)
526526 if not ok then
527527 logerror(("Failed to add extmark %d:%d\n\t%s"):format(line, col, result))