blob: 517dd43743f046cf1d67bf336df46371382d5727 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
local userregs = require("vim.userregs")
-- Get format from g:timestamp_register_format or use fallback
local function get_timestamp_format()
return vim.g.timestamp_register_format or "%Y-%m-%d %H:%M:%S"
end
local function generate_timestamp()
local ok, result = pcall(os.date, get_timestamp_format())
if not ok then
vim.notify("[userregs] Invalid timestamp format", vim.log.levels.WARN)
return os.date("%Y-%m-%d %H:%M:%S")
end
return result
end
userregs.register_handler('\20', {
put = function()
return generate_timestamp()
end,
yank = nil, -- read-only
})
|