minimal extui fuzzy finder for neovim

feat: allow scrolling

+15 -4
+3 -1
lua/artio/picker.lua
··· 59 59 if typed == "<down>" then 60 60 self.idx = self.idx + 1 61 61 self:fix() 62 + view:showitems() 62 63 view:hlselect() 63 64 return "" 64 65 elseif typed == "<up>" then 65 66 self.idx = self.idx - 1 66 67 self:fix() 68 + view:showitems() 67 69 view:hlselect() 68 70 return "" 69 71 elseif typed == "<cr>" then ··· 97 99 98 100 function Picker:fix() 99 101 self.idx = math.max(self.idx, self.opts.preselect and 1 or 0) 100 - self.idx = math.min(self.idx, self.win.height - 1, #self.items) 102 + self.idx = math.min(self.idx, #self.items) 101 103 end 102 104 103 105 function Picker:getitems(input)
+12 -3
lua/artio/view.lua
··· 305 305 hl_mode = "combine", 306 306 } 307 307 308 + local offset = 0 309 + 308 310 function View:showitems() 309 311 local indent = vim.fn.strdisplaywidth(self.picker.opts.pointer) + 1 310 312 local prefix = (" "):rep(indent) 311 313 314 + local _offset = math.max(0, self.picker.idx - (self.win.height - 1)) 315 + if _offset > offset then 316 + offset = _offset 317 + elseif self.picker.idx <= offset then 318 + offset = self.picker.idx - 1 319 + end 320 + 312 321 local lines = {} ---@type string[] 313 322 local hls = {} 314 - for i = 1, math.min(#self.picker.items, self.win.height - 1) do 323 + for i = 1 + offset, math.min(#self.picker.items, self.win.height - 1 + offset) do 315 324 lines[#lines + 1] = ("%s%s"):format(prefix, self.picker.items[i][1]) 316 325 hls[#hls + 1] = self.picker.items[i][2] 317 326 end ··· 326 335 view_ns, 327 336 cmdline.srow + i - 1, 328 337 col, 329 - vim.tbl_extend("force", ext_match_opts, { end_col = col+1 }) 338 + vim.tbl_extend("force", ext_match_opts, { end_col = col + 1 }) 330 339 ) 331 340 end 332 341 end ··· 343 352 return 344 353 end 345 354 346 - self.select_ext = vim.api.nvim_buf_set_extmark(ext.bufs.cmd, view_ns, cmdline.srow + idx - 1, 0, { 355 + self.select_ext = vim.api.nvim_buf_set_extmark(ext.bufs.cmd, view_ns, cmdline.srow + idx - offset - 1, 0, { 347 356 virt_text = { { self.picker.opts.pointer, "ArtioPointer" } }, 348 357 hl_mode = "combine", 349 358 virt_text_pos = "overlay",