vimwiki

Personal wiki for vim
git clone https://github.com/vimwiki/vimwiki.git
Log | Files | Refs | README | LICENSE

commit d72ef4dd707c986620755d159bc467b18150e826
parent b99a3dc988dfae985617d9785de577f9d97e2e5f
Author: Ivan Tishchenko <ivan.tishchenko@dsr-company.con>
Date:   Sat, 10 Jan 2015 16:39:11 +0300

Treat tags as anchors (wikilink completion, jumping to)

Diffstat:
Mautoload/vimwiki/base.vim | 21++++++++++++++++++++-
Mdoc/vimwiki.txt | 6++++++
Msyntax/omnipresent_syntax.vim | 3+++
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim @@ -620,6 +620,7 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{ let rxheader = g:vimwiki_{a:syntax}_header_search let rxbold = g:vimwiki_{a:syntax}_bold_search + let rxtag = g:vimwiki_{a:syntax}_tag_search let anchor_level = ['', '', '', '', '', '', ''] let anchors = [] @@ -664,6 +665,20 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{ let bold_count += 1 endwhile + " collect tags text (there can be several in one line) + let tag_count = 1 + while 1 + let tag_text = matchstr(line, rxtag, 0, tag_count) + if tag_text == '' + break + endif + call add(anchors, tag_text) + if current_complete_anchor != '' + call add(anchors, current_complete_anchor.'#'.tag_text) + endif + let tag_count += 1 + endwhile + endfor return anchors @@ -684,8 +699,12 @@ function! s:jump_to_anchor(anchor) "{{{ \ '__Header__', "\\='".segment."'", '') let anchor_bold = substitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match, \ '__Text__', "\\='".segment."'", '') + let anchor_tag = substitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match, + \ '__Tag__', "\\='".segment."'", '') - if !search(anchor_header, 'Wc') && !search(anchor_bold, 'Wc') + if !search(anchor_header, 'Wc') + \ && !search(anchor_bold, 'Wc') + \ && !search(anchor_tag, 'Wc') call setpos('.', oldpos) break endif diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt @@ -1249,6 +1249,8 @@ Typing tags can be simplified by using Vim's omni completion (see which opens up a popup menu with all tags defined in the wiki starting with "ind". +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 can be manually updated by running |:VimwikiRebuildTags|. There is an option |vimwiki-option-auto_tags|, when @@ -1622,6 +1624,7 @@ of the form > For example, consider the following file "Todo.wiki": > = My tasks = + :todo-lists: == Home == - [ ] bathe my dog == Work == @@ -1637,6 +1640,9 @@ Then, to jump from your index.wiki directly to your knitting projects, use: > Or, to jump to an individual project, use this link: > [[Todo#pig]] +Or, to jump to a tag, use this link: > + [[Todo#todo-lists]] + If there are multiple instances of an anchor, you can use the long form which consists of the complete header hierarchy, separated by '#': > [[Todo#My tasks#Knitting club#Knitting projects#dog]] diff --git a/syntax/omnipresent_syntax.vim b/syntax/omnipresent_syntax.vim @@ -15,6 +15,7 @@ let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:sp let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@=' let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]' let g:vimwiki_default_tag_search = ':\zs[^:[:space:]]\+\ze:' +let g:vimwiki_default_tag_match = ':__Tag__:' let g:vimwiki_markdown_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$' let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$' @@ -22,6 +23,7 @@ let g:vimwiki_markdown_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:s let g:vimwiki_markdown_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@=' let g:vimwiki_markdown_wikilink = g:vimwiki_default_wikilink "XXX plus markdown-style links let g:vimwiki_markdown_tag_search = g:vimwiki_default_tag_search +let g:vimwiki_markdown_tag_match = g:vimwiki_default_tag_match let g:vimwiki_media_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$' let g:vimwiki_media_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$' @@ -31,3 +33,4 @@ let g:vimwiki_media_bold_match = '''''''__Text__''''''' " want to call escape() on this string, we must keep it in single quotes let g:vimwiki_media_wikilink = g:vimwiki_default_wikilink let g:vimwiki_media_tag_search = g:vimwiki_default_tag_search " XXX rework to mediawiki categories format? +let g:vimwiki_media_tag_match = g:vimwiki_default_tag_match " XXX rework to mediawiki categories format?