wiki.vim
wiki.vim copied to clipboard
How: Go to week/month summary ?
Description
Plug 'lervag/wiki.vim'
let g:wiki_root = expand("<sfile>:p:h:h:h") . "/Vimwiki/"
let g:wiki_index_name = 'index'
let g:wiki_filetypes = ['md']
scene1 - Go to week summary: fail
<leader>w<leader>wopen today journal<leader>wu
scene2 - Go to week summary: ok - but quite complex
<leader>wwopen wiki.vim index:cd %:p:hset pwd to index folder<leader>w<leader>wopen today journal<leader>wu
scene3 - Go to week summary: fail - if today journal exist
<leader>wwopen wiki.vim index:cd %:p:hset pwd to index folder<leader>w<leader>wopen today journal:wqsave today joural and quit vim- Repeat scene2: Nothing happened except for the undo.
scene4 - Go to month summary: fail
<leader>w<leader>wopen today journal<leader>wm
scene5 - Go to month summary: fail
<leader>wwopen wiki.vim index:cd %:p:hset pwd to index folder<leader>w<leader>wopen today journal<leader>wmNothing happened
You don't need the last two options, since you are not changing them from their default values. So, this should suffice:
Plug 'lervag/wiki.vim'
let g:wiki_root = expand("<sfile>:p:h:h:h") . "/Vimwiki/"
scene1 - Go to week summary: fail
This seems to be related to the Windows specific file paths. But I'm not quite sure. I've never used wiki.vim on a Windows machine. I have tried to make it compatible, though.
I'm looking at the code, and I notice that the error comes from the date and time handlers:
https://github.com/lervag/wiki.vim/blob/121a62fcb47cd7a5230175d94df44daa8b5dcd29/autoload/wiki/date/strptime.vim#L17-L19
I believe the problem is related to the conversion between a path and the date.
scene2 - Go to week summary: ok - but quite complex
:cd %:p:hset pwd to index folder
What happens if you set pwd to index folder with scene1?
scene3 - Go to week summary: fail - if today journal exist
This is very strange! I don't understand it. Is it OK if we focus on scenes 1 and 2 first?
scene4 - Go to month summary: fail
This is most likely the same error as for scene1, so let's ignore scene4 for now.
scene5 - Go to month summary: fail
I'm not sure about this one, but I propose we ignore it until we've figured out the problem with scene1. OK?
Can you do this:
<leader>wwopen wiki.vim index<leader>w<leader>wopen today journal- Run
:echo wiki#journal#get_current_node()- what's the output? :cd %:p:hset pwd to index folder- Again, run
:echo wiki#journal#get_current_node()- what's the output?
I'm also worrying that the function s:node_to_path may not work properly on Windows. To test that, you should change the function name to e.g. wiki#journal#node_to_path, then you could test it with e.g. :echo wiki#journal#node_to_path("2024-04-01"); let me know if you need more help to do that.
vimrc
I have simplified vimrc as per your suggestion to the following
Plug 'lervag/wiki.vim'
let g:wiki_root = expand("<sfile>:p:h:h:h") . "/Vimwiki/"
and set shellslash for the Windows environment:
function! ToggleShellslashForVimPlug()
if exists('g:plugs')
autocmd User PlugBegin set noshellslash
autocmd User PlugEnd set shellslash
endif
endfunction
set noshellslash
call plug#begin()
.......
call plug#end()
set shellslash
call ToggleShellslashForVimPlug()
test 1:>Can you do this
<leader>wwopen wiki.vim index<leader>w<leader>wopen today journal- Run
:echo wiki#journal#get_current_node()- what's the output?
d:/WeirdData/Vimwiki/journal/2024-03-27
:cd %:p:hset pwd to journal folder
:pwd
D:/WeirdData/Vimwiki/journal
or :cd %:p:h:h set pwd to index folder. This adjustment does not affect the results of subsequent experiments.
:pwd
D:/WeirdData/Vimwiki
- Again, run
:echo wiki#journal#get_current_node()- what's the output?
D:/WeirdData/Vimwiki/journal/2024-03-27
test 2: If I change the order, the output is different
> 1. `<leader>ww` open wiki.vim index
> 4. `:cd %:p:h` set pwd to index folder
> 2. `<leader>w<leader>w` open today journal
> 3. Run `:echo wiki#journal#get_current_node()`
- what's the output?
Noneblank/nothing
test 3: If I open today journal first, the output change again:
> 2. `<leader>w<leader>w` open today journal
> 1. `<leader>ww` open wiki.vim index
> 4. `:cd %:p:h` set pwd to index folder
> 2. `<leader>w<leader>w` open today journal
> 3. Run `:echo wiki#journal#get_current_node()`
- what's the output?
2024-03-27
test 4 : Q&A
What happens if you set pwd to index folder with scene1?
<leader>w<leader>wopen today journal:cd %:p:h:hset pwd to index folder<leader>wu
test 5: FIX scene2
To run successfully, we need to first open today's journal with <leader>w<leader>w.
0. `<leader>w<leader>w` open today journal
1. `<leader>ww ` open wiki.vim index
2. `:cd %:p:h` set pwd to index folder
3. `<leader>w<leader>w` open today journal
4. `<leader>wu`
What's the key issue
After numerous experiments, and comparing experiments test 1-3, the crux of the issue may lie in whether the journal is activated (I don't know how to express it accurately), resulting in completely different outcomes for wiki#journal#get_current_node().
Whether journal is activated can be clearly seen in the statusline set statusline+=\ %f by whether the file path uses a relative path.
- If journal is activated (test 3 and test 5), then a relative path is used, and the output is
2024-03-27. - If journal is not activated (test 1-2 adn test 4), then an absolute path is used. Even if you manually specify pwd using the cd command, the output is
D:/WeirdData/Vimwiki/journal/2024-03-27or 'None'.
To summarize, the current steps to activate wiki.vim journal are: 1. open today journal 2. open wikiroot index 3. set pwd to index 4.open today journal again.
PS: The mechanism of vimwiki is such that it automatically switches the pwd to the wiki root when opening the index, diary or any wiki file. And, the pwd remains constant. Even if you switch to other non-wiki files during use and the pwd changes, as soon as you switch back to any of the vimwiki-related pages, the pwd will automatically switch back to the index.
But wiki.vim does not switch the pwd automatically and even if we manually set the pwd to the index, the related pages of wiki.vim might not necessarily use a relative path..
:echo wiki#journal#node_to_path("2024-04-01")
base on test 3 step:
1. `<leader>w<leader>w` open today journal
2. `<leader>ww` open wiki.vim index
3. `:cd %:p:h` set pwd to index folder
4. `<leader>w<leader>w` open today journal
5. Run `:echo wiki#journal#node_to_path("2024-04-01")`
E117: Unknown function: wiki#journal#node_to_path
Based on your answer, I'm more confident that the problem is related to the Window paths. Specifically:
- Run
:echo wiki#journal#get_current_node()- what's the output?
d:/WeirdData/Vimwiki/journal/2024-03-27
The expected output should be "2024-03-27". I've found a possible fix for this. Can you update and test this same thing again?
PS: The mechanism of vimwiki is such that it automatically switches the pwd to the wiki root when opening the index, diary or any wiki file. And, the pwd remains constant. Even if you switch to other non-wiki files during use and the pwd changes, as soon as you switch back to any of the vimwiki-related pages, the pwd will automatically switch back to the index.
But wiki.vim does not switch the pwd automatically and even if we manually set the pwd to the index, the related pages of wiki.vim might not necessarily use a relative path..
Yes, wiki.vim will not change your cwd; why should it? You can use set autochdir if you like that behaviour. The solution to this issue is not to change your cwd, but to fix the bugs in wiki.vim.
1. `<leader>w<leader>w` open today journal 2. `<leader>ww` open wiki.vim index 3. `:cd %:p:h` set pwd to index folder 4. `<leader>w<leader>w` open today journal 5. Run `:echo wiki#journal#node_to_path("2024-04-01")`E117: Unknown function: wiki#journal#node_to_path
Ah, yes; for this to work I wanted you to actually change wiki.vim code first. Specifically, you must change the function named s:node_to_path to the name wiki#journal#node_to_path. But this may not be necessary if my fix was sufficient.
update wiki.vim and test this same thing (test 1)
<leader>wwopen wiki.vim index<leader>w<leader>wopen today journal- Run
:echo wiki#journal#get_current_node()- what's the output?
d:/WeirdData/wiki/journal/2024-03-28
:cd %:p:h:hset pwd to index folder- Again, run
:echo wiki#journal#get_current_node()- what's the output?
D:/WeirdData/wiki/journal/2024-03-28
Notice: d: ==> D:
change the function named and repeat test 1
- c:\Users\yourname\vimfiles\plugged\wiki.vim\autoload\wiki\journal.vim
function! s:node_to_path(node) abort " {{{1 ==>
function! wiki#journal#node_to_path(node) abort " {{{1
- repeat test 1
<leader>wwopen wiki.vim index<leader>w<leader>wopen today journal- Run
:echo wiki#journal#get_current_node()- what's the output?
d:/WeirdData/wiki/journal/2024-03-28
:cd %:p:h:hset pwd to index folder- Again, run
:echo wiki#journal#get_current_node()- what's the output?
D:/WeirdData/wiki/journal/2024-03-28
echo wiki#journal#node_to_path(2024-04-01)
d:/WeirdData/wiki/journal/2019.md
And if I change [A-Z] to [a-zA-Z], the result is same.
if has('win32') || v:true
let l:target = substitute(l:target, '^[a-zA-Z]:', '', '')
let l:common = substitute(l:common, '^[a-zA-Z]:', '', '')
endif
You can use
set autochdirif you like that behaviour.
I've created a simulated implementation.
let g:wiki_root = expand("<sfile>:p:h:h:h") . "/wiki/"
augroup wiki_vim_autochdir
autocmd!
autocmd BufEnter *.md,*.wiki if getbufvar(expand('%'), '&filetype') == 'markdown' | execute 'cd ' . g:wiki_root | endif
augroup END
Sorry for the late reply; I'm on vacation and I'm a bit busy.
update wiki.vim and test this same thing (test 1)
<leader>wwopen wiki.vim index<leader>w<leader>wopen today journal- Run
:echo wiki#journal#get_current_node()- what's the output?
d:/WeirdData/wiki/journal/2024-03-28
:cd %:p:h:hset pwd to index folder- Again, run
:echo wiki#journal#get_current_node()- what's the output?
D:/WeirdData/wiki/journal/2024-03-28Notice:
d:==>D:
Ok, thanks. The d -> D is not important, I think. But i's surprising that my earlier attempt at fixing this did not work; I'll look into this further.
change the function named and repeat test 1
* c:\Users\yourname\vimfiles\plugged\wiki.vim\autoload\wiki\journal.vim
function! s:node_to_path(node) abort " {{{1==>function! wiki#journal#node_to_path(node) abort " {{{1
Good! Notice you should either make this change of names very temporary, or make a copy of the function. If not, you are likely to break things alltogether, since a lot of other functions use s:node_to_path and expects it to exist.
- repeat test 1
Ah, no, sorry: I did not want you to repeat the test. I wanted you to specifically execute :echo wiki#journal#node_to_path("2024-04-01") and see what the function returns. However, I see you also did that:
echo wiki#journal#node_to_path(2024-04-01)
d:/WeirdData/wiki/journal/2019.md
Ah, that's not as expected at all.
What's the output of :echo wiki#get_root() (from anywhere)?
I'm sorry for not being able to help with this very quickly. It's hard to pinpoint the error when I can't reproduce locally. I hope you don't mind doing some investigation based on my suggestions.
Can you do these steps and report the output of the echos?
<leader>w<leader>w:echo expand('%:p'):echo wiki#get_root():echo wiki#journal#get_root():echo wiki#journal#get_current_node()
<leader>w<leader>w:echo expand('%:p')
D:/WeirdData/wiki/journal/2024/2024-03-31.md
:echo wiki#get_root()
d:/WeirdData/wiki
:echo wiki#journal#get_root()
d:/WeirdData/wiki/journal
:echo wiki#journal#get_current_node()
D:/WeirdData/wiki/journal/2024/2024-03-31
PS: my vimrc config: https://github.com/VimWei/vim-init
Thanks! The expected output of :echo wiki#journal#get_current_node() is 2024/2024-03-31.
Now, please show:
- Just to be sure, update your plugins again.
:echo fnamemodify(expand('%:p'), ':r'):echo wiki#journal#get_root():echo wiki#paths#relative(fnamemodify(expand('%:p'), ':r'), wiki#journal#get_root())
Based on the earlier output, I expect the following:
D:/WeirdData/wiki/journal/2024/2024-03-31d:/WeirdData/wiki/journalD:/WeirdData/wiki/journal/2024/2024-03-31
PS: my vimrc config: https://github.com/VimWei/vim-init
Thanks. A few comments:
-
I don't understand why you want the
autochdirstuff. It shouldn't be necessary. Although, if it is a workaround for the present issue, then leave it for now. But generally, wiki.vim does not really care about your current work directory (cwd). -
You don't need to specify settings that are already default. E.g.` you can remove lines like this. Thus, you could simplify your config to this:
let g:wiki_journal = { \ 'date_format': { \ 'daily' : '%Y/%Y-%m-%d', \ 'weekly' : '%Y/%Y_w%V', \ 'monthly' : '%Y/%Y_m%m', \ }, \} let g:wiki_link_creation = { \ 'md': { 'link_type': 'md', 'url_extension': '' }, \ '_': { 'link_type': 'wiki', 'url_extension': '' }, \} let g:wiki_journal_index = { \ 'link_text_parser': { b, d, p -> wiki#toc#get_page_title(p) } \} let g:wiki_mappings_global = { \ '<plug>(wiki-page-toc)' : '', \} let g:wiki_mappings_local_journal = { \ '<plug>(wiki-journal-prev)' : '[w', \ '<plug>(wiki-journal-next)' : ']w', \}
Also, it is very useful to know that you've changed the date_format settings.
- Just to be sure, update your plugins again.
Yes
:echo fnamemodify(expand('%:p'), ':r')
D:/WeirdData/wiki/journal/2024/2024-03-31
:echo wiki#journal#get_root()
d:/WeirdData/wiki/journal
:echo wiki#paths#relative(fnamemodify(expand('%:p'), ':r'), wiki#journal#get_root())
D:/WeirdData/wiki/journal/2024/2024-03-31
The expected output of
:echo wiki#journal#get_current_node()is2024/2024-03-31.
Yes, I understand. However, in my previous tests, there were three different outcomes, as detailed in the earlier tests 1-3.
- If journal is activated (test 3 and test 5), then a relative path is used, and the output is
2024-03-27.- If journal is not activated (test 1-2 adn test 4), then an absolute path is used. Even if you manually specify pwd using the cd command, the output is
D:/WeirdData/Vimwiki/journal/2024-03-27or 'None'.
I am very grateful that you could take the time to answer my questions despite your busy schedule. I am not in a hurry to resolve this issue, so we can take our time with it. P.S.: I have completely switched from vimwiki to wiki.vim, and it now meets my daily needs. The main reason I abandoned vimwiki is that some of its bugs can cause serious garbling and result in data loss. The design philosophy of wiki.vim is excellent—focused and flexible, allowing me to choose third-party filetype and lists plugins.
you've changed the
date_formatsettings.
I set the date_format to be divided by year mainly because when there are many files in the same directory, the related software on Windows tends to load more slowly.
- I don't understand why you want the
autochdirstuff.
I am currently using it just to make the file path in the statusline a bit shorter, instead of always showing the long full path. It's to improve the experience.
11.
echo wiki#journal#node_to_path(2024-04-01)
d:/WeirdData/wiki/journal/2019.mdAh, that's not as expected at all.
I found the possible source of the '2019' pattern: the earliest entry in my journal dates back to the year 2019.
:echo wiki#paths#relative(fnamemodify(expand('%:p'), ':r'), wiki#journal#get_root())D:/WeirdData/wiki/journal/2024/2024-03-31
Ok, thanks. This is very strange. I've created the following script to debug on my end:
set nocompatible
set runtimepath^=~/.local/plugged/wiki.vim
filetype plugin indent on
syntax enable
runtime plugin/wiki.vim
let s:root = 'd:/WeirdData/wiki/journal'
let s:path = 'D:/WeirdData/wiki/journal/2024/2024-03-31'
echo s:root
echo s:path
echo wiki#paths#relative(s:path, s:root)
quitall!
I run it from a terminal with vim --clean -u test.vim, in which case it outputs this:
d:/WeirdData/wiki/journal
D:/WeirdData/wiki/journal/2024/2024-03-31
2024/2024-03-31
Which is what I would expect from you as well. I pushed a new very minor update that shouldn't really have any effect on your side, but it would be useful if you still updated and tested again. And, if possible, it would be useful if you are able to reproduce the issue with the above script.
The expected output of
:echo wiki#journal#get_current_node()is2024/2024-03-31.Yes, I understand. However, in my previous tests, there were three different outcomes, as detailed in the earlier tests 1-3.
Yes, but those were not expected outputs either.
I am very grateful that you could take the time to answer my questions despite your busy schedule. I am not in a hurry to resolve this issue, so we can take our time with it. P.S.: I have completely switched from vimwiki to wiki.vim, and it now meets my daily needs. The main reason I abandoned vimwiki is that some of its bugs can cause serious garbling and result in data loss. The design philosophy of wiki.vim is excellent—focused and flexible, allowing me to choose third-party filetype and lists plugins.
I'm glad to hear that you find wiki.vim useful! And I hope that we can figure this thing out. It may be multiple errors, in fact I think that's likely, because the wiki#paths#relative thing should not be that relevant for the s:node_to_path function.
you've changed the
date_formatsettings.I set the date_format to be divided by year mainly because when there are many files in the same directory, the related software on Windows tends to load more slowly.
Yes, that makes sense.
- I don't understand why you want the
autochdirstuff.I am currently using it just to make the file path in the statusline a bit shorter, instead of always showing the long full path. It's to improve the experience.
Ah; in that case, you can also just change your statusline. But it doesn't really matter, if you find it useful then great - keep it!
echo wiki#journal#node_to_path(2024-04-01)
d:/WeirdData/wiki/journal/2019.mdAh, that's not as expected at all.
I found the possible source of the '2019' pattern:
the earliest entryin my journal dates back to the year 2019.
Yes, that makes sense - sort of.
set nocompatible
set runtimepath^=%USERPROFILE%/vimfiles/plugged/wiki.vim
filetype plugin indent on
syntax enable
runtime plugin/wiki.vim
let s:root = 'd:/WeirdData/wiki/journal'
let s:path = 'D:/WeirdData/wiki/journal/2024/2024-03-31'
echo s:root
echo s:path
echo wiki#paths#relative(s:path, s:root)
quitall!
"C:\Program Files\Vim\vim91\gvim.exe" --clean -u "c:\Users\chenw\vimfiles\test.vim"
Ok; that's really strange. Can we go deeper here? That is:
-
Confirm that your own
autoload/vimtex/paths.vimfile looks like this. -
Change the function by adding some
echos:function! wiki#paths#relative(path, current) abort " {{{1 " Note: This algorithm is based on the one presented by @Offirmo at SO, " http://stackoverflow.com/a/12498485/51634 let l:target = simplify(substitute(a:path, '\\', '/', 'g')) let l:target = substitute(l:target, '^\a:', '', '') let l:common = simplify(substitute(a:current, '\\', '/', 'g')) let l:common = substitute(l:common, '^\a:', '', '') if l:common[-1:] ==# '/' let l:common = l:common[:-2] endif echo 1 l:target echo 2 l:common " This only works on absolute paths if !wiki#paths#is_abs(l:target) return substitute(a:path, '^\.\/', '', '') endif let l:tries = 50 let l:result = '' while stridx(l:target, l:common) != 0 && l:tries > 0 let l:common = fnamemodify(l:common, ':h') let l:result = empty(l:result) ? '..' : '../' . l:result let l:tries -= 1 endwhile echo 3 l:result l:tries echo 4 l:common if l:tries == 0 | return a:path | endif if l:common ==# '/' let l:result .= '/' endif let l:forward = strpart(l:target, strlen(l:common)) if !empty(l:forward) let l:result = empty(l:result) \ ? l:forward[1:] \ : l:result . l:forward endif echo 5 l:result -
Repeat the script from the previous reply. On my end, the script now outputs this:
d:/WeirdData/wiki/journal D:/WeirdData/wiki/journal/2024/2024-03-31 1 /WeirdData/wiki/journal/2024/2024-03-31 2 /WeirdData/wiki/journal 3 50 4 /WeirdData/wiki/journal 5 2024/2024-03-31 2024/2024-03-31
There is no autoload/vimtex/paths.vim here, only plugged\wiki.vim\autoload\wiki\paths.vim. Following your guidance above, I have added 5 echo statements in plugged\wiki.vim\autoload\wiki\paths.vim.
The condition if !wiki#paths#is_abs(l:target) evaluates to true, and echo3-5 did not appear.
if !wiki#paths#is_abs(l:target)
return substitute(a:path, '^\.\/', '', '')
endif
If I comment out the above statement, the results appear as you would expect.
There is no
autoload/vimtex/paths.vimhere, onlyplugged\wiki.vim\autoload\wiki\paths.vim.
Yes, sorry about the confusion. I meant to write autoload/wiki/paths.vim!
The condition
if !wiki#paths#is_abs(l:target)evaluates to true, and echo3-5 did not appear.
Ah! This is very useful! I'm pushing an update now. Revert the changes you made while debugging and update. I believe this should resolve the issue with wiki#paths#relative.
I would not be surprised if there may be more things to fix, but I believe we are getting closer now.
Upgrade(reinstall) wiki.vim and config with: https://github.com/VimWei/vim-init/blob/master/init/plugins.vim#L166-L203
There are still some issues:
NewTest 1
- restart gvim
- open today journal:
<leader>w<leader>w - open week summary:
<leader>wu
Result: open a new week summary but the content is blank.
NewTest 2
- restart gvim
- open wikiindex:
<leader>ww - open today journal:
<leader>w<leader>w - open week summary:
<leader>wu
Result: <leader>wu can't work, just mean undo.
NewTest 3
- restart gvim
- open today journal:
<leader>w<leader>w - open wikiindex:
<leader>ww - open today journal:
<leader>w<leader>w - open week summary:
<leader>wu
Result: open a new week summary, and the content is from wiki template.
Upgrade(reinstall) wiki.vim and config with: https://github.com/VimWei/vim-init/blob/master/init/plugins.vim#L166-L203
Just a kind reminder that you can simplify your config as I explained here.
There are still some issues:
Interesting. It seems the third test yields the expected result, right?
I'll try and reproduce this on my end.
A quick question: Do I understand correctly that the feature to open the current journal entry now works as expected? I.e., the current issue is now related to the weekly summaries?
Sorry for writing multiple replies instead of collecting it in a single reply! Here's a list of questions for following this up:
- Do you agree that your third test returns the expected result?
- Do I understand correctly that the feature to open the current journal entry now works as expected? I.e., the current issue is now related to the weekly summaries?
Also, can you do this:
- restart gvim
<leader>w<leader>w:echo wiki#journal#node_to_timestamp()
It should return something like this:[1711839600, 'daily']:echo strftime('%Y-w%V', 1711839600)It should return something like this:2024-w13:echo wiki#journal#node_to_date()
It should return something like this:['2024-03-31', 'daily']
It will help me pinpoint where the next problem is.
you can simplify your config
I've simplify config: https://github.com/VimWei/vim-init/blob/master/init/plugins.vim#L166-L182
- Do you agree that your third test returns the expected result?
Yes, the final result of the third test is what I expected. However, the preliminary steps required to trigger the third test are too complicated. In my understanding, as long as I enter the journal (such as <leader>w<leader>w), no matter what the preceding steps are, it should correctly trigger <plug>(wiki-journal-toweek) and call wiki-templates-journal-summaries.
Therefore, the ideal steps is:
- any operation
<leader>w<leader>w: open today's journal. According to the help documentation, "the lines annotated[JOURNAL]are only available within the journal". At this point, it should satisfy the conditions within the journal.wu: open week summary, and call wiki-templates-journal-summaries
- Do I understand correctly that the feature to open the current journal entry now works as expected? I.e., the current issue is now related to the weekly summaries?
Yes, the current issue is now related to the weekly summaries. The core issue is, "I have already met the condition of being in the journal, but why can't I correctly trigger WikiJournalToWeek?"
- can you do this:
The results of the execution are all as you expected.
restart gvim<leader>w<leader>w:echo wiki#journal#node_to_timestamp()
Result:[1711900800, 'daily']
:echo strftime('%Y-w%V', 1711900800)
Result: 2024-w14
:echo wiki#journal#node_to_date()
Result: ['2024-04-01', 'daily']
- Do you agree that your third test returns the expected result?
Yes, the final result of the third test is what I expected.
Great!
However, the preliminary steps required to trigger the third test are too complicated. …
Yes, of course - I only wanted to know if the result was as expected. I very much agree that this should work for all cases.
Yes, the current issue is now related to the weekly summaries. The core issue is, "I have already met the condition of being in the journal, but why can't I correctly trigger WikiJournalToWeek?"
:+1:
- can you do this:
The results of the execution are all as you expected. …
Great. This is good and seems to imply that the problem is mainly with the templating function. However, in your above "NewTest 2", it seems there may be another bug as well. Can you therefore do this:
- restart gvim
<leader>ww<leader>w<leader>w:echo wiki#journal#node_to_date()
Also, I now think that there is some bug within wiki#template#weekly_summary or any of the functions called deeper in that stack. It's a little hard to pinpoint based on the current input. But I think it could be enlightening to see some echo outputs. Could you do something like this and report the output?
function! wiki#template#weekly_summary(year, week) abort " {{{1
let l:parser = s:summary.new()
let l:title = copy(g:wiki_template_title_week)
let l:title = substitute(l:title, '%(week)', a:week, 'g')
let l:title = substitute(l:title, '%(year)', a:year, 'g')
let l:dates = wiki#date#get_week_dates(a:week, a:year)
unsilent echo "input " a:week "|" a:year
unsilent echo "output" l:dates
call append(0, [l:title] + l:parser.parse(l:dates))
call setpos('.', [0, 3, 0, 0])
endfunction
In particular, I want to know if the week and year inputs look correct and if the dates output from wiki#date#get_week_dates seems correct.
- restart gvim
<leader>ww<leader>w<leader>w:echo wiki#journal#node_to_date()
['2024-04-01', 'daily']
- add two line in
wiki#template#weekly_summary
unsilent echom "input " a:week "|" a:year
unsilent echom "output" l:dates
- restart gvim
<leader>w<leader>wOpen today journal that was previously saved.<leader>wuOpen new week summary with template content.
:messages
Ok, thanks. I still don't see any unexpected results here. Can you try and reproduce the problem again, and if/when you do, can you report the related outputs in the case where it fails?
After upgrading gvim to gvim9.1.0399x64_signed.exe and adjusting many vimrc configurations, I noticed some new phenomena.
Firstly, "Go to week summary" is working properly now!
- restart gvim
<Leader>w<Leader>w<Leader>wu
Secondly, "Go to month summary" still doesn't work, although the prompt message is different from before.
- restart gvim
<Leader>w<Leader>w<Leader>wm
Thirdly, "Go to month summary" operates the same in neovim 0.95 as in gvim.