-
Hi! I'm working on converting from Logseq over to wiki.vim, due to my desire to keep everything in Markdown and human-readable. I read with interest the documentation on templates, but I'm not sure I get how to make them work. I'm using Neovim with the Lazy package manager. I converted the setup for journals in the docs over to Lua: return {
{
'lervag/wiki.vim',
config = function()
vim.g.wiki_journal = {
name = 'journal',
root = '',
frequency = 'daily',
date_format = {
daily = '%Y/%m/%d',
weekly = '%Y/week_%V',
monthly = '%Y/%m/summary',
},
}
end
},
{
'lervag/lists.vim',
}
} Using this setup, I want to make a template for both the monthly and the daily journal. The docs mention a file called I am a tech writer, so I would be happy to contribute documentation back in return for some help in setting this up. Thank you! --Rich |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
I assume this is a lazy.nvim configuration. First, you should use the return {
{
'lervag/wiki.vim',
init = function()
vim.g.wiki_journal = {
date_format = {
daily = '%Y/%m/%d',
weekly = '%Y/week_%V',
monthly = '%Y/%m/summary',
},
}
end
},
{
'lervag/lists.vim',
}
} Notice, though, I would suggest you also define the Now, the templates are slightly complicated. First, there are builtin templates for the monthly and weekly frequencies that are made to summarize the daily and weekly entries, respectively. These builtin templates will copy contents from the more frequent steps. These templates are really built around my own personal preference/need and may not be what you want. Let's consider the daily template, or for that matter, just any template you want for a "general" wiki page: you want to use the return {
{
'lervag/wiki.vim',
init = function()
vim.g.wiki_root = "/home/USER/wiki/.templates"
vim.g.wiki_templates = {
{
match_re = "\d\d\d\d\/\d\d\/\d\d",
source_filename = "/home/USER/wiki/.templates/daily.md"
},
},
end
}, where the daily template # {name}
# Plans
# Meetings The relevant parts of the current docs are Notice that any wiki pages will only have one template. Thus, if you define a template that matches any weekly or monthly pages, then the builtin tempolates will be deactivated.
If my help motivates you to suggest improvements to the docs I'll be very happy! :) |
Beta Was this translation helpful? Give feedback.
-
Okay; here's what I've got so far, but it's not working: return {
{
'lervag/wiki.vim',
init = function()
vim.g.wiki_journal = {
name = 'journal',
root = '',
frequency = 'daily',
date_format = {
daily = '%Y/%m/%d',
weekly = '%Y/week_%V',
monthly = '%Y/%m/summary',
},
}
vim.g.wiki_templates = {
{
match_re = "%d%d%d%d/%d%d/%d%d",
source_filename = "~/.VimStar/wiki/templates/daily.md"
},
}
end
},
{
'lervag/lists.vim',
}
} As you can see, I changed the I have my template in the proper location, and I set the wiki location in another file, but I still get a blank file when I use ww to open the journal. |
Beta Was this translation helpful? Give feedback.
-
It is not a Lua pattern, it is a Vim regex. So my version was correct, except it should be Also, not sure why you still include the keys you are not changing from their default values... So, this should work: return {
{
'lervag/wiki.vim',
init = function()
vim.g.wiki_journal = {
date_format = {
daily = '%Y/%m/%d',
weekly = '%Y/week_%V',
monthly = '%Y/%m/summary',
},
}
vim.g.wiki_templates = {
{
match_re = [[\d\d\d\d\/\d\d\/\d\d]],
source_filename = "/home/USER/wiki/.templates/daily.md"
},
},
end
},
{
'lervag/lists.vim',
}
} |
Beta Was this translation helpful? Give feedback.
-
Thank you for the correct syntax. For whatever reason, though, I'm still getting a blank file instead of my template when I use the code above. Also, as far as I can tell, I'm not using the defaults. From your code (which is in my call wiki#init#option('wiki_journal', {
\ 'name' : 'journal',
\ 'root' : '',
\ 'frequency' : 'daily',
\ 'date_format' : {
\ 'daily' : '%Y-%m-%d',
\ 'weekly' : '%Y_w%V',
\ 'monthly' : '%Y_m%m',
\ },
\}) This resulted in a more flat structure for the journal. I preferred what you had in the documentation, which breaks the journal out into year/month directories and then uses the day as the title for the file. That's why I'm specifying that in my configuration. |
Beta Was this translation helpful? Give feedback.
-
To start, you could try to use a more including regex. E.g., try
What I mean is that you don't need to specify the keys that you don't change. That is, you are only changing the Btw., I'm not used to the discussion feature on Github. It seems we should have used the comment thread to my initial reply instead of adding new comments. Not really important, just thought I'd mention it. |
Beta Was this translation helpful? Give feedback.
Ah, sorry, I just remembered - the
match_re
is only matched against the name, not the path. So, you should do this:Notice, here we use Lua patterns, since we are matching with a Lua function.