minimal extui fuzzy finder for neovim

fix(view): extmark priority

- add priority to extmarks
- use end_row +1 instead of line_hl
- override `:mark()` opts with `{ hl_mode = "combine", invalide = true }`

+43 -39
+43 -39
lua/artio/view.lua
··· 368 368 end 369 369 370 370 local view_ns = vim.api.nvim_create_namespace("artio:view:ns") 371 - ---@type vim.api.keyset.set_extmark 372 - local ext_match_opts = { 373 - hl_group = "ArtioMatch", 374 - hl_mode = "combine", 375 - invalidate = true, 371 + local ext_priority = { 372 + prompt = 1, 373 + info = 2, 374 + select = 4, 375 + marker = 8, 376 + hl = 16, 377 + icon = 32, 378 + match = 64, 376 379 } 377 380 378 381 ---@param line integer 0-based ··· 380 383 ---@param opts vim.api.keyset.set_extmark 381 384 ---@return integer 382 385 function View:mark(line, col, opts) 386 + opts.hl_mode = "combine" 387 + opts.invalidate = true 388 + 383 389 local ok, result 384 390 vim._with({ noautocmd = true }, function() 385 391 ok, result = pcall(vim.api.nvim_buf_set_extmark, ext.bufs.cmd, view_ns, line, col, opts) 386 392 end) 387 393 if not ok then 388 - vim.notify(("Failed to add extmark %d:%d"):format(line, col), vim.log.levels.ERROR) 394 + vim.notify(("Failed to add extmark %d:%d\n\t%s"):format(line, col, result), vim.log.levels.ERROR) 389 395 return -1 390 396 end 391 397 ··· 394 400 395 401 function View:drawprompt() 396 402 if promptlen > 0 and prompthl_id > 0 then 397 - self:mark(promptidx, 0, { hl_group = prompthl_id, end_col = promptlen }) 403 + self:mark(promptidx, 0, { hl_group = prompthl_id, end_col = promptlen, priority = ext_priority.prompt }) 398 404 self:mark(promptidx, 0, { 399 405 virt_text = { 400 406 { ··· 403 409 }, 404 410 }, 405 411 virt_text_pos = "eol_right_align", 406 - hl_mode = "combine", 407 - invalidate = true, 412 + priority = ext_priority.info, 408 413 }) 409 414 end 410 415 end ··· 480 485 local icon_indent = has_icon and (#icons[i][1] + icon_pad) or 0 481 486 482 487 if has_icon and icons[i][2] then 483 - self:mark( 484 - cmdline.srow + i - 1, 485 - indent, 486 - vim.tbl_extend("force", ext_match_opts, { 487 - end_col = indent + icon_indent, 488 - hl_group = icons[i][2], 489 - }) 490 - ) 488 + self:mark(cmdline.srow + i - 1, indent, { 489 + end_col = indent + icon_indent, 490 + hl_group = icons[i][2], 491 + priority = ext_priority.icon, 492 + }) 491 493 end 492 494 493 495 local line_hls = custom_hls[i] 494 496 if line_hls then 495 497 for j = 1, #line_hls do 496 498 local hl = line_hls[j] 497 - self:mark( 498 - cmdline.srow + i - 1, 499 - indent + icon_indent + hl[1][1], 500 - vim.tbl_extend("force", ext_match_opts, { 501 - end_col = indent + icon_indent + hl[1][2], 502 - hl_group = hl[2], 503 - }) 504 - ) 499 + self:mark(cmdline.srow + i - 1, indent + icon_indent + hl[1][1], { 500 + end_col = indent + icon_indent + hl[1][2], 501 + hl_group = hl[2], 502 + priority = ext_priority.hl, 503 + }) 505 504 end 506 505 end 507 506 508 507 if marks[i] then 509 508 self:mark(cmdline.srow + i - 1, indent - 1, { 510 509 virt_text = { { self.picker.opts.marker, "ArtioMarker" } }, 511 - hl_mode = "combine", 512 510 virt_text_pos = "overlay", 513 - invalidate = true, 511 + priority = ext_priority.marker, 514 512 }) 515 513 end 516 514 517 515 if hls[i] then 518 516 for j = 1, #hls[i] do 519 517 local col = indent + icon_indent + hls[i][j] 520 - self:mark(cmdline.srow + i - 1, col, vim.tbl_extend("force", ext_match_opts, { end_col = col + 1 })) 518 + self:mark(cmdline.srow + i - 1, col, { 519 + hl_group = "ArtioMatch", 520 + end_col = col + 1, 521 + priority = ext_priority.match, 522 + }) 521 523 end 522 524 end 523 525 end ··· 544 546 return 545 547 end 546 548 547 - do 548 - local extid = self:mark(row, 0, { 549 - virt_text = { { self.picker.opts.pointer, "ArtioPointer" } }, 550 - hl_mode = "combine", 551 - virt_text_pos = "overlay", 552 - line_hl_group = "ArtioSel", 553 - invalidate = true, 554 - }) 555 - if extid ~= -1 then 556 - self.select_ext = extid 557 - end 549 + local extid = self:mark(row, 0, { 550 + virt_text = { { self.picker.opts.pointer, "ArtioPointer" } }, 551 + virt_text_pos = "overlay", 552 + 553 + hl_group = "ArtioSel", 554 + hl_eol = true, 555 + end_row = row + 1, 556 + end_col = 0, 557 + 558 + priority = ext_priority.select, 559 + }) 560 + if extid ~= -1 then 561 + self.select_ext = extid 558 562 end 559 563 end 560 564