-
It's me again. :-) It's a new month, and in my planning system that means I plan out what I want to do that month in a separate file. To create that file in wiki.vim, I decided to auto-create a link in my I have this super-simple global function in lua: function WikiMonthLink()
return print(os.date("[%B %Y](/journal/%Y/%m/plan.md)"))
end Here's my template: # {name}
{{WikiMonthLink}}
## Schedule
## Actions
## Roles
## Notes Where the placeholder is in the template, I just have a blank space. I am, admittedly, a Lua beginner, but this seemed so simple I can't see how it's not working. What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi :)
Sounds like a good idea!
The problem is that the file-based template only works with Vimscript functions. To be honest, I don't know quite how to fix that, but I think there is a decent workaround: instead of using a file template, you can use a function template. E.g.: vim.g.wiki_templates = {
{
match_re = ".*",
source_func = function(ctx)
vim.api.nvim_put({
"# " .. ctx.name,
"",
os.date("[%B %Y](/journal/%Y/%m/plan.md)"),
"",
"# Schedule",
"...",
}, "l", false, false)
end
},
} The concept here is that the source function must add the desired lines by use of e.g. The other alternative, of course, is to use a Vimscript function. |
Beta Was this translation helpful? Give feedback.
Hi :)
Sounds like a good idea!
The proble…