-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to arrange diary file with a more organized folder structure? #1368
Comments
Hi, I think my configuration could be of help to you. Therefore, I have modified diary.vim like this: # line 100
- return strftime('%Y-%m-%f', l:computed_timestamp)
+ return strftime('%Y/%m/%f', l:computed_timestamp)
# line 505
- return link = a:year.'-'.month.'-'.day
+ return link = a:year.'/'.month.'/'.day
# line 532
- \ . a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
+ \ . a:year.'/'.month.'/'.day.vimwiki#vars#get_wikilocal('ext') The result is like this: diary_rel_path
|
+--- 2022
| |
| +--- 12
| |
| +--- 06.wiki
| |
| +--- ...
|
+--- 2023
|
+--- 1
| |
| +--- 01.wiki
| |
| +--- ...
+--- 2
| |
| +--- 01.wiki
| |
| +--- ...
|
+--- ... |
Hi @Jaeyong-Cho , thanks for your hints, I will try on my side and let you know |
@Jaeyong-Cho , is diary index generating OK on your side after the change? My local patch is as the following. (I still want the node file name be M autoload/vimwiki/diary.vim
@@ -97,7 +97,7 @@ function! vimwiki#diary#diary_date_link(...) abort
let l:computed_timestamp = localtime() + l:delta_periods*l:day_s
endif
- return strftime('%Y-%m-%d', l:computed_timestamp)
+ return strftime('%Y/%m/%Y-%m-%d', l:computed_timestamp)
endfunction
@@ -502,7 +502,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) abort
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
- let link = a:year.'-'.month.'-'.day
+ let link = a:year.'/'.month.'/'.year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir ==? 'V'
vsplit
@@ -529,7 +529,7 @@ function! vimwiki#diary#calendar_sign(day, month, year) abort
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
- \ . a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
+ \ . a:year.'/'.month.'/'.year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction The generation of diary wiki looks good, but the index refreshing is not working |
It seems like this modification will work. diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
index b47e6c9..92f8c9e 100644
--- a/autoload/vimwiki/diary.vim
+++ b/autoload/vimwiki/diary.vim
@@ -97,7 +97,7 @@ function! vimwiki#diary#diary_date_link(...) abort
let l:computed_timestamp = localtime() + l:delta_periods*l:day_s
endif
- return strftime('%Y-%m-%d', l:computed_timestamp)
+ return strftime('%Y/%m/%Y-%m-%d', l:computed_timestamp)
endfunction
@@ -230,7 +230,7 @@ function! vimwiki#diary#get_diary_files() abort
" Return: <list> diary file names
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(vimwiki#vars#get_wikilocal('path').
- \ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
+ \ vimwiki#vars#get_wikilocal('diary_rel_path').'*/*/*'.vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
@@ -445,8 +445,14 @@ function! vimwiki#diary#generate_diary_section() abort
let top_link_tpl = link_tpl
endif
+ let my_fl = "__Directory__/__Filename__"
+ let my_fl = substitute(my_fl, "__Filename__", fl, "")
+ let fl = substitute(fl, "-", "/", "")
+ let fl = substitute(fl, "-[0-9][0-9]", "", "")
+ let my_fl = substitute(my_fl, "__Directory__", fl, "")
+
let bullet = vimwiki#lst#default_symbol().' '
- let entry = substitute(top_link_tpl, '__LinkUrl__', fl, '')
+ let entry = substitute(top_link_tpl, '__LinkUrl__', my_fl, '')
let entry = substitute(entry, '__LinkDescription__', topcap, '')
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
let extension = vimwiki#vars#get_wikilocal('ext', wiki_nr)
@@ -463,7 +469,7 @@ function! vimwiki#diary#generate_diary_section() abort
if empty(subcap)
continue
endif
- let entry = substitute(link_tpl, '__LinkUrl__', fl.'#'.subcap, '')
+ let entry = substitute(link_tpl, '__LinkUrl__', my_fl.'#'.subcap, '')
let entry = substitute(entry, '__LinkDescription__', subcap, '')
" if single H1 then depth H2=0, H3=1, H4=2, H5=3, H6=4
" if multiple H1 then depth H1= 0, H2=1, H3=2, H4=3, H5=4, H6=5
@@ -502,7 +508,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) abort
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
- let link = a:year.'-'.month.'-'.day
+ let link = a:year.'/'.month.'/'.year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir ==? 'V'
vsplit
@@ -529,7 +535,7 @@ function! vimwiki#diary#calendar_sign(day, month, year) abort
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
- \ . a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
+ \ . a:year.'/'.month.'/'.year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction |
Hi @Jaeyong-Cho , really appreciate your help. I tested with your patch and now index generation and navigation is OK. I did more test and find that the only remaining issue is |
Hi @ericsunplus, this patch will work well. diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
index b47e6c9..7aa1002 100644
--- a/autoload/vimwiki/diary.vim
+++ b/autoload/vimwiki/diary.vim
@@ -359,13 +359,17 @@ function! vimwiki#diary#goto_next_day() abort
" Jump to next day
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
+ let my_links = map(vimwiki#diary#get_diary_files(), 'fnamemodify(v:val, ":p:r")')
+ for i in range(0, len(my_links) - 1)
+ let my_links[i] = substitute(my_links[i], s:diary_path(), "", "")
+ endfor
if idx == (len(links) - 1)
return
endif
if idx != -1 && idx < len(links) - 1
- let link = 'diary:'.links[idx+1]
+ let link = 'diary:'.my_links[idx+1]
else
" goto today
let link = 'diary:'.vimwiki#diary#diary_date_link()
@@ -381,13 +385,17 @@ function! vimwiki#diary#goto_prev_day() abort
" Jump to previous day
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
+ let my_links = map(vimwiki#diary#get_diary_files(), 'fnamemodify(v:val, ":p:r")')
+ for i in range(0, len(my_links) - 1)
+ let my_links[i] = substitute(my_links[i], s:diary_path(), "", "")
+ endfor
if idx == 0
return
endif
if idx > 0
- let link = 'diary:'.links[idx-1]
+ let link = 'diary:'.my_links[idx-1]
else
" goto today
let link = 'diary:'.vimwiki#diary#diary_date_link() |
Hi @Jaeyong-Cho , thank you for all the help. It is now working fine on my side. And since I am working on windows, there are path sep diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
index 7b3be80..ca690ba 100644
--- a/autoload/vimwiki/diary.vim
+++ b/autoload/vimwiki/diary.vim
@@ -361,7 +361,7 @@ function! vimwiki#diary#goto_next_day() abort
let [idx, links] = s:get_position_links(expand('%:t:r'))
let my_links = map(vimwiki#diary#get_diary_files(), 'fnamemodify(v:val, ":p:r")')
for i in range(0, len(my_links) - 1)
- let my_links[i] = substitute(my_links[i], s:diary_path(), "", "")
+ let my_links[i] = substitute(substitute(my_links[i], "\\", "\/", "g"), substitute(s:diary_path(), "\\", "\/", "g"), "", "")
endfor
if idx == (len(links) - 1)
@@ -387,7 +387,7 @@ function! vimwiki#diary#goto_prev_day() abort
let [idx, links] = s:get_position_links(expand('%:t:r'))
let my_links = map(vimwiki#diary#get_diary_files(), 'fnamemodify(v:val, ":p:r")')
for i in range(0, len(my_links) - 1)
- let my_links[i] = substitute(my_links[i], s:diary_path(), "", "")
+ let my_links[i] = substitute(substitute(my_links[i], "\\", "\/", "g"), substitute(s:diary_path(), "\\", "\/", "g"), "", "")
endfor
if idx == 0 To be honest this is my first time touching inside vimscript. You really shed the light for me. Big appreciations! |
Prior to submitting a new issue make sure to complete these steps:
.vimrc
default
:VimwikiShowVersion
.I am using vimwiki diary to record daily work notes. With days expands, the diary file are flat scattered in the same directory. As the following screenshot shows
It can be imagined after years the folder will have hundreds of files in single layer.
Is it possible we can provide an option to arrange these daily diary files in a more structured way, like what is done in index file?
The text was updated successfully, but these errors were encountered: