mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
Merge 1d52816385
into bc0630e43b
This commit is contained in:
commit
d1acb83ab1
4 changed files with 39 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",
|
||||
|
|
|
@ -757,6 +757,35 @@ M.registers = {
|
|||
format = "register",
|
||||
preview = "preview",
|
||||
confirm = { "copy", "close" },
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<c-cr>"] = { "put_register", mode = { "n", "i" }, desc = "put, close" },
|
||||
["<s-cr>"] = { "put_register_before", mode = { "n", "i" }, desc = "put before, close" },
|
||||
["<c-g>"] = { "toggle_reg", mode = { "i", "n" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
actions = {
|
||||
put_register = function(picker, item, action)
|
||||
---@cast action snacks.picker.yank.Action
|
||||
picker:close()
|
||||
if item then
|
||||
local command = action and action.field == "before" and "P" or "p"
|
||||
vim.fn.feedkeys('"' .. item.reg .. command)
|
||||
end
|
||||
end,
|
||||
put_register_before = { action = "put_register", field = "before" },
|
||||
toggle_reg = function(picker)
|
||||
if string.match(picker.input.filter.pattern, "^reg:") then
|
||||
picker.input.filter.pattern = picker.input.filter.pattern:sub(5)
|
||||
else
|
||||
picker.input.filter.pattern = "reg:" .. picker.input.filter.pattern
|
||||
end
|
||||
picker.input:set()
|
||||
picker.input:update()
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
-- Special picker that resumes the last picker
|
||||
|
|
|
@ -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