Feature: Config: Normalize link so that user can choose [[]] or []() (Issue #892)

Main change:
        Create function: normalize_syntax_settings(syntax)

Problem:
        Some user prefer [[]] links more than []().
        As vimwiki know both of them, they should be able to choose
        without regex mastery and with tests

Solution:
        let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
This commit is contained in:
Tinmarino
2020-07-26 22:14:00 -04:00
parent 4672deb44e
commit d9d14cc3f7
5 changed files with 53 additions and 17 deletions

View File

@ -563,7 +563,7 @@ endfunction
" Helper path
" TODO move to path
" TODO move to path: Conflict with: vimwiki#path#path_norm && vimwiki#path#normalize
function! s:normalize_path(path) abort
" trim trailing / and \ because otherwise resolve() doesn't work quite right
let path = substitute(a:path, '[/\\]\+$', '', '')
@ -741,6 +741,8 @@ function! vimwiki#vars#populate_syntax_vars(syntax) abort
if a:syntax ==# 'markdown'
call s:populate_extra_markdown_vars()
endif
call s:normalize_syntax_settings(a:syntax)
endfunction
@ -975,6 +977,23 @@ function! s:populate_extra_markdown_vars() abort
endfunction
" Normalize syntax setting
" so that we dont have to branch for the syntax at each operation
" Called: vimwiki#vars#populate_syntax_vars
function! s:normalize_syntax_settings(syntax) abort
let syntax_dic = g:vimwiki_syntax_variables[a:syntax]
" Link1: used when:
" user press enter on a non-link (normalize_link)
" command generate link form file name (generate_link)
if a:syntax ==# 'markdown'
let syntax_dic.Link1 = syntax_dic.Weblink1Template
else
let syntax_dic.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
endif
endfunction
" ----------------------------------------------------------
" 4. Getter, Setter (exported)
" ----------------------------------------------------------