Treat tags as anchors (wikilink completion, jumping to)
This commit is contained in:
parent
b99a3dc988
commit
d72ef4dd70
@ -620,6 +620,7 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
|||||||
|
|
||||||
let rxheader = g:vimwiki_{a:syntax}_header_search
|
let rxheader = g:vimwiki_{a:syntax}_header_search
|
||||||
let rxbold = g:vimwiki_{a:syntax}_bold_search
|
let rxbold = g:vimwiki_{a:syntax}_bold_search
|
||||||
|
let rxtag = g:vimwiki_{a:syntax}_tag_search
|
||||||
|
|
||||||
let anchor_level = ['', '', '', '', '', '', '']
|
let anchor_level = ['', '', '', '', '', '', '']
|
||||||
let anchors = []
|
let anchors = []
|
||||||
@ -664,6 +665,20 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
|||||||
let bold_count += 1
|
let bold_count += 1
|
||||||
endwhile
|
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
|
endfor
|
||||||
|
|
||||||
return anchors
|
return anchors
|
||||||
@ -684,8 +699,12 @@ function! s:jump_to_anchor(anchor) "{{{
|
|||||||
\ '__Header__', "\\='".segment."'", '')
|
\ '__Header__', "\\='".segment."'", '')
|
||||||
let anchor_bold = substitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match,
|
let anchor_bold = substitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match,
|
||||||
\ '__Text__', "\\='".segment."'", '')
|
\ '__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)
|
call setpos('.', oldpos)
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
|
@ -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
|
which opens up a popup menu with all tags defined in the wiki starting with
|
||||||
"ind".
|
"ind".
|
||||||
|
|
||||||
|
Tags are also treated as |vimwiki-anchors| (similar to bold text).
|
||||||
|
|
||||||
Note that tag search/jump/completion commands need certain metadata saved in
|
Note that tag search/jump/completion commands need certain metadata saved in
|
||||||
the wiki folder. This metadata can be manually updated by running
|
the wiki folder. This metadata can be manually updated by running
|
||||||
|:VimwikiRebuildTags|. There is an option |vimwiki-option-auto_tags|, when
|
|: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": >
|
For example, consider the following file "Todo.wiki": >
|
||||||
= My tasks =
|
= My tasks =
|
||||||
|
:todo-lists:
|
||||||
== Home ==
|
== Home ==
|
||||||
- [ ] bathe my dog
|
- [ ] bathe my dog
|
||||||
== Work ==
|
== 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: >
|
Or, to jump to an individual project, use this link: >
|
||||||
[[Todo#pig]]
|
[[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
|
If there are multiple instances of an anchor, you can use the long form which
|
||||||
consists of the complete header hierarchy, separated by '#': >
|
consists of the complete header hierarchy, separated by '#': >
|
||||||
[[Todo#My tasks#Knitting club#Knitting projects#dog]]
|
[[Todo#My tasks#Knitting club#Knitting projects#dog]]
|
||||||
|
@ -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_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
||||||
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||||
let g:vimwiki_default_tag_search = ':\zs[^:[:space:]]\+\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_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
|
||||||
let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
|
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_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_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_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_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||||
let g:vimwiki_media_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\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
|
" 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_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_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?
|
||||||
|
Loading…
Reference in New Issue
Block a user