mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(picker): make register picker list more informative
This commit - adds separate hightlighting for different register types (numbered, named, other) - adds a hint about the register type (characterwise, linewise, blockwise) similar to the builtin :reg command
This commit is contained in:
parent
bc0630e43b
commit
00e7380b69
3 changed files with 10 additions and 2 deletions
|
@ -38,7 +38,9 @@ Snacks.util.set_hl({
|
|||
AuGroup = "Type",
|
||||
DiagnosticCode = "Special",
|
||||
DiagnosticSource = "Comment",
|
||||
Register = "Number",
|
||||
RegisterNumber = "Number",
|
||||
RegisterOther = "Constant",
|
||||
RegisterString = "String",
|
||||
KeymapMode = "Number",
|
||||
KeymapLhs = "Special",
|
||||
KeymapNowait = "@variable.builtin",
|
||||
|
|
|
@ -596,11 +596,14 @@ end
|
|||
|
||||
function M.register(item)
|
||||
local ret = {} ---@type snacks.picker.Highlight[]
|
||||
local hl = string.match(item.reg, "[0-9]") and "Number" or string.match(item.reg, "[a-z]") and "String" or "Other"
|
||||
ret[#ret + 1] = { " " }
|
||||
ret[#ret + 1] = { "[", "SnacksPickerDelim" }
|
||||
ret[#ret + 1] = { item.reg, "SnacksPickerRegister" }
|
||||
ret[#ret + 1] = { item.reg, "SnacksPickerRegister" .. hl }
|
||||
ret[#ret + 1] = { "]", "SnacksPickerDelim" }
|
||||
ret[#ret + 1] = { " " }
|
||||
ret[#ret + 1] = { item.type, "Comment" }
|
||||
ret[#ret + 1] = { " " }
|
||||
ret[#ret + 1] = { item.value }
|
||||
return ret
|
||||
end
|
||||
|
|
|
@ -273,11 +273,14 @@ function M.registers()
|
|||
value = (ok and reg_value or "") --[[@as string]]
|
||||
end
|
||||
if value ~= "" then
|
||||
local type = vim.fn.getregtype(reg)
|
||||
type = type == "v" and "c" or type == "V" and "l" or "b:" .. type:sub(2)
|
||||
table.insert(items, {
|
||||
text = ("%s: %s"):format(reg, value:gsub("\n", "\\n"):gsub("\r", "\\r")),
|
||||
reg = reg,
|
||||
label = reg,
|
||||
data = value,
|
||||
type = type,
|
||||
value = value:gsub("\n", "\\n"):gsub("\r", "\\r"),
|
||||
preview = {
|
||||
text = value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue