tangled
alpha
login
or
join now
robinwobin.dev
/
artio.nvim
3
fork
atom
minimal extui fuzzy finder for neovim
3
fork
atom
overview
issues
pulls
pipelines
feat: allow scrolling
robinwobin.dev
4 months ago
b33878df
f6418344
+15
-4
2 changed files
expand all
collapse all
unified
split
lua
artio
picker.lua
view.lua
+3
-1
lua/artio/picker.lua
···
59
59
if typed == "<down>" then
60
60
self.idx = self.idx + 1
61
61
self:fix()
62
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
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
100
-
self.idx = math.min(self.idx, self.win.height - 1, #self.items)
102
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
308
+
local offset = 0
309
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
314
+
local _offset = math.max(0, self.picker.idx - (self.win.height - 1))
315
315
+
if _offset > offset then
316
316
+
offset = _offset
317
317
+
elseif self.picker.idx <= offset then
318
318
+
offset = self.picker.idx - 1
319
319
+
end
320
320
+
312
321
local lines = {} ---@type string[]
313
322
local hls = {}
314
314
-
for i = 1, math.min(#self.picker.items, self.win.height - 1) do
323
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
329
-
vim.tbl_extend("force", ext_match_opts, { end_col = col+1 })
338
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
346
-
self.select_ext = vim.api.nvim_buf_set_extmark(ext.bufs.cmd, view_ns, cmdline.srow + idx - 1, 0, {
355
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",