62 lines
1.7 KiB
Lua
62 lines
1.7 KiB
Lua
function _G.dump(...)
|
|
local objects = vim.tbl_map(vim.inspect, { ... })
|
|
print(unpack(objects))
|
|
return ...
|
|
end
|
|
|
|
function _G.insert_uuid()
|
|
local uuid = vim.fn.system("uuidprint")
|
|
local errcode = vim.v.shell_error
|
|
if errcode ~= 0 then
|
|
vim.api.nvim_err_writeln("uuidprint returned error code: " .. errcode)
|
|
return
|
|
end
|
|
|
|
vim.fn.setreg("u", uuid)
|
|
vim.api.nvim_command([[normal! "up]])
|
|
end
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>pu", [[:lua _G.insert_uuid()<cr>]], { noremap = true, silent = true })
|
|
vim.api.nvim_set_keymap("i", "<c-d><c-u>", [[<esc>:lua _G.insert_uuid()<cr>a]], { noremap = true, silent = true })
|
|
|
|
function _G.insert_jira_url()
|
|
local url = vim.fn.system("jira")
|
|
local errcode = vim.v.shell_error
|
|
if errcode ~= 0 then
|
|
vim.api.nvim_err_writeln("jira returned error code: " .. errcode)
|
|
return
|
|
end
|
|
|
|
vim.fn.setreg("u", url)
|
|
vim.api.nvim_command([[normal! "up]])
|
|
end
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>pj", [[:lua _G.insert_jira_url()<cr>]], { noremap = true, silent = true })
|
|
vim.api.nvim_set_keymap("i", "<c-d><c-j>", [[<esc>:lua _G.insert_jira_url()<cr>a]], { noremap = true, silent = true })
|
|
|
|
function _G.insert_iso8601_timestamp()
|
|
local ts = vim.fn.system("echo -n $(date --iso-8601=seconds)")
|
|
|
|
local errcode = vim.v.shell_error
|
|
if errcode ~= 0 then
|
|
vim.api.nvim_err_writeln("date returned error code: " .. errcode)
|
|
return
|
|
end
|
|
|
|
vim.fn.setreg("u", ts)
|
|
vim.api.nvim_command([[normal! "up]])
|
|
end
|
|
|
|
vim.api.nvim_set_keymap(
|
|
"n",
|
|
"<leader>pt",
|
|
[[:lua _G.insert_iso8601_timestamp()<cr>]],
|
|
{ noremap = true, silent = true }
|
|
)
|
|
vim.api.nvim_set_keymap(
|
|
"i",
|
|
"<c-d><c-t>",
|
|
[[<esc>:lua _G.insert_iso8601_timestamp()<cr>a]],
|
|
{ noremap = true, silent = true }
|
|
)
|