minimal extui fuzzy finder for neovim

feat: fuzzy matching

+29 -5
+2 -2
lua/artio/init.lua
··· 16 16 if not findprg then 17 17 return {} 18 18 end 19 - local farg = string.format("'%s'", match) 19 + local farg = string.format("'%s'", match or '') 20 20 local findcmd, n = findprg:gsub("%$%*", farg) 21 21 if n == 0 then 22 22 findcmd = findcmd .. " " .. farg ··· 41 41 return artio.pick({ 42 42 prompt = "files", 43 43 fn = function(input) 44 - local lst = find_files(input) 44 + local lst = find_files() 45 45 if not lst or #lst == 0 then 46 46 return {} 47 47 end
+24 -3
lua/artio/view.lua
··· 298 298 promptidx = self.picker.opts.bottom and cmdline.erow or 0 299 299 end 300 300 301 + local view_ns = vim.api.nvim_create_namespace("artio:view:ns") 302 + ---@type vim.api.keyset.set_extmark 303 + local ext_match_opts = { 304 + hl_group = "ArtioMatch", 305 + hl_mode = "combine", 306 + } 307 + 301 308 function View:showitems() 302 - local prefix = (" "):rep(vim.fn.strdisplaywidth(self.picker.opts.pointer) + 1) 309 + local indent = vim.fn.strdisplaywidth(self.picker.opts.pointer) + 1 310 + local prefix = (" "):rep(indent) 303 311 304 312 local lines = {} ---@type string[] 313 + local hls = {} 305 314 for i = 1, math.min(#self.picker.items, self.win.height - 1) do 306 315 lines[#lines + 1] = ("%s%s"):format(prefix, self.picker.items[i][1]) 316 + hls[#hls + 1] = self.picker.items[i][2] 307 317 end 308 318 cmdline.erow = cmdline.srow + #lines 309 319 vim.api.nvim_buf_set_lines(ext.bufs.cmd, cmdline.srow, cmdline.erow, false, lines) 320 + 321 + for i = 1, #hls do 322 + for j = 1, #hls[i] do 323 + local col = indent + hls[i][j] 324 + vim.api.nvim_buf_set_extmark( 325 + ext.bufs.cmd, 326 + view_ns, 327 + cmdline.srow + i - 1, 328 + col, 329 + vim.tbl_extend("force", ext_match_opts, { end_col = col+1 }) 330 + ) 331 + end 332 + end 310 333 end 311 - 312 - local view_ns = vim.api.nvim_create_namespace("artio:view:ns") 313 334 314 335 function View:hlselect() 315 336 if self.select_ext then
+3
plugin/artio.lua
··· 19 19 local cursorline_hl = vim.api.nvim_get_hl(0, { name = "CursorLine" }) 20 20 vim.api.nvim_set_hl(0, "ArtioSel", { fg = cursor_hl.bg, bg = cursorline_hl.bg, default = true }) 21 21 vim.api.nvim_set_hl(0, "ArtioPointer", { fg = cursor_hl.bg, default = true }) 22 + 23 + vim.api.nvim_set_hl(0, "ArtioMatch", { link = "PmenuMatch", default = true }) 22 24 end, 23 25 }) 24 26 ··· 29 31 vim.api.nvim_set_hl(0, "ArtioPrompt", {}) 30 32 vim.api.nvim_set_hl(0, "ArtioSel", {}) 31 33 vim.api.nvim_set_hl(0, "ArtioPointer", {}) 34 + vim.api.nvim_set_hl(0, "ArtioMatch", {}) 32 35 end, 33 36 }) 34 37