From c8b02e4bc59dbeca81cce2a2c94af7e795a8c167 Mon Sep 17 00:00:00 2001 From: Zhuang Ma Date: Wed, 2 May 2018 03:22:07 +0800 Subject: [PATCH 01/64] Use markdown link syntax for the TOC Ref #483 Fix #200 --- autoload/vimwiki/base.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 929928e..19f6094 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1816,7 +1816,11 @@ function! vimwiki#base#table_of_contents(create) for [lvl, link, desc] in complete_header_infos let esc_link = substitute(link, "'", "''", 'g') let esc_desc = substitute(desc, "'", "''", 'g') - let link = s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__', + let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2') + if vimwiki#vars#get_wikilocal('syntax') == 'markdown' + let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template') + endif + let link = s:safesubstitute(link_tpl, '__LinkUrl__', \ '#'.esc_link, '') let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '') call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link) From b5dcd1ebebd39e0314aa7c741d76aa1b6a5ea73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Fri, 27 Apr 2018 14:48:21 +0200 Subject: [PATCH 02/64] Allow wikis in subfolders of other wikis --- autoload/vimwiki/base.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 19f6094..4013dda 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -82,18 +82,23 @@ endfunction " to any registered wiki. " The path can be the full path or just the directory of the file function! vimwiki#base#find_wiki(path) + let bestmatch = -1 + let bestlen = 0 let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path)) for idx in range(vimwiki#vars#number_of_wikis()) let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx)) let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path)) - if vimwiki#path#is_equal(vimwiki#path#path_common_pfx(idx_path, path), idx_path) - return idx + let common_pfx = vimwiki#path#path_common_pfx(idx_path, path) + if vimwiki#path#is_equal(common_pfx, idx_path) + if len(common_pfx) > bestlen + let bestlen = len(common_pfx) + let bestmatch = idx + endif endif let idx += 1 endfor - " an orphan page has been detected - return -1 + return bestmatch endfunction From d73c1e4ed6d6db4cc36148cae5d94901f1997604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Tue, 8 May 2018 10:54:48 +0200 Subject: [PATCH 03/64] Remove useless statement --- autoload/vimwiki/base.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 4013dda..8eb6397 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -95,7 +95,6 @@ function! vimwiki#base#find_wiki(path) let bestmatch = idx endif endif - let idx += 1 endfor return bestmatch From 9b744b42b1eb7b715ea52b3a930668127d9cfcfc Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Wed, 9 May 2018 22:02:07 +0200 Subject: [PATCH 04/64] Fix bug when creating a temporary wiki Fix #488 --- plugin/vimwiki.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index fe2cb80..52d6025 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -48,6 +48,10 @@ function! s:create_temporary_wiki() \ } call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings) + + " Update the wiki number of the current buffer, because it may have changed when adding this + " temporary wiki. + call vimwiki#vars#set_bufferlocal('wiki_nr', vimwiki#base#find_wiki(expand('%:p'))) endfunction From 818fe930c35c2637397cff2ac3c4a7aba4c43c29 Mon Sep 17 00:00:00 2001 From: Huy Le Date: Sun, 13 May 2018 07:43:47 -0600 Subject: [PATCH 05/64] set script variable for autowrite_all Ref #492 --- plugin/vimwiki.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 52d6025..dc8606f 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -13,6 +13,7 @@ let g:loaded_vimwiki = 1 let s:old_cpo = &cpo set cpo&vim +let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall " this is called when the cursor leaves the buffer function! s:setup_buffer_leave() From ed58049dbef69fff88f25e0615655547ffd2aa62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Mon, 14 May 2018 10:49:26 +0200 Subject: [PATCH 06/64] Revert "set script variable for autowrite_all" This reverts commit 818fe930c35c2637397cff2ac3c4a7aba4c43c29. --- plugin/vimwiki.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index dc8606f..52d6025 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -13,7 +13,6 @@ let g:loaded_vimwiki = 1 let s:old_cpo = &cpo set cpo&vim -let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall " this is called when the cursor leaves the buffer function! s:setup_buffer_leave() From f96d0c26d3711740bd93fc5e065e53db52b18edc Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Tue, 15 May 2018 21:26:05 +0200 Subject: [PATCH 07/64] Add section to doc about getting help via IRC Fix #490 --- doc/vimwiki.txt | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 92ce907..8fa39e6 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -47,10 +47,11 @@ CONTENTS *vimwiki* 12.2. Temporary Wiki |vimwiki-temporary-wiki| 12.3. Per-Wiki Options |vimwiki-local-options| 12.4. Global Options |vimwiki-global-options| - 13. Contributing |vimwiki-contributing| - 14. Development |vimwiki-development| - 15. Changelog |vimwiki-changelog| - 16. License |vimwiki-license| + 13. Getting help |vimwiki-help| + 14. Contributing & Bug reports |vimwiki-contributing| + 15. Development |vimwiki-development| + 16. Changelog |vimwiki-changelog| + 17. License |vimwiki-license| ============================================================================== @@ -2886,9 +2887,17 @@ Value Description~ Default: 0 +============================================================================== +13. Getting help *vimwiki-help* + +For questions, discussions, praise or rants there is a mailing list: +https://groups.google.com/forum/#!forum/vimwiki + +Also, there is the IRC channel #vimwiki on Freenode which can be accessed via +webchat: https://webchat.freenode.net/?channels=#vimwiki ============================================================================== -13. Contributing *vimwiki-contributing* +14. Contributing & Bug reports *vimwiki-contributing* Your help in making Vimwiki better is really appreciated! Any help, whether it is a spelling correction or a code snippet to patch -- @@ -2903,12 +2912,8 @@ Issues can be filed at https://github.com/vimwiki/vimwiki/issues/. If you want to provide a pull request on GitHub, please start from the dev branch, not from the master branch. -For questions, discussions, praise or rants there is a mailing list: -https://groups.google.com/forum/#!forum/vimwiki - - ============================================================================== -14. Development *vimwiki-development* +15. Development *vimwiki-development* Homepage: http://vimwiki.github.io/ Github: https://github.com/vimwiki/vimwiki/ @@ -2955,7 +2960,7 @@ Contributors and their Github usernames in roughly chronological order: ============================================================================== -15. Changelog *vimwiki-changelog* +16. Changelog *vimwiki-changelog* Issue numbers starting with '#' are issues from @@ -3197,7 +3202,7 @@ http://code.google.com/p/vimwiki/issues/list * First public version. ============================================================================== -16. License *vimwiki-license* +17. License *vimwiki-license* The MIT License http://www.opensource.org/licenses/mit-license.php From 7c5935b9ba1b903775e24f84740cfeb37961ebcd Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Tue, 15 May 2018 21:48:58 +0200 Subject: [PATCH 08/64] Do init s:vimwiki_autowriteall_saved, but perhaps with the default value Ref #492 --- plugin/vimwiki.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 52d6025..3f876db 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -14,6 +14,13 @@ let s:old_cpo = &cpo set cpo&vim +if exists('g:vimwiki_autowriteall') + let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall +else + let s:vimwiki_autowriteall_saved = 1 +endif + + " this is called when the cursor leaves the buffer function! s:setup_buffer_leave() " don't do anything if it's not managed by Vimwiki (that is, when it's not in From c08a9f8c7147c3bb1d30d803d62526914634fc71 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Wed, 16 May 2018 20:14:36 +0200 Subject: [PATCH 09/64] Add a note to the doc on how to use :VWS case insensitively Fix #480 --- doc/vimwiki.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 8fa39e6..92c0394 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -737,6 +737,11 @@ Vimwiki file. To display next match use |:lnext| command. To display previous match use |:lprevious| command. + Hint: this feature is simply a wrapper around |:lvimgrep|. For a + description of how the pattern can look like, see |:vimgrep|. For example, + to do a case insensitive search, use > + :VWS /\cpattern/ + *:VimwikiBacklinks* *:VWB* Search for wikilinks to the current wiki page in all files of current From 057fa3930394506fae8eca1bd993859602918f0c Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 May 2018 20:06:27 +0200 Subject: [PATCH 10/64] :VimwikiMakeDiaryNote makes a new note in the current wiki ... like the doc says, instead of always using the first wiki. Also, fix the menu entry, which always led to the wrong diary. Fix #482 --- autoload/vimwiki/diary.vim | 27 +++++++++++++++------------ plugin/vimwiki.vim | 10 +++++----- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 278da34..c55b3eb 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -170,21 +170,25 @@ function! s:format_diary() endfunction +" The given wiki number a:wnum is 1 for the first wiki, 2 for the second and so on. This is in +" contrast to most other places, where counting starts with 0. When a:wnum is 0, the current wiki +" is used. function! vimwiki#diary#make_note(wnum, ...) - if a:wnum > vimwiki#vars#number_of_wikis() - echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!' + if a:wnum == 0 + let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr') + else + let wiki_nr = a:wnum - 1 + endif + + if wiki_nr >= vimwiki#vars#number_of_wikis() + echomsg 'Vimwiki Error: Wiki '.wiki_nr.' is not registered in g:vimwiki_list!' return endif " TODO: refactor it. base#goto_index uses the same - if a:wnum > 0 - let idx = a:wnum - 1 - else - let idx = 0 - endif - call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', idx). - \ vimwiki#vars#get_wikilocal('diary_rel_path', idx)) + call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', wiki_nr). + \ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr)) let cmd = 'edit' if a:0 @@ -202,7 +206,7 @@ function! vimwiki#diary#make_note(wnum, ...) let link = 'diary:'.vimwiki#diary#diary_date_link() endif - call vimwiki#base#open_link(cmd, link, s:diary_index(idx)) + call vimwiki#base#open_link(cmd, link, s:diary_index(wiki_nr)) endfunction @@ -297,8 +301,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) endif endif - " XXX: Well, +1 is for inconsistent index basing... - call vimwiki#diary#make_note(vimwiki#vars#get_bufferlocal('wiki_nr')+1, 0, link) + call vimwiki#diary#make_note(0, 0, link) endfunction diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 3f876db..50405de 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -266,14 +266,14 @@ command! -count=1 VimwikiTabIndex command! -count=1 VimwikiDiaryIndex \ call vimwiki#diary#goto_diary_index(v:count1) command! -count=1 VimwikiMakeDiaryNote - \ call vimwiki#diary#make_note(v:count1) + \ call vimwiki#diary#make_note(v:count) command! -count=1 VimwikiTabMakeDiaryNote - \ call vimwiki#diary#make_note(v:count1, 1) + \ call vimwiki#diary#make_note(v:count, 1) command! -count=1 VimwikiMakeYesterdayDiaryNote - \ call vimwiki#diary#make_note(v:count1, 0, + \ call vimwiki#diary#make_note(v:count, 0, \ vimwiki#diary#diary_date_link(localtime() - 60*60*24)) command! -count=1 VimwikiMakeTomorrowDiaryNote - \ call vimwiki#diary#make_note(v:count1, 0, + \ call vimwiki#diary#make_note(v:count, 0, \ vimwiki#diary#diary_date_link(localtime() + 60*60*24)) command! VimwikiDiaryGenerateLinks @@ -341,7 +341,7 @@ function! s:build_menu(topmenu) execute 'menu '.a:topmenu.'.Open\ index.'.norm_path. \ ' :call vimwiki#base#goto_index('.idx.')' execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path. - \ ' :call vimwiki#diary#make_note('.idx.')' + \ ' :call vimwiki#diary#make_note('.(idx+1).')' endfor endfunction From c5b39a12b4bbdcec4f9f87cf7b592ef3464f97d3 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 May 2018 20:18:53 +0200 Subject: [PATCH 11/64] Add a help section to the readme Ref #490 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a407040..0160ee9 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,14 @@ Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master. Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed. + +Getting help +============================================================================== + +Have a question? Visit the IRC channel `#vimwiki` on Freenode ([webchat](https://webchat.freenode.net/?channels=#vimwiki)) +or post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki). + + ---- \* Screenshots made with the [solarized colorscheme](https://github.com/altercation/vim-colors-solarized) and [lightline](https://github.com/itchyny/lightline.vim) From 946b3feb12d201327d2da576aff71d9a4139392b Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 May 2018 21:47:50 +0200 Subject: [PATCH 12/64] Fix one-off error when opening a wiki via the menu --- plugin/vimwiki.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 50405de..1076588 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -339,7 +339,7 @@ function! s:build_menu(topmenu) let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t') let norm_path = escape(norm_path, '\ \.') execute 'menu '.a:topmenu.'.Open\ index.'.norm_path. - \ ' :call vimwiki#base#goto_index('.idx.')' + \ ' :call vimwiki#base#goto_index('.(idx+1).')' execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path. \ ' :call vimwiki#diary#make_note('.(idx+1).')' endfor From 9a8854756ec1cb596cb4dc5782c0ac3e06f21169 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sun, 20 May 2018 15:18:05 +0200 Subject: [PATCH 13/64] Refactoring: simplify and remove some regexes --- autoload/vimwiki/base.vim | 30 +++++++++++++++--------------- autoload/vimwiki/vars.vim | 26 ++++++++++++-------------- syntax/vimwiki.vim | 4 ++-- syntax/vimwiki_markdown_custom.vim | 4 ++-- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 8eb6397..2bb8c4d 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -116,11 +116,6 @@ function! vimwiki#base#resolve_link(link_text, ...) let link_text = a:link_text - " if link is schemeless add wikiN: scheme - if link_text !~# vimwiki#vars#get_global('rxSchemeUrl') - let link_text = 'wiki'.source_wiki.':'.link_text - endif - let link_infos = { \ 'index': -1, @@ -129,18 +124,23 @@ function! vimwiki#base#resolve_link(link_text, ...) \ 'anchor': '', \ } + if link_text == '' + return link_infos + endif - " extract scheme - let link_infos.scheme = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchScheme')) - if link_infos.scheme == '' || link_text == '' - let link_infos.filename = '' " malformed link - return link_infos + let scheme = matchstr(link_text, '^\zs'.vimwiki#vars#get_global('rxSchemes').'\ze:') + if scheme == '' + let link_infos.scheme = 'wiki'.source_wiki + else + let link_infos.scheme = scheme + + if link_infos.scheme !~# '\mwiki\d\+\|diary\|local\|file' + let link_infos.filename = link_text " unknown scheme, may be a weblink + return link_infos + endif + + let link_text = matchstr(link_text, '^'.vimwiki#vars#get_global('rxSchemes').':\zs.*\ze') endif - if link_infos.scheme !~# '\mwiki\d\+\|diary\|local\|file' - let link_infos.filename = link_text " unknown scheme, may be a weblink - return link_infos - endif - let link_text = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchUrl')) let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' || link_infos.scheme ==# 'diary' diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 82a6032..7b8e507 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -77,31 +77,29 @@ function! s:populate_global_variables() " Scheme regexes must be defined even if syntax file is not loaded yet cause users should be " able to ww without opening any vimwiki file first - let g:vimwiki_global_vars.schemes = 'wiki\d\+,diary,local' - let g:vimwiki_global_vars.web_schemes1 = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'. - \ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp' - let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel,data' + let g:vimwiki_global_vars.schemes = join(['wiki\d\+', 'diary', 'local'], '\|') + let g:vimwiki_global_vars.web_schemes1 = join(['http', 'https', 'file', 'ftp', 'gopher', + \ 'telnet', 'nntp', 'ldap', 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh', + \ 'git', 'ssh', 'fish', 'sftp'], '\|') + let web_schemes2 = + \ join(['mailto', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data'], '\|') - let rx_schemes = '\%('. - \ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'. - \ join(split(g:vimwiki_global_vars.web_schemes1, '\s*,\s*'), '\|').'\|'. - \ join(split(web_schemes2, '\s*,\s*'), '\|'). + let g:vimwiki_global_vars.rxSchemes = '\%('. + \ g:vimwiki_global_vars.schemes . '\|'. + \ g:vimwiki_global_vars.web_schemes1 . '\|'. + \ web_schemes2 . \ '\)' - let g:vimwiki_global_vars.rxSchemeUrl = rx_schemes.':.*' - let g:vimwiki_global_vars.rxSchemeUrlMatchScheme = '\zs'.rx_schemes.'\ze:.*' - let g:vimwiki_global_vars.rxSchemeUrlMatchUrl = rx_schemes.':\zs.*\ze' - " match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme " http://tools.ietf.org/html/rfc3986 let rxWebProtocols = \ '\%('. \ '\%('. - \ '\%('.join(split(g:vimwiki_global_vars.web_schemes1, '\s*,\s*'), '\|').'\):'. + \ '\%('.g:vimwiki_global_vars.web_schemes1 . '\):'. \ '\%(//\)'. \ '\)'. \ '\|'. - \ '\%('.join(split(web_schemes2, '\s*,\s*'), '\|').'\):'. + \ '\%('.web_schemes2.'\):'. \ '\)' let g:vimwiki_global_vars.rxWeblinkUrl = rxWebProtocols . '\S\{-1,}'. '\%(([^ \t()]*)\)\=' diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index 6da8a61..512aad9 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -106,8 +106,8 @@ call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiL " WikiLink " All remaining schemes are highlighted automatically let s:rxSchemes = '\%('. - \ join(split(vimwiki#vars#get_global('schemes'), '\s*,\s*'), '\|').'\|'. - \ join(split(vimwiki#vars#get_global('web_schemes1'), '\s*,\s*'), '\|'). + \ vimwiki#vars#get_global('schemes') . '\|'. + \ vimwiki#vars#get_global('web_schemes1'). \ '\):' " a) match [[nonwiki-scheme-URL]] diff --git a/syntax/vimwiki_markdown_custom.vim b/syntax/vimwiki_markdown_custom.vim index 038772c..46f3ce1 100644 --- a/syntax/vimwiki_markdown_custom.vim +++ b/syntax/vimwiki_markdown_custom.vim @@ -104,8 +104,8 @@ call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink1'), 'Vimwiki " WikiLink " All remaining schemes are highlighted automatically let s:rxSchemes = '\%('. - \ join(split(vimwiki#vars#get_global('schemes'), '\s*,\s*'), '\|').'\|'. - \ join(split(vimwiki#vars#get_global('web_schemes1'), '\s*,\s*'), '\|'). + \ vimwiki#vars#get_global('schemes') . '\|'. + \ vimwiki#vars#get_global('web_schemes1'). \ '\):' " a) match [nonwiki-scheme-URL] From d5c6cee5eb3526027c5079e9f672c25ab299f0e0 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Wed, 23 May 2018 18:28:03 +0200 Subject: [PATCH 14/64] Make VimwikiMakeDiaryNote etc work outside a wiki buffer Fix #497 --- autoload/vimwiki/diary.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index c55b3eb..1ceeb2e 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -176,6 +176,9 @@ endfunction function! vimwiki#diary#make_note(wnum, ...) if a:wnum == 0 let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr') + if wiki_nr < 0 " this happens when e.g. VimwikiMakeDiaryNote was called outside a wiki buffer + let wiki_nr = 0 + endif else let wiki_nr = a:wnum - 1 endif From 966a94bd477f3b10ae7b66693508274c9aaf1288 Mon Sep 17 00:00:00 2001 From: Nick Borden Date: Mon, 28 May 2018 12:24:29 -0700 Subject: [PATCH 15/64] Diary links should use markdown syntax when appropriate (#500) When markdown syntax is enabled, generated links should use markdown link syntax. Fix #499 --- autoload/vimwiki/diary.vim | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 1ceeb2e..164211d 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -150,17 +150,21 @@ function! s:format_diary() \ '__Header__', s:get_month_name(month), '')) for [fl, cap] in s:sort(items(g_files[year][month])) - if empty(cap) - let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), - \ '__LinkUrl__', fl, '') - let entry = substitute(entry, '__LinkDescription__', cap, '') - call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) - else - let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'), - \ '__LinkUrl__', fl, '') - let entry = substitute(entry, '__LinkDescription__', cap, '') - call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) + let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2') + + if vimwiki#vars#get_wikilocal('syntax') == 'markdown' + let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template') + + if empty(cap) " When using markdown syntax, we should ensure we always have a link description. + let cap = fl + endif + elseif empty(cap) + let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1') endif + + let entry = substitute(link_tpl, '__LinkUrl__', fl, '') + let entry = substitute(entry, '__LinkDescription__', cap, '') + call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) endfor endfor From 7ad365e142eeb9e0a4776c15a72ce6621f6d3000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Wed, 30 May 2018 20:17:54 +0200 Subject: [PATCH 16/64] Add Installation-Guide for Vim-plug Installation-note for vim-plug is important since vimplug defaults to master branch. See #503 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 0160ee9..11d0824 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,15 @@ Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=23 cd bundle git clone https://github.com/vimwiki/vimwiki.git +Installation using [Vim-Plug](https://github.com/junegunn/vim-plug) +------------------------------------------------------------------------------ + +Add the following to the plugin-configuration in your vimrc: + + Plug 'vimwiki/vimwiki', { 'branch': 'dev' } + +Then run `:PlugInstall`. + Installation using [Vundle](https://github.com/VundleVim/Vundle.vim) ------------------------------------------------------------------------------ From 4d4e88bfa26de6a638e4f3c0e3b7c315d29e9e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sun, 17 Jun 2018 15:31:57 +0200 Subject: [PATCH 17/64] Improve heuristic for cleaning urls in link descr. --- autoload/vimwiki/base.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 2bb8c4d..b1768c2 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1869,6 +1869,12 @@ function! s:clean_url(url) let url = filter(url, 'v:val !=# "https\:"') let url = filter(url, 'v:val !=# "file\:"') let url = filter(url, 'v:val !=# "xml\:"') + let url = filter(url, 'v:val !=# "html"') + let url = filter(url, 'v:val !=# "htm"') + let url = filter(url, 'v:val !=# "php"') + " remove words consisting of only hexadecimal digits or non-word characters + let url = filter(url, 'v:val !~ "^\\A\\{4,}$"') + let url = filter(url, 'v:val !~ "^\\x\\{4,}$" || v:val !~ "\\d"') return join(url, " ") endfunction From 50c95f1beffa3d80a0e636a28c23dd51a6bd7803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sun, 17 Jun 2018 16:10:44 +0200 Subject: [PATCH 18/64] Remove all protocols and tlds on URL-cleaning Also make removal of protocol, tld and 'www' more robust against fails-positives by considering the position in the url. --- autoload/vimwiki/base.vim | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index b1768c2..e13623a 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1858,20 +1858,17 @@ endfunction function! s:clean_url(url) - let url = split(a:url, '/\|=\|-\|&\|?\|\.') + " remove protocol and tld + let url = substitute(a:url, '^\a\+://', '', '') + let url = substitute(url, '^\([^/]\+\).\a\{2,4}/', '\1/', '') + let url = split(url, '/\|=\|-\|&\|?\|\.') let url = filter(url, 'v:val !=# ""') - let url = filter(url, 'v:val !=# "www"') - let url = filter(url, 'v:val !=# "com"') - let url = filter(url, 'v:val !=# "org"') - let url = filter(url, 'v:val !=# "net"') - let url = filter(url, 'v:val !=# "edu"') - let url = filter(url, 'v:val !=# "http\:"') - let url = filter(url, 'v:val !=# "https\:"') - let url = filter(url, 'v:val !=# "file\:"') - let url = filter(url, 'v:val !=# "xml\:"') - let url = filter(url, 'v:val !=# "html"') - let url = filter(url, 'v:val !=# "htm"') - let url = filter(url, 'v:val !=# "php"') + if url[0] == "www" + let url = url[1:] + endif + if url[-1] =~ '^\(htm\|html\|php\)$' + let url = url[0:-2] + endif " remove words consisting of only hexadecimal digits or non-word characters let url = filter(url, 'v:val !~ "^\\A\\{4,}$"') let url = filter(url, 'v:val !~ "^\\x\\{4,}$" || v:val !~ "\\d"') From 786aa470e36895107376e2f03326225b636be58b Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Tue, 26 Jun 2018 21:38:55 +0200 Subject: [PATCH 19/64] Remove the user-mappable function and use commands instead. --- autoload/vimwiki/base.vim | 14 ++++++------ doc/vimwiki.txt | 45 ++++++++++++--------------------------- ftplugin/vimwiki.vim | 4 ++-- 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index e13623a..3a6e128 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1101,8 +1101,10 @@ function! vimwiki#base#find_prev_link() endfunction -" This is an API function, that is, remappable by the user. Don't change the signature. -function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) +function! vimwiki#base#follow_link(split, ...) + let reuse_other_split_window = a:0 >= 1 ? a:1 : 0 + let move_cursor_to_new_window = a:0 >= 2 ? a:2 : 1 + " Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the " default open_link handler @@ -1138,7 +1140,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) " if we want to and can reuse a split window, jump to that window and open " the new file there - if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && a:reuse + if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && reuse_other_split_window let previous_window_nr = winnr('#') if previous_window_nr > 0 && previous_window_nr != winnr() execute previous_window_nr . 'wincmd w' @@ -1162,7 +1164,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) call vimwiki#base#open_link(cmd, lnk) - if !a:move_cursor + if !move_cursor_to_new_window if (a:split ==# 'hsplit' || a:split ==# 'vsplit') execute 'wincmd p' elseif a:split ==# 'tab' @@ -1171,8 +1173,8 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) endif else - if a:0 > 0 - execute "normal! ".a:1 + if a:0 >= 3 + execute "normal! ".a:3 else call vimwiki#base#normalize_link(0) endif diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 92c0394..4c4e541 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -677,12 +677,24 @@ Vimwiki file. *:VimwikiGoBackLink* Go back to the wiki page you came from. -*:VimwikiSplitLink* +*:VimwikiSplitLink* [reuse] [move_cursor] Split and follow wiki link (create target wiki page if needed). -*:VimwikiVSplitLink* + If the argument 'reuse' is given and nonzero, the link is opened in a + possibly existing split window instead of making a new split. + + If 'move_cursor' is given and nonzero, the cursor moves to the window with + the opened link, otherwise, it stays in the window with the link. + +*:VimwikiVSplitLink* [reuse] [move_cursor] Vertical split and follow wiki link (create target wiki page if needed). + If the argument 'reuse' is given and nonzero, the link is opened in a + possibly existing split window instead of making a new split. + + If 'move_cursor' is given and nonzero, the cursor moves to the window with + the opened link, otherwise, it stays in the window with the link. + *:VimwikiTabnewLink* Follow wiki link in a new tab (create target wiki page if needed). @@ -829,35 +841,6 @@ Vimwiki file. are specified, outputs all tags. To make this command work properly, make sure the tags have been built (see |vimwiki-build-tags|). ------------------------------------------------------------------------------- -4.3. Functions *vimwiki-functions* - -Functions to interact with Vimwiki. (It's intended that most commands will be -replaced with corresponding function calls in the future.) -Warning: this is currently unstable and likely to change. - - -To map them to a key, use > - nnoremap :call vimwiki#base#function_name(arg1, arg2) -< - - *vimwiki-follow_link* -vimwiki#base#follow_link({split}, {reuse}, {move_cursor}) - Open the link under the cursor. {split} can have the following values: - 'nosplit' open the link in the current window - 'vsplit' open in a vertically split window - 'hsplit' open in a horizontally split window - 'tab' open in a new tab - - If {reuse} is 1 and {split} one of 'vsplit' or 'hsplit', open the link in - a possibly existing split window instead of making a new split. - - If {move_cursor} is 1 the cursor moves to the window or tab with the - opened link, otherwise, it stays in the window or tab with the link. - - For example, is per default mapped to - vimwiki#base#follow_link('nosplit', 0, 1) - ============================================================================== 5. Wiki syntax *vimwiki-syntax* diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 6b517dc..a5c2e69 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -259,8 +259,8 @@ command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link() command! -buffer VimwikiRenameLink call vimwiki#base#rename_link() command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1) command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link() -command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('hsplit', 0, 1) -command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', 0, 1) +command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', ) +command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', ) command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link() From 51017f6b5efb8c38336a93530fba912bda7d6b77 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 5 Jul 2018 14:00:18 +0200 Subject: [PATCH 20/64] Update changelog Ref #504 --- doc/vimwiki.txt | 77 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 4c4e541..4081f93 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -9,7 +9,7 @@ |___| |___| |_| |_||__| |__||___| |___| |_||___| ~ - Version: 2.3 + Version: 2.4 ============================================================================== CONTENTS *vimwiki* @@ -877,6 +877,8 @@ is decorated: > super^script^ sub,,script,, +Furthermore, there are a number of words which are highlighted extra flashy: +TODO, DONE, STARTED, FIXME, FIXED, XXX. ------------------------------------------------------------------------------ 5.2. Links *vimwiki-syntax-links* @@ -2247,15 +2249,15 @@ be located at https://github.com/vimwiki-backup/vimwiki/issues/384 To use the internal wiki2html converter, use an empty string (the default). -vimwiki-option-custom_wiki2html_args +*vimwiki-option-custom_wiki2html_args* ----------------------------------------------------------------------------- Key Default value~ custom_wiki2html_args '' -Description +Description~ If a custom script is called with |vimwiki-option-custom_wiki2html|, additional -parameters can be passed by setting them using 'custom_wiki2html_args' in -|g:vimwiki_list|. +parameters can be passed using this option: > + let g:vimwiki_list = [{'path': '~/path/', 'custom_wiki2html_args': 'stuff'}] *vimwiki-option-list_margin* @@ -2945,6 +2947,20 @@ Contributors and their Github usernames in roughly chronological order: - Daniel Trnka (@trnila) - Yuchen Pei (@ycpei) - @maqiv + - @dpc + - Drew Hays (@Dru89) + - Daniel Etrata (@danetrata) + - Keith Haber (@kjhaber) + - @beuerle + - Silvio Ricardo Cordeiro (@silvioricardoc) + - @blyoa + - Jonathan McElroy (@jonathanmcelroy) + - @PetrusZ + - Brian Gianforcaro (@bgianfo) + - Ben Burrill (@benburrill) + - Zhuang Ma (@mzlogin) + - Huy Le (@huynle) + - Nick Borden (@hcwndbyw) ============================================================================== @@ -2957,14 +2973,61 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from https://github.com/vimwiki-backup/vimwiki/issues. +2.4 (not yet released)~ + +New:~ + * Add the option |g:vimwiki_text_ignore_newline|. + * |g:vimwiki_listsyms| can have fewer or more than 5 symbols. + * glx on a list item marks a checkbox as won't do, see |vimwiki_glx|. + * Add the option |g:vimwiki_listsym_rejected| to set the character used + for won't-do list items. + * gln and glp change the "done" status of a checkbox, see |vimwiki_gln|. + * |:VimwikiSplitLink| and |:VimwikiVSplitLink| can now reuse an existing + split window and not move the cursor. + * Add 'aH' and 'iH' text objects, see |vimwiki-text-objects|. + * Add the keys |vimwiki_[[|, |vimwiki_]]|, |vimwiki_[=|, |vimwiki_]=| and + |vimwiki_]u| for navigating between headers. + * Add the command |:VimwikiMakeTomorrowDiaryNote|. + * |g:vimwiki_folding| has a new option 'custom'. + * Add the ':quick' option for faster folding, see |g:vimwiki_folding|. + * Add the %date placeholder, see |vimwiki-date|. + * Add the option |vimwiki-option-custom_wiki2html_args|. + * Add support for HTML-style comments when using markdown syntax. + +Removed:~ + * Remove the undocumented and buggy command :VimwikiReadLocalOptions + which allowed to store Vimwiki related settings in a local file. + * Remove the undocumented command :VimwikiPrintWikiState. + * For complicated reasons, Vimwiki doesn't clean up its settings anymore + if you change the filetype of a wiki buffer. + +Fixed:~ + * Make |vimwiki-option-automatic_nested_syntaxes| work also for markdown. + * Issue #236: Highlight math blocks as TeX math, not TeX. + * Issue #264: Don't overwrite mappings to i_ from other plugins. + * Fix an error where sometimes didn't work under Windows. + * Issue #302: |:VimwikiDiaryGenerateLinks| had issues with markdown. + * Issue #445: Better handling of |'autowriteall'| and |'hidden'|. + * Improve 'ah' and 'ih' text objects, see |vimwiki-text-objects|. + * Allow opening of links using Powershell. + * Allow any visual mode to be used with |vimwiki_+|. + * Markdown syntax for |vimwiki-toc| is used, when appropriate. + * Wikis can now be in subfolders of other wikis. + * Issue #482: |:VimwikiMakeDiaryNote| now uses the diary of the current wiki. + * Opening the diary and wikis from the menu works correctly now. + * Issue #497: Make |:VimwikiMakeDiaryNote| work outside a wiki buffer. + * Use markdown syntax in the diary when appropriate. + * Various other minor fixes. + + 2.3 (2016-03-31)~ -New: +New:~ * Add |:VimwikiMakeYesterdayDiaryNote| command * Issue #128: add option |vimwiki-option-automatic_nested_syntaxes| * Issue #192: Sort links in the list generated by |:VimwikiGenerateTags| -Fixed: +Fixed:~ * Issue #176: Fix issue when the wiki path contains spaces * Also look for tags in wiki files in subdirectories * Locate the .tags file correctly on Windows From 44a1f3a6f36d9695029a5134a8ffd2809228d5e9 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 5 Jul 2018 14:11:37 +0200 Subject: [PATCH 21/64] Add a note to the doc about setting Vimwiki settings Ref #510 --- doc/vimwiki.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 4081f93..90b5b12 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1841,6 +1841,12 @@ as described in |vimwiki-register-wiki|, or may be registered on the fly as described in |vimwiki-temporary-wiki|. For a list of per-wiki options, see |vimwiki-local-options|. +A note for Vim power users: +If you have an elaborated Vim setup, where you e.g. load plugins +conditionally, make sure the settings are set before Vimwiki loads (that is, +before plugin/vimwiki.vim is sourced). If this is not possible, try this +command after the Vimwiki settings are (re-) set: > + :call vimwiki#vars#init() ------------------------------------------------------------------------------ 12.1 Registered Wiki *g:vimwiki_list* *vimwiki-register-wiki* From 2185815b0004018cc4c5261f7be1d6936c9fcd22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Fri, 27 Jul 2018 02:46:12 +0200 Subject: [PATCH 22/64] Fix problem with open swap-file --- autoload/vimwiki/base.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 3a6e128..0f399ea 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -720,19 +720,19 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) " This hack is necessary because apparently Vim messes up the result of " getpos() directly after this command. Strange. if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p'))) - try - if &autowriteall && !&hidden " in this case, the file is saved before switching to the - " new buffer. This causes Vim to show two messages in the command line which triggers - " the annoying hit-enter prompt. Solution: show no messages at all. - silent execute a:command fname - else + if &autowriteall && !&hidden " in this case, the file is saved before switching to the + " new buffer. This causes Vim to show two messages in the command line which triggers + " the annoying hit-enter prompt. Solution: show no messages at all. + silent execute a:command fname + else + try execute a:command fname - endif - catch /E37:/ - echomsg 'Vimwiki: The current file is modified. Hint: Take a look at' - \ ''':h g:vimwiki_autowriteall'' to see how to save automatically.' - return - endtry + catch /E37:/ + echomsg 'Vimwiki: The current file is modified. Hint: Take a look at' + \ ''':h g:vimwiki_autowriteall'' to see how to save automatically.' + return + endtry + endif " If the opened file was not already loaded by Vim, an autocommand is " triggered at this point From 5605f285c1b9d551044c464b4416b263800dde97 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Tue, 7 Aug 2018 21:39:54 +0200 Subject: [PATCH 23/64] Fix messing up folding when Vim is in diff mode --- plugin/vimwiki.vim | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 1076588..8b13d6c 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -157,23 +157,25 @@ endfunction " Vim defaults. So we enforce our settings here when the cursor enters a " Vimwiki buffer. function! s:set_windowlocal_options() - let foldmethod = vimwiki#vars#get_global('folding') - if foldmethod =~? '^expr.*' - setlocal foldmethod=expr - setlocal foldexpr=VimwikiFoldLevel(v:lnum) - setlocal foldtext=VimwikiFoldText() - elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*' - setlocal foldmethod=expr - setlocal foldexpr=VimwikiFoldListLevel(v:lnum) - setlocal foldtext=VimwikiFoldText() - elseif foldmethod =~? '^syntax.*' - setlocal foldmethod=syntax - setlocal foldtext=VimwikiFoldText() - elseif foldmethod =~? '^custom.*' - " do nothing - else - setlocal foldmethod=manual - normal! zE + if !&diff " if Vim is currently in diff mode, don't interfere with its folding + let foldmethod = vimwiki#vars#get_global('folding') + if foldmethod =~? '^expr.*' + setlocal foldmethod=expr + setlocal foldexpr=VimwikiFoldLevel(v:lnum) + setlocal foldtext=VimwikiFoldText() + elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*' + setlocal foldmethod=expr + setlocal foldexpr=VimwikiFoldListLevel(v:lnum) + setlocal foldtext=VimwikiFoldText() + elseif foldmethod =~? '^syntax.*' + setlocal foldmethod=syntax + setlocal foldtext=VimwikiFoldText() + elseif foldmethod =~? '^custom.*' + " do nothing + else + setlocal foldmethod=manual + normal! zE + endif endif if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel") From f639c0a342602aae9ec5cb881d8301c6f001e6c8 Mon Sep 17 00:00:00 2001 From: Fredrik Arnerup Date: Mon, 17 Sep 2018 12:20:17 +0200 Subject: [PATCH 24/64] Clean URLs that don't have slashes Will fix normalization of links like [[local:./foo.txt]] Also, allow schemes to end with a number, so that e.g. [[wiki1:foo]] will normalize as expected. --- autoload/vimwiki/base.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 0f399ea..3a81b57 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1861,7 +1861,8 @@ endfunction function! s:clean_url(url) " remove protocol and tld - let url = substitute(a:url, '^\a\+://', '', '') + let url = substitute(a:url, '^\a\+\d*:', '', '') + let url = substitute(url, '^//', '', '') let url = substitute(url, '^\([^/]\+\).\a\{2,4}/', '\1/', '') let url = split(url, '/\|=\|-\|&\|?\|\.') let url = filter(url, 'v:val !=# ""') From d7d94e21600930d9d81bc0dd4c583324ea9f5fd8 Mon Sep 17 00:00:00 2001 From: Steven Stallion Date: Thu, 12 Jul 2018 10:58:12 -0500 Subject: [PATCH 25/64] Initial commit --- autoload/vimwiki/diary.vim | 5 +++++ autoload/vimwiki/vars.vim | 1 + doc/vimwiki.txt | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 164211d..37f6d5c 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -231,6 +231,11 @@ function! vimwiki#diary#goto_diary_index(wnum) endif call vimwiki#base#edit_file('e', s:diary_index(idx), '') + + if vimwiki#vars#get_wikilocal('auto_diary_index') + call vimwiki#diary#generate_diary_section() + write! " save changes + endif endfunction diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 7b8e507..2e7d036 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -181,6 +181,7 @@ endfunction function! s:populate_wikilocal_options() let default_values = { + \ 'auto_diary_index': 0, \ 'auto_export': 0, \ 'auto_tags': 0, \ 'auto_toc': 0, diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 90b5b12..629ba9c 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2295,6 +2295,17 @@ current wiki page is saved: > let g:vimwiki_list = [{'path': '~/my_site/', 'auto_tags': 1}] +*vimwiki-option-auto_diary_index* +------------------------------------------------------------------------------ +Key Default value Values~ +auto_diary_index 0 0, 1 + +Description~ +Set this option to 1 to automatically update the diary index when opened. +See |:VimwikiDiaryGenerateLinks|: > + let g:vimwiki_list = [{'path': '~/my_site/', 'auto_diary_index': 1}] + + ------------------------------------------------------------------------------ 12.4 Global Options *vimwiki-global-options* From e6d0678b545b32ab932f58448024a4c9af7690a9 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Tue, 9 Oct 2018 21:54:02 +0200 Subject: [PATCH 26/64] Add CONTRIBUTING.md --- CONTRIBUTING.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ doc/vimwiki.txt | 9 +-------- 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..bffe109 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +# Filing a bug + +Before filing a bug or starting to write a patch, check the latest development version from +https://github.com/vimwiki/vimwiki/tree/dev to see if your problem is already fixed. + +Issues can be filed at https://github.com/vimwiki/vimwiki/issues/ . + +# Creating a pull request +If you want to provide a pull request on GitHub, please start from the `dev` branch, not from the +`master` branch. (Caution, GitHub shows `master` as the default branch from which to start a PR.) + + +# More info for (aspiring) core developers +## Git branching model +- there are two branches with eternal lifetime: + - `dev`: This is where the main development happens. Tasks which are done in one or only a few + commits go here directly. Always try to keep this branch in a working state, that is, if the + task you work on requires multiple commits, make sure intermediate commits don't make Vimwiki + unusable (or at least push these commits at one go). + - `master`: This branches is for released states only. Whenever a reasonable set of changes has + piled up in the `dev` branch, a [release is done](#Preparing a release). After a release, + `dev` has been merged into `master` and `master` got exactly one additional commit in which + the version number in `plugin/vimwiki.vim` is updated. Apart from these commits and the merge + commit from `dev`, nothing happens on `master`. Never should `master` merge into `dev`. When + the users ask, we should recommend this branch for them to use. +- Larger changes which require multiple commits are done in feature branches. They are based on + `dev` and merge into `dev` when the work is done. + +## Preparing a release + +1. `git checkout dev` +2. Update the changelog in the doc, nicely grouped, with a new version number and release date. +3. Update the list of contributors. +4. Update the version number at the top of the doc file. +5. If necessary, update the Readme and the home page. +6. `git checkout master && git merge dev` +7. Update the version number at the top of plugin/vimwiki.vim. +8. Set a tag with the version number in Git: `git tag vX.Y` +9. `git push --tags` +10. In GitHub, go to _Releases_ -> _Draft a new release_ -> choose the tag, convert the changelog from the + doc to markdown and post it there. Make plans to build an automatic converter and immediately + forget this plan. +11. Tell the world. + + +%% vim:tw=99 diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 629ba9c..fcea9eb 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2910,14 +2910,7 @@ Your help in making Vimwiki better is really appreciated! Any help, whether it is a spelling correction or a code snippet to patch -- everything is welcomed. -Before filing a bug or starting to write a patch, check the latest development -version from https://github.com/vimwiki/vimwiki/tree/dev to see if your -problem is already fixed. - -Issues can be filed at https://github.com/vimwiki/vimwiki/issues/. - -If you want to provide a pull request on GitHub, please start from the dev -branch, not from the master branch. +See CONTRIBUTING.md for info about how to file bugs etc. ============================================================================== 15. Development *vimwiki-development* From 76f51f1dba3ff3bc5aafcf3538567eb8a11d7f40 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Mon, 15 Oct 2018 07:36:41 +0200 Subject: [PATCH 27/64] Nicer error message when linking to not registered wiki --- autoload/vimwiki/base.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 3a81b57..12b5ea8 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -174,6 +174,7 @@ function! vimwiki#base#resolve_link(link_text, ...) if link_infos.scheme =~# '\mwiki\d\+' let link_infos.index = eval(matchstr(link_infos.scheme, '\D\+\zs\d\+\ze')) if link_infos.index < 0 || link_infos.index >= vimwiki#vars#number_of_wikis() + let link_infos.index = -1 let link_infos.filename = '' return link_infos endif @@ -268,7 +269,11 @@ function! vimwiki#base#open_link(cmd, link, ...) endif if link_infos.filename == '' - echomsg 'Vimwiki Error: Unable to resolve link!' + if link_infos.index == -1 + echomsg 'Vimwiki Error: No registered wiki ''' . link_infos.scheme . '''.' + else + echomsg 'Vimwiki Error: Unable to resolve link!' + endif return endif From bd88ea968baf4ce779d05f029acb63418a103e51 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Tue, 16 Oct 2018 22:25:33 +0200 Subject: [PATCH 28/64] Better error handling when opening a file of which a swapfile exists Ref #569 --- autoload/vimwiki/base.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 12b5ea8..cf93366 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -736,6 +736,9 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) echomsg 'Vimwiki: The current file is modified. Hint: Take a look at' \ ''':h g:vimwiki_autowriteall'' to see how to save automatically.' return + catch /E325:/ + echom 'Vimwiki: Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.' + return endtry endif From 7668985b43bb1d31933532e1a4f5e66329034c29 Mon Sep 17 00:00:00 2001 From: Benjamin Brandtner <37274870+BenjaminBrandtner@users.noreply.github.com> Date: Mon, 22 Oct 2018 20:23:07 +0200 Subject: [PATCH 29/64] Fixed system file handlers for windows Fixes #560 Opening external files containing spaces should now work on cmd and powershell. --- autoload/vimwiki/base.vim | 40 ++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index cf93366..6167060 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -220,22 +220,32 @@ endfunction function! vimwiki#base#system_open_link(url) " handlers function! s:win32_handler(url) - "http://vim.wikia.com/wiki/Opening_current_Vim_file_in_your_Windows_browser - "disable 'shellslash', otherwise the url will be enclosed in single quotes, - "which is problematic - "see https://github.com/vimwiki/vimwiki/issues/54#issuecomment-48011289 - if exists('+shellslash') - let old_ssl = &shellslash - set noshellslash - let url = shellescape(a:url, 1) - let &shellslash = old_ssl + "Disable shellslash for cmd and command.com, but enable for all other shells + "See Issue #560 + if (&shell =~? "cmd") || (&shell =~? "command.com") + + if exists('+shellslash') + let old_ssl = &shellslash + set noshellslash + let url = shellescape(a:url, 1) + let &shellslash = old_ssl + else + let url = shellescape(a:url, 1) + endif + execute 'silent ! start "Title" /B ' . url + else - let url = shellescape(a:url, 1) - endif - if &l:shell ==? "powershell" - execute 'silent ! start ' . a:url - else - execute 'silent ! start "Title" /B ' . a:url + + if exists('+shellslash') + let old_ssl = &shellslash + set shellslash + let url = shellescape(a:url, 1) + let &shellslash = old_ssl + else + let url = shellescape(a:url, 1) + endif + execute 'silent ! start ' . url + endif endfunction function! s:macunix_handler(url) From 5f762082d21194a1a1b9dfdd811819e3f9bec594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Thu, 25 Oct 2018 23:26:35 +0200 Subject: [PATCH 30/64] Fix bug: change links when renaming pages --- autoload/vimwiki/base.vim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 0f399ea..fa6a917 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -849,16 +849,16 @@ function! s:update_wiki_link(fname, old, new) endfunction -function! s:update_wiki_links_dir(dir, old_fname, new_fname) +function! s:update_wiki_links_dir(wiki_nr, dir, old_fname, new_fname) let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g') let new_fname = a:new_fname let old_fname_r = vimwiki#base#apply_template( \ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate'), old_fname, '', '') - let files = split(glob(vimwiki#vars#get_wikilocal('path').a:dir.'*'. - \ vimwiki#vars#get_wikilocal('ext')), '\n') - for fname in files + let files = split(glob(vimwiki#vars#get_wikilocal('path', a:wiki_nr).a:dir.'*'. + \ vimwiki#vars#get_wikilocal('ext', a:wiki_nr)), '\n') + for fname in l:files call s:update_wiki_link(fname, old_fname_r, new_fname) endfor endfunction @@ -872,7 +872,7 @@ function! s:tail_name(fname) endfunction -function! s:update_wiki_links(old_fname, new_fname) +function! s:update_wiki_links(wiki_nr, old_fname, new_fname) let old_fname = a:old_fname let new_fname = a:new_fname @@ -898,7 +898,7 @@ function! s:update_wiki_links(old_fname, new_fname) while idx < len(dirs_keys) let dir = dirs_keys[idx] let new_dir = dirs_vals[idx] - call s:update_wiki_links_dir(dir, new_dir.old_fname, new_dir.new_fname) + call s:update_wiki_links_dir(a:wiki_nr, dir, new_dir.old_fname, new_dir.new_fname) let idx = idx + 1 endwhile endfunction @@ -1290,6 +1290,7 @@ function! vimwiki#base#rename_link() endif let new_link = subdir.new_link + let wiki_nr = vimwiki#vars#get_bufferlocal("wiki_nr") let new_fname = vimwiki#vars#get_wikilocal('path') . new_link . vimwiki#vars#get_wikilocal('ext') " do not rename if file with such name exists @@ -1333,7 +1334,7 @@ function! vimwiki#base#rename_link() setlocal nomore " update links - call s:update_wiki_links(s:tail_name(old_fname), new_link) + call s:update_wiki_links(wiki_nr, s:tail_name(old_fname), new_link) " restore wiki buffers for bitem in blist From a32a06f3b81f80d6b839955a8f47964388e56d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Thu, 25 Oct 2018 23:39:45 +0200 Subject: [PATCH 31/64] Follow up to 5f76208 --- autoload/vimwiki/base.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index ebf4c1b..92ba84f 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -872,7 +872,8 @@ function! s:update_wiki_links_dir(wiki_nr, dir, old_fname, new_fname) let new_fname = a:new_fname let old_fname_r = vimwiki#base#apply_template( - \ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate'), old_fname, '', '') + \ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate', + \ vimwiki#vars#get_wikilocal('syntax', a:wiki_nr)), old_fname, '', '') let files = split(glob(vimwiki#vars#get_wikilocal('path', a:wiki_nr).a:dir.'*'. \ vimwiki#vars#get_wikilocal('ext', a:wiki_nr)), '\n') From 7969810b494c6ea66fd353b9071fb4d3fe06fc07 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Fri, 26 Oct 2018 16:35:02 +0200 Subject: [PATCH 32/64] Fix losing highlighting after VimwikiAll2HTML Apparently, switching buffers in connection with disabled events caused the highlighting to disappear. Solution: use the :wa command to save all buffers. A disadvantage is that now also non-Vimwiki buffers are saved, but I think that is bearable. --- autoload/vimwiki/html.vim | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index bce5465..0fd68d6 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -204,13 +204,6 @@ function! s:subst_func(line, regexp, func, ...) endfunction -function! s:save_vimwiki_buffer() - if &filetype ==? 'vimwiki' && filewritable(expand('%')) - silent update - endif -endfunction - - function! s:process_date(placeholders, default_date) if !empty(a:placeholders) for [placeholder, row, idx] in a:placeholders @@ -1586,9 +1579,11 @@ function! vimwiki#html#WikiAll2HTML(path_html) echomsg 'Vimwiki: Saving Vimwiki files ...' let save_eventignore = &eventignore let &eventignore = "all" - let cur_buf = bufname('%') - bufdo call s:save_vimwiki_buffer() - exe 'buffer '.cur_buf + try + wall + catch + " just ignore errors + endtry let &eventignore = save_eventignore let path_html = expand(a:path_html) From 6a6aeff0132be2c9ae8850c272588a42e84cc12d Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sun, 28 Oct 2018 21:04:24 +0100 Subject: [PATCH 33/64] Fix losing the highlight of headers when switching colorschemes Funnily, the code to fix this was there for over 8 years now, but didn't work. --- plugin/vimwiki.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 8b13d6c..2487072 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -231,11 +231,11 @@ endif augroup vimwiki autocmd! + autocmd ColorScheme * call s:setup_cleared_syntax() for s:ext in s:known_extensions exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()' exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()' exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()' - exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()' " Format tables when exit from insert mode. Do not use textwidth to " autowrap tables. if vimwiki#vars#get_global('table_auto_fmt') From 90722a47034ae827c5a733e06a62d194207a492d Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 1 Nov 2018 21:12:14 +0100 Subject: [PATCH 34/64] Make an error message more clear --- autoload/vimwiki/base.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 92ba84f..0c34da0 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -743,7 +743,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) try execute a:command fname catch /E37:/ - echomsg 'Vimwiki: The current file is modified. Hint: Take a look at' + echomsg 'Vimwiki: Can''t leave the current buffer, because it is modified. Hint: Take a look at' \ ''':h g:vimwiki_autowriteall'' to see how to save automatically.' return catch /E325:/ @@ -1292,12 +1292,10 @@ function! vimwiki#base#rename_link() let new_link = input('Enter new name: ') if new_link =~# '[/\\]' - " It is actually doable but I do not have free time to do it. echomsg 'Vimwiki Error: Cannot rename to a filename with path!' return endif - " check new_fname - it should be 'good', not empty if substitute(new_link, '\s', '', 'g') == '' echomsg 'Vimwiki Error: Cannot rename to an empty filename!' return From 675ff23ed145f63a045093f7e362acde303219c2 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Mon, 5 Nov 2018 22:36:25 +0100 Subject: [PATCH 35/64] Fix a few regexes Without this, things would go wrong if the user has >= 10 Wikis. --- ftplugin/vimwiki.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index a5c2e69..2d3688b 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -63,13 +63,13 @@ function! Complete_wikifiles(findstart, base) elseif a:base !~# '#' " we look for wiki files - if a:base =~# '^wiki\d:' - let wikinumber = eval(matchstr(a:base, '^wiki\zs\d')) + if a:base =~# '\m^wiki\d\+:' + let wikinumber = eval(matchstr(a:base, '\m^wiki\zs\d\+')) if wikinumber >= vimwiki#vars#number_of_wikis() return [] endif - let prefix = matchstr(a:base, '^wiki\d:\zs.*') - let scheme = matchstr(a:base, '^wiki\d:\ze') + let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*') + let scheme = matchstr(a:base, '\m^wiki\d\+:\ze') elseif a:base =~# '^diary:' let wikinumber = -1 let prefix = matchstr(a:base, '^diary:\zs.*') From bddd644fbb0ea3c04d0aa7ef997c136eb1f85347 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Wed, 7 Nov 2018 22:02:30 +0100 Subject: [PATCH 36/64] Use $HOME instead of ~/ in paths Apparently, the latter doesn't work on all platforms. Ref #565 --- autoload/vimwiki/vars.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 2e7d036..1bdda1a 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -198,12 +198,12 @@ function! s:populate_wikilocal_options() \ 'list_margin': -1, \ 'maxhi': 0, \ 'nested_syntaxes': {}, - \ 'path': '~/vimwiki/', + \ 'path': $HOME . '/vimwiki/', \ 'path_html': '', \ 'syntax': 'default', \ 'template_default': 'default', \ 'template_ext': '.tpl', - \ 'template_path': '~/vimwiki/templates/', + \ 'template_path': $HOME . '/vimwiki/templates/', \ } let g:vimwiki_wikilocal_vars = [] From 6f6023610cd86d66d1f58f099f558ad9c75d0083 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Mon, 12 Nov 2018 21:54:52 +0100 Subject: [PATCH 37/64] Don't jump to the TOC on C-o etc. Before, the cursor would jump to the TOC a lot when pressing etc., because it is changed every time the buffer is saved. Use :keepjumps to make it less intrusive. Sadly, the cursor still jumps to the TOC when you press u and C-r, but it seems there is no way around it. --- autoload/vimwiki/base.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 0c34da0..2358324 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1017,7 +1017,7 @@ endfunction " will only be updated if it already exists function! vimwiki#base#update_listing_in_buffer(strings, start_header, \ content_regex, default_lnum, create) - " apparently, Vim behaves strange when files change while in diff mode + " Vim behaves strangely when files change while in diff mode if &diff || &readonly return endif @@ -1063,8 +1063,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header, " fold gets deleted. So we temporarily disable folds, and then reenable " them right back. let foldenable_save = &l:foldenable - setlo nofoldenable - silent exe start_lnum.','.string(end_lnum - 1).'delete _' + setlocal nofoldenable + silent exe 'keepjumps ' . start_lnum.','.string(end_lnum - 1).'delete _' let &l:foldenable = foldenable_save let lines_diff = 0 - (end_lnum - start_lnum) else @@ -1079,16 +1079,16 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header, let new_header = whitespaces_in_first_line \ . s:safesubstitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'), \ '__Header__', a:start_header, '') - call append(start_lnum - 1, new_header) + keepjumps call append(start_lnum - 1, new_header) let start_lnum += 1 let lines_diff += 1 + len(a:strings) for string in a:strings - call append(start_lnum - 1, string) + keepjumps call append(start_lnum - 1, string) let start_lnum += 1 endfor " append an empty line if there is not one if start_lnum <= line('$') && getline(start_lnum) !~# '\m^\s*$' - call append(start_lnum - 1, '') + keepjumps call append(start_lnum - 1, '') let lines_diff += 1 endif From 2e523b308f28c775d7a42afde6e9c02490cc916b Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sat, 17 Nov 2018 20:05:58 +0100 Subject: [PATCH 38/64] Check if there is a TOC header before trying to update it --- autoload/vimwiki/base.vim | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 2358324..15e87fb 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1804,13 +1804,31 @@ endfunction " a:create == 0: update if TOC exists function! vimwiki#base#table_of_contents(create) let headers = s:collect_headers() + let toc_header_text = vimwiki#vars#get_global('toc_header') + + if !a:create + " Do nothing if there is no TOC to update. (This is a small performance optimization -- if + " auto_toc == 1, but the current buffer has no TOC but is long, saving the buffer could + " otherwise take a few seconds for nothing.) + let toc_already_present = 0 + for entry in headers + if entry[2] ==# toc_header_text + let toc_already_present = 1 + break + endif + endfor + if !toc_already_present + return + endif + endif + let numbering = vimwiki#vars#get_global('html_header_numbering') let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]] let complete_header_infos = [] for header in headers let h_text = header[2] let h_level = header[1] - if h_text ==# vimwiki#vars#get_global('toc_header') " don't include the TOC's header itself + if h_text ==# toc_header_text " don't include the TOC's header itself continue endif let headers_levels[h_level-1] = [h_text, headers_levels[h_level-1][1]+1] @@ -1852,8 +1870,7 @@ function! vimwiki#base#table_of_contents(create) let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' ' - call vimwiki#base#update_listing_in_buffer(lines, - \ vimwiki#vars#get_global('toc_header'), links_rx, 1, a:create) + call vimwiki#base#update_listing_in_buffer(lines, toc_header_text, links_rx, 1, a:create) endfunction From 12349b8cb6ee7cf8f46c2806c3ab21a1bed9ea55 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sat, 17 Nov 2018 20:07:09 +0100 Subject: [PATCH 39/64] Remove duplicated code --- autoload/vimwiki/lst.vim | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index d4ccbbd..66a4ad2 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -1003,20 +1003,6 @@ function! vimwiki#lst#increment_cb(from_line, to_line) endfunction -"Toggles checkbox between [ ] and [X] or creates one -"in the lines of the given range -function! vimwiki#lst#toggle_cb(from_line, to_line) - return s:toggle_create_cb(a:from_line, a:to_line, 100, 0) -endfunction - - -"Toggles checkbox between [ ] and [-] or creates one -"in the lines of the given range -function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) - return s:toggle_create_cb(a:from_line, a:to_line, -1, 0) -endfunction - - function! vimwiki#lst#remove_cb(first_line, last_line) let first_item = s:get_corresponding_item(a:first_line) let last_item = s:get_corresponding_item(a:last_line) From 2fb0e17adbf494531789c50ee8d24a15f978c33b Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sat, 17 Nov 2018 20:07:48 +0100 Subject: [PATCH 40/64] glx on a list item creates a checked checkbox ... instead of an unchecked one. --- autoload/vimwiki/lst.vim | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 66a4ad2..a9244b5 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -841,13 +841,13 @@ endfunction "Creates checkbox in a list item. "Returns: 1 if successful -function! s:create_cb(item) +function! s:create_cb(item, start_rate) if a:item.type == 0 || a:item.cb != '' return 0 endif let new_item = a:item - let new_item.cb = vimwiki#vars#get_syntaxlocal('listsyms_list')[0] + let new_item.cb = s:rate_to_state(a:start_rate) call s:substitute_rx_in_line(new_item.lnum, \ vimwiki#u#escape(new_item.mrkr) . '\zs\ze', ' [' . new_item.cb . ']') @@ -894,9 +894,9 @@ function! s:change_cb(from_line, to_line, new_rate) endfunction -"Toggles checkbox between two states in the lines of the given range, -"creates chceckboxes if there aren't any. -function! s:toggle_create_cb(from_line, to_line, state1, state2) +" Toggles checkbox between two states in the lines of the given range, creates chceckboxes (with +" a:start_rate as state) if there aren't any. +function! s:toggle_create_cb(from_line, to_line, state1, state2, start_rate) let from_item = s:get_corresponding_item(a:from_line) if from_item.type == 0 return @@ -908,7 +908,7 @@ function! s:toggle_create_cb(from_line, to_line, state1, state2) let parent_items_of_lines = [] for cur_ln in range(from_item.lnum, a:to_line) let cur_item = s:get_item(cur_ln) - let success = s:create_cb(cur_item) + let success = s:create_cb(cur_item, a:start_rate) if success let cur_parent_item = s:get_parent(cur_item) @@ -974,14 +974,14 @@ endfunction "Toggles checkbox between [ ] and [X] or creates one "in the lines of the given range function! vimwiki#lst#toggle_cb(from_line, to_line) - return s:toggle_create_cb(a:from_line, a:to_line, 100, 0) + return s:toggle_create_cb(a:from_line, a:to_line, 100, 0, 0) endfunction "Toggles checkbox between [ ] and [-] or creates one "in the lines of the given range function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) - return s:toggle_create_cb(a:from_line, a:to_line, -1, 0) + return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1) endfunction @@ -1381,7 +1381,7 @@ function! s:clone_marker_from_to(from, to) let new_indent = ( vimwiki#vars#get_syntaxlocal('recurring_bullets') ? 0 : indent(a:from) ) call s:set_indent(a:to, new_indent) if item_from.cb != '' - call s:create_cb(s:get_item(a:to)) + call s:create_cb(s:get_item(a:to), 0) call s:update_state(s:get_parent(s:get_item(a:to))) endif if item_from.type == 2 From dcd1c0a3646a7d8c146a309a89c6b2e4f3d14b6f Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Mon, 19 Nov 2018 21:02:37 +0100 Subject: [PATCH 41/64] Make gl* work again The problem was that map() also changed the given list in-place, that's not what was intended. --- autoload/vimwiki/vars.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 1bdda1a..77689f7 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -359,7 +359,7 @@ function! vimwiki#vars#populate_syntax_vars(syntax) "create regexp for bulleted list items if !empty(g:vimwiki_syntax_variables[a:syntax].bullet_types) let g:vimwiki_syntax_variables[a:syntax].rxListBullet = - \ join( map(g:vimwiki_syntax_variables[a:syntax].bullet_types, + \ join( map(copy(g:vimwiki_syntax_variables[a:syntax].bullet_types), \'vimwiki#u#escape(v:val).' \ .'repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)' \ ) , '\|') From 349d551181e9b0f979da390630508cd2d7df96f8 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sun, 25 Nov 2018 17:55:43 +0100 Subject: [PATCH 42/64] Diary: make + in visual mode work correctly --- autoload/vimwiki/base.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 15e87fb..dd73479 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1951,17 +1951,22 @@ function! s:normalize_link_in_diary(lnk) let link_exists_in_wiki = filereadable(link_wiki) let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d' - if ! link_exists_in_wiki || link_exists_in_diary || link_is_date + if link_exists_in_diary || link_is_date let str = a:lnk let rxUrl = vimwiki#vars#get_global('rxWord') let rxDesc = '' let template = vimwiki#vars#get_global('WikiLinkTemplate1') - else + elseif link_exists_in_wiki let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/')) let str = repeat('../', depth) . a:lnk . '|' . a:lnk let rxUrl = '^.*\ze|' let rxDesc = '|\zs.*$' let template = vimwiki#vars#get_global('WikiLinkTemplate2') + else + let str = a:lnk + let rxUrl = '.*' + let rxDesc = '' + let template = vimwiki#vars#get_global('WikiLinkTemplate1') endif return vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) From a653e2d8c2992867f1a28e55529df9b4d6da2ed7 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sun, 25 Nov 2018 17:56:43 +0100 Subject: [PATCH 43/64] HTML converter: trim strings correctly The old version didn't remove trailing spaces. --- autoload/vimwiki/html.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 0fd68d6..4d44510 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -366,7 +366,7 @@ endfunction function! s:linkify_link(src, descr) let src_str = ' href="'.s:escape_html_attribute(a:src).'"' - let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','') + let descr = vimwiki#u#trim(a:descr) let descr = (descr == "" ? a:src : descr) let descr_str = (descr =~# vimwiki#vars#get_global('rxWikiIncl') \ ? s:tag_wikiincl(descr) @@ -438,7 +438,8 @@ function! s:tag_wikilink(value) let str = a:value let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl')) let descr = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr')) - let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url) + let descr = vimwiki#u#trim(descr) + let descr = (descr != '' ? descr : url) let line = VimwikiLinkConverter(url, s:current_wiki_file, s:current_html_file) if line == '' @@ -836,7 +837,7 @@ function! s:process_tag_math(line, math) " environment properly let s:current_math_env = matchstr(class, '^%\zs\S\+\ze%') if s:current_math_env != "" - call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', '')) + call add(lines, substitute(class, '^%\(\S\+\)%', '\\begin{\1}', '')) elseif class != "" call add(lines, "\\\[".class) else From fa36bf38388d7e9a71d68b34b02be5a68d4a2dea Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Fri, 30 Nov 2018 17:02:38 +0100 Subject: [PATCH 44/64] Don't check a [-] list item when its parent is [X] checked --- autoload/vimwiki/lst.vim | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index a9244b5..e01b29d 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -299,6 +299,13 @@ function! s:regexp_of_marker(item) endfunction +" Returns: Whether or not the checkbox of a list item is [X] or [-] +function! s:is_closed(item) + let state = a:item.cb + return state ==# vimwiki#vars#get_syntaxlocal('listsyms_list')[-1] + \ || state ==# vimwiki#vars#get_global('listsym_rejected') +endfunction + " --------------------------------------------------------- " functions for navigating between items " --------------------------------------------------------- @@ -756,10 +763,15 @@ function! s:set_state(item, new_rate) endfunction -"Set state of the list item to [ ] or [o] or whatever -"Updates the states of its child items -function! s:set_state_plus_children(item, new_rate) - call s:set_state(a:item, a:new_rate) +" Sets the state of the list item to [ ] or [o] or whatever. Updates the states of its child items. +" If the new state should be [X] or [-], the state of the current list item is changed to this +" state, but if a child item already has [X] or [-] it is left alone. +function! s:set_state_plus_children(item, new_rate, ...) + let retain_checked_and_rejected = a:0 > 0 && a:1 > 0 + + if !(retain_checked_and_rejected && s:is_closed(a:item)) + call s:set_state(a:item, a:new_rate) + endif let child_item = s:get_first_child(a:item) while 1 @@ -767,7 +779,7 @@ function! s:set_state_plus_children(item, new_rate) break endif if child_item.cb != '' - call s:set_state_plus_children(child_item, a:new_rate) + call s:set_state_plus_children(child_item, a:new_rate, 1) endif let child_item = s:get_next_child_item(a:item, child_item) endwhile @@ -866,8 +878,7 @@ function! s:remove_cb(item) endfunction -"Change state of checkbox -"in the lines of the given range +" Change state of the checkboxes in the lines of the given range function! s:change_cb(from_line, to_line, new_rate) let from_item = s:get_corresponding_item(a:from_line) if from_item.type == 0 @@ -894,7 +905,7 @@ function! s:change_cb(from_line, to_line, new_rate) endfunction -" Toggles checkbox between two states in the lines of the given range, creates chceckboxes (with +" Toggles checkbox between two states in the lines of the given range, creates checkboxes (with " a:start_rate as state) if there aren't any. function! s:toggle_create_cb(from_line, to_line, state1, state2, start_rate) let from_item = s:get_corresponding_item(a:from_line) From c398f5cd811f95c2aa6fdd7d1266cc9bfc846636 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sat, 8 Dec 2018 21:06:30 +0100 Subject: [PATCH 45/64] Remove code duplicate --- autoload/vimwiki/lst.vim | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index e01b29d..294106d 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -996,24 +996,6 @@ function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) endfunction -"Increment checkbox between [ ] and [X] -"in the lines of the given range -function! vimwiki#lst#increment_cb(from_line, to_line) - let from_item = s:get_corresponding_item(a:from_line) - if from_item.type == 0 - return - endif - - "if from_line has CB, increment it and set all siblings to the same new state - let rate_first_line = s:get_rate(from_item) - let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) - let new_rate = min([rate_first_line + 100/(n-1)+1, 100]) - - call s:change_cb(a:from_line, a:to_line, new_rate) - -endfunction - - function! vimwiki#lst#remove_cb(first_line, last_line) let first_item = s:get_corresponding_item(a:first_line) let last_item = s:get_corresponding_item(a:last_line) From a72c14da1cd2bd50d7383eab8c769b987e956e01 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sat, 8 Dec 2018 21:13:04 +0100 Subject: [PATCH 46/64] More reasonable behavior for [-] and [X] list items A parent [-] list item should have only [-] items as children. --- autoload/vimwiki/lst.vim | 55 +++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 294106d..201a658 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -767,19 +767,51 @@ endfunction " If the new state should be [X] or [-], the state of the current list item is changed to this " state, but if a child item already has [X] or [-] it is left alone. function! s:set_state_plus_children(item, new_rate, ...) - let retain_checked_and_rejected = a:0 > 0 && a:1 > 0 + let retain_state_if_closed = a:0 > 0 && a:1 > 0 - if !(retain_checked_and_rejected && s:is_closed(a:item)) + if !(retain_state_if_closed && (a:new_rate == 100 || a:new_rate == -1) && s:is_closed(a:item)) call s:set_state(a:item, a:new_rate) endif + let all_children_are_done = 1 + let all_children_are_rejected = 1 + + let child_item = s:get_first_child(a:item) + while 1 + if child_item.type == 0 + break + endif + if child_item.cb != vimwiki#vars#get_global('listsym_rejected') + let all_children_are_rejected = 0 + endif + if child_item.cb != vimwiki#vars#get_syntaxlocal('listsyms_list')[-1] + let all_children_are_done = 0 + endif + if !all_children_are_done && !all_children_are_rejected + break + endif + let child_item = s:get_next_child_item(a:item, child_item) + endwhile + + if (a:new_rate == 100 && all_children_are_done) || + \ (a:new_rate == -1) && all_children_are_rejected + return + endif + + if (a:new_rate == -1 && all_children_are_done) || + \ (a:new_rate == 100 && all_children_are_rejected) + let retain_closed_children = 0 + else + let retain_closed_children = 1 + endif + let child_item = s:get_first_child(a:item) while 1 if child_item.type == 0 break endif if child_item.cb != '' - call s:set_state_plus_children(child_item, a:new_rate, 1) + call s:set_state_plus_children(child_item, a:new_rate, retain_closed_children) endif let child_item = s:get_next_child_item(a:item, child_item) endwhile @@ -814,6 +846,7 @@ function! s:update_state(item) let sum_children_rate = 0 let count_children_with_cb = 0 + let count_rejected_children = 0 let child_item = s:get_first_child(a:item) @@ -823,16 +856,24 @@ function! s:update_state(item) endif if child_item.cb != '' let rate = s:get_rate(child_item) - if rate != -1 - let count_children_with_cb += 1 - let sum_children_rate += rate + if rate == -1 + " for calculating the parent rate, a [-] item counts as much as a [X] item ... + let rate = 100 + " ... with the exception that a parent with *only* [-] items will be [-] too + let count_rejected_children += 1 endif + let count_children_with_cb += 1 + let sum_children_rate += rate endif let child_item = s:get_next_child_item(a:item, child_item) endwhile if count_children_with_cb > 0 - let new_rate = sum_children_rate / count_children_with_cb + if count_rejected_children == count_children_with_cb + let new_rate = -1 + else + let new_rate = sum_children_rate / count_children_with_cb + endif call s:set_state_recursively(a:item, new_rate) else let rate = s:get_rate(a:item) From 645ae61dc3f486918532a2c62763e7a485dc0186 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Fri, 14 Dec 2018 21:03:46 +0100 Subject: [PATCH 47/64] Fix error when trying to make a link out of '-' Fix #582 --- autoload/vimwiki/base.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index dd73479..af60bf9 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1898,7 +1898,7 @@ function! s:clean_url(url) " remove protocol and tld let url = substitute(a:url, '^\a\+\d*:', '', '') let url = substitute(url, '^//', '', '') - let url = substitute(url, '^\([^/]\+\).\a\{2,4}/', '\1/', '') + let url = substitute(url, '^\([^/]\+\)\.\a\{2,4}/', '\1/', '') let url = split(url, '/\|=\|-\|&\|?\|\.') let url = filter(url, 'v:val !=# ""') if url[0] == "www" @@ -2010,9 +2010,8 @@ function! s:normalize_link_syntax_n() if s:is_diary_file(expand("%:p")) let sub = s:normalize_link_in_diary(lnk) else - let sub = vimwiki#base#normalize_link_helper(lnk, - \ vimwiki#vars#get_global('rxWord'), '', - \ vimwiki#vars#get_global('WikiLinkTemplate1')) + let sub = s:safesubstitute( + \ vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', lnk, '') endif call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub) return From d9b6d77e90bea67ca714ae5695717956e65f9e9a Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Mon, 17 Dec 2018 20:27:15 +0100 Subject: [PATCH 48/64] Accept '.foo' and 'foo' as value for the ext option --- autoload/vimwiki/vars.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 77689f7..198acb4 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -263,8 +263,13 @@ function! s:validate_settings() \ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/') endif - let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path']) - let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path']) + let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path']) + let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path']) + + let ext = wiki_settings['ext'] + if !empty(ext) && ext[0] != '.' + let wiki_settings['ext'] = '.' . ext + endif endfor endfunction From 2366523001374ae92be97ccead296352a538fc27 Mon Sep 17 00:00:00 2001 From: sreejith994 Date: Fri, 21 Dec 2018 12:33:27 +0530 Subject: [PATCH 49/64] Fixed updation of links when renaming wiki files in subdirectories --- autoload/vimwiki/base.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index af60bf9..829df58 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -891,11 +891,11 @@ function! s:tail_name(fname) endfunction -function! s:update_wiki_links(wiki_nr, old_fname, new_fname) +function! s:update_wiki_links(wiki_nr, old_fname, new_fname,old_fname_relpath) let old_fname = a:old_fname let new_fname = a:new_fname - let subdirs = split(a:old_fname, '[/\\]')[: -2] + let subdirs = split(a:old_fname_relpath, '[/\\]')[: -2] " TODO: Use Dictionary here... let dirs_keys = [''] @@ -1351,7 +1351,7 @@ function! vimwiki#base#rename_link() setlocal nomore " update links - call s:update_wiki_links(wiki_nr, s:tail_name(old_fname), new_link) + call s:update_wiki_links(wiki_nr, s:tail_name(old_fname), s:tail_name(new_link),old_fname) " restore wiki buffers for bitem in blist From 599a0e9083a3d384b6707d45acd1b6d999c822d9 Mon Sep 17 00:00:00 2001 From: Raphael Feng Date: Thu, 19 Jul 2018 23:54:36 -0700 Subject: [PATCH 50/64] Update the links when renaming markdown wikis Two reasons whey the links in markdown wikis are not updated: 1. The markdown link pattern is wrong, should be []() rather than [][]; 2. The logic of getting wiki local var cannot get correct wiki index as: a. the renamed file's buffer is removed and %:p would return empty b. the function that gets the wiki local var depends on buffer's %:p value to find the wiki it belongs to and it would always return -1 and result in the default option values instead the user's option The fix is 1. fix the markdown link pattern regex; 2. keep the renamed file's buffer open during the period of updating the link --- autoload/vimwiki/base.vim | 22 +++++++++++++++++++--- autoload/vimwiki/vars.vim | 10 +++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 829df58..0f71a97 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1340,11 +1340,22 @@ function! vimwiki#base#rename_link() execute ':update' endfor + " activate the renamed buffer execute ':b '.escape(cur_buffer[0], ' ') - " remove wiki buffers + " rename the buffer name to the new name + " execute ':file '.new_link + + " leave the renamed buffer and remove the rest wiki buffers + " the reason we leave the renamed buffer is because the get_wikilocal + " function use the current file name to get the vars of current file's + " wiki, but after calling rename function, %:p still returns empty + " rather than the new full file path, so we just leave the renamed file's + " buffer so that %:p would be the renamed full file path for bitem in blist - execute 'bwipeout '.escape(bitem[0], ' ') + if !vimwiki#path#is_equal(bitem[0], cur_buffer[0]) + execute 'bwipeout '.escape(bitem[0], ' ') + endif endfor let setting_more = &more @@ -1353,6 +1364,12 @@ function! vimwiki#base#rename_link() " update links call s:update_wiki_links(wiki_nr, s:tail_name(old_fname), s:tail_name(new_link),old_fname) + " remove current buffer and reopen it after restoring all + " buffers to put it at the end of all buffers, vim does not + " support reorder the buffers so need to reopen it to put + " it at the end + execute 'bwipeout '.escape(cur_buffer[0], ' ') + " restore wiki buffers for bitem in blist if !vimwiki#path#is_equal(bitem[0], cur_buffer[0]) @@ -1361,7 +1378,6 @@ function! vimwiki#base#rename_link() endfor call s:open_wiki_buffer([new_fname, cur_buffer[1]]) - " execute 'bwipeout '.escape(cur_buffer[0], ' ') echomsg 'Vimwiki: '.old_fname.' is renamed to '.new_fname diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 198acb4..23de10a 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -477,8 +477,8 @@ function! s:populate_extra_markdown_vars() let mkd_syntax.rxWikiLink0MatchDescr = mkd_syntax.rxWikiLinkMatchDescr let wikilink_md_prefix = '[' - let wikilink_md_suffix = ']' - let wikilink_md_separator = '][' + let wikilink_md_separator = '](' + let wikilink_md_suffix = ')' let rx_wikilink_md_separator = vimwiki#u#escape(wikilink_md_separator) let mkd_syntax.rx_wikilink_md_prefix = vimwiki#u#escape(wikilink_md_prefix) let mkd_syntax.rx_wikilink_md_suffix = vimwiki#u#escape(wikilink_md_suffix) @@ -512,21 +512,21 @@ function! s:populate_extra_markdown_vars() let mkd_syntax.rx_wikilink_md_suffix = mkd_syntax.rx_wikilink_md_suffix. \ mkd_syntax.rxWikiLink1InvalidSuffix - " 1. match [URL][], [DESCRIPTION][URL] + " 1. match [URL][], [DESCRIPTION](URL) let mkd_syntax.rxWikiLink1 = mkd_syntax.rx_wikilink_md_prefix. \ mkd_syntax.rxWikiLink1Url. rx_wikilink_md_separator. \ mkd_syntax.rx_wikilink_md_suffix. \ '\|'. mkd_syntax.rx_wikilink_md_prefix. \ mkd_syntax.rxWikiLink1Descr . rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix - " 2. match URL within [URL][], [DESCRIPTION][URL] + " 2. match URL within [URL][], [DESCRIPTION](URL) let mkd_syntax.rxWikiLink1MatchUrl = mkd_syntax.rx_wikilink_md_prefix. \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. rx_wikilink_md_separator. \ mkd_syntax.rx_wikilink_md_suffix. \ '\|'. mkd_syntax.rx_wikilink_md_prefix. \ mkd_syntax.rxWikiLink1Descr. rx_wikilink_md_separator. \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. mkd_syntax.rx_wikilink_md_suffix - " 3. match DESCRIPTION within [DESCRIPTION][URL] + " 3. match DESCRIPTION within [DESCRIPTION](URL) let mkd_syntax.rxWikiLink1MatchDescr = mkd_syntax.rx_wikilink_md_prefix. \ '\zs'. mkd_syntax.rxWikiLink1Descr.'\ze'. rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix From 24f33e3e3f93fea2eac96e1896d2ab645c458a31 Mon Sep 17 00:00:00 2001 From: fte10kso Date: Thu, 27 Dec 2018 10:59:05 +0100 Subject: [PATCH 51/64] Clarify toggling of todo list items in visual mode --- doc/vimwiki.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index fcea9eb..2cbf87a 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1668,7 +1668,7 @@ checkbox without a childitem. It is possible to toggle several list items using visual mode. But note that instead of toggling every item individually, all items get checked if the -first item is unchecked and all items get unchecked if the first item is +first item was unchecked and all items get unchecked if the first item was checked. Use gl (see |vimwiki_gl|) to remove a single checkbox and From f9b890698599dd3aaf58b5ebe46bb4ebdb04ceb0 Mon Sep 17 00:00:00 2001 From: Kasper Socha Date: Thu, 3 Jan 2019 13:55:15 +0100 Subject: [PATCH 52/64] Fix section number for anchor, closes #597 --- doc/vimwiki.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 2cbf87a..b8dff84 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1754,7 +1754,7 @@ See |g:vimwiki_use_calendar| option to turn it off/on. ============================================================================== -12. Anchors *vimwiki-anchors* +11. Anchors *vimwiki-anchors* Every header, tag, and bold text can be used as an anchor. To jump to it, use a wikilink of the form > From 75819ca23a1244416aba3db2843f77cc55c06e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Thu, 13 Sep 2018 01:35:13 +0200 Subject: [PATCH 53/64] Allow to specify additional chars for lists See also #390 and #479 for earlier attempts --- autoload/vimwiki/html.vim | 6 +-- autoload/vimwiki/lst.vim | 31 +++++------ autoload/vimwiki/vars.vim | 111 +++++++++++++++++++++++--------------- ftplugin/vimwiki.vim | 2 +- syntax/vimwiki.vim | 10 ++-- 5 files changed, 92 insertions(+), 68 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 4d44510..396b6b1 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -886,8 +886,8 @@ function! s:process_tag_list(line, lists) let st_tag = '
  • ' let chk = matchlist(a:line, a:rx_list) if !empty(chk) && len(chk[1]) > 0 - let completion = index(vimwiki#vars#get_syntaxlocal('listsyms_list'), chk[1]) - let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) + let completion = index(vimwiki#vars#get_wikilocal('listsyms_list'), chk[1]) + let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) if completion == 0 let st_tag = '
  • ' elseif completion == -1 && chk[1] == vimwiki#vars#get_global('listsym_rejected') @@ -1476,7 +1476,7 @@ function! s:convert_file(path_html, wikifile) endif " prepare regexps for lists - let s:bullets = '[*-]' + let s:bullets = vimwiki#vars#get_wikilocal('rx_bullet_char') let s:numbers = '\C\%(#\|\d\+)\|\d\+\.\|[ivxlcdm]\+)\|[IVXLCDM]\+)\|\l\{1,2})\|\u\{1,2})\)' for line in lsource diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 201a658..58a0198 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -137,7 +137,7 @@ endfunction "Returns: the column where the text of a line starts (possible list item "markers and checkboxes are skipped) function! s:text_begin(lnum) - return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))) + return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem'))) endfunction @@ -145,9 +145,9 @@ endfunction " 1 for a marker and no text " 0 for no marker at all (empty line or only text) function! s:line_has_marker(lnum) - if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$' + if getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*$' return 1 - elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S' + elseif getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*\S' return 2 else return 0 @@ -172,7 +172,7 @@ function! s:get_item(lnum) return item endif - let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')) + let matches = matchlist(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem')) if matches == [] || \ (matches[1] == '' && matches[2] == '') || \ (matches[1] != '' && matches[2] != '') @@ -209,7 +209,7 @@ function! s:get_level(lnum) let level = indent(a:lnum) else let level = s:string_length(matchstr(getline(a:lnum), - \ vimwiki#vars#get_syntaxlocal(rx_bullet_chars)))-1 + \ vimwiki#vars#get_wikilocal(rx_bullet_chars)))-1 if level < 0 let level = (indent(a:lnum) == 0) ? 0 : 9999 endif @@ -744,8 +744,8 @@ function! s:get_rate(item) if state == vimwiki#vars#get_global('listsym_rejected') return -1 endif - let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) - return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 100/(n-1) + let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) + return index(vimwiki#vars#get_wikilocal('listsyms_list'), state) * 100/(n-1) endfunction @@ -820,7 +820,7 @@ endfunction "Returns: the appropriate symbol for a given percent rate function! s:rate_to_state(rate) - let listsyms_list = vimwiki#vars#get_syntaxlocal('listsyms_list') + let listsyms_list = vimwiki#vars#get_wikilocal('listsyms_list') let state = '' let n = len(listsyms_list) if a:rate == 100 @@ -997,7 +997,7 @@ function! vimwiki#lst#decrement_cb(from_line, to_line) "if from_line has CB, decrement it and set all siblings to the same new state let rate_first_line = s:get_rate(from_item) - let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) + let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) let new_rate = max([rate_first_line - 100/(n-1)-1, 0]) call s:change_cb(a:from_line, a:to_line, new_rate) @@ -1015,7 +1015,7 @@ function! vimwiki#lst#increment_cb(from_line, to_line) "if from_line has CB, increment it and set all siblings to the same new state let rate_first_line = s:get_rate(from_item) - let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) + let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) let new_rate = min([rate_first_line + 100/(n-1)+1, 100]) call s:change_cb(a:from_line, a:to_line, new_rate) @@ -1034,6 +1034,7 @@ endfunction "in the lines of the given range function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1) + endfunction @@ -1101,7 +1102,7 @@ endfunction function! s:decrease_level(item) let removed_indent = 0 if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 && - \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), \ s:first_char(a:item.mrkr)) > -1 if s:string_length(a:item.mrkr) >= 2 call s:substitute_string_in_line(a:item.lnum, s:first_char(a:item.mrkr), '') @@ -1124,7 +1125,7 @@ endfunction function! s:increase_level(item) let additional_indent = 0 if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 && - \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), \ s:first_char(a:item.mrkr)) > -1 call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr . \ s:first_char(a:item.mrkr)) @@ -1148,7 +1149,7 @@ endfunction function! s:indent_line_by(lnum, indent_by) let item = s:get_item(a:lnum) if vimwiki#vars#get_syntaxlocal('recurring_bullets') && item.type == 1 && - \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), \ s:first_char(item.mrkr)) > -1 if a:indent_by > 0 call s:substitute_string_in_line(a:lnum, item.mrkr, item.mrkr . s:first_char(item.mrkr)) @@ -1323,7 +1324,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) endif "handle markers like *** - if index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1 + if index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1 "use *** if the item above has *** too let item_above = s:get_prev_list_item(cur_item, 1) if item_above.type == 1 && s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr) @@ -1394,7 +1395,7 @@ function! s:adjust_mrkr(item) "if possible, set e.g. *** if parent has ** as marker if neighbor_item.type == 0 && a:item.type == 1 && - \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), \ s:first_char(a:item.mrkr)) > -1 let parent_item = s:get_parent(a:item) if parent_item.type == 1 && s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 23de10a..5a49943 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -204,6 +204,7 @@ function! s:populate_wikilocal_options() \ 'template_default': 'default', \ 'template_ext': '.tpl', \ 'template_path': $HOME . '/vimwiki/templates/', + \ 'bullet_types': [], \ } let g:vimwiki_wikilocal_vars = [] @@ -246,6 +247,13 @@ function! s:populate_wikilocal_options() let temporary_wiki_settings = deepcopy(default_wiki_settings) let temporary_wiki_settings.is_temporary_wiki = 1 call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings) + " Set up variables for the lists, depending on config and syntax + for wiki in g:vimwiki_wikilocal_vars + if len(wiki.bullet_types) == 0 + let wiki.bullet_types = vimwiki#vars#get_syntaxlocal('bullet_types', wiki.syntax) + endif + call vimwiki#vars#populate_list_vars(wiki) + endfor call s:validate_settings() endfunction @@ -343,20 +351,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax) let g:vimwiki_syntax_variables[a:syntax].rxMathEnd = \ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$' - " list stuff - let g:vimwiki_syntax_variables[a:syntax].rx_bullet_chars = - \ '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+' - - let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars = - \ g:vimwiki_syntax_variables[a:syntax].recurring_bullets - \ ? g:vimwiki_syntax_variables[a:syntax].bullet_types : [] - - let g:vimwiki_syntax_variables[a:syntax].number_kinds = [] - let g:vimwiki_syntax_variables[a:syntax].number_divisors = '' - for i in g:vimwiki_syntax_variables[a:syntax].number_types - call add(g:vimwiki_syntax_variables[a:syntax].number_kinds, i[0]) - let g:vimwiki_syntax_variables[a:syntax].number_divisors .= vimwiki#u#escape(i[1]) - endfor let char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+', \ 'a': '\l\{1,2}', 'A': '\u\{1,2}'} @@ -388,36 +382,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax) let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '$^' endif - "the user can set the listsyms as string, but vimwiki needs a list - let g:vimwiki_syntax_variables[a:syntax].listsyms_list = - \ split(vimwiki#vars#get_global('listsyms'), '\zs') - if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1 - echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected (''' - \ . vimwiki#vars#get_global('listsym_rejected') - \ . ''') must not be a part of g:vimwiki_listsyms (''' . - \ . vimwiki#vars#get_global('listsyms') . ''')' - endif - let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB = - \ '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\(' - \ .g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s' - let g:vimwiki_syntax_variables[a:syntax].rxListItem = - \ g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB - \ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms') - \ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?' - if g:vimwiki_syntax_variables[a:syntax].recurring_bullets - let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = - \ '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\[[' - \ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1] - \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\%(' - \ .g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*' - else - let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = - \ '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|' - \ . g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\[[' - \ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1] - \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' - endif - " 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L)) " let g:vimwiki_rxWeblink = '[\["(|]\@ Date: Thu, 13 Sep 2018 02:16:39 +0200 Subject: [PATCH 54/64] Allow list symbols to be configured per wiki --- autoload/vimwiki/vars.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 5a49943..ce12302 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -205,6 +205,8 @@ function! s:populate_wikilocal_options() \ 'template_ext': '.tpl', \ 'template_path': $HOME . '/vimwiki/templates/', \ 'bullet_types': [], + \ 'listsyms': vimwiki#vars#get_global("listsyms"), + \ 'listsym_rejected': vimwiki#vars#get_global("listsym_rejected"), \ } let g:vimwiki_wikilocal_vars = [] @@ -456,14 +458,12 @@ function! vimwiki#vars#populate_list_vars(wiki) endif "the user can set the listsyms as string, but vimwiki needs a list - " TODO make a true wikilocal and use global only as fallback for compatibility - let a:wiki.listsyms_list = - \ split(vimwiki#vars#get_global('listsyms'), '\zs') - if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1 - echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected (''' - \ . vimwiki#vars#get_global('listsym_rejected') - \ . ''') must not be a part of g:vimwiki_listsyms (''' . - \ . vimwiki#vars#get_global('listsyms') . ''')' + let a:wiki.listsyms_list = split(a:wiki.listsyms, '\zs') + + if match(a:wiki.listsyms, a:wiki.listsym_rejected) != -1 + echomsg 'Vimwiki Warning: the value of listsym_rejected (''' + \ . a:wiki.listsym_rejected . ''') must not be a part of listsyms (''' + \ . a:wiki.listsyms . ''')' endif let a:wiki.rxListItemWithoutCB = @@ -471,20 +471,20 @@ function! vimwiki#vars#populate_list_vars(wiki) \ .rxListNumber.'\)\)\s' let a:wiki.rxListItem = \ a:wiki.rxListItemWithoutCB - \ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms') - \ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?' + \ . '\+\%(\[\(['.a:wiki.listsyms + \ . a:wiki.listsym_rejected.']\)\]\s\)\?' if recurring_bullets let a:wiki.rxListItemAndChildren = \ '^\('.rxListBullet.'\)\s\+\[[' \ . a:wiki.listsyms_list[-1] - \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\%(' + \ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\%(' \ .rxListBullet.'\).*\|^$\|\s.*\)\)*' else let a:wiki.rxListItemAndChildren = \ '^\(\s*\)\%('.rxListBullet.'\|' \ . rxListNumber.'\)\s\+\[[' \ . a:wiki.listsyms_list[-1] - \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' + \ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' endif endfunction From 7ea136dd0bd14d79164d68eaccd3ade33e8376c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Thu, 13 Sep 2018 14:17:32 +0200 Subject: [PATCH 55/64] Update documentation --- doc/vimwiki.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index b8dff84..8129755 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1656,7 +1656,7 @@ parent items: > Parent items should change when their child items change. If not, use |vimwiki_glr|. The symbol between [ ] depends on the percentage of toggled -child items (see also |g:vimwiki_listsyms|): > +child items (see also |vimwiki-listsyms|): > [ ] -- 0% [.] -- 1-33% [o] -- 34-66% @@ -2284,6 +2284,53 @@ Note: if you use MediaWiki syntax, you probably would like to set this option to 0, because every indented line is considered verbatim text. +*vimwiki-bullet_types* +------------------------------------------------------------------------------ +Key Default value~ +bullet_types ['-', '*', '#'] (default-syntax) + ['-', '*', '+'] (markdown-syntax) + ['*', '#'] (mediawiki-syntax) + +List of the characters that can be used as bullets of lists. The default value +depends on the chosen syntax. + +You can set it to include more fancy symbols like this: +> + let g:vimwiki_list = [{'path': '~/path/', 'bullet_types' = ['-', '•', '→']}] + + +*vimwiki-listsyms* +------------------------------------------------------------------------------ +Key Default value~ +listsyms ' .oOX' + +String of at least two symbols to show the progression of todo list items. +Default value is ' .oOX'. This overwrites the global |g:vimwiki_listsyms| on a +per wiki base. + +The first char is for 0% done items. +The last is for 100% done items. + +You can set it to some more fancy symbols like this: +> + let g:vimwiki_list = [{'path': '~/path/', 'listsyms' = '✗○◐●✓'}] + + +*vimwiki-listsym_rejected* +------------------------------------------------------------------------------ + +Character that is used to show that an item of a todo list will not be done. +Default value is '-'. This overwrites the global |g:vimwiki_listsym_rejected| on a +per wiki base. + + +The character used here must not be part of |vimwiki-listsyms|. + +You can set it to a more fancy symbol like this: +> + let g:vimwiki_list = [{'path': '~/path/', 'listsym_rejected' = '✗'}] + + *vimwiki-option-auto_tags* ------------------------------------------------------------------------------ Key Default value Values~ @@ -2409,7 +2456,8 @@ Default: 'Vimwiki' *g:vimwiki_listsyms* String of at least two symbols to show the progression of todo list items. -Default value is ' .oOX'. +Default value is ' .oOX'. You can also set this on a per-wiki level with +|vimwiki-listsyms|. The first char is for 0% done items. The last is for 100% done items. @@ -2423,7 +2471,9 @@ You can set it to some more fancy symbols like this: *g:vimwiki_listsym_rejected* Character that is used to show that an item of a todo list will not be done. -Default value is '-'. +Default value is '-'. You can also set this on a per-wiki level with +|vimwiki-listsym_rejected|. + The character used here must not be part of |g:vimwiki_listsyms|. @@ -2991,6 +3041,9 @@ New:~ * glx on a list item marks a checkbox as won't do, see |vimwiki_glx|. * Add the option |g:vimwiki_listsym_rejected| to set the character used for won't-do list items. + * The effect of |g:vimwiki_listsyms| and |g:vimwiki_listsym_rejected| can + be set on a per wiki level, see |vimwiki-listsyms| and + |vimwili-listsym_rejected| * gln and glp change the "done" status of a checkbox, see |vimwiki_gln|. * |:VimwikiSplitLink| and |:VimwikiVSplitLink| can now reuse an existing split window and not move the cursor. From 2346b7e29912022b57a33f43a4f3d14ca61a99ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Fri, 4 Jan 2019 01:19:26 +0100 Subject: [PATCH 56/64] Fix bug --- autoload/vimwiki/lst.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 58a0198..448d723 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -784,7 +784,7 @@ function! s:set_state_plus_children(item, new_rate, ...) if child_item.cb != vimwiki#vars#get_global('listsym_rejected') let all_children_are_rejected = 0 endif - if child_item.cb != vimwiki#vars#get_syntaxlocal('listsyms_list')[-1] + if child_item.cb != vimwiki#vars#get_wikilocal('listsyms_list')[-1] let all_children_are_done = 0 endif if !all_children_are_done && !all_children_are_rejected From 65b0c97c6de5921e05beb3d0ddf75c6b41b7e702 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Wed, 16 Jan 2019 20:56:49 +0100 Subject: [PATCH 57/64] Revert "Update the links when renaming markdown wikis" This reverts commit 599a0e9083a3d384b6707d45acd1b6d999c822d9. Sorry, we can't simply change the syntax of something as basic as a link, even if the old syntax is wrong. We need to keep Vimwiki reasonably backwards compatible. --- autoload/vimwiki/base.vim | 22 +++------------------- autoload/vimwiki/vars.vim | 10 +++++----- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 0f71a97..829df58 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1340,22 +1340,11 @@ function! vimwiki#base#rename_link() execute ':update' endfor - " activate the renamed buffer execute ':b '.escape(cur_buffer[0], ' ') - " rename the buffer name to the new name - " execute ':file '.new_link - - " leave the renamed buffer and remove the rest wiki buffers - " the reason we leave the renamed buffer is because the get_wikilocal - " function use the current file name to get the vars of current file's - " wiki, but after calling rename function, %:p still returns empty - " rather than the new full file path, so we just leave the renamed file's - " buffer so that %:p would be the renamed full file path + " remove wiki buffers for bitem in blist - if !vimwiki#path#is_equal(bitem[0], cur_buffer[0]) - execute 'bwipeout '.escape(bitem[0], ' ') - endif + execute 'bwipeout '.escape(bitem[0], ' ') endfor let setting_more = &more @@ -1364,12 +1353,6 @@ function! vimwiki#base#rename_link() " update links call s:update_wiki_links(wiki_nr, s:tail_name(old_fname), s:tail_name(new_link),old_fname) - " remove current buffer and reopen it after restoring all - " buffers to put it at the end of all buffers, vim does not - " support reorder the buffers so need to reopen it to put - " it at the end - execute 'bwipeout '.escape(cur_buffer[0], ' ') - " restore wiki buffers for bitem in blist if !vimwiki#path#is_equal(bitem[0], cur_buffer[0]) @@ -1378,6 +1361,7 @@ function! vimwiki#base#rename_link() endfor call s:open_wiki_buffer([new_fname, cur_buffer[1]]) + " execute 'bwipeout '.escape(cur_buffer[0], ' ') echomsg 'Vimwiki: '.old_fname.' is renamed to '.new_fname diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index ce12302..b4cc433 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -500,8 +500,8 @@ function! s:populate_extra_markdown_vars() let mkd_syntax.rxWikiLink0MatchDescr = mkd_syntax.rxWikiLinkMatchDescr let wikilink_md_prefix = '[' - let wikilink_md_separator = '](' - let wikilink_md_suffix = ')' + let wikilink_md_suffix = ']' + let wikilink_md_separator = '][' let rx_wikilink_md_separator = vimwiki#u#escape(wikilink_md_separator) let mkd_syntax.rx_wikilink_md_prefix = vimwiki#u#escape(wikilink_md_prefix) let mkd_syntax.rx_wikilink_md_suffix = vimwiki#u#escape(wikilink_md_suffix) @@ -535,21 +535,21 @@ function! s:populate_extra_markdown_vars() let mkd_syntax.rx_wikilink_md_suffix = mkd_syntax.rx_wikilink_md_suffix. \ mkd_syntax.rxWikiLink1InvalidSuffix - " 1. match [URL][], [DESCRIPTION](URL) + " 1. match [URL][], [DESCRIPTION][URL] let mkd_syntax.rxWikiLink1 = mkd_syntax.rx_wikilink_md_prefix. \ mkd_syntax.rxWikiLink1Url. rx_wikilink_md_separator. \ mkd_syntax.rx_wikilink_md_suffix. \ '\|'. mkd_syntax.rx_wikilink_md_prefix. \ mkd_syntax.rxWikiLink1Descr . rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix - " 2. match URL within [URL][], [DESCRIPTION](URL) + " 2. match URL within [URL][], [DESCRIPTION][URL] let mkd_syntax.rxWikiLink1MatchUrl = mkd_syntax.rx_wikilink_md_prefix. \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. rx_wikilink_md_separator. \ mkd_syntax.rx_wikilink_md_suffix. \ '\|'. mkd_syntax.rx_wikilink_md_prefix. \ mkd_syntax.rxWikiLink1Descr. rx_wikilink_md_separator. \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. mkd_syntax.rx_wikilink_md_suffix - " 3. match DESCRIPTION within [DESCRIPTION](URL) + " 3. match DESCRIPTION within [DESCRIPTION][URL] let mkd_syntax.rxWikiLink1MatchDescr = mkd_syntax.rx_wikilink_md_prefix. \ '\zs'. mkd_syntax.rxWikiLink1Descr.'\ze'. rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix From 54e064f5c4c3dd539bfb27a2058954fef95e8699 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 Jan 2019 21:57:28 +0100 Subject: [PATCH 58/64] Revert "Fix bug" This reverts commit 2346b7e29912022b57a33f43a4f3d14ca61a99ee. --- autoload/vimwiki/lst.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 448d723..58a0198 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -784,7 +784,7 @@ function! s:set_state_plus_children(item, new_rate, ...) if child_item.cb != vimwiki#vars#get_global('listsym_rejected') let all_children_are_rejected = 0 endif - if child_item.cb != vimwiki#vars#get_wikilocal('listsyms_list')[-1] + if child_item.cb != vimwiki#vars#get_syntaxlocal('listsyms_list')[-1] let all_children_are_done = 0 endif if !all_children_are_done && !all_children_are_rejected From 05de247f365883952703c6ab14f21ebb29a3a0bf Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 Jan 2019 21:57:39 +0100 Subject: [PATCH 59/64] Revert "Update documentation" This reverts commit 7ea136dd0bd14d79164d68eaccd3ade33e8376c7. --- doc/vimwiki.txt | 59 +++---------------------------------------------- 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 8129755..b8dff84 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1656,7 +1656,7 @@ parent items: > Parent items should change when their child items change. If not, use |vimwiki_glr|. The symbol between [ ] depends on the percentage of toggled -child items (see also |vimwiki-listsyms|): > +child items (see also |g:vimwiki_listsyms|): > [ ] -- 0% [.] -- 1-33% [o] -- 34-66% @@ -2284,53 +2284,6 @@ Note: if you use MediaWiki syntax, you probably would like to set this option to 0, because every indented line is considered verbatim text. -*vimwiki-bullet_types* ------------------------------------------------------------------------------- -Key Default value~ -bullet_types ['-', '*', '#'] (default-syntax) - ['-', '*', '+'] (markdown-syntax) - ['*', '#'] (mediawiki-syntax) - -List of the characters that can be used as bullets of lists. The default value -depends on the chosen syntax. - -You can set it to include more fancy symbols like this: -> - let g:vimwiki_list = [{'path': '~/path/', 'bullet_types' = ['-', '•', '→']}] - - -*vimwiki-listsyms* ------------------------------------------------------------------------------- -Key Default value~ -listsyms ' .oOX' - -String of at least two symbols to show the progression of todo list items. -Default value is ' .oOX'. This overwrites the global |g:vimwiki_listsyms| on a -per wiki base. - -The first char is for 0% done items. -The last is for 100% done items. - -You can set it to some more fancy symbols like this: -> - let g:vimwiki_list = [{'path': '~/path/', 'listsyms' = '✗○◐●✓'}] - - -*vimwiki-listsym_rejected* ------------------------------------------------------------------------------- - -Character that is used to show that an item of a todo list will not be done. -Default value is '-'. This overwrites the global |g:vimwiki_listsym_rejected| on a -per wiki base. - - -The character used here must not be part of |vimwiki-listsyms|. - -You can set it to a more fancy symbol like this: -> - let g:vimwiki_list = [{'path': '~/path/', 'listsym_rejected' = '✗'}] - - *vimwiki-option-auto_tags* ------------------------------------------------------------------------------ Key Default value Values~ @@ -2456,8 +2409,7 @@ Default: 'Vimwiki' *g:vimwiki_listsyms* String of at least two symbols to show the progression of todo list items. -Default value is ' .oOX'. You can also set this on a per-wiki level with -|vimwiki-listsyms|. +Default value is ' .oOX'. The first char is for 0% done items. The last is for 100% done items. @@ -2471,9 +2423,7 @@ You can set it to some more fancy symbols like this: *g:vimwiki_listsym_rejected* Character that is used to show that an item of a todo list will not be done. -Default value is '-'. You can also set this on a per-wiki level with -|vimwiki-listsym_rejected|. - +Default value is '-'. The character used here must not be part of |g:vimwiki_listsyms|. @@ -3041,9 +2991,6 @@ New:~ * glx on a list item marks a checkbox as won't do, see |vimwiki_glx|. * Add the option |g:vimwiki_listsym_rejected| to set the character used for won't-do list items. - * The effect of |g:vimwiki_listsyms| and |g:vimwiki_listsym_rejected| can - be set on a per wiki level, see |vimwiki-listsyms| and - |vimwili-listsym_rejected| * gln and glp change the "done" status of a checkbox, see |vimwiki_gln|. * |:VimwikiSplitLink| and |:VimwikiVSplitLink| can now reuse an existing split window and not move the cursor. From 35d1f23b921d0657c1792fbed3c8a2ca2dac3e9a Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 Jan 2019 21:57:40 +0100 Subject: [PATCH 60/64] Revert "Allow list symbols to be configured per wiki" This reverts commit 79c295a92fad820719b6554a63f030f97e0adb9d. --- autoload/vimwiki/vars.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index b4cc433..40d7441 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -205,8 +205,6 @@ function! s:populate_wikilocal_options() \ 'template_ext': '.tpl', \ 'template_path': $HOME . '/vimwiki/templates/', \ 'bullet_types': [], - \ 'listsyms': vimwiki#vars#get_global("listsyms"), - \ 'listsym_rejected': vimwiki#vars#get_global("listsym_rejected"), \ } let g:vimwiki_wikilocal_vars = [] @@ -458,12 +456,14 @@ function! vimwiki#vars#populate_list_vars(wiki) endif "the user can set the listsyms as string, but vimwiki needs a list - let a:wiki.listsyms_list = split(a:wiki.listsyms, '\zs') - - if match(a:wiki.listsyms, a:wiki.listsym_rejected) != -1 - echomsg 'Vimwiki Warning: the value of listsym_rejected (''' - \ . a:wiki.listsym_rejected . ''') must not be a part of listsyms (''' - \ . a:wiki.listsyms . ''')' + " TODO make a true wikilocal and use global only as fallback for compatibility + let a:wiki.listsyms_list = + \ split(vimwiki#vars#get_global('listsyms'), '\zs') + if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1 + echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected (''' + \ . vimwiki#vars#get_global('listsym_rejected') + \ . ''') must not be a part of g:vimwiki_listsyms (''' . + \ . vimwiki#vars#get_global('listsyms') . ''')' endif let a:wiki.rxListItemWithoutCB = @@ -471,20 +471,20 @@ function! vimwiki#vars#populate_list_vars(wiki) \ .rxListNumber.'\)\)\s' let a:wiki.rxListItem = \ a:wiki.rxListItemWithoutCB - \ . '\+\%(\[\(['.a:wiki.listsyms - \ . a:wiki.listsym_rejected.']\)\]\s\)\?' + \ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms') + \ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?' if recurring_bullets let a:wiki.rxListItemAndChildren = \ '^\('.rxListBullet.'\)\s\+\[[' \ . a:wiki.listsyms_list[-1] - \ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\%(' + \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\%(' \ .rxListBullet.'\).*\|^$\|\s.*\)\)*' else let a:wiki.rxListItemAndChildren = \ '^\(\s*\)\%('.rxListBullet.'\|' \ . rxListNumber.'\)\s\+\[[' \ . a:wiki.listsyms_list[-1] - \ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' + \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' endif endfunction From 6257c8fa54e634b5dda12a09ae6b43524166e8e8 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 17 Jan 2019 21:57:42 +0100 Subject: [PATCH 61/64] Revert "Allow to specify additional chars for lists" This reverts commit 75819ca23a1244416aba3db2843f77cc55c06e16. --- autoload/vimwiki/html.vim | 6 +-- autoload/vimwiki/lst.vim | 31 ++++++----- autoload/vimwiki/vars.vim | 111 +++++++++++++++----------------------- ftplugin/vimwiki.vim | 2 +- syntax/vimwiki.vim | 10 ++-- 5 files changed, 68 insertions(+), 92 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 396b6b1..4d44510 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -886,8 +886,8 @@ function! s:process_tag_list(line, lists) let st_tag = '
  • ' let chk = matchlist(a:line, a:rx_list) if !empty(chk) && len(chk[1]) > 0 - let completion = index(vimwiki#vars#get_wikilocal('listsyms_list'), chk[1]) - let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) + let completion = index(vimwiki#vars#get_syntaxlocal('listsyms_list'), chk[1]) + let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) if completion == 0 let st_tag = '
  • ' elseif completion == -1 && chk[1] == vimwiki#vars#get_global('listsym_rejected') @@ -1476,7 +1476,7 @@ function! s:convert_file(path_html, wikifile) endif " prepare regexps for lists - let s:bullets = vimwiki#vars#get_wikilocal('rx_bullet_char') + let s:bullets = '[*-]' let s:numbers = '\C\%(#\|\d\+)\|\d\+\.\|[ivxlcdm]\+)\|[IVXLCDM]\+)\|\l\{1,2})\|\u\{1,2})\)' for line in lsource diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 58a0198..201a658 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -137,7 +137,7 @@ endfunction "Returns: the column where the text of a line starts (possible list item "markers and checkboxes are skipped) function! s:text_begin(lnum) - return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem'))) + return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))) endfunction @@ -145,9 +145,9 @@ endfunction " 1 for a marker and no text " 0 for no marker at all (empty line or only text) function! s:line_has_marker(lnum) - if getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*$' + if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$' return 1 - elseif getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*\S' + elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S' return 2 else return 0 @@ -172,7 +172,7 @@ function! s:get_item(lnum) return item endif - let matches = matchlist(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem')) + let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')) if matches == [] || \ (matches[1] == '' && matches[2] == '') || \ (matches[1] != '' && matches[2] != '') @@ -209,7 +209,7 @@ function! s:get_level(lnum) let level = indent(a:lnum) else let level = s:string_length(matchstr(getline(a:lnum), - \ vimwiki#vars#get_wikilocal(rx_bullet_chars)))-1 + \ vimwiki#vars#get_syntaxlocal(rx_bullet_chars)))-1 if level < 0 let level = (indent(a:lnum) == 0) ? 0 : 9999 endif @@ -744,8 +744,8 @@ function! s:get_rate(item) if state == vimwiki#vars#get_global('listsym_rejected') return -1 endif - let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) - return index(vimwiki#vars#get_wikilocal('listsyms_list'), state) * 100/(n-1) + let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) + return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 100/(n-1) endfunction @@ -820,7 +820,7 @@ endfunction "Returns: the appropriate symbol for a given percent rate function! s:rate_to_state(rate) - let listsyms_list = vimwiki#vars#get_wikilocal('listsyms_list') + let listsyms_list = vimwiki#vars#get_syntaxlocal('listsyms_list') let state = '' let n = len(listsyms_list) if a:rate == 100 @@ -997,7 +997,7 @@ function! vimwiki#lst#decrement_cb(from_line, to_line) "if from_line has CB, decrement it and set all siblings to the same new state let rate_first_line = s:get_rate(from_item) - let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) + let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) let new_rate = max([rate_first_line - 100/(n-1)-1, 0]) call s:change_cb(a:from_line, a:to_line, new_rate) @@ -1015,7 +1015,7 @@ function! vimwiki#lst#increment_cb(from_line, to_line) "if from_line has CB, increment it and set all siblings to the same new state let rate_first_line = s:get_rate(from_item) - let n = len(vimwiki#vars#get_wikilocal('listsyms_list')) + let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list')) let new_rate = min([rate_first_line + 100/(n-1)+1, 100]) call s:change_cb(a:from_line, a:to_line, new_rate) @@ -1034,7 +1034,6 @@ endfunction "in the lines of the given range function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1) - endfunction @@ -1102,7 +1101,7 @@ endfunction function! s:decrease_level(item) let removed_indent = 0 if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 && - \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), \ s:first_char(a:item.mrkr)) > -1 if s:string_length(a:item.mrkr) >= 2 call s:substitute_string_in_line(a:item.lnum, s:first_char(a:item.mrkr), '') @@ -1125,7 +1124,7 @@ endfunction function! s:increase_level(item) let additional_indent = 0 if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 && - \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), \ s:first_char(a:item.mrkr)) > -1 call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr . \ s:first_char(a:item.mrkr)) @@ -1149,7 +1148,7 @@ endfunction function! s:indent_line_by(lnum, indent_by) let item = s:get_item(a:lnum) if vimwiki#vars#get_syntaxlocal('recurring_bullets') && item.type == 1 && - \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), \ s:first_char(item.mrkr)) > -1 if a:indent_by > 0 call s:substitute_string_in_line(a:lnum, item.mrkr, item.mrkr . s:first_char(item.mrkr)) @@ -1324,7 +1323,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) endif "handle markers like *** - if index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1 + if index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1 "use *** if the item above has *** too let item_above = s:get_prev_list_item(cur_item, 1) if item_above.type == 1 && s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr) @@ -1395,7 +1394,7 @@ function! s:adjust_mrkr(item) "if possible, set e.g. *** if parent has ** as marker if neighbor_item.type == 0 && a:item.type == 1 && - \ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), + \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), \ s:first_char(a:item.mrkr)) > -1 let parent_item = s:get_parent(a:item) if parent_item.type == 1 && s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 40d7441..198acb4 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -204,7 +204,6 @@ function! s:populate_wikilocal_options() \ 'template_default': 'default', \ 'template_ext': '.tpl', \ 'template_path': $HOME . '/vimwiki/templates/', - \ 'bullet_types': [], \ } let g:vimwiki_wikilocal_vars = [] @@ -247,13 +246,6 @@ function! s:populate_wikilocal_options() let temporary_wiki_settings = deepcopy(default_wiki_settings) let temporary_wiki_settings.is_temporary_wiki = 1 call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings) - " Set up variables for the lists, depending on config and syntax - for wiki in g:vimwiki_wikilocal_vars - if len(wiki.bullet_types) == 0 - let wiki.bullet_types = vimwiki#vars#get_syntaxlocal('bullet_types', wiki.syntax) - endif - call vimwiki#vars#populate_list_vars(wiki) - endfor call s:validate_settings() endfunction @@ -351,6 +343,20 @@ function! vimwiki#vars#populate_syntax_vars(syntax) let g:vimwiki_syntax_variables[a:syntax].rxMathEnd = \ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$' + " list stuff + let g:vimwiki_syntax_variables[a:syntax].rx_bullet_chars = + \ '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+' + + let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars = + \ g:vimwiki_syntax_variables[a:syntax].recurring_bullets + \ ? g:vimwiki_syntax_variables[a:syntax].bullet_types : [] + + let g:vimwiki_syntax_variables[a:syntax].number_kinds = [] + let g:vimwiki_syntax_variables[a:syntax].number_divisors = '' + for i in g:vimwiki_syntax_variables[a:syntax].number_types + call add(g:vimwiki_syntax_variables[a:syntax].number_kinds, i[0]) + let g:vimwiki_syntax_variables[a:syntax].number_divisors .= vimwiki#u#escape(i[1]) + endfor let char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+', \ 'a': '\l\{1,2}', 'A': '\u\{1,2}'} @@ -382,6 +388,36 @@ function! vimwiki#vars#populate_syntax_vars(syntax) let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '$^' endif + "the user can set the listsyms as string, but vimwiki needs a list + let g:vimwiki_syntax_variables[a:syntax].listsyms_list = + \ split(vimwiki#vars#get_global('listsyms'), '\zs') + if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1 + echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected (''' + \ . vimwiki#vars#get_global('listsym_rejected') + \ . ''') must not be a part of g:vimwiki_listsyms (''' . + \ . vimwiki#vars#get_global('listsyms') . ''')' + endif + let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB = + \ '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\(' + \ .g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s' + let g:vimwiki_syntax_variables[a:syntax].rxListItem = + \ g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB + \ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms') + \ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?' + if g:vimwiki_syntax_variables[a:syntax].recurring_bullets + let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = + \ '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\[[' + \ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1] + \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\%(' + \ .g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*' + else + let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = + \ '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|' + \ . g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\[[' + \ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1] + \ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' + endif + " 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L)) " let g:vimwiki_rxWeblink = '[\["(|]\@ Date: Sat, 19 Jan 2019 21:05:27 +0100 Subject: [PATCH 62/64] Check all user settings for correct type, range etc. --- autoload/vimwiki/vars.vim | 281 ++++++++++++++++++++++++++++---------- plugin/vimwiki.vim | 4 +- 2 files changed, 209 insertions(+), 76 deletions(-) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 198acb4..81a1720 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -13,7 +13,7 @@ " global user variables and syntax stuff which is the same for every syntax. " " - wiki-local variables. They are stored in g:vimwiki_wikilocal_vars which is a list of -" dictionaries. One dict for every registered wiki. The last dictionary contains default values +" dictionaries, one dict for every registered wiki. The last dictionary contains default values " (used for temporary wikis). " " - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and @@ -28,50 +28,10 @@ function! s:populate_global_variables() - let g:vimwiki_global_vars = { - \ 'CJK_length': 0, - \ 'auto_chdir': 0, - \ 'autowriteall': 1, - \ 'conceallevel': 2, - \ 'diary_months': - \ { - \ 1: 'January', 2: 'February', 3: 'March', - \ 4: 'April', 5: 'May', 6: 'June', - \ 7: 'July', 8: 'August', 9: 'September', - \ 10: 'October', 11: 'November', 12: 'December' - \ }, - \ 'dir_link': '', - \ 'ext2syntax': {}, - \ 'folding': '', - \ 'global_ext': 1, - \ 'hl_cb_checked': 0, - \ 'hl_headers': 0, - \ 'html_header_numbering': 0, - \ 'html_header_numbering_sym': '', - \ 'list_ignore_newline': 1, - \ 'text_ignore_newline': 1, - \ 'listsyms': ' .oOX', - \ 'listsym_rejected': '-', - \ 'map_prefix': 'w', - \ 'menu': 'Vimwiki', - \ 'table_auto_fmt': 1, - \ 'table_mappings': 1, - \ 'toc_header': 'Contents', - \ 'url_maxsave': 15, - \ 'use_calendar': 1, - \ 'use_mouse': 0, - \ 'user_htmls': '', - \ 'valid_html_tags': 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em', - \ 'w32_dir_enc': '', - \ } + let g:vimwiki_global_vars = {} - " copy the user's settings from variables of the form g:vimwiki_