Skip to content

Instantly share code, notes, and snippets.

@shanehull
Created September 12, 2024 06:23
Show Gist options
  • Save shanehull/d5bdb0dbb162ab4d88d3e2da3ec69388 to your computer and use it in GitHub Desktop.
Save shanehull/d5bdb0dbb162ab4d88d3e2da3ec69388 to your computer and use it in GitHub Desktop.
-- **User command to insert a decision template at the current line** --
vim.api.nvim_create_user_command("Decision", function()
local template = [[
**Mental/physical state:**
- [ ] Energized
- [ ] Focused
- [ ] Relaxed
- [ ] Confident
- [ ] Tired
- [ ] Accepting
- [ ] Accommodating
- [ ] Anxious
- [ ] Resigned
- [ ] Frustrated
- [ ] Angry
**Decision opportunity:**
**Variables:**
**Alternatives:**
**The decision:**
**Expected outcome and probabilities:**
**Additional context:**
]]
-- Get the current cursor position
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
-- Insert the template at the current line
vim.api.nvim_buf_set_lines(0, row, row, false, vim.split(template, "\n"))
end, {})
-- **Keymap to run the 'Decision' user command** --
vim.api.nvim_set_keymap("n", "<leader>D", ":Decision<CR>", { desc = "New decision template" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment