From 777569f95fba78408d2ee0cdddcd39e08b51d351 Mon Sep 17 00:00:00 2001
From: mMontu
Date: Tue, 12 Jul 2016 11:41:44 -0300
Subject: [PATCH 001/108] Workaround for slow folding methods (issue #225)
---
doc/vimwiki.txt | 2 ++
plugin/vimwiki.vim | 14 +++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
index 9cc5dd9..7192574 100644
--- a/doc/vimwiki.txt
+++ b/doc/vimwiki.txt
@@ -2288,6 +2288,8 @@ Limitations:
- 'list' is intended to work with lists nicely indented with 'shiftwidth'.
- 'syntax' is only available for the default syntax so far.
+The options above can be suffixed with ':quick' (e.g.: 'expr:quick') in order
+to use some workarounds to make folds work faster.
------------------------------------------------------------------------------
*g:vimwiki_list_ignore_newline*
diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
index d7abb6c..90fb166 100644
--- a/plugin/vimwiki.vim
+++ b/plugin/vimwiki.vim
@@ -156,15 +156,15 @@ function! s:setup_buffer_enter() "{{{
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
" new tab with the same buffer folding is reset to vim defaults. So we
" insist vimwiki folding here.
- if g:vimwiki_folding ==? 'expr'
+ if g:vimwiki_folding =~? '^expr.*'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
- elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
+ elseif g:vimwiki_folding =~? '^list.*' || g:vimwiki_folding ==? '^lists.*'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
- elseif g:vimwiki_folding ==? 'syntax'
+ elseif g:vimwiki_folding =~? '^syntax.*'
setlocal fdm=syntax
setlocal foldtext=VimwikiFoldText()
else
@@ -446,6 +446,14 @@ augroup vimwiki
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
+ if g:vimwiki_folding =~? ':quick$'
+ " from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
+ " Don't screw up folds when inserting text that might affect them, until
+ " leaving insert mode. Foldmethod is local to the window. Protect against
+ " screwing up folding when switching between windows.
+ exe 'autocmd InsertEnter *'.s:ext.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif'
+ exe 'autocmd InsertLeave,WinLeave *'.s:ext.' if exists("w:last_fdm") | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
+ endif
endfor
augroup END
"}}}
From 6b34e954e8fd669e302e7ad5d679b8448dc128f1 Mon Sep 17 00:00:00 2001
From: EinfachToll
Date: Wed, 21 Dec 2016 17:09:25 +0100
Subject: [PATCH 002/108] Add new functions for variable access
Ref #256
---
autoload/vimwiki/vars.vim | 203 ++++++++++++++++++++++++++++++++++++++
1 file changed, 203 insertions(+)
create mode 100644 autoload/vimwiki/vars.vim
diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
new file mode 100644
index 0000000..f7ccdb8
--- /dev/null
+++ b/autoload/vimwiki/vars.vim
@@ -0,0 +1,203 @@
+" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
+" Vimwiki autoload plugin file
+" Desc: stuff concerning Vimwiki's state
+" Home: https://github.com/vimwiki/vimwiki/
+
+
+" copy the user's settings from variables of the form g:vimwiki_
")
let para = 0
diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim
index 41ef51b..b959b75 100644
--- a/autoload/vimwiki/lst.vim
+++ b/autoload/vimwiki/lst.vim
@@ -697,7 +697,8 @@ function! s:get_rate(item) "{{{
return -1
endif
let state = a:item.cb
- return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 25
+ let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
+ return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 100/(n-1)
endfunction "}}}
"Set state of the list item to [ ] or [o] or whatever
@@ -732,17 +733,16 @@ 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 state = ''
+ let n = len(listsyms_list)
if a:rate == 100
- let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[4]
+ let state = listsyms_list[n-1]
elseif a:rate == 0
- let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[0]
- elseif a:rate >= 67
- let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[3]
- elseif a:rate >= 34
- let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[2]
+ let state = listsyms_list[0]
else
- let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[1]
+ let index = float2nr(ceil(a:rate/100.0*(n-2)))
+ let state = listsyms_list[index]
endif
return state
endfunction "}}}
diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
index 36fb9f5..ab0cf2a 100644
--- a/autoload/vimwiki/vars.vim
+++ b/autoload/vimwiki/vars.vim
@@ -47,6 +47,7 @@ function! s:populate_global_variables()
\ 'html_header_numbering': 0,
\ 'html_header_numbering_sym': '',
\ 'list_ignore_newline': 1,
+ \ 'text_ignore_newline': 1,
\ 'listsyms': ' .oOX',
\ 'map_prefix': 'w',
\ 'menu': 'Vimwiki',
@@ -384,13 +385,13 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
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[4].'\]\s.*\%(\n\%(\1\%('
+ \ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1].'\]\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[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
+ \ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
endif
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
index d795ba7..6baceec 100644
--- a/doc/vimwiki.txt
+++ b/doc/vimwiki.txt
@@ -1277,40 +1277,50 @@ Tags-related commands and options:
6. Folding/Outline *vimwiki-folding*
Vimwiki can fold or outline sections using headers and preformatted blocks.
-Alternatively, one can fold list subitems instead.
+Alternatively, one can fold list subitems instead. Folding is not enabled
+by default, and requires the |g:vimwiki_folding| variable to be set.
+
+Example for list folding with |g:vimwiki_folding| set to 'list':
-Example for list folding:
= My current task =
- * [ ] Do stuff 1
- * [ ] Do substuff 1.1
- * [ ] Do substuff 1.2
- * [ ] Do substuff 1.2.1
- * [ ] Do substuff 1.2.2
- * [ ] Do substuff 1.3
- * [ ] Do stuff 2
- * [ ] Do stuff 3
+* [ ] Do stuff 1
+ * [ ] Do substuff 1.1
+ * [ ] Do substuff 1.2
+ * [ ] Do substuff 1.2.1
+ * [ ] Do substuff 1.2.2
+ * [ ] Do substuff 1.3
+* [ ] Do stuff 2
+* [ ] Do stuff 3
Hit |zM| :
-= My current task = [8] --------------------------------------~
+= My current task =
+* [ ] Do stuff 1 [6] --------------------------------------~
+* [ ] Do stuff 2
+* [ ] Do stuff 3
Hit |zr| :
-= My current task =~
- * [ ] Do stuff 1 [5] --------------------------------------~
- * [ ] Do stuff 2~
- * [ ] Do stuff 3~
+= My current task =
+* [ ] Do stuff 1
+ * [ ] Do substuff 1.1
+ * [ ] Do substuff 1.2 [3] -------------------------------~
+ * [ ] Do substuff 1.3
+* [ ] Do stuff 2
+* [ ] Do stuff 3
-Hit |zr| one more time:
-= My current task =~
- * [ ] Do stuff 1~
- * [ ] Do substuff 1.1~
- * [ ] Do substuff 1.2 [2] -------------------------------~
- * [ ] Do substuff 1.3~
- * [ ] Do stuff 2~
- * [ ] Do stuff 3~
+Hit |zr| one more time :
+= My current task =
+* [ ] Do stuff 1
+ * [ ] Do substuff 1.1
+ * [ ] Do substuff 1.2
+ * [ ] Do substuff 1.2.1
+ * [ ] Do substuff 1.2.2
+ * [ ] Do substuff 1.3
+* [ ] Do stuff 2
+* [ ] Do stuff 3
Note: If you use the default Vimwiki syntax, folding on list items will work
properly only if all of them are indented using the current 'shiftwidth'.
-For MediaWiki, * or # should be in the first column.
+For MediaWiki syntax, * or # should be in the first column.
To turn folding on/off check |g:vimwiki_folding|.
@@ -2241,11 +2251,11 @@ Default: 'Vimwiki'
------------------------------------------------------------------------------
*g:vimwiki_listsyms*
-String of 5 symbols to show the progression of todo list items.
+String of at least two symbols to show the progression of todo list items.
Default value is ' .oOX'.
The first char is for 0% done items.
-The fifth is for 100% done items.
+The last is for 100% done items.
You can set it to some more fancy symbols like this:
>
@@ -2298,6 +2308,19 @@ Value Description~
Default: 1
+------------------------------------------------------------------------------
+*g:vimwiki_text_ignore_newline*
+
+This is HTML related.
+Convert newlines to s in text.
+
+Value Description~
+0 Newlines in text are converted to s.
+1 Ignore newlines.
+
+Default: 1
+
+
------------------------------------------------------------------------------
*g:vimwiki_use_calendar*
diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim
index 44c07fe..e035711 100644
--- a/syntax/vimwiki.vim
+++ b/syntax/vimwiki.vim
@@ -235,9 +235,9 @@ execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
if vimwiki#vars#get_global('hl_cb_checked') == 1
- execute 'syntax match VimwikiCheckBoxDone '
- \ . ' /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'\s*\['.vimwiki#vars#get_syntaxlocal('listsyms_list')[4].'\]\s.*$/'
- \ . ' contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
+ execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
+ \ .'\s*\['.vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
+ \ .'\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemAndChildren').'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
endif
From 7d4254a75df7b899dc99062663280433bd75c217 Mon Sep 17 00:00:00 2001
From: EinfachToll
Date: Fri, 16 Feb 2018 17:47:32 +0100
Subject: [PATCH 052/108] Cherry-pick the changes from dev -- part2
---
autoload/vimwiki/base.vim | 96 +++++++++++++++++++-----------
autoload/vimwiki/markdown_base.vim | 55 -----------------
autoload/vimwiki/path.vim | 8 ++-
doc/vimwiki.txt | 35 ++++++++++-
ftplugin/vimwiki.vim | 10 ++--
5 files changed, 105 insertions(+), 99 deletions(-)
diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
index 4bc45af..14709a6 100644
--- a/autoload/vimwiki/base.vim
+++ b/autoload/vimwiki/base.vim
@@ -98,7 +98,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
let source_file = a:1
else
let source_wiki = vimwiki#vars#get_bufferlocal('wiki_nr')
- let source_file = expand('%:p')
+ let source_file = vimwiki#path#current_wiki_file()
endif
let link_text = a:link_text
@@ -257,7 +257,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
\ || link_infos.scheme =~# 'diary'
let update_prev_link = is_wiki_link &&
- \ !vimwiki#path#is_equal(link_infos.filename, expand('%:p'))
+ \ !vimwiki#path#is_equal(link_infos.filename, vimwiki#path#current_wiki_file())
let vimwiki_prev_link = []
" update previous link for wiki pages
@@ -265,7 +265,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
if a:0
let vimwiki_prev_link = [a:1, []]
elseif &ft ==# 'vimwiki'
- let vimwiki_prev_link = [expand('%:p'), getpos('.')]
+ let vimwiki_prev_link = [vimwiki#path#current_wiki_file(), getpos('.')]
endif
endif
@@ -1076,57 +1076,81 @@ function! vimwiki#base#find_prev_link() "{{{
endfunction " }}}
" vimwiki#base#follow_link
-function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pass
- " to VimwikiLinkHandler, or failing that, the default open_link handler
- if exists('*vimwiki#'.vimwiki#vars#get_wikilocal('syntax').'_base#follow_link')
- " Syntax-specific links
- " XXX: @Stuart: do we still need it?
- " XXX: @Maxim: most likely! I am still working on a seemless way to
- " integrate regexp's without complicating syntax/vimwiki.vim
- if a:0
- call vimwiki#{vimwiki#vars#get_wikilocal('syntax')}_base#follow_link(a:split, a:1)
- else
- call vimwiki#{vimwiki#vars#get_wikilocal('syntax')}_base#follow_link(a:split)
+function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
+ " Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
+ " default open_link handler
+
+ " try WikiLink
+ let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')),
+ \ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
+ " try WikiIncl
+ if lnk == ""
+ let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiIncl')),
+ \ vimwiki#vars#get_syntaxlocal('rxWikiInclMatchUrl'))
+ endif
+ " try Weblink
+ if lnk == ""
+ let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')),
+ \ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
+ endif
+
+ if lnk != "" " cursor is indeed on a link
+ let processed_by_user_defined_handler = VimwikiLinkHandler(lnk)
+ if processed_by_user_defined_handler
+ return
endif
- else
- if a:split ==# "split"
+
+ if a:split ==# "hsplit"
let cmd = ":split "
elseif a:split ==# "vsplit"
let cmd = ":vsplit "
- elseif a:split ==# "tabnew"
+ elseif a:split ==# "tab"
let cmd = ":tabnew "
else
let cmd = ":e "
endif
- " try WikiLink
- let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')),
- \ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
- " try WikiIncl
- if lnk == ""
- let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')),
- \ vimwiki#vars#get_global('rxWikiInclMatchUrl'))
- endif
- " try Weblink
- if lnk == ""
- let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')),
- \ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
- endif
-
- if lnk != ""
- if !VimwikiLinkHandler(lnk)
- call vimwiki#base#open_link(cmd, lnk)
+ " 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
+ let previous_window_nr = winnr('#')
+ if previous_window_nr > 0 && previous_window_nr != winnr()
+ execute previous_window_nr . 'wincmd w'
+ let cmd = ':e'
endif
- return
endif
+
+ if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
+ let processed_by_markdown_reflink = vimwiki#markdown_base#open_reflink(lnk)
+ if processed_by_markdown_reflink
+ return
+ endif
+
+ " remove the extension from the filename if exists, because non-vimwiki
+ " markdown files usually include the extension in links
+ let lnk = substitute(lnk, vimwiki#vars#get_wikilocal('ext').'$', '', '')
+ endif
+
+ let current_tab_page = tabpagenr()
+
+ call vimwiki#base#open_link(cmd, lnk)
+
+ if !a:move_cursor
+ if (a:split ==# 'hsplit' || a:split ==# 'vsplit')
+ execute 'wincmd p'
+ elseif a:split ==# 'tab'
+ execute 'tabnext ' . current_tab_page
+ endif
+ endif
+
+ else
if a:0 > 0
execute "normal! ".a:1
else
call vimwiki#base#normalize_link(0)
endif
endif
-
endfunction " }}}
" vimwiki#base#go_back_link
diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
index a207f53..021b44a 100644
--- a/autoload/vimwiki/markdown_base.vim
+++ b/autoload/vimwiki/markdown_base.vim
@@ -48,61 +48,6 @@ endfunction " }}}
" WIKI link following functions {{{
-" vimwiki#markdown_base#follow_link
-function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
- " to VimwikiLinkHandler, or failing that, the default open_link handler
- " echom "markdown_base#follow_link"
-
- if 0
- " Syntax-specific links
- " XXX: @Stuart: do we still need it?
- " XXX: @Maxim: most likely! I am still working on a seemless way to
- " integrate regexp's without complicating syntax/vimwiki.vim
- else
- if a:split ==# "split"
- let cmd = ":split "
- elseif a:split ==# "vsplit"
- let cmd = ":vsplit "
- elseif a:split ==# "tabnew"
- let cmd = ":tabnew "
- else
- let cmd = ":e "
- endif
-
- " try WikiLink
- let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')),
- \ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
- " try WikiIncl
- if lnk == ""
- let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')),
- \ vimwiki#vars#get_global('rxWikiInclMatchUrl'))
- endif
- " try Weblink
- if lnk == ""
- let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')),
- \ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
- endif
-
- if lnk != ""
- if !VimwikiLinkHandler(lnk)
- if !vimwiki#markdown_base#open_reflink(lnk)
- " remove the extension from the filename if exists
- let lnk = substitute(lnk, vimwiki#vars#get_wikilocal('ext').'$', '', '')
- call vimwiki#base#open_link(cmd, lnk)
- endif
- endif
- return
- endif
-
- if a:0 > 0
- execute "normal! ".a:1
- else
- call vimwiki#base#normalize_link(0)
- endif
- endif
-
-endfunction " }}}
-
" LINK functions {{{
" s:normalize_link_syntax_n
diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim
index ffa48c3..263466c 100644
--- a/autoload/vimwiki/path.vim
+++ b/autoload/vimwiki/path.vim
@@ -75,7 +75,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
endfunction "}}}
function! vimwiki#path#wikify_path(path) "{{{
- let result = resolve(expand(a:path, ':p'))
+ let result = resolve(fnamemodify(a:path, ':p'))
if vimwiki#u#is_windows()
let result = substitute(result, '\\', '/', 'g')
endif
@@ -83,6 +83,12 @@ function! vimwiki#path#wikify_path(path) "{{{
return result
endfunction "}}}
+
+function! vimwiki#path#current_wiki_file()
+ return vimwiki#path#wikify_path(expand('%:p'))
+endfunction
+
+
" Returns: the relative path from a:dir to a:file
function! vimwiki#path#relpath(dir, file) "{{{
let result = []
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
index 6baceec..7e236ad 100644
--- a/doc/vimwiki.txt
+++ b/doc/vimwiki.txt
@@ -363,7 +363,7 @@ glh Decrease the level of a list item.
gLh Decrease the level of a list item and all child items.
To remap: >
:map << VimwikiDecreaseLvlSingleItem
- :map >>> VimwikiDecreaseLvlWholeItem
+ :map <<< VimwikiDecreaseLvlWholeItem
<
*vimwiki_glr* *vimwiki_gLr*
glr Renumber list items if the cursor is on a numbered
@@ -594,6 +594,9 @@ il A single list item.
------------------------------------------------------------------------------
4.2. Local commands *vimwiki-local-commands*
+These commands are only available (and meaningful) when you are currently in a
+Vimwiki file.
+
*:VimwikiFollowLink*
Follow wiki link (or create target wiki page if needed).
@@ -742,6 +745,34 @@ il A single list item.
their instances. Supports |cmdline-completion|. If
no arguments (tags) are specified, outputs all 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#base#follow_link({split}, {reuse}, {move_cursor}) *follow_link*
+ 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*
@@ -850,7 +881,7 @@ Raw URLs are also supported: >
External files~
-The "file:" and "local:" schemes allow you to directly link to arbitray
+The "file:" and "local:" schemes allow you to directly link to arbitrary
resources using absolute or relative paths: >
[[file:/home/somebody/a/b/c/music.mp3]]
[[file:C:/Users/somebody/d/e/f/music.mp3]]
diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
index f924ba3..4e747a3 100644
--- a/ftplugin/vimwiki.vim
+++ b/ftplugin/vimwiki.vim
@@ -255,14 +255,14 @@ command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
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')
+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('split')
-command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit')
+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=? VimwikiNormalizeLink call vimwiki#base#normalize_link()
-command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
+command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tab', 0, 1)
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
@@ -322,7 +322,7 @@ command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
if vimwiki#vars#get_global('use_mouse')
nmap
nmap
- nnoremap <2-LeftMouse> :call vimwiki#base#follow_link("nosplit", "\2-LeftMouse>")
+ nnoremap <2-LeftMouse> :call vimwiki#base#follow_link('nosplit', 0, 1, "\2-LeftMouse>")
nnoremap :VimwikiSplitLink
nnoremap :VimwikiVSplitLink
nnoremap :VimwikiGoBackLink
From 73bda6b9ab98025a994013e9a39613f507b7a5d9 Mon Sep 17 00:00:00 2001
From: EinfachToll
Date: Fri, 16 Feb 2018 18:11:49 +0100
Subject: [PATCH 053/108] Cherry-pick the changes from dev -- part3
---
README.md | 11 ++++++++-
autoload/vimwiki/diary.vim | 12 +++++-----
autoload/vimwiki/html.vim | 34 ++++++++++++++++++++++----
autoload/vimwiki/markdown_base.vim | 2 +-
autoload/vimwiki/vars.vim | 2 +-
doc/vimwiki.txt | 38 +++++++++++++++++++++++-------
ftplugin/vimwiki.vim | 4 ++--
plugin/vimwiki.vim | 2 ++
syntax/vimwiki.vim | 7 +++---
9 files changed, 85 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
index 5816229..a407040 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@ A Personal Wiki For Vim
==============================================================================
![screenshot1](doc/screenshot_1.png)
-![screenshot2](doc/screenshot_2.png)
+![screenshot2](doc/screenshot_2.png) *
Intro
------------------------------------------------------------------------------
@@ -122,6 +122,11 @@ Make sure you have these settings in your vimrc file:
Without them Vimwiki will not work properly.
+Installation using [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528)
+------------------------------------------------------------------------------
+
+ git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
+
Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
------------------------------------------------------------------------------
@@ -140,3 +145,7 @@ Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run
Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it in `~/.vim/bundle/`
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed.
+
+----
+\* Screenshots made with the [solarized colorscheme](https://github.com/altercation/vim-colors-solarized)
+and [lightline](https://github.com/itchyny/lightline.vim)
diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
index 3f662ed..253f11c 100644
--- a/autoload/vimwiki/diary.vim
+++ b/autoload/vimwiki/diary.vim
@@ -42,7 +42,7 @@ function! s:get_position_links(link) "{{{
let idx = -1
let links = []
if a:link =~# '^\d\{4}-\d\d-\d\d'
- let links = keys(s:get_diary_links())
+ let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")')
" include 'today' into links
if index(links, vimwiki#diary#diary_date_link()) == -1
call add(links, vimwiki#diary#diary_date_link())
@@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{
return result
endfun "}}}
-fun! s:get_diary_links() "{{{
+fun! s:get_diary_files() "{{{
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
@@ -92,9 +92,7 @@ fun! s:get_diary_links() "{{{
" remove backup files (.wiki~)
call filter(files, 'v:val !~# ''.*\~$''')
- let links_with_captions = s:read_captions(files)
-
- return links_with_captions
+ return files
endfun "}}}
fun! s:group_links(links) "{{{
@@ -129,7 +127,9 @@ endfunction "}}}
function! s:format_diary() "{{{
let result = []
- let g_files = s:group_links(s:get_diary_links())
+
+ let links_with_captions = s:read_captions(s:get_diary_files())
+ let g_files = s:group_links(links_with_captions)
for year in s:sort(keys(g_files))
call add(result, '')
diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim
index d01b056..43b90cb 100644
--- a/autoload/vimwiki/html.vim
+++ b/autoload/vimwiki/html.vim
@@ -209,6 +209,19 @@ function! s:save_vimwiki_buffer() "{{{
endif
endfunction "}}}
+" get date.
+function! s:process_date(placeholders, default_date) "{{{
+ if !empty(a:placeholders)
+ for [placeholder, row, idx] in a:placeholders
+ let [type, param] = placeholder
+ if type ==# 'date' && !empty(param)
+ return param
+ endif
+ endfor
+ endif
+ return a:default_date
+endfunction "}}}
+
" get title.
function! s:process_title(placeholders, default_title) "{{{
if !empty(a:placeholders)
@@ -1190,7 +1203,7 @@ function! s:parse_line(line, state) " {{{
" nohtml -- placeholder
if !processed
- if line =~# '^\s*%nohtml'
+ if line =~# '\m^\s*%nohtml\s*$'
let processed = 1
let state.placeholder = ['nohtml']
endif
@@ -1198,18 +1211,27 @@ function! s:parse_line(line, state) " {{{
" title -- placeholder
if !processed
- if line =~# '^\s*%title'
+ if line =~# '\m^\s*%title\%(\s.*\)\?$'
let processed = 1
- let param = matchstr(line, '^\s*%title\s\zs.*')
+ let param = matchstr(line, '\m^\s*%title\s\+\zs.*')
let state.placeholder = ['title', param]
endif
endif
+ " date -- placeholder
+ if !processed
+ if line =~# '\m^\s*%date\%(\s.*\)\?$'
+ let processed = 1
+ let param = matchstr(line, '\m^\s*%date\s\+\zs.*')
+ let state.placeholder = ['date', param]
+ endif
+ endif
+
" html template -- placeholder "{{{
if !processed
- if line =~# '^\s*%template'
+ if line =~# '\m^\s*%template\%(\s.*\)\?$'
let processed = 1
- let param = matchstr(line, '^\s*%template\s\zs.*')
+ let param = matchstr(line, '\m^\s*%template\s\+\zs.*')
let state.placeholder = ['template', param]
endif
endif
@@ -1483,11 +1505,13 @@ function! s:convert_file(path_html, wikifile) "{{{
call extend(ldest, lines)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
+ let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
let html_lines = s:get_html_template(template_name)
" processing template variables (refactor to a function)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
+ call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
index 021b44a..f55be2d 100644
--- a/autoload/vimwiki/markdown_base.vim
+++ b/autoload/vimwiki/markdown_base.vim
@@ -123,7 +123,7 @@ function! s:normalize_link_syntax_v() " {{{
call setreg('"', link, 'v')
" paste result
- norm! `>pgvd
+ norm! `>""pgvd
finally
call setreg('"', rv, rt)
diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
index ab0cf2a..01b2263 100644
--- a/autoload/vimwiki/vars.vim
+++ b/autoload/vimwiki/vars.vim
@@ -77,7 +77,7 @@ function! s:populate_global_variables()
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'
+ let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel,data'
let rx_schemes = '\%('.
\ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'.
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
index 7e236ad..551d2e8 100644
--- a/doc/vimwiki.txt
+++ b/doc/vimwiki.txt
@@ -742,8 +742,9 @@ Vimwiki file.
*:VimwikiGenerateTags* tagname1 tagname2 ...
Creates or updates an overview on all tags of the wiki with links to all
- their instances. Supports |cmdline-completion|. If
- no arguments (tags) are specified, outputs all tags.
+ their instances. Supports |cmdline-completion|. If no arguments (tags)
+ 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*
@@ -755,9 +756,10 @@ 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#base#follow_link({split}, {reuse}, {move_cursor}) *follow_link*
+ *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
@@ -1171,7 +1173,8 @@ This might be useful for coloring program code with external JS tools
such as Google's syntax highlighter.
You can setup Vimwiki to highlight code snippets in preformatted text.
-See |vimwiki-option-nested_syntaxes|
+See |vimwiki-option-nested_syntaxes| and
+|vimwiki-option-automatic_nested_syntaxes|.
------------------------------------------------------------------------------
@@ -1291,8 +1294,9 @@ which opens up a popup menu with all tags defined in the wiki starting with
Tags are also treated as |vimwiki-anchors| (similar to bold text).
-Note that tag search/jump/completion commands need certain metadata saved in
-the wiki folder. This metadata file can be manually updated by running
+ *vimwiki-build-tags*
+Note that the tag search/jump/completion commands need certain metadata saved
+in the wiki folder. This metadata file can be manually updated by running
|:VimwikiRebuildTags|. When the option |vimwiki-option-auto_tags| is enabled,
the tags metadata will be auto-updated on each page save.
@@ -1391,6 +1395,18 @@ into it.
See |vimwiki-option-template_path| for details.
+------------------------------------------------------------------------------
+%date *vimwiki-date*
+
+The date of the wiki page. The value can be used in the HTML template, see
+|vimwiki-option-template_path| for details.
+
+%date 2017-07-08
+%date
+
+If you omit the date after the placeholder, the date of the HTML conversion is
+used.
+
==============================================================================
8. Lists *vimwiki-lists*
@@ -1942,11 +1958,13 @@ Each template could look like: >