You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tell us about what's bothering you...
While I understand having two different functions for creating a note, that means I need to memorize two keymaps! I created this function to give me a menu for creating a new note:
local Menu = require("nui.menu")
local event = require("nui.utils.autocmd").event
local telekasten = require("plugins.telekasten")
local menu = Menu({
position = "50%",
size = {
width = 25,
height = 5,
},
border = {
style = "single",
text = {
top = "[ Create New Note ]",
top_align = "center",
},
},
win_options = {
winhighlight = "Normal:Normal,FloatBorder:Normal",
},
}, {
lines = {
Menu.item("New Blank Note", { id = 1 }),
Menu.item("New Templated Note", { id = 2 }),
Menu.item("Quit", { id = 3 }),
},
max_width = 20,
keymap = {
focus_next = { "j", "<Down>", "<Tab>" },
focus_prev = { "k", "<Up>", "<S-Tab>" },
close = { "<Esc>", "<C-c>" },
submit = { "<CR>", "<Space>" },
},
on_close = function()
print("Menu Closed.")
end,
on_submit = function(item)
if item.id == 1 then
vim.cmd([[Telekasten new_note]])
elseif item.id == 2 then
vim.cmd([[Telekasten new_templated_note]])
else
print("Menu Closed.")
end
end,
})
-- mount the component
menu:mount()
I saved it in ~/.config/nvim/lua/functions/createNewNote.lua and then mapped it to the following:
thw26
changed the title
Combine Create New Note and Create Templated Note
A Script to Combine Create New Note and Create Templated Note
Jul 7, 2023
thw26
changed the title
A Script to Combine Create New Note and Create Templated Note
A Script to Combine new_note() and new_templated_note()
Jul 7, 2023
I am not sure I understand the purpose of that. If you are going to use a menu and require one more input before actually create the note, can't you just use new_templated_note in all cases and select the appropriate template when you just want to create a note?
In any case, once the code is a bit more refactored, I will completely rework the various function/pickers to simplify them and make them more versatile. Ideally, everything could be done by 3/4 pickers. We could then provide aliases to tailor the arguments of the picker functions automatically or just let the user specify their mappings as they want.
I am not sure I understand the purpose of that. If you are going to use a menu and require one more input before actually create the note, can't you just use new_templated_note in all cases and select the appropriate template when you just want to create a note?
Yes, but then I need a template for a blank file. I see your point though; a blank template would accomplish the same thing and remove the need for an extra menu.
Please confirm
Tell us about what's bothering you...
While I understand having two different functions for creating a note, that means I need to memorize two keymaps! I created this function to give me a menu for creating a new note:
I saved it in
~/.config/nvim/lua/functions/createNewNote.lua
and then mapped it to the following:Would you be interested in having this added to the wiki or somewhere else?
The text was updated successfully, but these errors were encountered: