parent
c9104fc2c1
commit
7c98ce3934
@ -220,8 +220,7 @@ endfunction " }}}
|
||||
" Returns: the number of the wiki a file belongs to
|
||||
function! vimwiki#base#find_wiki(path) "{{{
|
||||
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
for idx in range(vimwiki#vars#number_of_wikis())
|
||||
let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx))
|
||||
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
|
||||
if vimwiki#path#is_equal(
|
||||
@ -245,7 +244,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
||||
let source_wiki = vimwiki#base#find_wiki(a:1)
|
||||
let source_file = a:1
|
||||
else
|
||||
let source_wiki = g:vimwiki_current_idx
|
||||
let source_wiki = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let source_file = expand('%:p')
|
||||
endif
|
||||
|
||||
@ -309,7 +308,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
||||
" extract the other items depending on the scheme
|
||||
if link_infos.scheme =~# '\mwiki\d\+'
|
||||
let link_infos.index = eval(matchstr(link_infos.scheme, '\D\+\zs\d\+\ze'))
|
||||
if link_infos.index < 0 || link_infos.index >= len(g:vimwiki_list)
|
||||
if link_infos.index < 0 || link_infos.index >= vimwiki#vars#number_of_wikis()
|
||||
let link_infos.filename = ''
|
||||
return link_infos
|
||||
endif
|
||||
@ -421,10 +420,6 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
if is_wiki_link
|
||||
call vimwiki#base#edit_file(a:cmd, link_infos.filename, link_infos.anchor,
|
||||
\ vimwiki_prev_link, update_prev_link)
|
||||
if link_infos.index != g:vimwiki_current_idx
|
||||
" this call to setup_buffer_state may not be necessary
|
||||
call vimwiki#base#setup_buffer_state(link_infos.index)
|
||||
endif
|
||||
else
|
||||
call vimwiki#base#system_open_link(link_infos.filename)
|
||||
endif
|
||||
@ -455,7 +450,7 @@ endfunction " }}}
|
||||
function! vimwiki#base#generate_links() "{{{
|
||||
let lines = []
|
||||
|
||||
let links = vimwiki#base#get_wikilinks(g:vimwiki_current_idx, 0)
|
||||
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
|
||||
call sort(links)
|
||||
|
||||
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
|
||||
@ -464,7 +459,7 @@ function! vimwiki#base#generate_links() "{{{
|
||||
let abs_filepath = vimwiki#path#abs_path_of_link(link)
|
||||
if !s:is_diary_file(abs_filepath)
|
||||
call add(lines, bullet.
|
||||
\ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".link."'", ''))
|
||||
\ substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', '\='."'".link."'", ''))
|
||||
endif
|
||||
endfor
|
||||
|
||||
@ -488,7 +483,7 @@ endfunction "}}}
|
||||
function! vimwiki#base#backlinks() "{{{
|
||||
let current_filename = expand("%:p")
|
||||
let locations = []
|
||||
for idx in range(len(g:vimwiki_list))
|
||||
for idx in range(vimwiki#vars#number_of_wikis())
|
||||
let syntax = vimwiki#vars#get_wikilocal('syntax', idx)
|
||||
let wikifiles = vimwiki#base#find_files(idx, 0)
|
||||
for source_file in wikifiles
|
||||
@ -520,7 +515,7 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
|
||||
let root_directory = vimwiki#vars#get_wikilocal('path', wiki_nr)
|
||||
else
|
||||
let root_directory = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
let wiki_nr = g:vimwiki_current_idx
|
||||
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
endif
|
||||
if a:directories_only
|
||||
let ext = '/'
|
||||
@ -544,7 +539,7 @@ endfunction
|
||||
" If also_absolute_links is nonzero, also return links of the form /file
|
||||
function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
|
||||
let files = vimwiki#base#find_files(a:wiki_nr, 0)
|
||||
if a:wiki_nr == g:vimwiki_current_idx
|
||||
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let cwd = vimwiki#path#wikify_path(expand('%:p:h'))
|
||||
elseif a:wiki_nr < 0
|
||||
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
@ -559,7 +554,7 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
|
||||
endfor
|
||||
if a:also_absolute_links
|
||||
for wikifile in files
|
||||
if a:wiki_nr == g:vimwiki_current_idx
|
||||
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let cwd = vimwiki#vars#get_wikilocal('path')
|
||||
elseif a:wiki_nr < 0
|
||||
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
@ -575,7 +570,7 @@ endfunction
|
||||
" Returns: a list containing the links to all directories from the current file
|
||||
function! vimwiki#base#get_wiki_directories(wiki_nr)
|
||||
let dirs = vimwiki#base#find_files(a:wiki_nr, 1)
|
||||
if a:wiki_nr == g:vimwiki_current_idx
|
||||
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let cwd = vimwiki#path#wikify_path(expand('%:p:h'))
|
||||
let root_dir = vimwiki#vars#get_wikilocal('path')
|
||||
else
|
||||
@ -585,7 +580,7 @@ function! vimwiki#base#get_wiki_directories(wiki_nr)
|
||||
for wikidir in dirs
|
||||
let wikidir_relative = vimwiki#path#relpath(cwd, wikidir)
|
||||
call add(result, wikidir_relative)
|
||||
if a:wiki_nr == g:vimwiki_current_idx
|
||||
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let wikidir_absolute = '/'.vimwiki#path#relpath(root_dir, wikidir)
|
||||
call add(result, wikidir_absolute)
|
||||
endif
|
||||
@ -598,9 +593,9 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
||||
return []
|
||||
endif
|
||||
|
||||
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 rxheader = vimwiki#vars#get_syntaxlocal('header_search', a:syntax)
|
||||
let rxbold = vimwiki#vars#get_syntaxlocal('bold_search', a:syntax)
|
||||
let rxtag = vimwiki#vars#get_syntaxlocal('tag_search', a:syntax)
|
||||
|
||||
let anchor_level = ['', '', '', '', '', '', '']
|
||||
let anchors = []
|
||||
@ -675,16 +670,16 @@ function! s:jump_to_anchor(anchor) "{{{
|
||||
|
||||
let segments = split(anchor, '#', 0)
|
||||
|
||||
let current_syntax = vimwiki#vars#get_wikilocal('syntax')
|
||||
|
||||
for segment in segments
|
||||
|
||||
let anchor_header = substitute(
|
||||
\ g:vimwiki_{current_syntax}_header_match,
|
||||
\ vimwiki#vars#get_syntaxlocal('header_match'),
|
||||
\ '__Header__', "\\='".segment."'", '')
|
||||
let anchor_bold = substitute(g:vimwiki_{current_syntax}_bold_match,
|
||||
let anchor_bold = substitute(
|
||||
\ vimwiki#vars#get_syntaxlocal('bold_match'),
|
||||
\ '__Text__', "\\='".segment."'", '')
|
||||
let anchor_tag = substitute(g:vimwiki_{current_syntax}_tag_match,
|
||||
let anchor_tag = substitute(
|
||||
\ vimwiki#vars#get_syntaxlocal('tag_match'),
|
||||
\ '__Tag__', "\\='".segment."'", '')
|
||||
|
||||
if !search(anchor_tag, 'Wc')
|
||||
@ -707,7 +702,7 @@ function! s:get_links(wikifile, idx) "{{{
|
||||
endif
|
||||
|
||||
let syntax = vimwiki#vars#get_wikilocal('syntax', a:idx)
|
||||
let rx_link = g:vimwiki_{syntax}_wikilink
|
||||
let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax)
|
||||
let links = []
|
||||
let lnum = 0
|
||||
|
||||
@ -737,7 +732,7 @@ function! vimwiki#base#check_links() "{{{
|
||||
let anchors_of_files = {}
|
||||
let links_of_files = {}
|
||||
let errors = []
|
||||
for idx in range(len(g:vimwiki_list))
|
||||
for idx in range(vimwiki#vars#number_of_wikis())
|
||||
let syntax = vimwiki#vars#get_wikilocal('syntax', idx)
|
||||
let wikifiles = vimwiki#base#find_files(idx, 0)
|
||||
for wikifile in wikifiles
|
||||
@ -791,7 +786,7 @@ function! vimwiki#base#check_links() "{{{
|
||||
endfor
|
||||
|
||||
" mark every index file as reachable
|
||||
for idx in range(len(g:vimwiki_list))
|
||||
for idx in range(vimwiki#vars#number_of_wikis())
|
||||
let index_file = vimwiki#vars#get_wikilocal('path', idx) . vimwiki#vars#get_wikilocal('index', idx) .
|
||||
\ vimwiki#vars#get_wikilocal('ext', idx)
|
||||
if filereadable(index_file)
|
||||
@ -936,8 +931,8 @@ endf "}}}
|
||||
" s:print_wiki_list
|
||||
function! s:print_wiki_list() "{{{
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
if idx == g:vimwiki_current_idx
|
||||
while idx < vimwiki#vars#number_of_wikis()
|
||||
if idx == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let sep = ' * '
|
||||
echohl PmenuSel
|
||||
else
|
||||
@ -976,7 +971,7 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
let new_fname = a:new_fname
|
||||
|
||||
let old_fname_r = vimwiki#base#apply_template(
|
||||
\ g:vimwiki_WikiLinkMatchUrlTemplate, old_fname, '', '')
|
||||
\ vimwiki#vars#get_global('WikiLinkMatchUrlTemplate'), old_fname, '', '')
|
||||
|
||||
let files = split(glob(vimwiki#vars#get_wikilocal('path').a:dir.'*'.vimwiki#vars#get_wikilocal('ext')), '\n')
|
||||
for fname in files
|
||||
@ -1126,7 +1121,7 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
let already_there = 0
|
||||
|
||||
let header_rx = '\m^\s*'.
|
||||
\ substitute(g:vimwiki_rxH1_Template, '__Header__', a:start_header, '')
|
||||
\ substitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'), '__Header__', a:start_header, '')
|
||||
\ .'\s*$'
|
||||
|
||||
let start_lnum = 1
|
||||
@ -1178,7 +1173,7 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
|
||||
" write new listing
|
||||
let new_header = whitespaces_in_first_line
|
||||
\ . substitute(g:vimwiki_rxH1_Template,
|
||||
\ . substitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'),
|
||||
\ '__Header__', '\='."'".a:start_header."'", '')
|
||||
call append(start_lnum - 1, new_header)
|
||||
let start_lnum += 1
|
||||
@ -1208,7 +1203,7 @@ endfunction "}}}
|
||||
" WIKI link following functions {{{
|
||||
" vimwiki#base#find_next_link
|
||||
function! vimwiki#base#find_next_link() "{{{
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, '')
|
||||
call vimwiki#base#search_word(vimwiki#vars#get_global('rxAnyLink'), '')
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#find_prev_link
|
||||
@ -1216,9 +1211,9 @@ function! vimwiki#base#find_prev_link() "{{{
|
||||
"Jump 2 times if the cursor is in the middle of a link
|
||||
if synIDattr(synID(line('.'), col('.'), 0), "name") =~# "VimwikiLink.*" &&
|
||||
\ synIDattr(synID(line('.'), col('.')-1, 0), "name") =~# "VimwikiLink.*"
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||
call vimwiki#base#search_word(vimwiki#vars#get_global('rxAnyLink'), 'b')
|
||||
endif
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||
call vimwiki#base#search_word(vimwiki#vars#get_global('rxAnyLink'), 'b')
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#follow_link
|
||||
@ -1246,17 +1241,17 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
|
||||
endif
|
||||
|
||||
" try WikiLink
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl)
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiLink')),
|
||||
\ vimwiki#vars#get_global('rxWikiLinkMatchUrl'))
|
||||
" try WikiIncl
|
||||
if lnk == ""
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
|
||||
\ g:vimwiki_rxWikiInclMatchUrl)
|
||||
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(g:vimwiki_rxWeblink),
|
||||
\ g:vimwiki_rxWeblinkMatchUrl)
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWeblink')),
|
||||
\ vimwiki#vars#get_global('rxWeblinkMatchUrl'))
|
||||
endif
|
||||
|
||||
if lnk != ""
|
||||
@ -1373,7 +1368,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
let url = matchstr(new_link, g:vimwiki_rxWikiLinkMatchUrl)
|
||||
let url = matchstr(new_link, vimwiki#vars#get_global('rxWikiLinkMatchUrl'))
|
||||
if url != ''
|
||||
let new_link = url
|
||||
endif
|
||||
@ -1684,15 +1679,15 @@ endfunction "}}}
|
||||
function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
let rxHdr = g:vimwiki_rxH
|
||||
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
|
||||
if line =~# '^\s*$'
|
||||
return
|
||||
endif
|
||||
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
let level = vimwiki#u#count_first_sym(line)
|
||||
if level < 6
|
||||
if g:vimwiki_symH
|
||||
if vimwiki#vars#get_syntaxlocal('symH')
|
||||
let line = substitute(line, '\('.rxHdr.'\+\).\+\1', rxHdr.'&'.rxHdr, '')
|
||||
else
|
||||
let line = substitute(line, '\('.rxHdr.'\+\).\+', rxHdr.'&', '')
|
||||
@ -1701,7 +1696,7 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
endif
|
||||
else
|
||||
let line = substitute(line, '^\s*', '&'.rxHdr.' ', '')
|
||||
if g:vimwiki_symH
|
||||
if vimwiki#vars#get_syntaxlocal('symH')
|
||||
let line = substitute(line, '\s*$', ' '.rxHdr.'&', '')
|
||||
endif
|
||||
call setline(lnum, line)
|
||||
@ -1712,19 +1707,19 @@ endfunction "}}}
|
||||
function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
let rxHdr = g:vimwiki_rxH
|
||||
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
|
||||
if line =~# '^\s*$'
|
||||
return
|
||||
endif
|
||||
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
let level = vimwiki#u#count_first_sym(line)
|
||||
let old = repeat(rxHdr, level)
|
||||
let new = repeat(rxHdr, level - 1)
|
||||
|
||||
let chomp = line =~# rxHdr.'\s'
|
||||
|
||||
if g:vimwiki_symH
|
||||
if vimwiki#vars#get_syntaxlocal('symH')
|
||||
let line = substitute(line, old, new, 'g')
|
||||
else
|
||||
let line = substitute(line, old, new, '')
|
||||
@ -1751,27 +1746,27 @@ function! vimwiki#base#table_of_contents(create)
|
||||
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
||||
for lnum in range(1, line('$'))
|
||||
let line_content = getline(lnum)
|
||||
if (is_inside_pre_or_math == 1 && line_content =~# g:vimwiki_rxPreEnd) ||
|
||||
\ (is_inside_pre_or_math == 2 && line_content =~# g:vimwiki_rxMathEnd)
|
||||
if (is_inside_pre_or_math == 1 && line_content =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')) ||
|
||||
\ (is_inside_pre_or_math == 2 && line_content =~# vimwiki#vars#get_syntaxlocal('rxMathEnd'))
|
||||
let is_inside_pre_or_math = 0
|
||||
continue
|
||||
endif
|
||||
if is_inside_pre_or_math > 0
|
||||
continue
|
||||
endif
|
||||
if line_content =~# g:vimwiki_rxPreStart
|
||||
if line_content =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
||||
let is_inside_pre_or_math = 1
|
||||
continue
|
||||
endif
|
||||
if line_content =~# g:vimwiki_rxMathStart
|
||||
if line_content =~# vimwiki#vars#get_syntaxlocal('rxMathStart')
|
||||
let is_inside_pre_or_math = 2
|
||||
continue
|
||||
endif
|
||||
if line_content !~# g:vimwiki_rxHeader
|
||||
if line_content !~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
continue
|
||||
endif
|
||||
let h_level = vimwiki#u#count_first_sym(line_content)
|
||||
let h_text = vimwiki#u#trim(matchstr(line_content, g:vimwiki_rxHeader))
|
||||
let h_text = vimwiki#u#trim(matchstr(line_content, vimwiki#vars#get_syntaxlocal('rxHeader')))
|
||||
if h_text ==# vimwiki#vars#get_global('toc_header') " don't include the TOC's header itself
|
||||
continue
|
||||
endif
|
||||
@ -1804,7 +1799,7 @@ function! vimwiki#base#table_of_contents(create)
|
||||
for [lvl, link, desc] in headers
|
||||
let esc_link = substitute(link, "'", "''", 'g')
|
||||
let esc_desc = substitute(desc, "'", "''", 'g')
|
||||
let link = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__',
|
||||
let link = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__',
|
||||
\ '\='."'".'#'.esc_link."'", '')
|
||||
let link = substitute(link, '__LinkDescription__', '\='."'".esc_desc."'", '')
|
||||
call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
|
||||
@ -1897,15 +1892,15 @@ function! s:normalize_link_in_diary(lnk) " {{{
|
||||
|
||||
if ! link_exists_in_wiki || link_exists_in_diary || link_is_date
|
||||
let str = a:lnk
|
||||
let rxUrl = g:vimwiki_rxWord
|
||||
let rxUrl = vimwiki#vars#get_syntaxlocal('rxWord')
|
||||
let rxDesc = ''
|
||||
let template = g:vimwiki_WikiLinkTemplate1
|
||||
let template = vimwiki#vars#get_global('WikiLinkTemplate1')
|
||||
else
|
||||
let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/'))
|
||||
let str = repeat('../', depth) . a:lnk . '|' . a:lnk
|
||||
let rxUrl = '^.*\ze|'
|
||||
let rxDesc = '|\zs.*$'
|
||||
let template = g:vimwiki_WikiLinkTemplate2
|
||||
let template = vimwiki#vars#get_global('WikiLinkTemplate2')
|
||||
endif
|
||||
|
||||
return vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
|
||||
@ -1915,42 +1910,42 @@ endfunction " }}}
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
|
||||
" try WikiLink
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiLink'))
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLinkTemplate2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink, sub)
|
||||
\ vimwiki#vars#get_global('rxWikiLinkMatchUrl'), vimwiki#vars#get_global('rxWikiLinkMatchDescr'),
|
||||
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_global('rxWikiLink'), sub)
|
||||
return
|
||||
endif
|
||||
|
||||
" try WikiIncl
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl'))
|
||||
if !empty(lnk)
|
||||
" NO-OP !!
|
||||
return
|
||||
endif
|
||||
|
||||
" try Weblink
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWeblink'))
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ lnk, '', g:vimwiki_WikiLinkTemplate2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
|
||||
\ lnk, '', vimwiki#vars#get_global('WikiLinkTemplate2'))
|
||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_global('rxWeblink'), sub)
|
||||
return
|
||||
endif
|
||||
|
||||
" try Word (any characters except separators)
|
||||
" rxWord is less permissive than rxWikiLinkUrl which is used in
|
||||
" normalize_link_syntax_v
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWord'))
|
||||
if !empty(lnk)
|
||||
if s:is_diary_file(expand("%:p"))
|
||||
let sub = s:normalize_link_in_diary(lnk)
|
||||
else
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWord, '',
|
||||
\ g:vimwiki_WikiLinkTemplate1)
|
||||
\ vimwiki#vars#get_syntaxlocal('rxWord'), '',
|
||||
\ vimwiki#vars#get_global('WikiLinkTemplate1'))
|
||||
endif
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
return
|
||||
@ -1973,7 +1968,7 @@ function! s:normalize_link_syntax_v() " {{{
|
||||
if s:is_diary_file(expand("%:p"))
|
||||
let sub = s:normalize_link_in_diary(@")
|
||||
else
|
||||
let sub = substitute(g:vimwiki_WikiLinkTemplate1,
|
||||
let sub = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
|
||||
\ '__LinkUrl__', '\=' . "'" . @" . "'", '')
|
||||
endif
|
||||
|
||||
|
@ -159,7 +159,7 @@ endfunction "}}}
|
||||
" Diary index stuff }}}
|
||||
|
||||
function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
if a:wnum > len(g:vimwiki_list)
|
||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||
return
|
||||
endif
|
||||
@ -189,7 +189,7 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#diary#goto_diary_index(wnum) "{{{
|
||||
if a:wnum > len(g:vimwiki_list)
|
||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||
return
|
||||
endif
|
||||
|
@ -188,7 +188,7 @@ function! s:get_level(lnum) "{{{
|
||||
if getline(a:lnum) =~# '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
if vimwiki#vars#get_wikilocal('syntax') !=? 'media'
|
||||
if !vimwiki#vars#get_wikilocal('recurring_bullets')
|
||||
let level = indent(a:lnum)
|
||||
else
|
||||
let level = s:string_length(matchstr(getline(a:lnum), s:rx_bullet_chars))-1
|
||||
@ -922,7 +922,7 @@ endfunction "}}}
|
||||
|
||||
function! s:decrease_level(item) "{{{
|
||||
let removed_indent = 0
|
||||
if vimwiki#vars#get_wikilocal('syntax') ==? 'media' && a:item.type == 1 &&
|
||||
if vimwiki#vars#get_wikilocal('recurring_bullets') && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
if s:string_length(a:item.mrkr) >= 2
|
||||
call s:substitute_string_in_line(a:item.lnum,
|
||||
@ -944,7 +944,7 @@ endfunction "}}}
|
||||
|
||||
function! s:increase_level(item) "{{{
|
||||
let additional_indent = 0
|
||||
if vimwiki#vars#get_wikilocal('syntax') ==? 'media' && a:item.type == 1 &&
|
||||
if vimwiki#vars#get_wikilocal('recurring_bullets') && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
|
||||
\ s:first_char(a:item.mrkr))
|
||||
@ -966,7 +966,7 @@ endfunction "}}}
|
||||
"a:indent_by can be negative
|
||||
function! s:indent_line_by(lnum, indent_by) "{{{
|
||||
let item = s:get_item(a:lnum)
|
||||
if vimwiki#vars#get_wikilocal('syntax') ==? 'media' && item.type == 1 &&
|
||||
if vimwiki#vars#get_wikilocal('recurring_bullets') && item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(item.mrkr)) > -1
|
||||
if a:indent_by > 0
|
||||
call s:substitute_string_in_line(a:lnum, item.mrkr,
|
||||
@ -1112,7 +1112,7 @@ endfunction "}}}
|
||||
function! s:set_new_mrkr(item, new_mrkr) "{{{
|
||||
if a:item.type == 0
|
||||
call s:substitute_rx_in_line(a:item.lnum, '^\s*\zs\ze', a:new_mrkr.' ')
|
||||
if indent(a:item.lnum) == 0 && vimwiki#vars#get_wikilocal('syntax') !=? 'media'
|
||||
if indent(a:item.lnum) == 0 && !vimwiki#vars#get_wikilocal('recurring_bullets')
|
||||
call s:set_indent(a:item.lnum, vimwiki#lst#get_list_margin())
|
||||
endif
|
||||
else
|
||||
@ -1193,7 +1193,7 @@ endfunction "}}}
|
||||
|
||||
"sets kind of the item depending on neighbor items and the parent item
|
||||
function! s:adjust_mrkr(item) "{{{
|
||||
if a:item.type == 0 || vimwiki#vars#get_wikilocal('syntax') ==? 'media'
|
||||
if a:item.type == 0 || vimwiki#vars#get_wikilocal('recurring_bullets')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1223,7 +1223,7 @@ function! s:clone_marker_from_to(from, to) "{{{
|
||||
if item_from.type == 0 | return | endif
|
||||
let new_mrkr = item_from.mrkr . ' '
|
||||
call s:substitute_rx_in_line(a:to, '^\s*', new_mrkr)
|
||||
let new_indent = ( vimwiki#vars#get_wikilocal('syntax') !=? 'media' ? indent(a:from) : 0 )
|
||||
let new_indent = ( vimwiki#vars#get_wikilocal('recurring_bullets') ? 0 : indent(a:from) )
|
||||
call s:set_indent(a:to, new_indent)
|
||||
if item_from.cb != ''
|
||||
call s:create_cb(s:get_item(a:to))
|
||||
@ -1460,49 +1460,6 @@ endfunction "}}}
|
||||
"handle keys }}}
|
||||
|
||||
"misc stuff {{{
|
||||
function! vimwiki#lst#setup_marker_infos() "{{{
|
||||
let s:rx_bullet_chars = '['.join(keys(g:vimwiki_bullet_types), '').']\+'
|
||||
|
||||
let s:multiple_bullet_chars = []
|
||||
for i in keys(g:vimwiki_bullet_types)
|
||||
if g:vimwiki_bullet_types[i] == 1
|
||||
call add(s:multiple_bullet_chars, i)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let s:number_kinds = []
|
||||
let s:number_divisors = ""
|
||||
for i in g:vimwiki_number_types
|
||||
call add(s:number_kinds, i[0])
|
||||
let s:number_divisors .= vimwiki#u#escape(i[1])
|
||||
endfor
|
||||
|
||||
let s:char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+',
|
||||
\ 'a': '\l\{1,2}', 'A': '\u\{1,2}'}
|
||||
|
||||
"create regexp for bulleted list items
|
||||
let g:vimwiki_rxListBullet = join( map(keys(g:vimwiki_bullet_types),
|
||||
\'vimwiki#u#escape(v:val).repeat("\\+", g:vimwiki_bullet_types[v:val])'
|
||||
\ ) , '\|')
|
||||
|
||||
"create regex for numbered list items
|
||||
if !empty(g:vimwiki_number_types)
|
||||
let g:vimwiki_rxListNumber = '\C\%('
|
||||
for type in g:vimwiki_number_types[:-2]
|
||||
let g:vimwiki_rxListNumber .= s:char_to_rx[type[0]] .
|
||||
\ vimwiki#u#escape(type[1]) . '\|'
|
||||
endfor
|
||||
let g:vimwiki_rxListNumber .= s:char_to_rx[g:vimwiki_number_types[-1][0]].
|
||||
\ vimwiki#u#escape(g:vimwiki_number_types[-1][1]) . '\)'
|
||||
else
|
||||
"regex that matches nothing
|
||||
let g:vimwiki_rxListNumber = '$^'
|
||||
endif
|
||||
|
||||
"the user can set the listsyms as string, but vimwiki needs a list
|
||||
let g:vimwiki_listsyms_list = split(vimwiki#vars#get_global('listsyms'), '\zs')
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#lst#TO_list_item(inner, visual) "{{{
|
||||
let lnum = prevnonblank('.')
|
||||
let item = s:get_corresponding_item(lnum)
|
||||
|
@ -80,6 +80,106 @@ function! s:populate_global_variables()
|
||||
\ '\)'
|
||||
|
||||
let g:vimwiki_global_vars['rxWeblinkUrl'] = rxWebProtocols . '\S\{-1,}'. '\%(([^ \t()]*)\)\='
|
||||
|
||||
let wikilink_prefix = '[['
|
||||
let wikilink_suffix = ']]'
|
||||
let wikilink_separator = '|'
|
||||
let g:vimwiki_global_vars.rx_wikilink_prefix = vimwiki#u#escape(wikilink_prefix)
|
||||
let g:vimwiki_global_vars.rx_wikilink_suffix = vimwiki#u#escape(wikilink_suffix)
|
||||
let g:vimwiki_global_vars.rx_wikilink_separator = vimwiki#u#escape(wikilink_separator)
|
||||
|
||||
" templates for the creation of wiki links
|
||||
" [[URL]]
|
||||
let g:vimwiki_global_vars.WikiLinkTemplate1 = wikilink_prefix . '__LinkUrl__'. wikilink_suffix
|
||||
" [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_global_vars.WikiLinkTemplate2 = wikilink_prefix . '__LinkUrl__'. wikilink_separator
|
||||
\ . '__LinkDescription__' . wikilink_suffix
|
||||
|
||||
" template for matching all wiki links with a given target file
|
||||
let g:vimwiki_global_vars.WikiLinkMatchUrlTemplate =
|
||||
\ g:vimwiki_global_vars.rx_wikilink_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ g:vimwiki_global_vars.rx_wikilink_suffix .
|
||||
\ '\|' .
|
||||
\ g:vimwiki_global_vars.rx_wikilink_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ g:vimwiki_global_vars.rx_wikilink_separator .
|
||||
\ '.*' .
|
||||
\ g:vimwiki_global_vars.rx_wikilink_suffix
|
||||
|
||||
let valid_chars = '[^\\\]]'
|
||||
let g:vimwiki_global_vars.rxWikiLinkUrl = valid_chars.'\{-}'
|
||||
let g:vimwiki_global_vars.rxWikiLinkDescr = valid_chars.'\{-}'
|
||||
|
||||
" this regexp defines what can form a link when the user presses <CR> in the
|
||||
" buffer (and not on a link) to create a link
|
||||
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
|
||||
" non-Ascii characters
|
||||
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
||||
|
||||
" [[URL]], or [[URL|DESCRIPTION]]
|
||||
" a) match [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_global_vars.rxWikiLink = g:vimwiki_global_vars.rx_wikilink_prefix.
|
||||
\ g:vimwiki_global_vars.rxWikiLinkUrl.'\%('.g:vimwiki_global_vars.rx_wikilink_separator.
|
||||
\ g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
|
||||
" b) match URL within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_global_vars.rxWikiLinkMatchUrl = g:vimwiki_global_vars.rx_wikilink_prefix.
|
||||
\ '\zs'. g:vimwiki_global_vars.rxWikiLinkUrl.'\ze\%('. g:vimwiki_global_vars.rx_wikilink_separator.
|
||||
\ g:vimwiki_global_vars.rxWikiLinkDescr.'\)\?'.g:vimwiki_global_vars.rx_wikilink_suffix
|
||||
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_global_vars.rxWikiLinkMatchDescr = g:vimwiki_global_vars.rx_wikilink_prefix.
|
||||
\ g:vimwiki_global_vars.rxWikiLinkUrl . g:vimwiki_global_vars.rx_wikilink_separator.'\%('.
|
||||
\ '\zs'. g:vimwiki_global_vars.rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_global_vars.rx_wikilink_suffix
|
||||
|
||||
let rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix . g:vimwiki_global_vars.rxWikiLinkUrl .
|
||||
\ g:vimwiki_global_vars.rx_wikilink_separator
|
||||
let rx_wikilink_suffix1 = g:vimwiki_global_vars.rx_wikilink_suffix
|
||||
|
||||
let g:vimwiki_global_vars.rxWikiInclPrefix = '{{'
|
||||
let g:vimwiki_global_vars.rxWikiInclSuffix = '}}'
|
||||
let g:vimwiki_global_vars.rxWikiInclSeparator = '|'
|
||||
" '{{__LinkUrl__}}'
|
||||
let g:vimwiki_global_vars.WikiInclTemplate1 = g:vimwiki_global_vars.rxWikiInclPrefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_global_vars.rxWikiInclSuffix
|
||||
" '{{__LinkUrl____LinkDescription__}}'
|
||||
let g:vimwiki_global_vars.WikiInclTemplate2 = g:vimwiki_global_vars.rxWikiInclPrefix . '__LinkUrl__'.
|
||||
\ '__LinkDescription__'.
|
||||
\ g:vimwiki_global_vars.rxWikiInclSuffix
|
||||
|
||||
let valid_chars = '[^\\\}]'
|
||||
let g:vimwiki_global_vars.rxWikiInclUrl = valid_chars.'\{-}'
|
||||
let g:vimwiki_global_vars.rxWikiInclArg = valid_chars.'\{-}'
|
||||
let g:vimwiki_global_vars.rxWikiInclArgs = '\%('. g:vimwiki_global_vars.rxWikiInclSeparator.
|
||||
\ g:vimwiki_global_vars.rxWikiInclArg. '\)'.'\{-}'
|
||||
|
||||
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
|
||||
" *a) match {{URL}[{...}]}
|
||||
let g:vimwiki_global_vars.rxWikiIncl = g:vimwiki_global_vars.rxWikiInclPrefix.
|
||||
\ g:vimwiki_global_vars.rxWikiInclUrl.
|
||||
\ g:vimwiki_global_vars.rxWikiInclArgs. g:vimwiki_global_vars.rxWikiInclSuffix
|
||||
" *b) match URL within {{URL}[{...}]}
|
||||
let g:vimwiki_global_vars.rxWikiInclMatchUrl = g:vimwiki_global_vars.rxWikiInclPrefix.
|
||||
\ '\zs'. g:vimwiki_global_vars.rxWikiInclUrl . '\ze'.
|
||||
\ g:vimwiki_global_vars.rxWikiInclArgs . g:vimwiki_global_vars.rxWikiInclSuffix
|
||||
|
||||
let g:vimwiki_global_vars.rxWikiInclPrefix1 = g:vimwiki_global_vars.rxWikiInclPrefix.
|
||||
\ g:vimwiki_global_vars.rxWikiInclUrl . g:vimwiki_global_vars.rxWikiInclSeparator
|
||||
let g:vimwiki_global_vars.rxWikiInclSuffix1 = g:vimwiki_global_vars.rxWikiInclArgs.
|
||||
\ g:vimwiki_global_vars.rxWikiInclSuffix
|
||||
|
||||
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
|
||||
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
|
||||
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
|
||||
let g:vimwiki_global_vars.rxWeblink = '\<'. g:vimwiki_global_vars.rxWeblinkUrl . '\S*'
|
||||
" 0a) match URL within URL
|
||||
let g:vimwiki_global_vars.rxWeblinkMatchUrl = g:vimwiki_global_vars.rxWeblink
|
||||
" 0b) match DESCRIPTION within URL
|
||||
let g:vimwiki_global_vars.rxWeblinkMatchDescr = ''
|
||||
|
||||
let g:vimwiki_global_vars.rxAnyLink = g:vimwiki_global_vars.rxWikiLink.'\|'.
|
||||
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.g:vimwiki_global_vars.rxWeblink
|
||||
|
||||
let g:vimwiki_global_vars.rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
|
||||
endfunction
|
||||
|
||||
|
||||
@ -177,11 +277,83 @@ function! s:validate_settings()
|
||||
endfunction
|
||||
|
||||
|
||||
" TODO
|
||||
function! s:populate_syntax_vars(syntax)
|
||||
function! vimwiki#vars#populate_syntax_vars(syntax)
|
||||
if !exists('g:vimwiki_syntax_variables')
|
||||
let g:vimwiki_syntax_variables = {}
|
||||
endif
|
||||
if !has_key(g:vimwiki_syntax_variables, a:syntax)
|
||||
let g:vimwiki_syntax_variables[a:syntax] = {}
|
||||
endif
|
||||
|
||||
execute 'runtime! syntax/vimwiki_'.a:syntax.'.vim'
|
||||
|
||||
" generic stuff
|
||||
let header_symbol = g:vimwiki_syntax_variables[a:syntax].rxH
|
||||
if g:vimwiki_syntax_variables[a:syntax].symH
|
||||
" symmetric headers
|
||||
for i in range(1,6)
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i}_Template = repeat(header_symbol, i).' __Header__ '.repeat(header_symbol, i)
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i} = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'.header_symbol.'\{'.i.'}\s*$'
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i}_Start = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'.header_symbol.'\{'.i.'}\s*$'
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i}_End = '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'.header_symbol.'\{1,'.i.'}\s*$'
|
||||
endfor
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxHeader = '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze\1\s*$'
|
||||
else
|
||||
" asymmetric
|
||||
for i in range(1,6)
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i}_Template = repeat(header_symbol, i).' __Header__'
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i} = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i}_Start = '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxH{i}_End = '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*$'
|
||||
endfor
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxHeader = '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*\ze$'
|
||||
endif
|
||||
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxPreStart = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreStart
|
||||
let g:vimwiki_rxPreEnd = '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||
|
||||
let g:vimwiki_rxMathStart = '^\s*'.g:vimwiki_rxMathStart
|
||||
let g:vimwiki_rxMathEnd = '^\s*'.g:vimwiki_rxMathEnd.'\s*$'
|
||||
|
||||
" list stuff
|
||||
let rx_bullet_chars = '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+'
|
||||
|
||||
let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars = g:vimwiki_syntax_variables[a:syntax].recurring_bullets ? g:vimwiki_syntax_variables[a:syntax].bullet_types : []
|
||||
|
||||
let s:number_kinds = []
|
||||
let s:number_divisors = ""
|
||||
for i in g:vimwiki_number_types
|
||||
call add(s:number_kinds, i[0])
|
||||
let s:number_divisors .= vimwiki#u#escape(i[1])
|
||||
endfor
|
||||
|
||||
let s:char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+',
|
||||
\ 'a': '\l\{1,2}', 'A': '\u\{1,2}'}
|
||||
|
||||
"create regexp for bulleted list items
|
||||
let g:vimwiki_rxListBullet = join( map(keys(bullet_types),
|
||||
\'vimwiki#u#escape(v:val).repeat("\\+", bullet_types[v:val])'
|
||||
\ ) , '\|')
|
||||
|
||||
"create regex for numbered list items
|
||||
if !empty(g:vimwiki_number_types)
|
||||
let g:vimwiki_rxListNumber = '\C\%('
|
||||
for type in g:vimwiki_number_types[:-2]
|
||||
let g:vimwiki_rxListNumber .= s:char_to_rx[type[0]] .
|
||||
\ vimwiki#u#escape(type[1]) . '\|'
|
||||
endfor
|
||||
let g:vimwiki_rxListNumber .= s:char_to_rx[g:vimwiki_number_types[-1][0]].
|
||||
\ vimwiki#u#escape(g:vimwiki_number_types[-1][1]) . '\)'
|
||||
else
|
||||
"regex that matches nothing
|
||||
let g:vimwiki_rxListNumber = '$^'
|
||||
endif
|
||||
|
||||
"the user can set the listsyms as string, but vimwiki needs a list
|
||||
let g:vimwiki_listsyms_list = split(vimwiki#vars#get_global('listsyms'), '\zs')
|
||||
let s:default_syntax.rxListItemWithoutCB = '^\s*\%(\('.s:default_syntax.rxListBullet.'\)\|\('.s:default_syntax.rxListNumber.'\)\)\s'
|
||||
let s:default_syntax.rxListItem = s:default_syntax.rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
|
||||
let s:default_syntax.rxListItemAndChildren = '^\(\s*\)\%('.s:default_syntax.rxListBullet.'\|'.s:default_syntax.rxListNumber.'\)\s\+\['.s:default_syntax.listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||
endfunction
|
||||
|
||||
|
||||
@ -191,12 +363,17 @@ function! vimwiki#vars#init()
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#get_syntaxlocal(syntax, key)
|
||||
if !exists('g:vimwiki_syntax_variables') || !has_key(g:vimwiki_syntax_variables, a:syntax)
|
||||
call s:populate_syntax_vars(a:syntax)
|
||||
function! vimwiki#vars#get_syntaxlocal(key, ...)
|
||||
if a:0
|
||||
let syntax = a:1
|
||||
else
|
||||
let syntax = vimwiki#vars#get_wikilocal('syntax')
|
||||
endif
|
||||
if !exists('g:vimwiki_syntax_variables') || !has_key(g:vimwiki_syntax_variables, syntax)
|
||||
call vimwiki#vars#populate_syntax_vars(syntax)
|
||||
endif
|
||||
|
||||
return g:vimwiki_syntax_variables[a:syntax][a:key]
|
||||
return g:vimwiki_syntax_variables[syntax][a:key]
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -7,8 +7,6 @@ if exists("b:did_ftplugin")
|
||||
endif
|
||||
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
|
||||
|
||||
call vimwiki#u#reload_regexes()
|
||||
call vimwiki#u#reload_omni_regexes()
|
||||
|
||||
" UNDO list {{{
|
||||
" Reset the following options to undo this plugin.
|
||||
@ -78,7 +76,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
|
||||
if a:base =~# '^wiki\d:'
|
||||
let wikinumber = eval(matchstr(a:base, '^wiki\zs\d'))
|
||||
if wikinumber >= len(g:vimwiki_list)
|
||||
if wikinumber >= vimwiki#vars#number_of_wikis()
|
||||
return []
|
||||
endif
|
||||
let prefix = matchstr(a:base, '^wiki\d:\zs.*')
|
||||
@ -141,7 +139,7 @@ setlocal formatoptions-=2
|
||||
setlocal formatoptions+=n
|
||||
|
||||
"Create 'formatlistpat'
|
||||
let &formatlistpat = g:vimwiki_rxListItem
|
||||
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
|
||||
|
||||
if !empty(&langmap)
|
||||
" Valid only if langmap is a comma separated pairs of chars
|
||||
@ -532,7 +530,7 @@ endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRemoveCBInList :VimwikiRemoveCBInList<CR>
|
||||
|
||||
for s:char in keys(g:vimwiki_bullet_types)
|
||||
for s:char in keys(vimwiki#vars#get_syntaxlocal('bullet_types'))
|
||||
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
|
||||
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
|
||||
endif
|
||||
|
@ -16,7 +16,7 @@ set cpo&vim
|
||||
function! s:setup_buffer_leave() "{{{
|
||||
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
||||
" a registered wiki and not a temporary wiki)
|
||||
if vimwiki#vars#get_buffer_var('wiki_nr') == -1
|
||||
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
||||
return
|
||||
endif
|
||||
|
||||
@ -78,7 +78,7 @@ endfunction "}}}
|
||||
function! s:setup_buffer_enter() "{{{
|
||||
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
||||
" a registered wiki and not a temporary wiki)
|
||||
if vimwiki#vars#get_buffer_var('wiki_nr') == -1
|
||||
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -17,134 +17,10 @@ if vimwiki#vars#get_wikilocal('maxhi')
|
||||
\ vimwiki#base#get_wiki_directories(g:vimwiki_current_idx)
|
||||
endif
|
||||
|
||||
let s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
|
||||
|
||||
call vimwiki#u#reload_regexes()
|
||||
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
||||
|
||||
" LINKS: setup of larger regexes {{{
|
||||
|
||||
" LINKS: setup wikilink regexps {{{
|
||||
let s:wikilink_prefix = '[['
|
||||
let s:wikilink_suffix = ']]'
|
||||
let s:wikilink_separator = '|'
|
||||
let s:rx_wikilink_prefix = vimwiki#u#escape(s:wikilink_prefix)
|
||||
let s:rx_wikilink_suffix = vimwiki#u#escape(s:wikilink_suffix)
|
||||
let s:rx_wikilink_separator = vimwiki#u#escape(s:wikilink_separator)
|
||||
|
||||
" templates for the creation of wiki links
|
||||
" [[URL]]
|
||||
let g:vimwiki_WikiLinkTemplate1 = s:wikilink_prefix . '__LinkUrl__'.
|
||||
\ s:wikilink_suffix
|
||||
" [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_WikiLinkTemplate2 = s:wikilink_prefix . '__LinkUrl__'.
|
||||
\ s:wikilink_separator . '__LinkDescription__' . s:wikilink_suffix
|
||||
|
||||
" template for matching all wiki links with a given target file
|
||||
let g:vimwiki_WikiLinkMatchUrlTemplate =
|
||||
\ s:rx_wikilink_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_suffix .
|
||||
\ '\|' .
|
||||
\ s:rx_wikilink_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_separator .
|
||||
\ '.*' .
|
||||
\ s:rx_wikilink_suffix
|
||||
|
||||
let s:valid_chars = '[^\\\]]'
|
||||
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
|
||||
|
||||
" this regexp defines what can form a link when the user presses <CR> in the
|
||||
" buffer (and not on a link) to create a link
|
||||
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
|
||||
" non-Ascii characters
|
||||
let g:vimwiki_rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
||||
|
||||
|
||||
" [[URL]], or [[URL|DESCRIPTION]]
|
||||
" a) match [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLink = s:rx_wikilink_prefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.'\%('.s:rx_wikilink_separator.
|
||||
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
|
||||
" b) match URL within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLinkMatchUrl = s:rx_wikilink_prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. s:rx_wikilink_separator.
|
||||
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
|
||||
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLinkMatchDescr = s:rx_wikilink_prefix.
|
||||
\ g:vimwiki_rxWikiLinkUrl.s:rx_wikilink_separator.'\%('.
|
||||
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. s:rx_wikilink_suffix
|
||||
" }}}
|
||||
|
||||
" LINKS: Syntax helper {{{
|
||||
let s:rx_wikilink_prefix1 = s:rx_wikilink_prefix . g:vimwiki_rxWikiLinkUrl .
|
||||
\ s:rx_wikilink_separator
|
||||
let s:rx_wikilink_suffix1 = s:rx_wikilink_suffix
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: setup of wikiincl regexps {{{
|
||||
let g:vimwiki_rxWikiInclPrefix = '{{'
|
||||
let g:vimwiki_rxWikiInclSuffix = '}}'
|
||||
let g:vimwiki_rxWikiInclSeparator = '|'
|
||||
"
|
||||
" '{{__LinkUrl__}}'
|
||||
let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiInclSuffix
|
||||
" '{{__LinkUrl____LinkDescription__}}'
|
||||
let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
|
||||
\ '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWikiInclSuffix
|
||||
|
||||
|
||||
let s:valid_chars = '[^\\\}]'
|
||||
let g:vimwiki_rxWikiInclUrl = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArg = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
|
||||
"
|
||||
"
|
||||
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
|
||||
" *a) match {{URL}[{...}]}
|
||||
let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix.
|
||||
\ g:vimwiki_rxWikiInclUrl.
|
||||
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
|
||||
" *b) match URL within {{URL}[{...}]}
|
||||
let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiInclUrl. '\ze'.
|
||||
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
|
||||
" }}}
|
||||
|
||||
" LINKS: Syntax helper {{{
|
||||
let g:vimwiki_rxWikiInclPrefix1 = g:vimwiki_rxWikiInclPrefix.
|
||||
\ g:vimwiki_rxWikiInclUrl.g:vimwiki_rxWikiInclSeparator
|
||||
let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
|
||||
\ g:vimwiki_rxWikiInclSuffix
|
||||
" }}}
|
||||
|
||||
" LINKS: Setup weblink regexps {{{
|
||||
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
|
||||
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
|
||||
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
|
||||
" Maxim:
|
||||
" Simplify free-standing links: URL starts with non(letter|digit)scheme till
|
||||
" the whitespace.
|
||||
" Stuart, could you check it with markdown templated links? [](http://...), as
|
||||
" the last bracket is the part of URL now?
|
||||
let g:vimwiki_rxWeblink = '\<'. vimwiki#vars#get_global('rxWeblinkUrl') . '\S*'
|
||||
" 0a) match URL within URL
|
||||
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
|
||||
" 0b) match DESCRIPTION within URL
|
||||
let g:vimwiki_rxWeblinkMatchDescr = ''
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: Setup anylink regexps {{{
|
||||
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
|
||||
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
|
||||
" }}}
|
||||
|
||||
|
||||
" }}} end of Links
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
||||
function! s:add_target_syntax_ON(target, type) " {{{
|
||||
@ -177,34 +53,34 @@ function! s:highlight_existing_links() "{{{
|
||||
|
||||
" match [[URL]]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
|
||||
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
|
||||
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match [[URL|DESCRIPTION]]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
|
||||
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
||||
\ safe_links, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
|
||||
" match {{URL}}
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
|
||||
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
|
||||
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match {{URL|...}}
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
|
||||
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
|
||||
\ safe_links, vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match [[DIRURL]]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
|
||||
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
" match [[DIRURL|DESCRIPTION]]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
||||
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||
endfunction "}}}
|
||||
|
||||
@ -212,21 +88,21 @@ endfunction "}}}
|
||||
" use max highlighting - could be quite slow if there are too many wikifiles
|
||||
if vimwiki#vars#get_wikilocal('maxhi')
|
||||
" WikiLink
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink)
|
||||
call s:add_target_syntax_OFF(vimwiki#vars#get_global('rxWikiLink'))
|
||||
" WikiIncl
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
|
||||
call s:add_target_syntax_OFF(vimwiki#vars#get_global('rxWikiIncl'))
|
||||
|
||||
" Subsequently, links verified on vimwiki's path are highlighted as existing
|
||||
call s:highlight_existing_links()
|
||||
else
|
||||
" Wikilink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
|
||||
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiLink'), 'VimwikiLink')
|
||||
" WikiIncl
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
|
||||
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiIncl'), 'VimwikiLink')
|
||||
endif
|
||||
|
||||
" Weblink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
|
||||
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWeblink'), 'VimwikiLink')
|
||||
|
||||
" WikiLink
|
||||
" All remaining schemes are highlighted automatically
|
||||
@ -237,77 +113,54 @@ let s:rxSchemes = '\%('.
|
||||
|
||||
" a) match [[nonwiki-scheme-URL]]
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
|
||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'), vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'), vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
|
||||
" a) match {{nonwiki-scheme-URL}}
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
|
||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'), vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
" b) match {{nonwiki-scheme-URL}[{...}]}
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
|
||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'), vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||
|
||||
" }}}
|
||||
|
||||
" generic headers "{{{
|
||||
if g:vimwiki_symH
|
||||
"" symmetric
|
||||
for s:i in range(1,6)
|
||||
let g:vimwiki_rxH{s:i}_Template = repeat(g:vimwiki_rxH, s:i).' __Header__ '.repeat(g:vimwiki_rxH, s:i)
|
||||
let g:vimwiki_rxH{s:i} = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.s:i.'}\s*$'
|
||||
let g:vimwiki_rxH{s:i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.s:i.'}\s*$'
|
||||
let g:vimwiki_rxH{s:i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.s:i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{1,'.s:i.'}\s*$'
|
||||
endfor
|
||||
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$'
|
||||
else
|
||||
" asymmetric
|
||||
for s:i in range(1,6)
|
||||
let g:vimwiki_rxH{s:i}_Template = repeat(g:vimwiki_rxH, s:i).' __Header__'
|
||||
let g:vimwiki_rxH{s:i} = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
let g:vimwiki_rxH{s:i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
let g:vimwiki_rxH{s:i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.s:i.'}[^'.g:vimwiki_rxH.'].*$'
|
||||
endfor
|
||||
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$'
|
||||
endif
|
||||
|
||||
" Header levels, 1-6
|
||||
for s:i in range(1,6)
|
||||
execute 'syntax match VimwikiHeader'.s:i.' /'.g:vimwiki_rxH{s:i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
|
||||
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.g:vimwiki_rxH{s:i}_Start.
|
||||
\ '/ end=/'.g:vimwiki_rxH{s:i}_End.'/me=s-1 transparent fold'
|
||||
|
||||
execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.si, s:current_syntax).'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
|
||||
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).
|
||||
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).'/me=s-1 transparent fold'
|
||||
endfor
|
||||
|
||||
|
||||
" }}}
|
||||
|
||||
let g:vimwiki_rxPreStart = '^\s*'.g:vimwiki_rxPreStart
|
||||
let g:vimwiki_rxPreEnd = '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||
|
||||
let g:vimwiki_rxMathStart = '^\s*'.g:vimwiki_rxMathStart
|
||||
let g:vimwiki_rxMathEnd = '^\s*'.g:vimwiki_rxMathEnd.'\s*$'
|
||||
|
||||
" possibly concealed chars " {{{
|
||||
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
|
||||
|
||||
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'.s:conceal
|
||||
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'.s:conceal
|
||||
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'.s:conceal
|
||||
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'.s:conceal
|
||||
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'.s:conceal
|
||||
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'.s:conceal
|
||||
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'.s:conceal
|
||||
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'.s:conceal
|
||||
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.s:conceal
|
||||
execute 'syn match VimwikiEqInChar contained /'.vimwiki#vars#get_syntaxlocal('char_eqin').'/'.s:conceal
|
||||
execute 'syn match VimwikiBoldChar contained /'.vimwiki#vars#get_syntaxlocal('char_bold').'/'.s:conceal
|
||||
execute 'syn match VimwikiItalicChar contained /'.vimwiki#vars#get_syntaxlocal('char_italic').'/'.s:conceal
|
||||
execute 'syn match VimwikiBoldItalicChar contained /'.vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'.s:conceal
|
||||
execute 'syn match VimwikiItalicBoldChar contained /'.vimwiki#vars#get_syntaxlocal('char_italicbold').'/'.s:conceal
|
||||
execute 'syn match VimwikiCodeChar contained /'.vimwiki#vars#get_syntaxlocal('char_code').'/'.s:conceal
|
||||
execute 'syn match VimwikiDelTextChar contained /'.vimwiki#vars#get_syntaxlocal('char_deltext').'/'.s:conceal
|
||||
execute 'syn match VimwikiSuperScript contained /'.vimwiki#vars#get_syntaxlocal('char_superscript').'/'.s:conceal
|
||||
execute 'syn match VimwikiSubScript contained /'.vimwiki#vars#get_syntaxlocal('char_subscript').'/'.s:conceal
|
||||
" }}}
|
||||
|
||||
" concealed link parts " {{{
|
||||
@ -329,35 +182,34 @@ endif
|
||||
" is present) and may be concealed
|
||||
|
||||
" conceal wikilinks
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix1.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix1.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix').'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix').'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_prefix1').'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rx_wikilink_suffix1').'/'.s:options
|
||||
|
||||
" conceal wikiincls
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix').'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix').'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix1').'/'.s:options
|
||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1').'/'.s:options
|
||||
" }}}
|
||||
|
||||
" non concealed chars " {{{
|
||||
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.g:vimwiki_rxH.'\+\)\|\%('.g:vimwiki_rxH.'\+\s*$\)/'
|
||||
execute 'syn match VimwikiEqInCharT contained /'.g:vimwiki_char_eqin.'/'
|
||||
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
|
||||
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
|
||||
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
|
||||
execute 'syn match VimwikiItalicBoldCharT contained /'.g:vimwiki_char_italicbold.'/'
|
||||
execute 'syn match VimwikiCodeCharT contained /'.g:vimwiki_char_code.'/'
|
||||
execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
|
||||
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
|
||||
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
|
||||
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH').'\+\s*$\)/'
|
||||
execute 'syn match VimwikiEqInCharT contained /'.vimwiki#vars#get_syntaxlocal('char_eqin').'/'
|
||||
execute 'syn match VimwikiBoldCharT contained /'.vimwiki#vars#get_syntaxlocal('char_bold').'/'
|
||||
execute 'syn match VimwikiItalicCharT contained /'.vimwiki#vars#get_syntaxlocal('char_italic').'/'
|
||||
execute 'syn match VimwikiBoldItalicCharT contained /'.vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'
|
||||
execute 'syn match VimwikiItalicBoldCharT contained /'.vimwiki#vars#get_syntaxlocal('char_italicbold').'/'
|
||||
execute 'syn match VimwikiCodeCharT contained /'.vimwiki#vars#get_syntaxlocal('char_code').'/'
|
||||
execute 'syn match VimwikiDelTextCharT contained /'.vimwiki#vars#get_syntaxlocal('char_deltext').'/'
|
||||
execute 'syn match VimwikiSuperScriptT contained /'.vimwiki#vars#get_syntaxlocal('char_superscript').'/'
|
||||
execute 'syn match VimwikiSubScriptT contained /'.vimwiki#vars#get_syntaxlocal('char_subscript').'/'
|
||||
|
||||
" Emoticons
|
||||
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
|
||||
|
||||
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
|
||||
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
|
||||
execute 'syntax match VimwikiTodo /'. vimwiki#vars#get_global('rxTodo') .'/'
|
||||
" }}}
|
||||
|
||||
" main syntax groups {{{
|
||||
@ -383,12 +235,12 @@ syntax match VimwikiCellSeparator
|
||||
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
||||
|
||||
" Lists
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/'
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
||||
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/'
|
||||
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
|
||||
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 /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '.
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '.
|
||||
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
|
@ -3,93 +3,102 @@
|
||||
" Desc: Defines default syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" s:default_syntax is kind of a reference to the dict in
|
||||
" g:vimwiki_syntax_variables['default']. It is used here simply as an
|
||||
" abbreviation for the latter.
|
||||
let s:default_syntax = g:vimwiki_syntax_variables['default']
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
let g:vimwiki_char_eqin = '\$'
|
||||
let s:default_syntax.rxEqIn = '\$[^$`]\+\$'
|
||||
let s:default_syntax.char_eqin = '\$'
|
||||
|
||||
" text: *strong*
|
||||
" let g:vimwiki_rxBold = '\*[^*]\+\*'
|
||||
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
" let s:default_syntax.rxBold = '\*[^*]\+\*'
|
||||
let s:default_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'\*'.
|
||||
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
|
||||
\'\*'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_bold = '*'
|
||||
let s:default_syntax.char_bold = '*'
|
||||
|
||||
" text: _emphasis_
|
||||
" let g:vimwiki_rxItalic = '_[^_]\+_'
|
||||
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
" let s:default_syntax.rxItalic = '_[^_]\+_'
|
||||
let s:default_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'_'.
|
||||
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
|
||||
\'_'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_italic = '_'
|
||||
let s:default_syntax.char_italic = '_'
|
||||
|
||||
" text: *_bold italic_* or _*italic bold*_
|
||||
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
let s:default_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'\*_'.
|
||||
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
|
||||
\'_\*'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_bolditalic = '\*_'
|
||||
let s:default_syntax.char_bolditalic = '\*_'
|
||||
|
||||
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
let s:default_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'_\*'.
|
||||
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
|
||||
\'\*_'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_italicbold = '_\*'
|
||||
let s:default_syntax.char_italicbold = '_\*'
|
||||
|
||||
" text: `code`
|
||||
let g:vimwiki_rxCode = '`[^`]\+`'
|
||||
let g:vimwiki_char_code = '`'
|
||||
let s:default_syntax.rxCode = '`[^`]\+`'
|
||||
let s:default_syntax.char_code = '`'
|
||||
|
||||
" text: ~~deleted text~~
|
||||
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
|
||||
let g:vimwiki_char_deltext = '\~\~'
|
||||
let s:default_syntax.rxDelText = '\~\~[^~`]\+\~\~'
|
||||
let s:default_syntax.char_deltext = '\~\~'
|
||||
|
||||
" text: ^superscript^
|
||||
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
|
||||
let g:vimwiki_char_superscript = '^'
|
||||
let s:default_syntax.rxSuperScript = '\^[^^`]\+\^'
|
||||
let s:default_syntax.char_superscript = '^'
|
||||
|
||||
" text: ,,subscript,,
|
||||
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
|
||||
let g:vimwiki_char_subscript = ',,'
|
||||
let s:default_syntax.rxSubScript = ',,[^,`]\+,,'
|
||||
let s:default_syntax.char_subscript = ',,'
|
||||
|
||||
" generic headers
|
||||
let g:vimwiki_rxH = '='
|
||||
let g:vimwiki_symH = 1
|
||||
let s:default_syntax.rxH = '='
|
||||
let s:default_syntax.symH = 1
|
||||
|
||||
|
||||
|
||||
" <hr>, horizontal rule
|
||||
let g:vimwiki_rxHR = '^-----*$'
|
||||
let s:default_syntax.rxHR = '^-----*$'
|
||||
|
||||
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
let s:default_syntax.rxTableSep = '|'
|
||||
|
||||
" Lists
|
||||
"1 means multiple bullets, like * ** ***
|
||||
let g:vimwiki_bullet_types = { '-':0, '*':0, '#':0 }
|
||||
let g:vimwiki_number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
|
||||
let s:default_syntax.bullet_types = ['-', '*', '#']
|
||||
" 1 means the bullets can be repeatet to indicate the level, like * ** ***
|
||||
" 0 means the bullets stand on their own and the level is indicated by the indentation
|
||||
let s:default_syntax.recurring_bullets = 0
|
||||
let s:default_syntax.number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
|
||||
"this should contain at least one element
|
||||
"it is used for i_<C-L><C-J> among other things
|
||||
let g:vimwiki_list_markers = ['-', '1.', '*', 'I)', 'a)']
|
||||
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
|
||||
call vimwiki#lst#setup_marker_infos()
|
||||
|
||||
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
|
||||
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||
let s:default_syntax.list_markers = ['-', '1.', '*', 'I)', 'a)']
|
||||
let s:default_syntax.rxListDefine = '::\(\s\|$\)'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '{{{'
|
||||
let g:vimwiki_rxPreEnd = '}}}'
|
||||
let s:default_syntax.rxPreStart = '{{{'
|
||||
let s:default_syntax.rxPreEnd = '}}}'
|
||||
|
||||
" Math block
|
||||
let g:vimwiki_rxMathStart = '{{\$'
|
||||
let g:vimwiki_rxMathEnd = '}}\$'
|
||||
let s:default_syntax.rxMathStart = '{{\$'
|
||||
let s:default_syntax.rxMathEnd = '}}\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
" see also g:vimwiki_default_tag_search
|
||||
let s:default_syntax.rxComment = '^\s*%%.*$'
|
||||
let s:default_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
|
||||
let s:default_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||
let s:default_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
||||
let s:default_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let s:default_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let s:default_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||
let s:default_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||
let s:default_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||
|
@ -50,7 +50,8 @@ let g:vimwiki_rxHR = '^-----*$'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
|
||||
" Lists
|
||||
let g:vimwiki_bullet_types = { '*':1, '#':1 }
|
||||
let g:vimwiki_bullet_types = ['*', '#']
|
||||
let s:media_syntax.recurring_bullets = 1
|
||||
let g:vimwiki_number_types = []
|
||||
let g:vimwiki_list_markers = ['*', '#']
|
||||
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
|
||||
|
Loading…
Reference in New Issue
Block a user