Add toc_link_format option

Add an option for setting the format of the links in the Table of Contents:
- Extended (the current and default)
- Brief (new format for the Vimwiki markup)
This commit is contained in:
Michal Cizmazia 2019-03-29 21:25:27 +01:00
parent e56c26c7ba
commit b849a411e3
No known key found for this signature in database
GPG Key ID: BD2505DF2FD1DB18
3 changed files with 26 additions and 6 deletions

View File

@ -1893,11 +1893,13 @@ function! vimwiki#base#table_of_contents(create)
for idx in range(h_level, 5) | let headers_levels[idx] = ['', 0] | endfor
let h_complete_id = ''
for l in range(h_level-1)
if headers_levels[l][0] != ''
let h_complete_id .= headers_levels[l][0].'#'
endif
endfor
if vimwiki#vars#get_global('toc_link_format') == 0
for l in range(h_level-1)
if headers_levels[l][0] != ''
let h_complete_id .= headers_levels[l][0].'#'
endif
endfor
endif
let h_complete_id .= headers_levels[h_level-1][0]
if numbering > 0 && numbering <= h_level
@ -1916,8 +1918,10 @@ function! vimwiki#base#table_of_contents(create)
for [lvl, link, desc] in complete_header_infos
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink2Template')
else
elseif vimwiki#vars#get_global('toc_link_format') == 0
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1')
endif
let link = s:safesubstitute(link_tpl, '__LinkUrl__',
\ '#'.link, '')

View File

@ -181,6 +181,7 @@ function! s:read_global_settings_from_user()
\ 'tags_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 5},
\ 'toc_header': {'type': type(''), 'default': 'Contents', 'min_length': 1},
\ 'toc_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 6},
\ 'toc_link_format': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'url_maxsave': {'type': type(0), 'default': 15, 'min': 0},
\ 'use_calendar': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'use_mouse': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},

View File

@ -2992,6 +2992,21 @@ are from 1 to 6.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_toc_link_format*
The format of the links in the Table of Contents (see |vimwiki-toc|).
Value Description~
0 Extended: The link contains the description and URL. URL
references all levels.
1 Brief: The link contains only the URL. URL references only
the immediate level.
Default: 0
------------------------------------------------------------------------------
*g:vimwiki_map_prefix*