nvimrc: Add timestamp shortcuts

This commit is contained in:
Rob Watson 2022-06-17 17:08:40 +02:00
parent c113cdedd8
commit 344bb1783f
1 changed files with 19 additions and 2 deletions

21
nvimrc
View File

@ -164,7 +164,7 @@ function _G.insert_uuid()
vim.api.nvim_command([[normal! "up]])
end
vim.api.nvim_set_keymap("n", "<leader>uu", [[:lua _G.insert_uuid()<cr>]], {noremap = true, silent = true})
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()
@ -179,9 +179,26 @@ function _G.insert_jira_url()
vim.api.nvim_command([[normal! "up]])
end
vim.api.nvim_set_keymap("n", "<leader>ji", [[:lua _G.insert_jira_url()<cr>]], {noremap = true, silent = true})
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.call("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.call("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})
_G._test_cmd_to_wins = {}
_G._build_test_cmd = function()