-
Notifications
You must be signed in to change notification settings - Fork 66
WikiJournalIndex: only wiki text files with any naming in the journal folder #260
Copy link
Copy link
Closed
Description
I want to thank contributors for this plugin and for their work! I use this tool often.
Description
In short, :WikiJournalIndex doesn't create links for files like 2022-12-02-2020_some_name_here.md. I wish :WikiJournalIndex would create links in the current buffer to existing files which is named arbitrary. I create many files in my diary with nvim --nofork $HOME/mydir/notes/$(date +%Y)/$(date +%Y-%m-%d-%H%M).md -- -c WikiEnable -c 'cd ~/mydir/notes'.
Steps:
- My config as below. I open file
./2022/дневник.md. It contains files like:2022-12-01-1330_my_name_of_file.md,2022-03-03.md, etc., as well as images, PDF files. - Run
:WikiJournalIndex. - Result:
# 2022
## 01.Январь
[2022-01-01](/2022/2022-01-01) // This is wrong link! No such file. There though files like "./2022-01-01-2230.md"
[2022-01-01](/2022/2022-01-01)
[2022-01-01](/2022/2022-01-01)
[2022-01-01](/2022/2022-01-01)
[2022-01-02](/2022/2022-01-02)
[2022-01-02](/2022/2022-01-02)
[2022-01-03](/2022/2022-01-03)
[2022-01-03](/2022/2022-01-03)
[2022-01-03](/2022/2022-01-03)
[2022-01-03](/2022/2022-01-03)
[2022-01-04](/2022/2022-01-04)
[2022-01-04](/2022/2022-01-04)
...
Expected: correct links to existing files.
Minimal working example
/path/to/minimal-working-example-wiki
├── index.wiki
├── 2022
│ └── 2017-11-24-2359_name_here.md
├── дневник.md
Config
set nocompatible
let g:wiki_root = '~/mydir/notes/'
let g:wiki_link_extension = ''
let g:wiki_filetypes = ['md', 'wiki']
let g:wiki_link_target_type = 'md'
let g:wiki_month_names = [ '01.Январь', '02.Февраль', '03.Март', '04.Апрель', '05.Май', '06.Июнь', '07.Июль', '08.Август', '09.Сентябрь', '10.Октябрь', '11.Ноябрь', '12.Декабрь' ]
let g:wiki_toc_title = 'Содержание'
let g:wiki_journal = {
\ 'index_use_journal_scheme': v:false,
\ 'name': '2022',
\ 'frequency': 'daily',
\ 'date_format': {
\ 'daily' : '%Y-%m-%d',
\ },
\}
let g:wiki_template_title_week = '# %(year). %(week) неделя'
let g:wiki_template_title_month = '# %(year). %(month-name) месяц'
function! MyWikiBufferInit()
try
let $TYPESET_PATH = expand("%:p")
if $TYPESET_PATH !~# '\v\.(index.md|index.wiki)$'
"set guifont=Liberation\ Mono:h13
endif
catch
endtry
set laststatus=0
set foldcolumn=4
au! BufWritePost ~/mydir/notes/* !git add "%";git commit -m "Auto commit of %:t." "%"
nmap <leader>mh :s_\v^((#+) +)?(.*)_#\2 \3_e<CR> :noh<CR>
nmap <leader>mH :s_\v^#(#* )? *(.*)_\1\2_e<CR> :noh<CR>
set foldlevel=1
"CocDisable
endfunction
augroup MyWikiAutocmds
autocmd!
autocmd User WikiBufferInitialized call MyWikiBufferInit()
augroup END
let g:wiki_map_text_to_link = 'WikiMapTextToLink'
function WikiMapTextToLink(text) abort
if a:text !~# '\v\.(md|wiki|txt)$'
let t = substitute(tolower(a:text), '\v[ \t;:.*?\)\(]+', '_', 'g')
if getcwd() !~# '\v\/0$|\/0\/'
return [strftime('%Y-%m-%d-%H-%M') . '_' . t . '.md', a:text]
else
return [strftime('%Y%m%d%H%M') . '_' . t . '.md', a:text]
endif
endif
return [a:text, a:text]
endfunction
let g:wiki_viewer = {'_' : 'xdg-open'}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels