Merge branch 'refactor-internal-state-handling' into dev
Conflicts: autoload/vimwiki/base.vim autoload/vimwiki/diary.vim autoload/vimwiki/html.vim autoload/vimwiki/lst.vim autoload/vimwiki/markdown_base.vim doc/vimwiki.txt ftplugin/vimwiki.vim plugin/vimwiki.vim syntax/vimwiki.vim syntax/vimwiki_default.vim syntax/vimwiki_markdown.vim syntax/vimwiki_media.vim
This commit is contained in:
commit
f8ee21aa64
@ -20,165 +20,17 @@ function! s:vimwiki_get_known_syntaxes() " {{{
|
||||
" Getting all syntaxes that different wikis could have
|
||||
let syntaxes = {}
|
||||
let syntaxes['default'] = 1
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'syntax')
|
||||
let syntaxes[wiki.syntax] = 1
|
||||
endif
|
||||
for wiki_nr in range(vimwiki#vars#number_of_wikis())
|
||||
let wiki_syntax = vimwiki#vars#get_wikilocal('syntax', wiki_nr)
|
||||
let syntaxes[wiki_syntax] = 1
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for syn in values(g:vimwiki_ext2syntax)
|
||||
" also consider the syntaxes from g:vimwiki_ext2syntax
|
||||
for syn in values(vimwiki#vars#get_global('ext2syntax'))
|
||||
let syntaxes[syn] = 1
|
||||
endfor
|
||||
return keys(syntaxes)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#apply_wiki_options
|
||||
function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
||||
" wiki using the options dictionary
|
||||
for kk in keys(a:options)
|
||||
let g:vimwiki_list[g:vimwiki_current_idx][kk] = a:options[kk]
|
||||
endfor
|
||||
call Validate_wiki_options(g:vimwiki_current_idx)
|
||||
call vimwiki#base#setup_buffer_state(g:vimwiki_current_idx)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#read_wiki_options
|
||||
function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" options from the current page's directory, or its ancesters. If a file
|
||||
" named vimwiki.vimrc is found, which declares a wiki-options dictionary
|
||||
" named g:local_wiki, a message alerts the user that an update has been
|
||||
" found and may be applied. If the argument check=1, the user is queried
|
||||
" before applying the update to the current wiki's option.
|
||||
|
||||
" Save global vimwiki options ... after all, the global list is often
|
||||
" initialized for the first time in vimrc files, and we don't want to
|
||||
" overwrite !! (not to mention all the other globals ...)
|
||||
let l:vimwiki_list = deepcopy(g:vimwiki_list, 1)
|
||||
"
|
||||
if a:check > 1
|
||||
call vimwiki#base#print_wiki_state()
|
||||
echo " \n"
|
||||
endif
|
||||
"
|
||||
let g:local_wiki = {}
|
||||
let done = 0
|
||||
" ... start the wild-goose chase!
|
||||
for invsubdir in ['.', '..', '../..', '../../..']
|
||||
" other names are possible, but most vimrc files will cause grief!
|
||||
for nm in ['vimwiki.vimrc']
|
||||
" TODO: use an alternate strategy, instead of source, to read options
|
||||
if done
|
||||
continue
|
||||
endif
|
||||
"
|
||||
let local_wiki_options_filename = expand('%:p:h').'/'.invsubdir.'/'.nm
|
||||
if !filereadable(local_wiki_options_filename)
|
||||
continue
|
||||
endif
|
||||
"
|
||||
echo "\nFound file : ".local_wiki_options_filename
|
||||
let query = "Vimwiki: Check for options in this file [Y]es/[n]o? "
|
||||
if a:check > 0 && input(query) =~? '^n')
|
||||
continue
|
||||
endif
|
||||
"
|
||||
try
|
||||
execute 'source '.local_wiki_options_filename
|
||||
catch
|
||||
endtry
|
||||
if empty(g:local_wiki)
|
||||
continue
|
||||
endif
|
||||
"
|
||||
if a:check > 0
|
||||
echo "\n\nFound wiki options\n g:local_wiki = ".string(g:local_wiki)
|
||||
let query = "Vimwiki: Apply these options [Y]es/[n]o? "
|
||||
if input(query) =~? '^n'
|
||||
let g:local_wiki = {}
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
"
|
||||
" restore global list
|
||||
" - this prevents corruption by g:vimwiki_list in options_file
|
||||
let g:vimwiki_list = deepcopy(l:vimwiki_list, 1)
|
||||
"
|
||||
call vimwiki#base#apply_wiki_options(g:local_wiki)
|
||||
let done = 1
|
||||
endfor
|
||||
endfor
|
||||
if !done
|
||||
"
|
||||
" restore global list, if no local options were found
|
||||
" - this prevents corruption by g:vimwiki_list in options_file
|
||||
let g:vimwiki_list = deepcopy(l:vimwiki_list, 1)
|
||||
"
|
||||
endif
|
||||
if a:check > 1
|
||||
echo " \n "
|
||||
if done
|
||||
call vimwiki#base#print_wiki_state()
|
||||
else
|
||||
echo "Vimwiki: No options were applied."
|
||||
endif
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#setup_buffer_state
|
||||
function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variables
|
||||
" Only call this function *after* opening a wiki page.
|
||||
if a:idx < 0
|
||||
return
|
||||
endif
|
||||
|
||||
let g:vimwiki_current_idx = a:idx
|
||||
|
||||
" The following state depends on the current active wiki page
|
||||
let subdir = vimwiki#base#current_subdir(a:idx)
|
||||
call VimwikiSet('subdir', subdir, a:idx)
|
||||
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx)
|
||||
|
||||
if g:vimwiki_auto_chdir == 1
|
||||
exe 'lcd' VimwikiGet('path')
|
||||
endif
|
||||
|
||||
" update cache
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#cache_buffer_state
|
||||
function! vimwiki#base#cache_buffer_state() "{{{
|
||||
let b:vimwiki_idx = g:vimwiki_current_idx
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#recall_buffer_state
|
||||
function! vimwiki#base#recall_buffer_state() "{{{
|
||||
if !exists('b:vimwiki_idx')
|
||||
return 0
|
||||
else
|
||||
let g:vimwiki_current_idx = b:vimwiki_idx
|
||||
return 1
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#print_wiki_state
|
||||
function! vimwiki#base#print_wiki_state() "{{{ print wiki options
|
||||
" and buffer state variables
|
||||
let g_width = 18
|
||||
let b_width = 18
|
||||
echo "- Wiki Options (idx=".g:vimwiki_current_idx.") -"
|
||||
for kk in VimwikiGetOptionNames()
|
||||
echo " '".kk."': ".repeat(' ', g_width-len(kk)).string(VimwikiGet(kk))
|
||||
endfor
|
||||
if !exists('b:vimwiki_list')
|
||||
return
|
||||
endif
|
||||
echo "- Cached Variables -"
|
||||
for kk in keys(b:vimwiki_list)
|
||||
echo " '".kk."': ".repeat(' ', b_width-len(kk)).string(b:vimwiki_list[kk])
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#file_pattern
|
||||
function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
|
||||
" string. Aim to support *all* special characters, forcing the user to choose
|
||||
@ -215,8 +67,8 @@ function! vimwiki#base#subdir(path, filename) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#current_subdir
|
||||
function! vimwiki#base#current_subdir(idx)"{{{
|
||||
return vimwiki#base#subdir(VimwikiGet('path', a:idx), expand('%:p'))
|
||||
function! vimwiki#base#current_subdir()"{{{
|
||||
return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), expand('%:p'))
|
||||
endfunction"}}}
|
||||
|
||||
" vimwiki#base#invsubdir
|
||||
@ -228,16 +80,15 @@ 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)
|
||||
let idx_path = expand(VimwikiGet('path', idx))
|
||||
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(
|
||||
\ vimwiki#path#path_common_pfx(idx_path, path), idx_path)
|
||||
return idx
|
||||
endif
|
||||
let idx += 1
|
||||
endwhile
|
||||
endfor
|
||||
|
||||
" an orphan page has been detected
|
||||
return -1
|
||||
@ -253,14 +104,14 @@ 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 = vimwiki#path#current_wiki_file()
|
||||
endif
|
||||
|
||||
let link_text = a:link_text
|
||||
|
||||
" if link is schemeless add wikiN: scheme
|
||||
if link_text !~# g:vimwiki_rxSchemeUrl
|
||||
if link_text !~# vimwiki#vars#get_global('rxSchemeUrl')
|
||||
let link_text = 'wiki'.source_wiki.':'.link_text
|
||||
endif
|
||||
|
||||
@ -274,7 +125,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
||||
|
||||
|
||||
" extract scheme
|
||||
let link_infos.scheme = matchstr(link_text, g:vimwiki_rxSchemeUrlMatchScheme)
|
||||
let link_infos.scheme = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchScheme'))
|
||||
if link_infos.scheme == '' || link_text == ''
|
||||
let link_infos.filename = '' " malformed link
|
||||
return link_infos
|
||||
@ -283,7 +134,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
||||
let link_infos.filename = link_text " unknown scheme, may be a weblink
|
||||
return link_infos
|
||||
endif
|
||||
let link_text = matchstr(link_text, g:vimwiki_rxSchemeUrlMatchUrl)
|
||||
let link_text = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchUrl'))
|
||||
|
||||
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' ||
|
||||
\ link_infos.scheme ==# 'diary'
|
||||
@ -317,34 +168,34 @@ 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
|
||||
|
||||
if !is_relative || link_infos.index != source_wiki
|
||||
let root_dir = VimwikiGet('path', link_infos.index)
|
||||
let root_dir = vimwiki#vars#get_wikilocal('path', link_infos.index)
|
||||
endif
|
||||
|
||||
let link_infos.filename = root_dir . link_text
|
||||
|
||||
if vimwiki#path#is_link_to_dir(link_text)
|
||||
if g:vimwiki_dir_link != ''
|
||||
let link_infos.filename .= g:vimwiki_dir_link .
|
||||
\ VimwikiGet('ext', link_infos.index)
|
||||
if vimwiki#vars#get_global('dir_link') != ''
|
||||
let link_infos.filename .= vimwiki#vars#get_global('dir_link') .
|
||||
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
|
||||
endif
|
||||
else
|
||||
let link_infos.filename .= VimwikiGet('ext', link_infos.index)
|
||||
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
|
||||
endif
|
||||
|
||||
elseif link_infos.scheme ==# 'diary'
|
||||
let link_infos.index = source_wiki
|
||||
|
||||
let link_infos.filename =
|
||||
\ VimwikiGet('path', link_infos.index) .
|
||||
\ VimwikiGet('diary_rel_path', link_infos.index) .
|
||||
\ vimwiki#vars#get_wikilocal('path', link_infos.index) .
|
||||
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
|
||||
\ link_text .
|
||||
\ VimwikiGet('ext', link_infos.index)
|
||||
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
|
||||
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local')
|
||||
\ && is_relative
|
||||
let link_infos.filename = simplify(root_dir . link_text)
|
||||
@ -429,10 +280,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
|
||||
@ -444,9 +291,9 @@ function! vimwiki#base#get_globlinks_escaped() abort "{{{only get links from the
|
||||
let orig_pwd = getcwd()
|
||||
lcd! %:h
|
||||
" all path are relative to the current file's location
|
||||
let globlinks = glob('*'.VimwikiGet('ext'),1)."\n"
|
||||
let globlinks = glob('*'.vimwiki#vars#get_wikilocal('ext'), 1)."\n"
|
||||
" remove extensions
|
||||
let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\ze\n', '', 'g')
|
||||
let globlinks = substitute(globlinks, '\'.vimwiki#vars#get_wikilocal('ext').'\ze\n', '', 'g')
|
||||
" restore the original working directory
|
||||
exe 'lcd! '.orig_pwd
|
||||
" convert to a List
|
||||
@ -463,7 +310,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()).
|
||||
@ -472,7 +319,8 @@ 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.
|
||||
\ s:safesubstitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', link, ''))
|
||||
\ s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
|
||||
\ '__LinkUrl__', link, ''))
|
||||
endif
|
||||
endfor
|
||||
|
||||
@ -488,7 +336,7 @@ function! vimwiki#base#goto(...) "{{{
|
||||
let anchor = a:0 > 1 ? a:2 : ''
|
||||
|
||||
call vimwiki#base#edit_file(':e',
|
||||
\ VimwikiGet('path') . key . VimwikiGet('ext'),
|
||||
\ vimwiki#vars#get_wikilocal('path') . key . vimwiki#vars#get_wikilocal('ext'),
|
||||
\ anchor)
|
||||
endfunction "}}}
|
||||
|
||||
@ -496,8 +344,8 @@ endfunction "}}}
|
||||
function! vimwiki#base#backlinks() "{{{
|
||||
let current_filename = expand("%:p")
|
||||
let locations = []
|
||||
for idx in range(len(g:vimwiki_list))
|
||||
let syntax = VimwikiGet('syntax', idx)
|
||||
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
|
||||
let links = s:get_links(source_file, idx)
|
||||
@ -525,20 +373,20 @@ endfunction "}}}
|
||||
function! vimwiki#base#find_files(wiki_nr, directories_only)
|
||||
let wiki_nr = a:wiki_nr
|
||||
if wiki_nr >= 0
|
||||
let root_directory = VimwikiGet('path', wiki_nr)
|
||||
let root_directory = vimwiki#vars#get_wikilocal('path', wiki_nr)
|
||||
else
|
||||
let root_directory = VimwikiGet('path').VimwikiGet('diary_rel_path')
|
||||
let wiki_nr = g:vimwiki_current_idx
|
||||
let root_directory = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
endif
|
||||
if a:directories_only
|
||||
let ext = '/'
|
||||
else
|
||||
let ext = VimwikiGet('ext', wiki_nr)
|
||||
let ext = vimwiki#vars#get_wikilocal('ext', wiki_nr)
|
||||
endif
|
||||
" if current wiki is temporary -- was added by an arbitrary wiki file then do
|
||||
" not search wiki files in subdirectories. Or it would hang the system if
|
||||
" wiki file was created in $HOME or C:/ dirs.
|
||||
if VimwikiGet('temp', wiki_nr)
|
||||
if vimwiki#vars#get_wikilocal('is_temporary_wiki', wiki_nr)
|
||||
let pattern = '*'.ext
|
||||
else
|
||||
let pattern = '**/*'.ext
|
||||
@ -552,12 +400,12 @@ 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 = VimwikiGet('path').VimwikiGet('diary_rel_path')
|
||||
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
else
|
||||
let cwd = VimwikiGet('path', a:wiki_nr)
|
||||
let cwd = vimwiki#vars#get_wikilocal('path', a:wiki_nr)
|
||||
endif
|
||||
let result = []
|
||||
for wikifile in files
|
||||
@ -567,10 +415,10 @@ 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
|
||||
let cwd = VimwikiGet('path')
|
||||
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let cwd = vimwiki#vars#get_wikilocal('path')
|
||||
elseif a:wiki_nr < 0
|
||||
let cwd = VimwikiGet('path').VimwikiGet('diary_rel_path')
|
||||
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
endif
|
||||
let wikifile = fnamemodify(wikifile, ':r') " strip extension
|
||||
let wikifile = '/'.vimwiki#path#relpath(cwd, wikifile)
|
||||
@ -583,17 +431,17 @@ 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 = VimwikiGet('path')
|
||||
let root_dir = vimwiki#vars#get_wikilocal('path')
|
||||
else
|
||||
let cwd = VimwikiGet('path', a:wiki_nr)
|
||||
let cwd = vimwiki#vars#get_wikilocal('path', a:wiki_nr)
|
||||
endif
|
||||
let result = ['./']
|
||||
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
|
||||
@ -606,9 +454,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 = []
|
||||
@ -682,14 +530,17 @@ function! s:jump_to_anchor(anchor) "{{{
|
||||
let anchor = vimwiki#u#escape(a:anchor)
|
||||
|
||||
let segments = split(anchor, '#', 0)
|
||||
|
||||
for segment in segments
|
||||
|
||||
let anchor_header = s:safesubstitute(
|
||||
\ g:vimwiki_{VimwikiGet('syntax')}_header_match,
|
||||
\ vimwiki#vars#get_syntaxlocal('header_match'),
|
||||
\ '__Header__', segment, '')
|
||||
let anchor_bold = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match,
|
||||
let anchor_bold = s:safesubstitute(
|
||||
\ vimwiki#vars#get_syntaxlocal('bold_match'),
|
||||
\ '__Text__', segment, '')
|
||||
let anchor_tag = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match,
|
||||
let anchor_tag = s:safesubstitute(
|
||||
\ vimwiki#vars#get_syntaxlocal('tag_match'),
|
||||
\ '__Tag__', segment, '')
|
||||
|
||||
if !search(anchor_tag, 'Wc')
|
||||
@ -711,8 +562,8 @@ function! s:get_links(wikifile, idx) "{{{
|
||||
return []
|
||||
endif
|
||||
|
||||
let syntax = VimwikiGet('syntax', a:idx)
|
||||
let rx_link = g:vimwiki_{syntax}_wikilink
|
||||
let syntax = vimwiki#vars#get_wikilocal('syntax', a:idx)
|
||||
let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax)
|
||||
let links = []
|
||||
let lnum = 0
|
||||
|
||||
@ -742,8 +593,8 @@ function! vimwiki#base#check_links() "{{{
|
||||
let anchors_of_files = {}
|
||||
let links_of_files = {}
|
||||
let errors = []
|
||||
for idx in range(len(g:vimwiki_list))
|
||||
let syntax = VimwikiGet('syntax', idx)
|
||||
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
|
||||
let links_of_files[wikifile] = s:get_links(wikifile, idx)
|
||||
@ -796,9 +647,9 @@ function! vimwiki#base#check_links() "{{{
|
||||
endfor
|
||||
|
||||
" mark every index file as reachable
|
||||
for idx in range(len(g:vimwiki_list))
|
||||
let index_file = VimwikiGet('path', idx) . VimwikiGet('index', idx) .
|
||||
\ VimwikiGet('ext', idx)
|
||||
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)
|
||||
let reachable_wikifiles[index_file] = 1
|
||||
endif
|
||||
@ -864,11 +715,15 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
||||
" getpos() directly after this command. Strange.
|
||||
if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p')))
|
||||
execute a:command.' '.fname
|
||||
|
||||
" If the opened file was not already loaded by Vim, an autocommand is
|
||||
" triggered at this point
|
||||
|
||||
" Make sure no other plugin takes ownership over the new file. Vimwiki
|
||||
" rules them all! Well, except for directories, which may be opened with
|
||||
" Netrw
|
||||
if &filetype != 'vimwiki' && fname !~ '\m/$'
|
||||
set filetype=vimwiki
|
||||
setfiletype vimwiki
|
||||
endif
|
||||
endif
|
||||
if a:anchor != ''
|
||||
@ -879,7 +734,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
||||
" a:1 -- previous vimwiki link to save
|
||||
" a:2 -- should we update previous link
|
||||
if a:0 && a:2 && len(a:1) > 0
|
||||
let b:vimwiki_prev_link = a:1
|
||||
call vimwiki#vars#set_bufferlocal('prev_link', a:1)
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
@ -941,15 +796,15 @@ 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
|
||||
let sep = ' '
|
||||
echohl None
|
||||
endif
|
||||
echo (idx + 1).sep.VimwikiGet('path', idx)
|
||||
echo (idx + 1) . sep . vimwiki#vars#get_wikilocal('path', idx)
|
||||
let idx += 1
|
||||
endwhile
|
||||
echohl None
|
||||
@ -981,9 +836,9 @@ 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_syntaxlocal('WikiLinkMatchUrlTemplate'), old_fname, '', '')
|
||||
|
||||
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
|
||||
let files = split(glob(vimwiki#vars#get_wikilocal('path').a:dir.'*'.vimwiki#vars#get_wikilocal('ext')), '\n')
|
||||
for fname in files
|
||||
call s:update_wiki_link(fname, old_fname_r, new_fname)
|
||||
endfor
|
||||
@ -1037,8 +892,10 @@ function! s:get_wiki_buffers() "{{{
|
||||
while bcount<=bufnr("$")
|
||||
if bufexists(bcount)
|
||||
let bname = fnamemodify(bufname(bcount), ":p")
|
||||
if bname =~# VimwikiGet('ext')."$"
|
||||
let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
|
||||
" this may find buffers that are not part of the current wiki, but that
|
||||
" doesn't hurt
|
||||
if bname =~# vimwiki#vars#get_wikilocal('ext')."$"
|
||||
let bitem = [bname, vimwiki#vars#get_bufferlocal('prev_link', bcount)]
|
||||
call add(blist, bitem)
|
||||
endif
|
||||
endif
|
||||
@ -1051,7 +908,7 @@ endfunction " }}}
|
||||
function! s:open_wiki_buffer(item) "{{{
|
||||
call vimwiki#base#edit_file(':e', a:item[0], '')
|
||||
if !empty(a:item[1])
|
||||
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
|
||||
call vimwiki#vars#set_bufferlocal('prev_link', a:item[1], a:item[0])
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
@ -1131,7 +988,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
|
||||
@ -1183,7 +1040,7 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
|
||||
" write new listing
|
||||
let new_header = whitespaces_in_first_line
|
||||
\ . s:safesubstitute(g:vimwiki_rxH1_Template,
|
||||
\ . s:safesubstitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'),
|
||||
\ '__Header__', a:start_header, '')
|
||||
call append(start_lnum - 1, new_header)
|
||||
let start_lnum += 1
|
||||
@ -1213,7 +1070,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_syntaxlocal('rxAnyLink'), '')
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#find_prev_link
|
||||
@ -1221,9 +1078,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_syntaxlocal('rxAnyLink'), 'b')
|
||||
endif
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), 'b')
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#follow_link
|
||||
@ -1232,17 +1089,17 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
|
||||
" default open_link handler
|
||||
|
||||
" 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_syntaxlocal('rxWikiLink')),
|
||||
\ vimwiki#vars#get_syntaxlocal('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_syntaxlocal('rxWikiIncl')),
|
||||
\ vimwiki#vars#get_syntaxlocal('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_syntaxlocal('rxWeblink')),
|
||||
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
|
||||
endif
|
||||
|
||||
if lnk != "" " cursor is indeed on a link
|
||||
@ -1272,7 +1129,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
|
||||
endif
|
||||
|
||||
|
||||
if VimwikiGet('syntax') == 'markdown'
|
||||
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
|
||||
let processed_by_markdown_reflink = vimwiki#markdown_base#open_reflink(lnk)
|
||||
if processed_by_markdown_reflink
|
||||
return
|
||||
@ -1280,7 +1137,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
|
||||
|
||||
" remove the extension from the filename if exists, because non-vimwiki
|
||||
" markdown files usually include the extension in links
|
||||
let lnk = substitute(lnk, '\'.VimwikiGet('ext').'$', '', '')
|
||||
let lnk = substitute(lnk, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '')
|
||||
endif
|
||||
|
||||
let current_tab_page = tabpagenr()
|
||||
@ -1306,11 +1163,11 @@ endfunction " }}}
|
||||
|
||||
" vimwiki#base#go_back_link
|
||||
function! vimwiki#base#go_back_link() "{{{
|
||||
if exists("b:vimwiki_prev_link")
|
||||
let prev_link = vimwiki#vars#get_bufferlocal('prev_link')
|
||||
if !empty(prev_link)
|
||||
" go back to saved wiki link
|
||||
let prev_word = b:vimwiki_prev_link
|
||||
execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g')
|
||||
call setpos('.', prev_word[1])
|
||||
execute ":e ".substitute(prev_link[0], '\s', '\\\0', 'g')
|
||||
call setpos('.', prev_link[1])
|
||||
else
|
||||
" maybe we came here by jumping to a tag -> pop from the tag stack
|
||||
silent! pop!
|
||||
@ -1319,13 +1176,13 @@ endfunction " }}}
|
||||
|
||||
" vimwiki#base#goto_index
|
||||
function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
if a:wnum > len(g:vimwiki_list)
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in your Vimwiki settings!'
|
||||
return
|
||||
endif
|
||||
|
||||
" usually a:wnum is greater then 0 but with the following command it is == 0:
|
||||
" vim -n -c "exe 'VimwikiIndex' | echo g:vimwiki_current_idx"
|
||||
" vim -n -c ":VimwikiIndex"
|
||||
if a:wnum > 0
|
||||
let idx = a:wnum - 1
|
||||
else
|
||||
@ -1344,12 +1201,11 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
|
||||
call Validate_wiki_options(idx)
|
||||
call vimwiki#base#edit_file(cmd,
|
||||
\ VimwikiGet('path', idx).VimwikiGet('index', idx).
|
||||
\ VimwikiGet('ext', idx),
|
||||
\ '')
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
let index_file = vimwiki#vars#get_wikilocal('path', idx).
|
||||
\ vimwiki#vars#get_wikilocal('index', idx).
|
||||
\ vimwiki#vars#get_wikilocal('ext', idx)
|
||||
|
||||
call vimwiki#base#edit_file(cmd, index_file, '')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#delete_link
|
||||
@ -1380,7 +1236,7 @@ endfunction "}}}
|
||||
" vimwiki#base#rename_link
|
||||
" Rename current file, update all links to it
|
||||
function! vimwiki#base#rename_link() "{{{
|
||||
let subdir = VimwikiGet('subdir')
|
||||
let subdir = vimwiki#vars#get_bufferlocal('subdir')
|
||||
let old_fname = subdir.expand('%:t')
|
||||
|
||||
" there is no file (new one maybe)
|
||||
@ -1409,13 +1265,13 @@ function! vimwiki#base#rename_link() "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
let url = matchstr(new_link, g:vimwiki_rxWikiLinkMatchUrl)
|
||||
let url = matchstr(new_link, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
|
||||
if url != ''
|
||||
let new_link = url
|
||||
endif
|
||||
|
||||
let new_link = subdir.new_link
|
||||
let new_fname = VimwikiGet('path').new_link.VimwikiGet('ext')
|
||||
let new_fname = vimwiki#vars#get_wikilocal('path') . new_link . vimwiki#vars#get_wikilocal('ext')
|
||||
|
||||
" do not rename if file with such name exists
|
||||
let fname = glob(new_fname)
|
||||
@ -1426,7 +1282,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
endif
|
||||
" rename wiki link file
|
||||
try
|
||||
echomsg 'Vimwiki: Renaming '.VimwikiGet('path').old_fname.' to '.new_fname
|
||||
echomsg 'Vimwiki: Renaming '.vimwiki#vars#get_wikilocal('path').old_fname.' to '.new_fname
|
||||
let res = rename(expand('%:p'), expand(new_fname))
|
||||
if res != 0
|
||||
throw "Cannot rename!"
|
||||
@ -1439,7 +1295,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
let &buftype="nofile"
|
||||
|
||||
let cur_buffer = [expand('%:p'),
|
||||
\getbufvar(expand('%:p'), "vimwiki_prev_link")]
|
||||
\ vimwiki#vars#get_bufferlocal('prev_link')]
|
||||
|
||||
let blist = s:get_wiki_buffers()
|
||||
|
||||
@ -1720,15 +1576,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.'&', '')
|
||||
@ -1737,7 +1593,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)
|
||||
@ -1748,19 +1604,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, '')
|
||||
@ -1782,32 +1638,33 @@ endfunction " }}}
|
||||
function! vimwiki#base#table_of_contents(create)
|
||||
" collect new headers
|
||||
let is_inside_pre_or_math = 0 " 1: inside pre, 2: inside math, 0: outside
|
||||
let numbering = vimwiki#vars#get_global('html_header_numbering')
|
||||
let headers = []
|
||||
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))
|
||||
if h_text ==# g:vimwiki_toc_header " don't include the TOC's header itself
|
||||
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
|
||||
let headers_levels[h_level-1] = [h_text, headers_levels[h_level-1][1]+1]
|
||||
@ -1821,11 +1678,11 @@ function! vimwiki#base#table_of_contents(create)
|
||||
endfor
|
||||
let h_complete_id .= headers_levels[h_level-1][0]
|
||||
|
||||
if g:vimwiki_html_header_numbering > 0
|
||||
\ && g:vimwiki_html_header_numbering <= h_level
|
||||
if numbering > 0
|
||||
\ && numbering <= h_level
|
||||
let h_number = join(map(copy(headers_levels[
|
||||
\ g:vimwiki_html_header_numbering-1 : h_level-1]), 'v:val[1]'), '.')
|
||||
let h_number .= g:vimwiki_html_header_numbering_sym
|
||||
\ numbering-1 : h_level-1]), 'v:val[1]'), '.')
|
||||
let h_number .= vimwiki#vars#get_global('html_header_numbering_sym')
|
||||
let h_text = h_number.' '.h_text
|
||||
endif
|
||||
|
||||
@ -1839,7 +1696,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 = s:safesubstitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__',
|
||||
let link = s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__',
|
||||
\ '#'.esc_link, '')
|
||||
let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '')
|
||||
call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
|
||||
@ -1847,7 +1704,7 @@ function! vimwiki#base#table_of_contents(create)
|
||||
|
||||
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
||||
|
||||
call vimwiki#base#update_listing_in_buffer(lines, g:vimwiki_toc_header, links_rx,
|
||||
call vimwiki#base#update_listing_in_buffer(lines, vimwiki#vars#get_global('toc_header'), links_rx,
|
||||
\ 1, a:create)
|
||||
endfunction
|
||||
"}}}
|
||||
@ -1892,8 +1749,8 @@ endfunction " }}}
|
||||
" s:is_diary_file
|
||||
function! s:is_diary_file(filename) " {{{
|
||||
let file_path = vimwiki#path#path_norm(a:filename)
|
||||
let rel_path = VimwikiGet('diary_rel_path')
|
||||
let diary_path = vimwiki#path#path_norm(VimwikiGet('path') . rel_path)
|
||||
let rel_path = vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('path') . rel_path)
|
||||
return rel_path != ''
|
||||
\ && file_path =~# '^'.vimwiki#u#escape(diary_path)
|
||||
endfunction " }}}
|
||||
@ -1922,25 +1779,25 @@ endfunction " }}}
|
||||
|
||||
" s:normalize_link_in_diary
|
||||
function! s:normalize_link_in_diary(lnk) " {{{
|
||||
let link = a:lnk . VimwikiGet('ext')
|
||||
let link_wiki = VimwikiGet('path') . '/' . link
|
||||
let link_diary = VimwikiGet('path') . '/'
|
||||
\ . VimwikiGet('diary_rel_path') . '/' . link
|
||||
let link = a:lnk . vimwiki#vars#get_wikilocal('ext')
|
||||
let link_wiki = vimwiki#vars#get_wikilocal('path') . '/' . link
|
||||
let link_diary = vimwiki#vars#get_wikilocal('path') . '/'
|
||||
\ . vimwiki#vars#get_wikilocal('diary_rel_path') . '/' . link
|
||||
let link_exists_in_diary = filereadable(link_diary)
|
||||
let link_exists_in_wiki = filereadable(link_wiki)
|
||||
let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d'
|
||||
|
||||
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_global('rxWord')
|
||||
let rxDesc = ''
|
||||
let template = g:vimwiki_WikiLinkTemplate1
|
||||
let template = vimwiki#vars#get_global('WikiLinkTemplate1')
|
||||
else
|
||||
let depth = len(split(VimwikiGet('diary_rel_path'), '/'))
|
||||
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)
|
||||
@ -1950,42 +1807,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_syntaxlocal('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_syntaxlocal('rxWikiLinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
||||
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('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_syntaxlocal('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_syntaxlocal('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_global('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_global('rxWord'), '',
|
||||
\ vimwiki#vars#get_global('WikiLinkTemplate1'))
|
||||
endif
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
return
|
||||
@ -2008,7 +1865,7 @@ function! s:normalize_link_syntax_v() " {{{
|
||||
if s:is_diary_file(expand("%:p"))
|
||||
let sub = s:normalize_link_in_diary(@")
|
||||
else
|
||||
let sub = s:safesubstitute(g:vimwiki_WikiLinkTemplate1,
|
||||
let sub = s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
|
||||
\ '__LinkUrl__', @", '')
|
||||
endif
|
||||
|
||||
@ -2023,9 +1880,9 @@ endfunction " }}}
|
||||
|
||||
" vimwiki#base#normalize_link
|
||||
function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
||||
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#normalize_link')
|
||||
if exists('*vimwiki#'.vimwiki#vars#get_wikilocal('syntax').'_base#normalize_link')
|
||||
" Syntax-specific links
|
||||
call vimwiki#{VimwikiGet('syntax')}_base#normalize_link(a:is_visual_mode)
|
||||
call vimwiki#{vimwiki#vars#get_wikilocal('syntax')}_base#normalize_link(a:is_visual_mode)
|
||||
else
|
||||
if !a:is_visual_mode
|
||||
call s:normalize_link_syntax_n()
|
||||
|
@ -20,23 +20,22 @@ function! s:prefix_zero(num) "{{{
|
||||
return a:num
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_date_link(fmt) "{{{
|
||||
return strftime(a:fmt)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_path(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
|
||||
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
|
||||
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_index(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return s:diary_path(idx).VimwikiGet('diary_index', idx).VimwikiGet('ext', idx)
|
||||
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
|
||||
return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_date_link(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return s:get_date_link(VimwikiGet('diary_link_fmt', idx))
|
||||
function! vimwiki#diary#diary_date_link(...) "{{{
|
||||
if a:0
|
||||
return strftime('%Y-%m-%d', a:1)
|
||||
else
|
||||
return strftime('%Y-%m-%d')
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_position_links(link) "{{{
|
||||
@ -45,8 +44,8 @@ function! s:get_position_links(link) "{{{
|
||||
if a:link =~# '^\d\{4}-\d\d-\d\d'
|
||||
let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")')
|
||||
" include 'today' into links
|
||||
if index(links, s:diary_date_link()) == -1
|
||||
call add(links, s:diary_date_link())
|
||||
if index(links, vimwiki#diary#diary_date_link()) == -1
|
||||
call add(links, vimwiki#diary#diary_date_link())
|
||||
endif
|
||||
call sort(links)
|
||||
let idx = index(links, a:link)
|
||||
@ -55,7 +54,7 @@ function! s:get_position_links(link) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:get_month_name(month) "{{{
|
||||
return g:vimwiki_diary_months[str2nr(a:month)]
|
||||
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
|
||||
endfun "}}}
|
||||
|
||||
" Helpers }}}
|
||||
@ -63,14 +62,15 @@ endfun "}}}
|
||||
" Diary index stuff {{{
|
||||
fun! s:read_captions(files) "{{{
|
||||
let result = {}
|
||||
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
for fl in a:files
|
||||
" remove paths and extensions
|
||||
let fl_key = substitute(fnamemodify(fl, ':t'), VimwikiGet('ext').'$', '', '')
|
||||
let fl_key = substitute(fnamemodify(fl, ':t'), vimwiki#vars#get_wikilocal('ext').'$', '', '')
|
||||
|
||||
if filereadable(fl)
|
||||
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
|
||||
if line =~# g:vimwiki_rxHeader && !has_key(result, fl_key)
|
||||
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
|
||||
if line =~# rx_header && !has_key(result, fl_key)
|
||||
let result[fl_key] = vimwiki#u#trim(matchstr(line, rx_header))
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
@ -85,7 +85,7 @@ endfun "}}}
|
||||
|
||||
fun! s:get_diary_files() "{{{
|
||||
let rx = '^\d\{4}-\d\d-\d\d'
|
||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||
let s_files = glob(vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
|
||||
let files = split(s_files, '\n')
|
||||
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
|
||||
|
||||
@ -117,7 +117,7 @@ fun! s:group_links(links) "{{{
|
||||
endfun "}}}
|
||||
|
||||
function! s:sort(lst) "{{{
|
||||
if VimwikiGet("diary_sort") ==? 'desc'
|
||||
if vimwiki#vars#get_wikilocal('diary_sort') ==? 'desc'
|
||||
return reverse(sort(a:lst))
|
||||
else
|
||||
return sort(a:lst)
|
||||
@ -133,19 +133,19 @@ function! s:format_diary() "{{{
|
||||
|
||||
for year in s:sort(keys(g_files))
|
||||
call add(result, '')
|
||||
call add(result, substitute(g:vimwiki_rxH2_Template, '__Header__', year , ''))
|
||||
call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , ''))
|
||||
|
||||
for month in s:sort(keys(g_files[year]))
|
||||
call add(result, '')
|
||||
call add(result, substitute(g:vimwiki_rxH3_Template, '__Header__', s:get_month_name(month), ''))
|
||||
call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'), '__Header__', s:get_month_name(month), ''))
|
||||
|
||||
for [fl, cap] in s:sort(items(g_files[year][month]))
|
||||
if empty(cap)
|
||||
let entry = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', fl, '')
|
||||
let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', fl, '')
|
||||
let entry = substitute(entry, '__LinkDescription__', cap, '')
|
||||
call add(result, repeat(' ', &sw).'* '.entry)
|
||||
else
|
||||
let entry = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', fl, '')
|
||||
let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__', fl, '')
|
||||
let entry = substitute(entry, '__LinkDescription__', cap, '')
|
||||
call add(result, repeat(' ', &sw).'* '.entry)
|
||||
endif
|
||||
@ -160,7 +160,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
|
||||
@ -172,7 +172,7 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
let idx = 0
|
||||
endif
|
||||
|
||||
call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
|
||||
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx))
|
||||
|
||||
let cmd = 'edit'
|
||||
if a:0
|
||||
@ -187,15 +187,14 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
if a:0>1
|
||||
let link = 'diary:'.a:2
|
||||
else
|
||||
let link = 'diary:'.s:diary_date_link(idx)
|
||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||
endif
|
||||
|
||||
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
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
|
||||
@ -208,7 +207,6 @@ function! vimwiki#diary#goto_diary_index(wnum) "{{{
|
||||
endif
|
||||
|
||||
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#diary#goto_next_day() "{{{
|
||||
@ -223,7 +221,7 @@ function! vimwiki#diary#goto_next_day() "{{{
|
||||
let link = 'diary:'.links[idx+1]
|
||||
else
|
||||
" goto today
|
||||
let link = 'diary:'.s:diary_date_link()
|
||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
@ -243,7 +241,7 @@ function! vimwiki#diary#goto_prev_day() "{{{
|
||||
let link = 'diary:'.links[idx-1]
|
||||
else
|
||||
" goto today
|
||||
let link = 'diary:'.s:diary_date_link()
|
||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
@ -255,9 +253,9 @@ function! vimwiki#diary#generate_diary_section() "{{{
|
||||
let current_file = vimwiki#path#path_norm(expand("%:p"))
|
||||
let diary_file = vimwiki#path#path_norm(s:diary_index())
|
||||
if vimwiki#path#is_equal(current_file, diary_file)
|
||||
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.g:vimwiki_rxHeader.'\)'
|
||||
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)'
|
||||
call vimwiki#base#update_listing_in_buffer(s:format_diary(),
|
||||
\ VimwikiGet('diary_header'), content_rx, line('$')+1, 1)
|
||||
\ vimwiki#vars#get_wikilocal('diary_header'), content_rx, line('$')+1, 1)
|
||||
else
|
||||
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
|
||||
endif
|
||||
@ -284,15 +282,15 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
endif
|
||||
|
||||
" XXX: Well, +1 is for inconsistent index basing...
|
||||
call vimwiki#diary#make_note(g:vimwiki_current_idx+1, 0, link)
|
||||
call vimwiki#diary#make_note(vimwiki#vars#get_bufferlocal('wiki_nr')+1, 0, link)
|
||||
endfunction "}}}
|
||||
|
||||
" Sign function.
|
||||
function vimwiki#diary#calendar_sign(day, month, year) "{{{
|
||||
let day = s:prefix_zero(a:day)
|
||||
let month = s:prefix_zero(a:month)
|
||||
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
|
||||
\ a:year.'-'.month.'-'.day.VimwikiGet('ext')
|
||||
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
|
||||
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
|
||||
return filereadable(expand(sfile))
|
||||
endfunction "}}}
|
||||
|
||||
|
@ -26,7 +26,7 @@ function! s:root_path(subdir) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:syntax_supported() " {{{
|
||||
return VimwikiGet('syntax') ==? "default"
|
||||
return vimwiki#vars#get_wikilocal('syntax') ==? "default"
|
||||
endfunction " }}}
|
||||
|
||||
function! s:remove_blank_lines(lines) " {{{
|
||||
@ -68,7 +68,7 @@ endfunction " }}}
|
||||
|
||||
function! s:default_CSS_full_name(path) " {{{
|
||||
let path = expand(a:path)
|
||||
let css_full_name = path.VimwikiGet('css_name')
|
||||
let css_full_name = path . vimwiki#vars#get_wikilocal('css_name')
|
||||
return css_full_name
|
||||
endfunction "}}}
|
||||
|
||||
@ -88,13 +88,13 @@ endfunction "}}}
|
||||
|
||||
function! s:template_full_name(name) "{{{
|
||||
if a:name == ''
|
||||
let name = VimwikiGet('template_default')
|
||||
let name = vimwiki#vars#get_wikilocal('template_default')
|
||||
else
|
||||
let name = a:name
|
||||
endif
|
||||
|
||||
let fname = expand(VimwikiGet('template_path').
|
||||
\ name.VimwikiGet('template_ext'))
|
||||
let fname = expand(vimwiki#vars#get_wikilocal('template_path').
|
||||
\ name . vimwiki#vars#get_wikilocal('template_ext'))
|
||||
|
||||
if filereadable(fname)
|
||||
return fname
|
||||
@ -157,14 +157,14 @@ function! s:delete_html_files(path) "{{{
|
||||
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
|
||||
for fname in htmlfiles
|
||||
" ignore user html files, e.g. search.html,404.html
|
||||
if stridx(g:vimwiki_user_htmls, fnamemodify(fname, ":t")) >= 0
|
||||
if stridx(vimwiki#vars#get_global('user_htmls'), fnamemodify(fname, ":t")) >= 0
|
||||
continue
|
||||
endif
|
||||
|
||||
" delete if there is no corresponding wiki file
|
||||
let subdir = vimwiki#base#subdir(VimwikiGet('path_html'), fname)
|
||||
let wikifile = VimwikiGet('path').subdir.
|
||||
\fnamemodify(fname, ":t:r").VimwikiGet('ext')
|
||||
let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path_html'), fname)
|
||||
let wikifile = vimwiki#vars#get_wikilocal('path').subdir.
|
||||
\fnamemodify(fname, ":t:r").vimwiki#vars#get_wikilocal('ext')
|
||||
if filereadable(wikifile)
|
||||
continue
|
||||
endif
|
||||
@ -244,7 +244,7 @@ function! s:is_html_uptodate(wikifile) "{{{
|
||||
endif
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
let htmlfile = expand(VimwikiGet('path_html').VimwikiGet('subdir').
|
||||
let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') . vimwiki#vars#get_bufferlocal('subdir') .
|
||||
\fnamemodify(wikifile, ":t:r").".html")
|
||||
|
||||
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
|
||||
@ -358,12 +358,12 @@ endfunction "}}}
|
||||
" match n-th ARG within {{URL[|ARG1|ARG2|...]}} " {{{
|
||||
" *c,d,e),...
|
||||
function! vimwiki#html#incl_match_arg(nn_index)
|
||||
let rx = g:vimwiki_rxWikiInclPrefix. g:vimwiki_rxWikiInclUrl
|
||||
let rx = rx. repeat(g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg, a:nn_index-1)
|
||||
let rx = vimwiki#vars#get_global('rxWikiInclPrefix'). vimwiki#vars#get_global('rxWikiInclUrl')
|
||||
let rx = rx. repeat(vimwiki#vars#get_global('rxWikiInclSeparator'). vimwiki#vars#get_global('rxWikiInclArg'), a:nn_index-1)
|
||||
if a:nn_index > 0
|
||||
let rx = rx. g:vimwiki_rxWikiInclSeparator. '\zs'. g:vimwiki_rxWikiInclArg. '\ze'
|
||||
let rx = rx. vimwiki#vars#get_global('rxWikiInclSeparator'). '\zs'. vimwiki#vars#get_global('rxWikiInclArg'). '\ze'
|
||||
endif
|
||||
let rx = rx. g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
|
||||
let rx = rx. vimwiki#vars#get_global('rxWikiInclArgs'). vimwiki#vars#get_global('rxWikiInclSuffix')
|
||||
return rx
|
||||
endfunction
|
||||
"}}}
|
||||
@ -372,7 +372,7 @@ function! vimwiki#html#linkify_link(src, descr) "{{{
|
||||
let src_str = ' href="'.s:safe_html_anchor(a:src).'"'
|
||||
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
|
||||
let descr = (descr == "" ? a:src : descr)
|
||||
let descr_str = (descr =~# g:vimwiki_rxWikiIncl
|
||||
let descr_str = (descr =~# vimwiki#vars#get_global('rxWikiIncl')
|
||||
\ ? s:tag_wikiincl(descr)
|
||||
\ : descr)
|
||||
return '<a'.src_str.'>'.descr_str.'</a>'
|
||||
@ -388,8 +388,8 @@ endfunction "}}}
|
||||
function! s:tag_weblink(value) "{{{
|
||||
" Weblink Template -> <a href="url">descr</a>
|
||||
let str = a:value
|
||||
let url = matchstr(str, g:vimwiki_rxWeblinkMatchUrl)
|
||||
let descr = matchstr(str, g:vimwiki_rxWeblinkMatchDescr)
|
||||
let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
|
||||
let descr = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWeblinkMatchDescr'))
|
||||
let line = vimwiki#html#linkify_link(url, descr)
|
||||
return line
|
||||
endfunction "}}}
|
||||
@ -404,7 +404,7 @@ function! s:tag_wikiincl(value) "{{{
|
||||
let line = VimwikiWikiIncludeHandler(str)
|
||||
" otherwise, assume image transclusion
|
||||
if line == ''
|
||||
let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl)
|
||||
let url_0 = matchstr(str, vimwiki#vars#get_global('rxWikiInclMatchUrl'))
|
||||
let descr = matchstr(str, vimwiki#html#incl_match_arg(1))
|
||||
let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2))
|
||||
|
||||
@ -437,8 +437,8 @@ function! s:tag_wikilink(value) "{{{
|
||||
" [[url#a1#a2]] -> <a href="url.html#a1-a2">url#a1#a2</a>
|
||||
" [[#a1#a2]] -> <a href="#a1-a2">#a1#a2</a>
|
||||
let str = a:value
|
||||
let url = matchstr(str, g:vimwiki_rxWikiLinkMatchUrl)
|
||||
let descr = matchstr(str, g:vimwiki_rxWikiLinkMatchDescr)
|
||||
let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
|
||||
let descr = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'))
|
||||
let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url)
|
||||
|
||||
let line = VimwikiLinkConverter(url, s:current_wiki_file,
|
||||
@ -527,16 +527,16 @@ function! s:make_tag(line, regexp, func, ...) "{{{
|
||||
" Exclude preformatted text and href links.
|
||||
" FIXME
|
||||
let patt_splitter = '\(`[^`]\+`\)\|'.
|
||||
\ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'.
|
||||
\ '\('.vimwiki#vars#get_syntaxlocal('rxPreStart').'.\+'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'\)\|'.
|
||||
\ '\(<a href.\{-}</a>\)\|'.
|
||||
\ '\(<img src.\{-}/>\)\|'.
|
||||
\ '\(<pre.\{-}</pre>\)\|'.
|
||||
\ '\('.g:vimwiki_rxEqIn.'\)'
|
||||
\ '\('.vimwiki#vars#get_syntaxlocal('rxEqIn').'\)'
|
||||
|
||||
"FIXME FIXME !!! these can easily occur on the same line!
|
||||
"XXX {{{ }}} ??? obsolete
|
||||
if '`[^`]\+`' ==# a:regexp || '{{{.\+}}}' ==# a:regexp ||
|
||||
\ g:vimwiki_rxEqIn ==# a:regexp
|
||||
\ vimwiki#vars#get_syntaxlocal('rxEqIn') ==# a:regexp
|
||||
let res_line = s:subst_func(a:line, a:regexp, a:func)
|
||||
else
|
||||
let pos = 0
|
||||
@ -570,23 +570,23 @@ endfunction " }}}
|
||||
|
||||
function! s:process_tags_typefaces(line, header_ids) "{{{
|
||||
let line = a:line
|
||||
let line = s:make_tag(line, g:vimwiki_rxItalic, 's:tag_em')
|
||||
let line = s:make_tag(line, g:vimwiki_rxBold, 's:tag_strong', a:header_ids)
|
||||
let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo')
|
||||
let line = s:make_tag(line, g:vimwiki_rxDelText, 's:tag_strike')
|
||||
let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super')
|
||||
let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
|
||||
let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
|
||||
let line = s:make_tag(line, g:vimwiki_rxEqIn, 's:tag_eqin')
|
||||
let line = s:make_tag(line, g:vimwiki_rxTags, 's:tag_tags', a:header_ids)
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxItalic'), 's:tag_em')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxBold'), 's:tag_strong', a:header_ids)
|
||||
let line = s:make_tag(line, vimwiki#vars#get_global('rxTodo'), 's:tag_todo')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxDelText'), 's:tag_strike')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxSuperScript'), 's:tag_super')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxSubScript'), 's:tag_sub')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxCode'), 's:tag_code')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxEqIn'), 's:tag_eqin')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxTags'), 's:tag_tags', a:header_ids)
|
||||
return line
|
||||
endfunction " }}}
|
||||
|
||||
function! s:process_tags_links(line) " {{{
|
||||
let line = a:line
|
||||
let line = s:make_tag(line, g:vimwiki_rxWikiLink, 's:tag_wikilink')
|
||||
let line = s:make_tag(line, g:vimwiki_rxWikiIncl, 's:tag_wikiincl')
|
||||
let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_weblink')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxWikiLink'), 's:tag_wikilink')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_global('rxWikiIncl'), 's:tag_wikiincl')
|
||||
let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxWeblink'), 's:tag_weblink')
|
||||
return line
|
||||
endfunction " }}}
|
||||
|
||||
@ -872,11 +872,11 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
let st_tag = '<li>'
|
||||
let chk = matchlist(a:line, a:rx_list)
|
||||
if !empty(chk) && len(chk[1]) > 0
|
||||
let completion = index(g:vimwiki_listsyms_list, chk[1])
|
||||
let n = len(g:vimwiki_listsyms_list)
|
||||
let completion = index(vimwiki#vars#get_syntaxlocal('listsyms_list'), chk[1])
|
||||
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
|
||||
if completion == 0
|
||||
let st_tag = '<li class="done0">'
|
||||
elseif completion == -1 && chk[1] == g:vimwiki_listsym_rejected
|
||||
elseif completion == -1 && chk[1] == vimwiki#vars#get_global('listsym_rejected')
|
||||
let st_tag = '<li class="rejected">'
|
||||
elseif completion > 0 && completion < n
|
||||
let completion = float2nr(round(completion / (n-1.0) * 3.0 + 0.5 ))
|
||||
@ -892,7 +892,7 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
" text.
|
||||
" XXX necessary? in *bold* text, no space must follow the first *
|
||||
if !in_list
|
||||
let pos = match(a:line, '^\s*'.g:vimwiki_rxBold)
|
||||
let pos = match(a:line, '^\s*'.vimwiki#vars#get_syntaxlocal('rxBold'))
|
||||
if pos != -1
|
||||
return [0, []]
|
||||
endif
|
||||
@ -952,7 +952,7 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
|
||||
let processed = 1
|
||||
elseif in_list && a:line =~# '^\s\+\S\+'
|
||||
if g:vimwiki_list_ignore_newline
|
||||
if vimwiki#vars#get_global('list_ignore_newline')
|
||||
call add(lines, a:line)
|
||||
else
|
||||
call add(lines, '<br />'.a:line)
|
||||
@ -998,7 +998,7 @@ function! s:process_tag_para(line, para) "{{{
|
||||
let para = 1
|
||||
endif
|
||||
let processed = 1
|
||||
if g:vimwiki_text_ignore_newline == 1
|
||||
if vimwiki#vars#get_global('text_ignore_newline')
|
||||
call add(lines, a:line)
|
||||
else
|
||||
call add(lines, a:line."<br />")
|
||||
@ -1017,18 +1017,18 @@ function! s:process_tag_h(line, id) "{{{
|
||||
let h_text = ''
|
||||
let h_id = ''
|
||||
|
||||
if a:line =~# g:vimwiki_rxHeader
|
||||
if a:line =~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
let h_level = vimwiki#u#count_first_sym(a:line)
|
||||
endif
|
||||
if h_level > 0
|
||||
|
||||
let h_text = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
|
||||
let h_text = vimwiki#u#trim(matchstr(line, vimwiki#vars#get_syntaxlocal('rxHeader')))
|
||||
let h_number = ''
|
||||
let h_complete_id = ''
|
||||
let h_id = s:safe_html_anchor(h_text)
|
||||
let centered = (a:line =~# '^\s')
|
||||
|
||||
if h_text !=# g:vimwiki_toc_header
|
||||
if h_text !=# vimwiki#vars#get_global('toc_header')
|
||||
|
||||
let a:id[h_level-1] = [h_text, a:id[h_level-1][1]+1]
|
||||
|
||||
@ -1046,11 +1046,11 @@ function! s:process_tag_h(line, id) "{{{
|
||||
let h_number .= a:id[h_level-1][1]
|
||||
let h_complete_id .= a:id[h_level-1][0]
|
||||
|
||||
if g:vimwiki_html_header_numbering
|
||||
if vimwiki#vars#get_global('html_header_numbering')
|
||||
let num = matchstr(h_number,
|
||||
\ '^\(\d.\)\{'.(g:vimwiki_html_header_numbering-1).'}\zs.*')
|
||||
\ '^\(\d.\)\{'.(vimwiki#vars#get_global('html_header_numbering')-1).'}\zs.*')
|
||||
if !empty(num)
|
||||
let num .= g:vimwiki_html_header_numbering_sym
|
||||
let num .= vimwiki#vars#get_global('html_header_numbering_sym')
|
||||
endif
|
||||
let h_text = num.' '.h_text
|
||||
endif
|
||||
@ -1198,7 +1198,7 @@ function! s:parse_line(line, state) " {{{
|
||||
"}}}
|
||||
|
||||
if !processed
|
||||
if line =~# g:vimwiki_rxComment
|
||||
if line =~# vimwiki#vars#get_syntaxlocal('rxComment')
|
||||
let processed = 1
|
||||
endif
|
||||
endif
|
||||
@ -1380,24 +1380,24 @@ function! s:parse_line(line, state) " {{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:use_custom_wiki2html() "{{{
|
||||
let custom_wiki2html = VimwikiGet('custom_wiki2html')
|
||||
let custom_wiki2html = vimwiki#vars#get_wikilocal('custom_wiki2html')
|
||||
return !empty(custom_wiki2html) && (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html))
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
|
||||
call vimwiki#path#mkdir(a:path)
|
||||
echomsg system(VimwikiGet('custom_wiki2html'). ' '.
|
||||
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '.
|
||||
\ a:force. ' '.
|
||||
\ VimwikiGet('syntax'). ' '.
|
||||
\ strpart(VimwikiGet('ext'), 1). ' '.
|
||||
\ vimwiki#vars#get_wikilocal('syntax'). ' '.
|
||||
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '.
|
||||
\ shellescape(a:path). ' '.
|
||||
\ shellescape(a:wikifile). ' '.
|
||||
\ shellescape(s:default_CSS_full_name(a:path)). ' '.
|
||||
\ (len(VimwikiGet('template_path')) > 1 ? shellescape(expand(VimwikiGet('template_path'))) : '-'). ' '.
|
||||
\ (len(VimwikiGet('template_default')) > 0 ? VimwikiGet('template_default') : '-'). ' '.
|
||||
\ (len(VimwikiGet('template_ext')) > 0 ? VimwikiGet('template_ext') : '-'). ' '.
|
||||
\ (len(VimwikiGet('subdir')) > 0 ? shellescape(s:root_path(VimwikiGet('subdir'))) : '-'). ' '.
|
||||
\ (len(VimwikiGet('custom_wiki2html_args')) > 0 ? VimwikiGet('custom_wiki2html_args') : '-'))
|
||||
\ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ? shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '.
|
||||
\ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ? vimwiki#vars#get_wikilocal('template_default') : '-'). ' '.
|
||||
\ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ? vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '.
|
||||
\ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ? shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '.
|
||||
\ (len(vimwiki#vars#get_global('custom_wiki2html_args')) > 0 ? vimwiki#vars#get_global('custom_wiki2html_args') : '-'))
|
||||
endfunction " }}}
|
||||
|
||||
function! s:convert_file(path_html, wikifile) "{{{
|
||||
@ -1405,7 +1405,7 @@ function! s:convert_file(path_html, wikifile) "{{{
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
|
||||
let path_html = expand(a:path_html).VimwikiGet('subdir')
|
||||
let path_html = expand(a:path_html).vimwiki#vars#get_bufferlocal('subdir')
|
||||
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
|
||||
|
||||
" the currently processed file name is needed when processing links
|
||||
@ -1450,8 +1450,8 @@ function! s:convert_file(path_html, wikifile) "{{{
|
||||
" prepare constants for s:safe_html_line()
|
||||
let s:lt_pattern = '<'
|
||||
let s:gt_pattern = '>'
|
||||
if g:vimwiki_valid_html_tags != ''
|
||||
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
if vimwiki#vars#get_global('valid_html_tags') != ''
|
||||
let tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
|
||||
let s:lt_pattern = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
|
||||
let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
|
||||
endif
|
||||
@ -1516,9 +1516,9 @@ function! s:convert_file(path_html, wikifile) "{{{
|
||||
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
|
||||
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
|
||||
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
|
||||
\ s:root_path(VimwikiGet('subdir')) .'", "g")')
|
||||
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
|
||||
|
||||
let css_name = expand(VimwikiGet('css_name'))
|
||||
let css_name = expand(vimwiki#vars#get_wikilocal('css_name'))
|
||||
let css_name = substitute(css_name, '\', '/', 'g')
|
||||
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
|
||||
|
||||
@ -1576,17 +1576,17 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{
|
||||
setlocal nomore
|
||||
|
||||
" temporarily adjust current_subdir global state variable
|
||||
let current_subdir = VimwikiGet('subdir')
|
||||
let current_invsubdir = VimwikiGet('invsubdir')
|
||||
let current_subdir = vimwiki#vars#get_bufferlocal('subdir')
|
||||
let current_invsubdir = vimwiki#vars#get_bufferlocal('invsubdir')
|
||||
|
||||
let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
|
||||
let wikifiles = split(glob(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext')), '\n')
|
||||
for wikifile in wikifiles
|
||||
let wikifile = fnamemodify(wikifile, ":p")
|
||||
|
||||
" temporarily adjust 'subdir' and 'invsubdir' state variables
|
||||
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||
call VimwikiSet('subdir', subdir)
|
||||
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir))
|
||||
let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), wikifile)
|
||||
call vimwiki#vars#set_bufferlocal('subdir', subdir)
|
||||
call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir))
|
||||
|
||||
if !s:is_html_uptodate(wikifile)
|
||||
echomsg 'Vimwiki: Processing '.wikifile
|
||||
@ -1597,8 +1597,8 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{
|
||||
endif
|
||||
endfor
|
||||
" reset 'subdir' state variable
|
||||
call VimwikiSet('subdir', current_subdir)
|
||||
call VimwikiSet('invsubdir', current_invsubdir)
|
||||
call vimwiki#vars#set_bufferlocal('subdir', current_subdir)
|
||||
call vimwiki#vars#set_bufferlocal('invsubdir', current_invsubdir)
|
||||
|
||||
let created = s:create_default_CSS(path_html)
|
||||
if created
|
||||
@ -1618,10 +1618,9 @@ function! s:binary_exists(fname) "{{{
|
||||
return executable(expand(a:fname))
|
||||
endfunction "}}}
|
||||
|
||||
" uses VimwikiGet('path')
|
||||
function! s:get_wikifile_url(wikifile) "{{{
|
||||
return VimwikiGet('path_html').
|
||||
\ vimwiki#base#subdir(VimwikiGet('path'), a:wikifile).
|
||||
return vimwiki#vars#get_wikilocal('path_html') .
|
||||
\ vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), a:wikifile).
|
||||
\ fnamemodify(a:wikifile, ":t:r").'.html'
|
||||
endfunction "}}}
|
||||
|
||||
|
@ -109,30 +109,31 @@ else
|
||||
endif "}}}
|
||||
|
||||
function! vimwiki#lst#default_symbol() "{{{
|
||||
return g:vimwiki_list_markers[0]
|
||||
return vimwiki#vars#get_syntaxlocal('list_markers')[0]
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#lst#get_list_margin() "{{{
|
||||
if VimwikiGet('list_margin') < 0
|
||||
let list_margin = vimwiki#vars#get_wikilocal('list_margin')
|
||||
if list_margin < 0
|
||||
return &sw
|
||||
else
|
||||
return VimwikiGet('list_margin')
|
||||
return list_margin
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
"Returns: the column where the text of a line starts (possible list item
|
||||
"markers and checkboxes are skipped)
|
||||
function! s:text_begin(lnum) "{{{
|
||||
return s:string_length(matchstr(getline(a:lnum), g:vimwiki_rxListItem))
|
||||
return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')))
|
||||
endfunction "}}}
|
||||
|
||||
"Returns: 2 if there is a marker and text
|
||||
" 1 for a marker and no text
|
||||
" 0 for no marker at all (empty line or only text)
|
||||
function! s:line_has_marker(lnum) "{{{
|
||||
if getline(a:lnum) =~# g:vimwiki_rxListItem.'\s*$'
|
||||
if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$'
|
||||
return 1
|
||||
elseif getline(a:lnum) =~# g:vimwiki_rxListItem.'\s*\S'
|
||||
elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S'
|
||||
return 2
|
||||
else
|
||||
return 0
|
||||
@ -156,7 +157,7 @@ function! s:get_item(lnum) "{{{
|
||||
return item
|
||||
endif
|
||||
|
||||
let matches = matchlist(getline(a:lnum), g:vimwiki_rxListItem)
|
||||
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))
|
||||
if matches == [] ||
|
||||
\ (matches[1] == '' && matches[2] == '') ||
|
||||
\ (matches[1] != '' && matches[2] != '')
|
||||
@ -187,10 +188,10 @@ function! s:get_level(lnum) "{{{
|
||||
if getline(a:lnum) =~# '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
if VimwikiGet('syntax') !=? 'media'
|
||||
if !vimwiki#vars#get_syntaxlocal('recurring_bullets')
|
||||
let level = indent(a:lnum)
|
||||
else
|
||||
let level = s:string_length(matchstr(getline(a:lnum), s:rx_bullet_chars))-1
|
||||
let level = s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal(rx_bullet_chars)))-1
|
||||
if level < 0
|
||||
let level = (indent(a:lnum) == 0) ? 0 : 9999
|
||||
endif
|
||||
@ -206,17 +207,19 @@ function! s:guess_kind_of_numbered_item(item) "{{{
|
||||
let number_chars = a:item.mrkr[:-2]
|
||||
let divisor = a:item.mrkr[-1:]
|
||||
|
||||
let number_kinds = vimwiki#vars#get_syntaxlocal('number_kinds')
|
||||
|
||||
if number_chars =~# '\d\+'
|
||||
return '1'
|
||||
endif
|
||||
if number_chars =~# '\l\+'
|
||||
if number_chars !~# '^[ivxlcdm]\+' || index(s:number_kinds, 'i') == -1
|
||||
if number_chars !~# '^[ivxlcdm]\+' || index(number_kinds, 'i') == -1
|
||||
return 'a'
|
||||
else
|
||||
|
||||
let item_above = s:get_prev_list_item(a:item, 0)
|
||||
if item_above.type != 0
|
||||
if index(s:number_kinds, 'a') == -1 ||
|
||||
if index(number_kinds, 'a') == -1 ||
|
||||
\ (item_above.mrkr[-1:] !=# divisor && number_chars =~# 'i\+') ||
|
||||
\ s:increment_i(item_above.mrkr[:-2]) ==# number_chars
|
||||
return 'i'
|
||||
@ -224,7 +227,7 @@ function! s:guess_kind_of_numbered_item(item) "{{{
|
||||
return 'a'
|
||||
endif
|
||||
else
|
||||
if number_chars =~# 'i\+' || index(s:number_kinds, 'a') == -1
|
||||
if number_chars =~# 'i\+' || index(number_kinds, 'a') == -1
|
||||
return 'i'
|
||||
else
|
||||
return 'a'
|
||||
@ -234,13 +237,13 @@ function! s:guess_kind_of_numbered_item(item) "{{{
|
||||
endif
|
||||
endif
|
||||
if number_chars =~# '\u\+'
|
||||
if number_chars !~# '^[IVXLCDM]\+' || index(s:number_kinds, 'I') == -1
|
||||
if number_chars !~# '^[IVXLCDM]\+' || index(number_kinds, 'I') == -1
|
||||
return 'A'
|
||||
else
|
||||
|
||||
let item_above = s:get_prev_list_item(a:item, 0)
|
||||
if item_above.type != 0
|
||||
if index(s:number_kinds, 'A') == -1 ||
|
||||
if index(number_kinds, 'A') == -1 ||
|
||||
\ (item_above.mrkr[-1:] !=# divisor && number_chars =~# 'I\+') ||
|
||||
\ s:increment_I(item_above.mrkr[:-2]) ==# number_chars
|
||||
return 'I'
|
||||
@ -248,7 +251,7 @@ function! s:guess_kind_of_numbered_item(item) "{{{
|
||||
return 'A'
|
||||
endif
|
||||
else
|
||||
if number_chars =~# 'I\+' || index(s:number_kinds, 'A') == -1
|
||||
if number_chars =~# 'I\+' || index(number_kinds, 'A') == -1
|
||||
return 'I'
|
||||
else
|
||||
return 'A'
|
||||
@ -263,8 +266,9 @@ function! s:regexp_of_marker(item) "{{{
|
||||
if a:item.type == 1
|
||||
return vimwiki#u#escape(a:item.mrkr)
|
||||
elseif a:item.type == 2
|
||||
let number_divisors = vimwiki#vars#get_syntaxlocal('number_divisors')
|
||||
for ki in ['d', 'u', 'l']
|
||||
let match = matchstr(a:item.mrkr, '\'.ki.'\+['.s:number_divisors.']')
|
||||
let match = matchstr(a:item.mrkr, '\'.ki.'\+['.number_divisors.']')
|
||||
if match != ''
|
||||
return '\'.ki.'\+'.vimwiki#u#escape(match[-1:])
|
||||
endif
|
||||
@ -376,10 +380,10 @@ endfunction "}}}
|
||||
"If there is no second argument, 0 is returned at a header, otherwise the
|
||||
"header is skipped
|
||||
function! s:get_next_line(lnum, ...) "{{{
|
||||
if getline(a:lnum) =~# g:vimwiki_rxPreStart
|
||||
if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
||||
let cur_ln = a:lnum + 1
|
||||
while cur_ln <= line('$') &&
|
||||
\ getline(cur_ln) !~# g:vimwiki_rxPreEnd
|
||||
\ getline(cur_ln) !~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
|
||||
let cur_ln += 1
|
||||
endwhile
|
||||
let next_line = cur_ln
|
||||
@ -387,12 +391,12 @@ function! s:get_next_line(lnum, ...) "{{{
|
||||
let next_line = nextnonblank(a:lnum+1)
|
||||
endif
|
||||
|
||||
if a:0 > 0 && getline(next_line) =~# g:vimwiki_rxHeader
|
||||
if a:0 > 0 && getline(next_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
let next_line = s:get_next_line(next_line, 1)
|
||||
endif
|
||||
|
||||
if next_line < 0 || next_line > line('$') ||
|
||||
\ (getline(next_line) =~# g:vimwiki_rxHeader && a:0 == 0)
|
||||
\ (getline(next_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader') && a:0 == 0)
|
||||
return 0
|
||||
endif
|
||||
|
||||
@ -404,10 +408,10 @@ endfunction "}}}
|
||||
function! s:get_prev_line(lnum) "{{{
|
||||
let prev_line = prevnonblank(a:lnum-1)
|
||||
|
||||
if getline(prev_line) =~# g:vimwiki_rxPreEnd
|
||||
if getline(prev_line) =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
|
||||
let cur_ln = a:lnum - 1
|
||||
while 1
|
||||
if cur_ln == 0 || getline(cur_ln) =~# g:vimwiki_rxPreStart
|
||||
if cur_ln == 0 || getline(cur_ln) =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
||||
break
|
||||
endif
|
||||
let cur_ln -= 1
|
||||
@ -416,7 +420,7 @@ function! s:get_prev_line(lnum) "{{{
|
||||
endif
|
||||
|
||||
if prev_line < 0 || prev_line > line('$') ||
|
||||
\ getline(prev_line) =~# g:vimwiki_rxHeader
|
||||
\ getline(prev_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
return 0
|
||||
endif
|
||||
|
||||
@ -693,11 +697,11 @@ function! s:get_rate(item) "{{{
|
||||
return -1
|
||||
endif
|
||||
let state = a:item.cb
|
||||
if state == g:vimwiki_listsym_rejected
|
||||
if state == vimwiki#vars#get_global('listsym_rejected')
|
||||
return -1
|
||||
endif
|
||||
let n=len(g:vimwiki_listsyms_list)
|
||||
return index(g:vimwiki_listsyms_list, state) * 100/(n-1)
|
||||
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
|
||||
return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 100/(n-1)
|
||||
endfunction "}}}
|
||||
|
||||
"Set state of the list item to [ ] or [o] or whatever
|
||||
@ -732,17 +736,18 @@ endfunction "}}}
|
||||
|
||||
"Returns: the appropriate symbol for a given percent rate
|
||||
function! s:rate_to_state(rate) "{{{
|
||||
let listsyms_list = vimwiki#vars#get_syntaxlocal('listsyms_list')
|
||||
let state = ''
|
||||
let n=len(g:vimwiki_listsyms_list)
|
||||
let n = len(listsyms_list)
|
||||
if a:rate == 100
|
||||
let state = g:vimwiki_listsyms_list[n-1]
|
||||
let state = listsyms_list[n-1]
|
||||
elseif a:rate == 0
|
||||
let state = g:vimwiki_listsyms_list[0]
|
||||
let state = listsyms_list[0]
|
||||
elseif a:rate == -1
|
||||
let state = g:vimwiki_listsym_rejected
|
||||
let state = vimwiki#vars#get_global('listsym_rejected')
|
||||
else
|
||||
let index = float2nr(ceil(a:rate/100.0*(n-2)))
|
||||
let state = g:vimwiki_listsyms_list[index]
|
||||
let state = listsyms_list[index]
|
||||
endif
|
||||
return state
|
||||
endfunction "}}}
|
||||
@ -799,7 +804,7 @@ function! s:create_cb(item) "{{{
|
||||
endif
|
||||
|
||||
let new_item = a:item
|
||||
let new_item.cb = g:vimwiki_listsyms_list[0]
|
||||
let new_item.cb = vimwiki#vars#get_syntaxlocal('listsyms_list')[0]
|
||||
call s:substitute_rx_in_line(new_item.lnum,
|
||||
\ vimwiki#u#escape(new_item.mrkr) . '\zs\ze', ' [' . new_item.cb . ']')
|
||||
|
||||
@ -893,7 +898,7 @@ function! vimwiki#lst#decrement_cb(from_line, to_line) "{{{
|
||||
|
||||
"if from_line has CB, decrement it and set all siblings to the same new state
|
||||
let rate_first_line = s:get_rate(from_item)
|
||||
let n=len(g:vimwiki_listsyms_list)
|
||||
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
|
||||
let new_rate = max([rate_first_line - 100/(n-1)-1, 0])
|
||||
|
||||
call s:change_cb(a:from_line, a:to_line, new_rate)
|
||||
@ -910,7 +915,36 @@ function! vimwiki#lst#increment_cb(from_line, to_line) "{{{
|
||||
|
||||
"if from_line has CB, increment it and set all siblings to the same new state
|
||||
let rate_first_line = s:get_rate(from_item)
|
||||
let n=len(g:vimwiki_listsyms_list)
|
||||
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
|
||||
let new_rate = min([rate_first_line + 100/(n-1)+1, 100])
|
||||
|
||||
call s:change_cb(a:from_line, a:to_line, new_rate)
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
"Toggles checkbox between [ ] and [X] or creates one
|
||||
"in the lines of the given range
|
||||
function! vimwiki#lst#toggle_cb(from_line, to_line) "{{{
|
||||
return s:toggle_create_cb(a:from_line, a:to_line, 100, 0)
|
||||
endfunction "}}}
|
||||
|
||||
"Toggles checkbox between [ ] and [-] or creates one
|
||||
"in the lines of the given range
|
||||
function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) "{{{
|
||||
return s:toggle_create_cb(a:from_line, a:to_line, -1, 0)
|
||||
endfunction "}}}
|
||||
|
||||
"Increment checkbox between [ ] and [X]
|
||||
"in the lines of the given range
|
||||
function! vimwiki#lst#increment_cb(from_line, to_line) "{{{
|
||||
let from_item = s:get_corresponding_item(a:from_line)
|
||||
if from_item.type == 0
|
||||
return
|
||||
endif
|
||||
|
||||
"if from_line has CB, increment it and set all siblings to the same new state
|
||||
let rate_first_line = s:get_rate(from_item)
|
||||
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
|
||||
let new_rate = min([rate_first_line + 100/(n-1)+1, 100])
|
||||
|
||||
call s:change_cb(a:from_line, a:to_line, new_rate)
|
||||
@ -990,8 +1024,8 @@ endfunction "}}}
|
||||
|
||||
function! s:decrease_level(item) "{{{
|
||||
let removed_indent = 0
|
||||
if VimwikiGet('syntax') ==? 'media' && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 &&
|
||||
\ index(vimwiki#vars#get_syntaxlocal('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,
|
||||
\ s:first_char(a:item.mrkr), '')
|
||||
@ -1012,8 +1046,8 @@ endfunction "}}}
|
||||
|
||||
function! s:increase_level(item) "{{{
|
||||
let additional_indent = 0
|
||||
if VimwikiGet('syntax') ==? 'media' && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 &&
|
||||
\ index(vimwiki#vars#get_syntaxlocal('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))
|
||||
let additional_indent = 1
|
||||
@ -1034,8 +1068,8 @@ endfunction "}}}
|
||||
"a:indent_by can be negative
|
||||
function! s:indent_line_by(lnum, indent_by) "{{{
|
||||
let item = s:get_item(a:lnum)
|
||||
if VimwikiGet('syntax') ==? 'media' && item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(item.mrkr)) > -1
|
||||
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && item.type == 1 &&
|
||||
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(item.mrkr)) > -1
|
||||
if a:indent_by > 0
|
||||
call s:substitute_string_in_line(a:lnum, item.mrkr,
|
||||
\ item.mrkr . s:first_char(item.mrkr))
|
||||
@ -1149,38 +1183,40 @@ function! s:get_idx_list_markers(item) "{{{
|
||||
else
|
||||
let m = s:guess_kind_of_numbered_item(a:item) . a:item.mrkr[-1:]
|
||||
endif
|
||||
return index(g:vimwiki_list_markers, m)
|
||||
return index(vimwiki#vars#get_syntaxlocal('list_markers'), m)
|
||||
endfunction "}}}
|
||||
|
||||
"changes the marker of the given item to the next in g:vimwiki_list_markers
|
||||
function! s:get_next_mrkr(item) "{{{
|
||||
let markers = vimwiki#vars#get_syntaxlocal('list_markers')
|
||||
if a:item.type == 0
|
||||
let new_mrkr = g:vimwiki_list_markers[0]
|
||||
let new_mrkr = markers[0]
|
||||
else
|
||||
let idx = s:get_idx_list_markers(a:item)
|
||||
let new_mrkr = g:vimwiki_list_markers[(idx+1) % len(g:vimwiki_list_markers)]
|
||||
let new_mrkr = markers[(idx+1) % len(markers)]
|
||||
endif
|
||||
return new_mrkr
|
||||
endfunction "}}}
|
||||
|
||||
"changes the marker of the given item to the previous in g:vimwiki_list_markers
|
||||
function! s:get_prev_mrkr(item) "{{{
|
||||
let markers = vimwiki#vars#get_syntaxlocal('list_markers')
|
||||
if a:item.type == 0
|
||||
return g:vimwiki_list_markers[-1]
|
||||
return markers[-1]
|
||||
endif
|
||||
let idx = s:get_idx_list_markers(a:item)
|
||||
if idx == -1
|
||||
return g:vimwiki_list_markers[-1]
|
||||
return markers[-1]
|
||||
else
|
||||
return g:vimwiki_list_markers[(idx - 1 + len(g:vimwiki_list_markers)) %
|
||||
\ len(g:vimwiki_list_markers)]
|
||||
return markers[(idx - 1 + len(markers)) %
|
||||
\ len(markers)]
|
||||
endif
|
||||
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 && VimwikiGet('syntax') !=? 'media'
|
||||
if indent(a:item.lnum) == 0 && !vimwiki#vars#get_syntaxlocal('recurring_bullets')
|
||||
call s:set_indent(a:item.lnum, vimwiki#lst#get_list_margin())
|
||||
endif
|
||||
else
|
||||
@ -1202,7 +1238,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
||||
endif
|
||||
|
||||
"handle markers like ***
|
||||
if index(s:multiple_bullet_chars, s:first_char(new_mrkr)) > -1
|
||||
if index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1
|
||||
"use *** if the item above has *** too
|
||||
let item_above = s:get_prev_list_item(cur_item, 1)
|
||||
if item_above.type == 1 &&
|
||||
@ -1217,7 +1253,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
||||
else
|
||||
"if the old is ### and the new is * use ***
|
||||
if cur_item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars,s:first_char(cur_item.mrkr))>-1
|
||||
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(cur_item.mrkr))>-1
|
||||
let new_mrkr = repeat(new_mrkr, s:string_length(cur_item.mrkr))
|
||||
else
|
||||
"use *** if the parent item has **
|
||||
@ -1261,7 +1297,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 || VimwikiGet('syntax') ==? 'media'
|
||||
if a:item.type == 0 || vimwiki#vars#get_syntaxlocal('recurring_bullets')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1273,7 +1309,7 @@ function! s:adjust_mrkr(item) "{{{
|
||||
|
||||
"if possible, set e.g. *** if parent has ** as marker
|
||||
if neighbor_item.type == 0 && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(a:item.mrkr)) > -1
|
||||
let parent_item = s:get_parent(a:item)
|
||||
if parent_item.type == 1 &&
|
||||
\ s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr)
|
||||
@ -1291,7 +1327,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 = ( VimwikiGet('syntax') !=? 'media' ? indent(a:from) : 0 )
|
||||
let new_indent = ( vimwiki#vars#get_syntaxlocal('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))
|
||||
@ -1328,7 +1364,7 @@ function! s:create_marker(lnum) "{{{
|
||||
call s:clone_marker_from_to(new_sibling.lnum, a:lnum)
|
||||
else
|
||||
let cur_item = s:get_item(a:lnum)
|
||||
call s:set_new_mrkr(cur_item, g:vimwiki_list_markers[0])
|
||||
call s:set_new_mrkr(cur_item, vimwiki#vars#get_syntaxlocal('list_markers')[0])
|
||||
call s:adjust_numbered_list(cur_item, 0, 0)
|
||||
endif
|
||||
endfunction "}}}
|
||||
@ -1528,53 +1564,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(g:vimwiki_listsyms, '\zs')
|
||||
|
||||
if match(g:vimwiki_listsyms, g:vimwiki_listsym_rejected) != -1
|
||||
echomsg "Warning: g:vimwiki_listsyms and g:vimwiki_listsym_rejected overlap"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#lst#TO_list_item(inner, visual) "{{{
|
||||
let lnum = prevnonblank('.')
|
||||
let item = s:get_corresponding_item(lnum)
|
||||
|
@ -13,58 +13,36 @@ function! s:safesubstitute(text, search, replace, mode) "{{{
|
||||
return substitute(a:text, a:search, escaped, a:mode)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#markdown_base#reset_mkd_refs
|
||||
function! vimwiki#markdown_base#reset_mkd_refs() "{{{
|
||||
call VimwikiClear('markdown_refs')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#markdown_base#scan_reflinks
|
||||
function! vimwiki#markdown_base#scan_reflinks() " {{{
|
||||
let mkd_refs = {}
|
||||
" construct list of references using vimgrep
|
||||
try
|
||||
" Why noautocmd? Because https://github.com/vimwiki/vimwiki/issues/121
|
||||
noautocmd execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
|
||||
noautocmd execute 'vimgrep #'.vimwiki#vars#get_syntaxlocal('rxMkdRef').'#j %'
|
||||
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
||||
"Ignore it, and move on to the next file
|
||||
endtry
|
||||
"
|
||||
for d in getqflist()
|
||||
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
|
||||
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
|
||||
let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl)
|
||||
let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr'))
|
||||
let url = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchUrl'))
|
||||
if descr != '' && url != ''
|
||||
let mkd_refs[descr] = url
|
||||
endif
|
||||
endfor
|
||||
call VimwikiSet('markdown_refs', mkd_refs)
|
||||
call vimwiki#vars#set_bufferlocal('markdown_refs', mkd_refs)
|
||||
return mkd_refs
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" vimwiki#markdown_base#get_reflinks
|
||||
function! vimwiki#markdown_base#get_reflinks() " {{{
|
||||
let done = 1
|
||||
try
|
||||
let mkd_refs = VimwikiGet('markdown_refs')
|
||||
catch
|
||||
" work-around hack
|
||||
let done = 0
|
||||
" ... the following command does not work inside catch block !?
|
||||
" > let mkd_refs = vimwiki#markdown_base#scan_reflinks()
|
||||
endtry
|
||||
if !done
|
||||
let mkd_refs = vimwiki#markdown_base#scan_reflinks()
|
||||
endif
|
||||
return mkd_refs
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#markdown_base#open_reflink
|
||||
" try markdown reference links
|
||||
function! vimwiki#markdown_base#open_reflink(link) " {{{
|
||||
" echom "vimwiki#markdown_base#open_reflink"
|
||||
let link = a:link
|
||||
let mkd_refs = vimwiki#markdown_base#get_reflinks()
|
||||
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
|
||||
if has_key(mkd_refs, link)
|
||||
let url = mkd_refs[link]
|
||||
call vimwiki#base#system_open_link(url)
|
||||
@ -84,50 +62,50 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
let lnum = line('.')
|
||||
|
||||
" 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 WikiLink0: replace with WikiLink1
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'))
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLink1Template2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
|
||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
||||
\ vimwiki#vars#get_syntaxlocal('WikiLink1Template2'))
|
||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'), sub)
|
||||
return
|
||||
endif
|
||||
|
||||
" try WikiLink1: replace with WikiLink0
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'))
|
||||
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_rxWikiLink1, sub)
|
||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
||||
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), sub)
|
||||
return
|
||||
endif
|
||||
|
||||
" try Weblink
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'))
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
|
||||
\ g:vimwiki_Weblink1Template)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
|
||||
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWeblinkMatchDescr'),
|
||||
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
|
||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('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_global('rxWord'))
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWord, '',
|
||||
\ g:vimwiki_Weblink1Template)
|
||||
\ vimwiki#vars#get_global('rxWord'), '',
|
||||
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
return
|
||||
endif
|
||||
@ -146,7 +124,8 @@ function! s:normalize_link_syntax_v() " {{{
|
||||
try
|
||||
norm! gvy
|
||||
let visual_selection = @"
|
||||
let link = s:safesubstitute(g:vimwiki_Weblink1Template, '__LinkUrl__', visual_selection, '')
|
||||
let link = s:safesubstitute(vimwiki#vars#get_syntaxlocal('Weblink1Template'),
|
||||
\ '__LinkUrl__', visual_selection, '')
|
||||
let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
|
||||
|
||||
call setreg('"', link, 'v')
|
||||
|
@ -133,8 +133,8 @@ function! vimwiki#path#mkdir(path, ...) "{{{
|
||||
endif
|
||||
|
||||
let path = vimwiki#path#chomp_slash(path)
|
||||
if vimwiki#u#is_windows() && !empty(g:vimwiki_w32_dir_enc)
|
||||
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
||||
if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc'))
|
||||
let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc'))
|
||||
endif
|
||||
|
||||
if a:0 && a:1 && input("Vimwiki: Make new directory: "
|
||||
|
@ -28,7 +28,7 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
|
||||
let all_files = a:all_files != ''
|
||||
if !a:full_rebuild
|
||||
" Updating for one page (current)
|
||||
let page_name = VimwikiGet('subdir') . expand('%:t:r')
|
||||
let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r')
|
||||
" Collect tags in current file
|
||||
let tags = s:scan_tags(getline(1, '$'), page_name)
|
||||
" Load metadata file
|
||||
@ -40,8 +40,8 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
|
||||
" Save
|
||||
call s:write_tags_metadata(metadata)
|
||||
else " full rebuild
|
||||
let files = vimwiki#base#find_files(g:vimwiki_current_idx, 0)
|
||||
let wiki_base_dir = VimwikiGet('path', g:vimwiki_current_idx)
|
||||
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
|
||||
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
|
||||
let tags_file_last_modification =
|
||||
\ getftime(vimwiki#tags#metadata_file_path())
|
||||
let metadata = s:load_tags_metadata()
|
||||
@ -68,8 +68,8 @@ function! s:scan_tags(lines, page_name) "{{{
|
||||
" Code wireframe to scan for headers -- borrowed from
|
||||
" vimwiki#base#get_anchors(), with minor modifications.
|
||||
|
||||
let rxheader = g:vimwiki_{VimwikiGet('syntax')}_header_search
|
||||
let rxtag = g:vimwiki_{VimwikiGet('syntax')}_tag_search
|
||||
let rxheader = vimwiki#vars#get_syntaxlocal('header_search')
|
||||
let rxtag = vimwiki#vars#get_syntaxlocal('tag_search')
|
||||
|
||||
let anchor_level = ['', '', '', '', '', '', '']
|
||||
let current_complete_anchor = ''
|
||||
@ -141,7 +141,7 @@ endfunction " }}}
|
||||
" vimwiki#tags#metadata_file_path
|
||||
" Returns tags metadata file path
|
||||
function! vimwiki#tags#metadata_file_path() abort "{{{
|
||||
return fnamemodify(vimwiki#path#join_path(VimwikiGet('path'), s:TAGS_METADATA_FILE_NAME), ':p')
|
||||
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'), s:TAGS_METADATA_FILE_NAME), ':p')
|
||||
endfunction " }}}
|
||||
|
||||
" s:load_tags_metadata
|
||||
@ -261,7 +261,7 @@ function! s:write_tags_metadata(metadata) "{{{
|
||||
let entry_data = substitute(entry_data, "\n", '\\n', 'g')
|
||||
call add(tags,
|
||||
\ entry.tagname . "\t"
|
||||
\ . pagename . VimwikiGet('ext') . "\t"
|
||||
\ . pagename . vimwiki#vars#get_wikilocal('ext') . "\t"
|
||||
\ . entry.lineno
|
||||
\ . ';"'
|
||||
\ . "\t" . "vimwiki:" . entry_data
|
||||
@ -315,18 +315,18 @@ function! vimwiki#tags#generate_tags(...) abort "{{{
|
||||
if need_all_tags || index(specific_tags, tagname) != -1
|
||||
call extend(lines, [
|
||||
\ '',
|
||||
\ substitute(g:vimwiki_rxH2_Template, '__Header__', tagname, ''),
|
||||
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''),
|
||||
\ '' ])
|
||||
for taglink in sort(tags_entries[tagname])
|
||||
call add(lines, bullet .
|
||||
\ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', taglink, ''))
|
||||
\ substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', taglink, ''))
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
let links_rx = '\m\%(^\s*$\)\|\%('.g:vimwiki_rxH2.'\)\|\%(^\s*'
|
||||
let links_rx = '\m\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH2').'\)\|\%(^\s*'
|
||||
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
||||
\ .g:vimwiki_rxWikiLink.'$\)'
|
||||
\ .vimwiki#vars#get_syntaxlocal('rxWikiLink').'$\)'
|
||||
|
||||
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx,
|
||||
\ line('$')+1, 1)
|
||||
|
@ -19,7 +19,7 @@ let s:textwidth = &tw
|
||||
|
||||
" Misc functions {{{
|
||||
function! s:rxSep() "{{{
|
||||
return g:vimwiki_rxTableSep
|
||||
return vimwiki#vars#get_syntaxlocal('rxTableSep')
|
||||
endfunction "}}}
|
||||
|
||||
function! s:wide_len(str) "{{{
|
||||
@ -29,7 +29,7 @@ function! s:wide_len(str) "{{{
|
||||
endif
|
||||
|
||||
" get str display width in vim ver < 7.2
|
||||
if !g:vimwiki_CJK_length
|
||||
if !vimwiki#vars#get_global('CJK_length')
|
||||
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
|
||||
else
|
||||
let savemodified = &modified
|
||||
|
@ -43,17 +43,12 @@ endfunction "}}}
|
||||
|
||||
" Load concrete Wiki syntax: sets regexes and templates for headers and links
|
||||
function vimwiki#u#reload_regexes() "{{{
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
|
||||
endfunction "}}}
|
||||
|
||||
" Load omnipresent Wiki syntax
|
||||
function vimwiki#u#reload_omni_regexes() "{{{
|
||||
execute 'runtime! syntax/omnipresent_syntax.vim'
|
||||
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'.vim'
|
||||
endfunction "}}}
|
||||
|
||||
" Load syntax-specific functionality
|
||||
function vimwiki#u#reload_regexes_custom() "{{{
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
|
||||
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'_custom.vim'
|
||||
endfunction "}}}
|
||||
|
||||
" Backward compatible version of the built-in function shiftwidth()
|
||||
|
699
autoload/vimwiki/vars.vim
Normal file
699
autoload/vimwiki/vars.vim
Normal file
@ -0,0 +1,699 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||
" Vimwiki autoload plugin file
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" ------------------------------------------------------------------------------------------------
|
||||
" This file provides functions to manage the various state variables which are needed during a
|
||||
" Vimwiki session.
|
||||
" They consist of:
|
||||
"
|
||||
" - global variables. These are stored in the dict g:vimwiki_global_vars. They consist mainly of
|
||||
" global user variables and syntax stuff which is the same for every syntax.
|
||||
"
|
||||
" - wiki-local variables. They are stored in g:vimwiki_wikilocal_vars which is a list of
|
||||
" dictionaries. One dict for every registered wiki. The last dictionary contains default values
|
||||
" (used for temporary wikis).
|
||||
"
|
||||
" - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and
|
||||
" other stuff which is needed for highlighting.
|
||||
"
|
||||
" - buffer-local variables. They are stored as buffer variables directly (b:foo)
|
||||
|
||||
" As a developer, you should, if possible, only use the get_ and set_ functions for these types of
|
||||
" variables, not the underlying dicts!
|
||||
" ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function! s:populate_global_variables()
|
||||
|
||||
let g:vimwiki_global_vars = {
|
||||
\ 'CJK_length': 0,
|
||||
\ 'auto_chdir': 0,
|
||||
\ 'autowriteall': 1,
|
||||
\ 'conceallevel': 2,
|
||||
\ 'diary_months':
|
||||
\ {
|
||||
\ 1: 'January', 2: 'February', 3: 'March',
|
||||
\ 4: 'April', 5: 'May', 6: 'June',
|
||||
\ 7: 'July', 8: 'August', 9: 'September',
|
||||
\ 10: 'October', 11: 'November', 12: 'December'
|
||||
\ },
|
||||
\ 'dir_link': '',
|
||||
\ 'ext2syntax': {},
|
||||
\ 'folding': '',
|
||||
\ 'global_ext': 1,
|
||||
\ 'hl_cb_checked': 0,
|
||||
\ 'hl_headers': 0,
|
||||
\ 'html_header_numbering': 0,
|
||||
\ 'html_header_numbering_sym': '',
|
||||
\ 'list_ignore_newline': 1,
|
||||
\ 'text_ignore_newline': 1,
|
||||
\ 'listsyms': ' .oOX',
|
||||
\ 'listsym_rejected': '-',
|
||||
\ 'map_prefix': '<Leader>w',
|
||||
\ 'menu': 'Vimwiki',
|
||||
\ 'table_auto_fmt': 1,
|
||||
\ 'table_mappings': 1,
|
||||
\ 'toc_header': 'Contents',
|
||||
\ 'url_maxsave': 15,
|
||||
\ 'use_calendar': 1,
|
||||
\ 'use_mouse': 0,
|
||||
\ 'user_htmls': '',
|
||||
\ 'valid_html_tags': 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em',
|
||||
\ 'w32_dir_enc': '',
|
||||
\ }
|
||||
|
||||
" copy the user's settings from variables of the form g:vimwiki_<option> into the dict
|
||||
" g:vimwiki_global_vars (or set a default value)
|
||||
for key in keys(g:vimwiki_global_vars)
|
||||
if exists('g:vimwiki_'.key)
|
||||
let g:vimwiki_global_vars[key] = g:vimwiki_{key}
|
||||
endif
|
||||
endfor
|
||||
|
||||
" non-configurable global variables:
|
||||
|
||||
" Scheme regexes must be defined even if syntax file is not loaded yet cause users should be
|
||||
" able to <leader>w<leader>w without opening any vimwiki file first
|
||||
let g:vimwiki_global_vars.schemes = 'wiki\d\+,diary,local'
|
||||
let g:vimwiki_global_vars.web_schemes1 = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'.
|
||||
\ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp'
|
||||
let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel,data'
|
||||
|
||||
let rx_schemes = '\%('.
|
||||
\ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_global_vars.web_schemes1, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(web_schemes2, '\s*,\s*'), '\|').
|
||||
\ '\)'
|
||||
|
||||
let g:vimwiki_global_vars.rxSchemeUrl = rx_schemes.':.*'
|
||||
let g:vimwiki_global_vars.rxSchemeUrlMatchScheme = '\zs'.rx_schemes.'\ze:.*'
|
||||
let g:vimwiki_global_vars.rxSchemeUrlMatchUrl = rx_schemes.':\zs.*\ze'
|
||||
|
||||
" match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme
|
||||
" http://tools.ietf.org/html/rfc3986
|
||||
let rxWebProtocols =
|
||||
\ '\%('.
|
||||
\ '\%('.
|
||||
\ '\%('.join(split(g:vimwiki_global_vars.web_schemes1, '\s*,\s*'), '\|').'\):'.
|
||||
\ '\%(//\)'.
|
||||
\ '\)'.
|
||||
\ '\|'.
|
||||
\ '\%('.join(split(web_schemes2, '\s*,\s*'), '\|').'\):'.
|
||||
\ '\)'
|
||||
|
||||
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
|
||||
|
||||
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:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
||||
|
||||
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix .
|
||||
\ g:vimwiki_global_vars.rxWikiLinkUrl . g:vimwiki_global_vars.rx_wikilink_separator
|
||||
let g:vimwiki_global_vars.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__' . g:vimwiki_global_vars.rxWikiInclSeparator . '__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
|
||||
|
||||
let g:vimwiki_global_vars.rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
|
||||
|
||||
" default colors when headers of different levels are highlighted differently
|
||||
" not making it yet another option; needed by ColorScheme autocommand
|
||||
let g:vimwiki_global_vars.hcolor_guifg_light = ['#aa5858', '#507030', '#1030a0', '#103040'
|
||||
\ , '#505050', '#636363']
|
||||
let g:vimwiki_global_vars.hcolor_ctermfg_light = ['DarkRed', 'DarkGreen', 'DarkBlue', 'Black'
|
||||
\ , 'Black', 'Black']
|
||||
let g:vimwiki_global_vars.hcolor_guifg_dark = ['#e08090', '#80e090', '#6090e0', '#c0c0f0'
|
||||
\ , '#e0e0f0', '#f0f0f0']
|
||||
let g:vimwiki_global_vars.hcolor_ctermfg_dark = ['Red', 'Green', 'Blue', 'White', 'White'
|
||||
\ , 'White']
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:populate_wikilocal_options()
|
||||
let default_values = {
|
||||
\ 'auto_export': 0,
|
||||
\ 'auto_tags': 0,
|
||||
\ 'auto_toc': 0,
|
||||
\ 'automatic_nested_syntaxes': 1,
|
||||
\ 'css_name': 'style.css',
|
||||
\ 'custom_wiki2html': '',
|
||||
\ 'diary_header': 'Diary',
|
||||
\ 'diary_index': 'diary',
|
||||
\ 'diary_rel_path': 'diary/',
|
||||
\ 'diary_sort': 'desc',
|
||||
\ 'ext': '.wiki',
|
||||
\ 'index': 'index',
|
||||
\ 'list_margin': -1,
|
||||
\ 'maxhi': 0,
|
||||
\ 'nested_syntaxes': {},
|
||||
\ 'path': '~/vimwiki/',
|
||||
\ 'path_html': '',
|
||||
\ 'syntax': 'default',
|
||||
\ 'template_default': 'default',
|
||||
\ 'template_ext': '.tpl',
|
||||
\ 'template_path': '~/vimwiki/templates/',
|
||||
\ }
|
||||
|
||||
let g:vimwiki_wikilocal_vars = []
|
||||
|
||||
" set the wiki-local variables according to g:vimwiki_list (or the default settings)
|
||||
if exists('g:vimwiki_list')
|
||||
for users_options in g:vimwiki_list
|
||||
let new_wiki_settings = {}
|
||||
for key in keys(default_values)
|
||||
if has_key(users_options, key)
|
||||
let new_wiki_settings[key] = users_options[key]
|
||||
elseif exists('g:vimwiki_'.key)
|
||||
let new_wiki_settings[key] = g:vimwiki_{key}
|
||||
else
|
||||
let new_wiki_settings[key] = default_values[key]
|
||||
endif
|
||||
endfor
|
||||
|
||||
let new_wiki_settings.is_temporary_wiki = 0
|
||||
|
||||
call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
|
||||
endfor
|
||||
endif
|
||||
|
||||
" default values for temporary wikis
|
||||
let temporary_options_dict = {}
|
||||
for key in keys(default_values)
|
||||
if exists('g:vimwiki_'.key)
|
||||
let temporary_options_dict[key] = g:vimwiki_{key}
|
||||
else
|
||||
let temporary_options_dict[key] = default_values[key]
|
||||
endif
|
||||
endfor
|
||||
let temporary_options_dict.is_temporary_wiki = 1
|
||||
call add(g:vimwiki_wikilocal_vars, temporary_options_dict)
|
||||
|
||||
call s:validate_settings()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:validate_settings()
|
||||
for wiki_settings in g:vimwiki_wikilocal_vars
|
||||
let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
|
||||
|
||||
let path_html = wiki_settings['path_html']
|
||||
if !empty(path_html)
|
||||
let wiki_settings['path_html'] = s:normalize_path(path_html)
|
||||
else
|
||||
let wiki_settings['path_html'] = s:normalize_path(
|
||||
\ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/')
|
||||
endif
|
||||
|
||||
let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path'])
|
||||
let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path'])
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:normalize_path(path) "{{{
|
||||
" trim trailing / and \ because otherwise resolve() doesn't work quite right
|
||||
let path = substitute(a:path, '[/\\]\+$', '', '')
|
||||
if path !~# '^scp:'
|
||||
return resolve(expand(path)).'/'
|
||||
else
|
||||
return path.'/'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
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)
|
||||
return
|
||||
endif
|
||||
|
||||
let g:vimwiki_syntax_variables[a:syntax] = {}
|
||||
|
||||
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_syntax_variables[a:syntax].rxPreEnd =
|
||||
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreEnd.'\s*$'
|
||||
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxMathStart =
|
||||
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathStart
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxMathEnd =
|
||||
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$'
|
||||
|
||||
" list stuff
|
||||
let g:vimwiki_syntax_variables[a:syntax].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 g:vimwiki_syntax_variables[a:syntax].number_kinds = []
|
||||
let g:vimwiki_syntax_variables[a:syntax].number_divisors = ''
|
||||
for i in g:vimwiki_syntax_variables[a:syntax].number_types
|
||||
call add(g:vimwiki_syntax_variables[a:syntax].number_kinds, i[0])
|
||||
let g:vimwiki_syntax_variables[a:syntax].number_divisors .= vimwiki#u#escape(i[1])
|
||||
endfor
|
||||
|
||||
let char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+',
|
||||
\ 'a': '\l\{1,2}', 'A': '\u\{1,2}'}
|
||||
|
||||
"create regexp for bulleted list items
|
||||
if !empty(g:vimwiki_syntax_variables[a:syntax].bullet_types)
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListBullet =
|
||||
\ join( map(g:vimwiki_syntax_variables[a:syntax].bullet_types,
|
||||
\'vimwiki#u#escape(v:val).'
|
||||
\ .'repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)'
|
||||
\ ) , '\|')
|
||||
else
|
||||
"regex that matches nothing
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListBullet = '$^'
|
||||
endif
|
||||
|
||||
"create regex for numbered list items
|
||||
if !empty(g:vimwiki_syntax_variables[a:syntax].number_types)
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '\C\%('
|
||||
for type in g:vimwiki_syntax_variables[a:syntax].number_types[:-2]
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[type[0]] .
|
||||
\ vimwiki#u#escape(type[1]) . '\|'
|
||||
endfor
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .=
|
||||
\ char_to_rx[g:vimwiki_syntax_variables[a:syntax].number_types[-1][0]].
|
||||
\ vimwiki#u#escape(g:vimwiki_syntax_variables[a:syntax].number_types[-1][1]) . '\)'
|
||||
else
|
||||
"regex that matches nothing
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '$^'
|
||||
endif
|
||||
|
||||
"the user can set the listsyms as string, but vimwiki needs a list
|
||||
let g:vimwiki_syntax_variables[a:syntax].listsyms_list =
|
||||
\ split(vimwiki#vars#get_global('listsyms'), '\zs')
|
||||
if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1
|
||||
echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected ('''
|
||||
\ . vimwiki#vars#get_global('listsym_rejected')
|
||||
\ . ''') must not be a part of g:vimwiki_listsyms (''' .
|
||||
\ . vimwiki#vars#get_global('listsyms') . ''')'
|
||||
endif
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB =
|
||||
\ '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\('
|
||||
\ .g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s'
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListItem =
|
||||
\ g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB
|
||||
\ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms')
|
||||
\ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?'
|
||||
if g:vimwiki_syntax_variables[a:syntax].recurring_bullets
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
|
||||
\ '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\['
|
||||
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1].'\]\s.*\%(\n\%(\1\%('
|
||||
\ .g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*'
|
||||
else
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
|
||||
\ '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|'
|
||||
\ . g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\['
|
||||
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||
endif
|
||||
|
||||
" 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_syntax_variables[a:syntax].rxWeblink =
|
||||
\ '\<'. g:vimwiki_global_vars.rxWeblinkUrl . '\S*'
|
||||
" 0a) match URL within URL
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchUrl =
|
||||
\ g:vimwiki_syntax_variables[a:syntax].rxWeblink
|
||||
" 0b) match DESCRIPTION within URL
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxWeblinkMatchDescr = ''
|
||||
|
||||
" template for matching all wiki links with a given target file
|
||||
let g:vimwiki_syntax_variables[a:syntax].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
|
||||
|
||||
" a) match [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_syntax_variables[a:syntax].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
|
||||
let g:vimwiki_syntax_variables[a:syntax].rxAnyLink =
|
||||
\ g:vimwiki_syntax_variables[a:syntax].rxWikiLink.'\|'.
|
||||
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.g:vimwiki_syntax_variables[a:syntax].rxWeblink
|
||||
" b) match URL within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_syntax_variables[a:syntax].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_syntax_variables[a:syntax].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
|
||||
|
||||
if a:syntax ==# 'markdown'
|
||||
call s:populate_extra_markdown_vars()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:populate_extra_markdown_vars()
|
||||
let mkd_syntax = g:vimwiki_syntax_variables['markdown']
|
||||
|
||||
" 0a) match [[URL|DESCRIPTION]]
|
||||
let mkd_syntax.rxWikiLink0 = mkd_syntax.rxWikiLink
|
||||
" 0b) match URL within [[URL|DESCRIPTION]]
|
||||
let mkd_syntax.rxWikiLink0MatchUrl = mkd_syntax.rxWikiLinkMatchUrl
|
||||
" 0c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
||||
let mkd_syntax.rxWikiLink0MatchDescr = mkd_syntax.rxWikiLinkMatchDescr
|
||||
|
||||
let wikilink_md_prefix = '['
|
||||
let wikilink_md_suffix = ']'
|
||||
let wikilink_md_separator = ']['
|
||||
let rx_wikilink_md_separator = vimwiki#u#escape(wikilink_md_separator)
|
||||
let mkd_syntax.rx_wikilink_md_prefix = vimwiki#u#escape(wikilink_md_prefix)
|
||||
let mkd_syntax.rx_wikilink_md_suffix = vimwiki#u#escape(wikilink_md_suffix)
|
||||
|
||||
" [URL][]
|
||||
let mkd_syntax.WikiLink1Template1 = wikilink_md_prefix . '__LinkUrl__'.
|
||||
\ wikilink_md_separator. wikilink_md_suffix
|
||||
" [DESCRIPTION][URL]
|
||||
let mkd_syntax.WikiLink1Template2 = wikilink_md_prefix. '__LinkDescription__'.
|
||||
\ wikilink_md_separator. '__LinkUrl__'. wikilink_md_suffix
|
||||
let mkd_syntax.WikiLinkMatchUrlTemplate .=
|
||||
\ '\|' .
|
||||
\ mkd_syntax.rx_wikilink_md_prefix .
|
||||
\ '.*' .
|
||||
\ rx_wikilink_md_separator .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ mkd_syntax.rx_wikilink_md_suffix .
|
||||
\ '\|' .
|
||||
\ mkd_syntax.rx_wikilink_md_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ rx_wikilink_md_separator .
|
||||
\ mkd_syntax.rx_wikilink_md_suffix
|
||||
|
||||
let valid_chars = '[^\\\[\]]'
|
||||
let mkd_syntax.rxWikiLink1Url = valid_chars.'\{-}'
|
||||
let mkd_syntax.rxWikiLink1Descr = valid_chars.'\{-}'
|
||||
let mkd_syntax.rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
|
||||
let mkd_syntax.rxWikiLink1InvalidSuffix = '[\]\[]\@!'
|
||||
let mkd_syntax.rx_wikilink_md_prefix = mkd_syntax.rxWikiLink1InvalidPrefix.
|
||||
\ mkd_syntax.rx_wikilink_md_prefix
|
||||
let mkd_syntax.rx_wikilink_md_suffix = mkd_syntax.rx_wikilink_md_suffix.
|
||||
\ mkd_syntax.rxWikiLink1InvalidSuffix
|
||||
|
||||
" 1. match [URL][], [DESCRIPTION][URL]
|
||||
let mkd_syntax.rxWikiLink1 = mkd_syntax.rx_wikilink_md_prefix.
|
||||
\ mkd_syntax.rxWikiLink1Url. rx_wikilink_md_separator.
|
||||
\ mkd_syntax.rx_wikilink_md_suffix.
|
||||
\ '\|'. mkd_syntax.rx_wikilink_md_prefix.
|
||||
\ mkd_syntax.rxWikiLink1Descr . rx_wikilink_md_separator.
|
||||
\ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix
|
||||
" 2. match URL within [URL][], [DESCRIPTION][URL]
|
||||
let mkd_syntax.rxWikiLink1MatchUrl = mkd_syntax.rx_wikilink_md_prefix.
|
||||
\ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. rx_wikilink_md_separator.
|
||||
\ mkd_syntax.rx_wikilink_md_suffix.
|
||||
\ '\|'. mkd_syntax.rx_wikilink_md_prefix.
|
||||
\ mkd_syntax.rxWikiLink1Descr. rx_wikilink_md_separator.
|
||||
\ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. mkd_syntax.rx_wikilink_md_suffix
|
||||
" 3. match DESCRIPTION within [DESCRIPTION][URL]
|
||||
let mkd_syntax.rxWikiLink1MatchDescr = mkd_syntax.rx_wikilink_md_prefix.
|
||||
\ '\zs'. mkd_syntax.rxWikiLink1Descr.'\ze'. rx_wikilink_md_separator.
|
||||
\ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix
|
||||
|
||||
let mkd_syntax.rxWikiLink1Prefix1 = mkd_syntax.rx_wikilink_md_prefix
|
||||
let mkd_syntax.rxWikiLink1Suffix1 = rx_wikilink_md_separator.
|
||||
\ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix
|
||||
|
||||
" 1. match ANY wikilink
|
||||
let mkd_syntax.rxWikiLink = mkd_syntax.rxWikiLink0 . '\|' . mkd_syntax.rxWikiLink1
|
||||
" 2. match URL within ANY wikilink
|
||||
let mkd_syntax.rxWikiLinkMatchUrl = mkd_syntax.rxWikiLink0MatchUrl . '\|' .
|
||||
\ mkd_syntax.rxWikiLink1MatchUrl
|
||||
" 3. match DESCRIPTION within ANY wikilink
|
||||
let mkd_syntax.rxWikiLinkMatchDescr = mkd_syntax.rxWikiLink0MatchDescr . '\|' .
|
||||
\ mkd_syntax.rxWikiLink1MatchDescr
|
||||
|
||||
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
|
||||
let mkd_syntax.rxWeblink0 = mkd_syntax.rxWeblink
|
||||
" 0a) match URL within URL
|
||||
let mkd_syntax.rxWeblinkMatchUrl0 = mkd_syntax.rxWeblinkMatchUrl
|
||||
" 0b) match DESCRIPTION within URL
|
||||
let mkd_syntax.rxWeblinkMatchDescr0 = mkd_syntax.rxWeblinkMatchDescr
|
||||
|
||||
let mkd_syntax.rxWeblink1Prefix = '['
|
||||
let mkd_syntax.rxWeblink1Suffix = ')'
|
||||
let mkd_syntax.rxWeblink1Separator = ']('
|
||||
" [DESCRIPTION](URL)
|
||||
let mkd_syntax.Weblink1Template = mkd_syntax.rxWeblink1Prefix . '__LinkDescription__'.
|
||||
\ mkd_syntax.rxWeblink1Separator. '__LinkUrl__'.
|
||||
\ mkd_syntax.rxWeblink1Suffix
|
||||
|
||||
let valid_chars = '[^\\]'
|
||||
|
||||
let mkd_syntax.rxWeblink1Prefix = vimwiki#u#escape(mkd_syntax.rxWeblink1Prefix)
|
||||
let mkd_syntax.rxWeblink1Suffix = vimwiki#u#escape(mkd_syntax.rxWeblink1Suffix)
|
||||
let mkd_syntax.rxWeblink1Separator = vimwiki#u#escape(mkd_syntax.rxWeblink1Separator)
|
||||
let mkd_syntax.rxWeblink1Url = valid_chars.'\{-}'
|
||||
let mkd_syntax.rxWeblink1Descr = valid_chars.'\{-}'
|
||||
|
||||
" 1. [DESCRIPTION](URL)
|
||||
" 1a) match [DESCRIPTION](URL)
|
||||
let mkd_syntax.rxWeblink1 = mkd_syntax.rxWeblink1Prefix.
|
||||
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1Separator.
|
||||
\ mkd_syntax.rxWeblink1Descr . mkd_syntax.rxWeblink1Suffix
|
||||
" 1b) match URL within [DESCRIPTION](URL)
|
||||
let mkd_syntax.rxWeblink1MatchUrl = mkd_syntax.rxWeblink1Prefix.
|
||||
\ mkd_syntax.rxWeblink1Descr. mkd_syntax.rxWeblink1Separator.
|
||||
\ '\zs' . mkd_syntax.rxWeblink1Url . '\ze' . mkd_syntax.rxWeblink1Suffix
|
||||
" 1c) match DESCRIPTION within [DESCRIPTION](URL)
|
||||
let mkd_syntax.rxWeblink1MatchDescr = mkd_syntax.rxWeblink1Prefix.
|
||||
\ '\zs'.mkd_syntax.rxWeblink1Descr.'\ze'. mkd_syntax.rxWeblink1Separator.
|
||||
\ mkd_syntax.rxWeblink1Url. mkd_syntax.rxWeblink1Suffix
|
||||
|
||||
" TODO: image links too !!
|
||||
let mkd_syntax.rxWeblink1Prefix1 = mkd_syntax.rxWeblink1Prefix
|
||||
let mkd_syntax.rxWeblink1Suffix1 = mkd_syntax.rxWeblink1Separator.
|
||||
\ mkd_syntax.rxWeblink1Url . mkd_syntax.rxWeblink1Suffix
|
||||
|
||||
" *a) match ANY weblink
|
||||
let mkd_syntax.rxWeblink = ''.
|
||||
\ mkd_syntax.rxWeblink1.'\|'.
|
||||
\ mkd_syntax.rxWeblink0
|
||||
" *b) match URL within ANY weblink
|
||||
let mkd_syntax.rxWeblinkMatchUrl = ''.
|
||||
\ mkd_syntax.rxWeblink1MatchUrl.'\|'.
|
||||
\ mkd_syntax.rxWeblinkMatchUrl0
|
||||
" *c) match DESCRIPTION within ANY weblink
|
||||
let mkd_syntax.rxWeblinkMatchDescr = ''.
|
||||
\ mkd_syntax.rxWeblink1MatchDescr.'\|'.
|
||||
\ mkd_syntax.rxWeblinkMatchDescr0
|
||||
|
||||
let mkd_syntax.rxAnyLink = mkd_syntax.rxWikiLink.'\|'.
|
||||
\ g:vimwiki_global_vars.rxWikiIncl.'\|'.mkd_syntax.rxWeblink
|
||||
|
||||
let mkd_syntax.rxMkdRef = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
|
||||
\ mkd_syntax.rxWeblink0
|
||||
let mkd_syntax.rxMkdRefMatchDescr =
|
||||
\ '\[\zs'.g:vimwiki_global_vars.rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'. mkd_syntax.rxWeblink0
|
||||
let mkd_syntax.rxMkdRefMatchUrl =
|
||||
\ '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
|
||||
\ mkd_syntax.rxWeblink0.'\ze'
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#init()
|
||||
call s:populate_global_variables()
|
||||
call s:populate_wikilocal_options()
|
||||
endfunction
|
||||
|
||||
|
||||
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[syntax][a:key]
|
||||
endfunction
|
||||
|
||||
|
||||
" Get a variable for the buffer we are currently in or for the given buffer (number or name).
|
||||
" Populate the variable, if it doesn't exist.
|
||||
function! vimwiki#vars#get_bufferlocal(key, ...)
|
||||
let buffer = a:0 ? a:1 : '%'
|
||||
|
||||
let value = getbufvar(buffer, 'vimwiki_'.a:key, '/\/\')
|
||||
if type(value) != 1 || value !=# '/\/\'
|
||||
return value
|
||||
elseif a:key ==# 'wiki_nr'
|
||||
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
|
||||
elseif a:key ==# 'subdir'
|
||||
call setbufvar(buffer, 'vimwiki_subdir', vimwiki#base#current_subdir())
|
||||
elseif a:key ==# 'invsubdir'
|
||||
let subdir = vimwiki#vars#get_bufferlocal('subdir')
|
||||
call setbufvar(buffer, 'vimwiki_invsubdir', vimwiki#base#invsubdir(subdir))
|
||||
elseif a:key ==# 'existing_wikifiles'
|
||||
call setbufvar(buffer, 'vimwiki_existing_wikifiles',
|
||||
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 1))
|
||||
elseif a:key ==# 'existing_wikidirs'
|
||||
call setbufvar(buffer, 'vimwiki_existing_wikidirs',
|
||||
\ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr')))
|
||||
elseif a:key ==# 'prev_link'
|
||||
call setbufvar(buffer, 'vimwiki_prev_link', [])
|
||||
elseif a:key ==# 'markdown_refs'
|
||||
call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks())
|
||||
else
|
||||
echoerr 'Vimwiki Error: unknown buffer variable ' . string(a:key)
|
||||
endif
|
||||
|
||||
return getbufvar(buffer, 'vimwiki_'.a:key)
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#set_bufferlocal(key, value, ...)
|
||||
let buffer = a:0 ? a:1 : '%'
|
||||
call setbufvar(buffer, 'vimwiki_' . a:key, a:value)
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#get_global(key)
|
||||
return g:vimwiki_global_vars[a:key]
|
||||
endfunction
|
||||
|
||||
|
||||
" the second argument can be a wiki number. When absent, the wiki of the currently active buffer is
|
||||
" used
|
||||
function! vimwiki#vars#get_wikilocal(key, ...)
|
||||
if a:0
|
||||
return g:vimwiki_wikilocal_vars[a:1][a:key]
|
||||
else
|
||||
return g:vimwiki_wikilocal_vars[vimwiki#vars#get_bufferlocal('wiki_nr')][a:key]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#get_wikilocal_default(key)
|
||||
return g:vimwiki_wikilocal_vars[-1][a:key]
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#set_wikilocal(key, value, wiki_nr)
|
||||
if a:wiki_nr == len(g:vimwiki_wikilocal_vars) - 1
|
||||
call insert(g:vimwiki_wikilocal_vars, {}, -1)
|
||||
endif
|
||||
let g:vimwiki_wikilocal_vars[a:wiki_nr][a:key] = a:value
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#add_temporary_wiki(settings)
|
||||
let new_temp_wiki_settings = copy(g:vimwiki_wikilocal_vars[-1])
|
||||
for [key, value] in items(a:settings)
|
||||
let new_temp_wiki_settings[key] = value
|
||||
endfor
|
||||
call insert(g:vimwiki_wikilocal_vars, new_temp_wiki_settings, -1)
|
||||
call s:validate_settings()
|
||||
endfunction
|
||||
|
||||
" number of registered wikis + temporary
|
||||
function! vimwiki#vars#number_of_wikis()
|
||||
return len(g:vimwiki_wikilocal_vars) - 1
|
||||
endfunction
|
@ -222,7 +222,7 @@ To remap one of these keys, either put it in your .vimrc like this >
|
||||
or, the better way, put it in a file .vim/ftplugin/vimwiki.vim like this >
|
||||
:nmap <silent><buffer> <Leader>wc <Plug>Vimwiki2HTML
|
||||
|
||||
The latter has the advantage that the mapping is local to viwiki buffers in
|
||||
The latter has the advantage that the mapping is local to Vimwiki buffers in
|
||||
every case.
|
||||
|
||||
Also note that some keys work in normal mode as well as in visual mode. If you
|
||||
@ -868,7 +868,7 @@ which opens up a popup menu with all the wiki files starting with "ind".
|
||||
When |vimwiki-option-maxhi| equals 1, a distinct highlighting style is used to
|
||||
identify wikilinks whose targets are not found.
|
||||
|
||||
Interwiki:~
|
||||
Interwiki~
|
||||
|
||||
If you maintain more than one wiki, you can create interwiki links between
|
||||
them by adding a numbered prefix "wikiX:" in front of a link: >
|
||||
@ -879,15 +879,11 @@ or: >
|
||||
The number behind "wiki" is in the range 0..N-1 and identifies the destination
|
||||
wiki in |g:vimwiki_list|.
|
||||
|
||||
Diary:~
|
||||
Diary~
|
||||
|
||||
The "diary:" scheme is used to concisely link to diary entries: >
|
||||
The "diary:" scheme is used to link to diary entries: >
|
||||
[[diary:2012-03-05]]
|
||||
|
||||
This scheme precludes explicit inclusion of |vimwiki-option-diary_rel_path|,
|
||||
and is most useful on subwiki pages to avoid links such as: >
|
||||
[[../../diary/2012-03-05]]
|
||||
|
||||
Anchors~
|
||||
|
||||
A wikilink, interwiki link or diary link can be followed by a '#' and the name
|
||||
@ -1633,8 +1629,7 @@ gL<Space> (see |vimwiki_gL<Space>|) to remove all checkboxes of the list the
|
||||
cursor is in.
|
||||
|
||||
You can mark an item as rejected ("won't do") with
|
||||
|vimwiki_glx|. A rejected item will not influence the status of it's
|
||||
parents.
|
||||
|vimwiki_glx|. A rejected item will not influence the status of its parents.
|
||||
|
||||
|
||||
==============================================================================
|
||||
@ -2366,9 +2361,9 @@ You can set it to some more fancy symbols like this:
|
||||
Character that is used to show that an item of a todo list will not be done.
|
||||
Default value is '-'.
|
||||
|
||||
The character used here may not be part of g:vimwiki_listsyms.
|
||||
The character used here must not be part of |g:vimwiki_listsyms|.
|
||||
|
||||
You can set it to some more fancy symbols like this:
|
||||
You can set it to a more fancy symbol like this:
|
||||
>
|
||||
let g:vimwiki_listsym_rejected = '✗'
|
||||
|
||||
|
@ -7,27 +7,17 @@ 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.
|
||||
let b:undo_ftplugin = "setlocal ".
|
||||
\ "suffixesadd< isfname< formatlistpat< ".
|
||||
\ "formatoptions< foldtext< ".
|
||||
\ "foldmethod< foldexpr< commentstring< "
|
||||
" UNDO }}}
|
||||
|
||||
" MISC STUFF {{{
|
||||
|
||||
setlocal commentstring=%%%s
|
||||
|
||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
||||
let &l:conceallevel = g:vimwiki_conceallevel
|
||||
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
||||
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
|
||||
endif
|
||||
|
||||
" GOTO FILE: gf {{{
|
||||
execute 'setlocal suffixesadd='.VimwikiGet('ext')
|
||||
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
|
||||
setlocal isfname-=[,]
|
||||
" gf}}}
|
||||
|
||||
@ -45,7 +35,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
let s:line_context = '['
|
||||
return startoflink
|
||||
endif
|
||||
if VimwikiGet('syntax') ==? 'markdown'
|
||||
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
|
||||
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
|
||||
if startofinlinelink != -1
|
||||
let s:line_context = '['
|
||||
@ -78,7 +68,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.*')
|
||||
@ -88,7 +78,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
let prefix = matchstr(a:base, '^diary:\zs.*')
|
||||
let scheme = matchstr(a:base, '^diary:\ze')
|
||||
else " current wiki
|
||||
let wikinumber = g:vimwiki_current_idx
|
||||
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
let prefix = a:base
|
||||
let scheme = ''
|
||||
endif
|
||||
@ -109,7 +99,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
|
||||
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
|
||||
let wikifile = link_infos.filename
|
||||
let syntax = VimwikiGet('syntax', link_infos.index)
|
||||
let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index)
|
||||
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
|
||||
|
||||
let filtered_anchors = []
|
||||
@ -141,7 +131,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
|
||||
@ -170,12 +160,12 @@ function! VimwikiFoldLevel(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
|
||||
" Header/section folding...
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
if line =~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||
return '>'.vimwiki#u#count_first_sym(line)
|
||||
" Code block folding...
|
||||
elseif line =~# g:vimwiki_rxPreStart
|
||||
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
||||
return 'a1'
|
||||
elseif line =~# g:vimwiki_rxPreEnd
|
||||
elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')
|
||||
return 's1'
|
||||
else
|
||||
return "="
|
||||
@ -221,7 +211,7 @@ function! VimwikiFoldText() "{{{
|
||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||
let fold_len = v:foldend - v:foldstart + 1
|
||||
let len_text = ' ['.fold_len.'] '
|
||||
if line !~# g:vimwiki_rxPreStart
|
||||
if line !~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
||||
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
||||
return main_text.len_text
|
||||
else
|
||||
@ -245,18 +235,19 @@ endfunction "}}}
|
||||
command! -buffer Vimwiki2HTML
|
||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||
\ <bar>
|
||||
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
|
||||
\ expand('%'))
|
||||
\ <bar>
|
||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '.expand(VimwikiGet('path_html')) | endif
|
||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
|
||||
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
|
||||
command! -buffer Vimwiki2HTMLBrowse
|
||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||
\ <bar>
|
||||
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
|
||||
\ expand(VimwikiGet('path_html')),
|
||||
\ expand(vimwiki#vars#get_wikilocal('path_html')),
|
||||
\ expand('%')))
|
||||
command! -buffer VimwikiAll2HTML
|
||||
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
|
||||
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')))
|
||||
|
||||
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
|
||||
|
||||
@ -279,10 +270,10 @@ command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
|
||||
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
|
||||
|
||||
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
|
||||
|
||||
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
|
||||
|
||||
command! -buffer -nargs=+ -complete=custom,vimwiki#base#complete_links_escaped
|
||||
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
|
||||
@ -291,14 +282,18 @@ command! -buffer VimwikiCheckLinks call vimwiki#base#check_links()
|
||||
|
||||
" list commands
|
||||
command! -buffer -nargs=+ VimwikiReturn call <SID>CR(<f-args>)
|
||||
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
|
||||
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
|
||||
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call vimwiki#lst#change_marker_in_list(<f-args>)
|
||||
command! -buffer -range -nargs=1 VimwikiChangeSymbolTo
|
||||
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'n')
|
||||
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI
|
||||
\ call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
|
||||
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo
|
||||
\ call vimwiki#lst#change_marker_in_list(<f-args>)
|
||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
||||
command! -buffer -range VimwikiToggleRejectedListItem call vimwiki#lst#toggle_rejected_cb(<line1>, <line2>)
|
||||
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
|
||||
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
|
||||
command! -buffer -range -nargs=+ VimwikiListChangeLvl call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
||||
command! -buffer -range -nargs=+ VimwikiListChangeLvl
|
||||
\ call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
||||
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
|
||||
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
|
||||
command! -buffer VimwikiRenumberList call vimwiki#lst#adjust_numbered_list()
|
||||
@ -327,7 +322,7 @@ command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
||||
" COMMANDS }}}
|
||||
|
||||
" KEYBINDINGS {{{
|
||||
if g:vimwiki_use_mouse
|
||||
if vimwiki#vars#get_global('use_mouse')
|
||||
nmap <buffer> <S-LeftMouse> <NOP>
|
||||
nmap <buffer> <C-LeftMouse> <NOP>
|
||||
nnoremap <silent><buffer> <2-LeftMouse> :call vimwiki#base#follow_link('nosplit', 0, 1, "\<lt>2-LeftMouse>")<CR>
|
||||
@ -338,13 +333,13 @@ endif
|
||||
|
||||
|
||||
if !hasmapto('<Plug>Vimwiki2HTML')
|
||||
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'h <Plug>Vimwiki2HTML'
|
||||
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'h <Plug>Vimwiki2HTML'
|
||||
endif
|
||||
nnoremap <script><buffer>
|
||||
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
||||
|
||||
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
|
||||
exe 'nmap <buffer> '.g:vimwiki_map_prefix.'hh <Plug>Vimwiki2HTMLBrowse'
|
||||
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'hh <Plug>Vimwiki2HTMLBrowse'
|
||||
endif
|
||||
nnoremap <script><buffer>
|
||||
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
||||
@ -411,13 +406,13 @@ nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDeleteLink')
|
||||
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'d <Plug>VimwikiDeleteLink'
|
||||
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'d <Plug>VimwikiDeleteLink'
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRenameLink')
|
||||
exe 'nmap <silent><buffer> '.g:vimwiki_map_prefix.'r <Plug>VimwikiRenameLink'
|
||||
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'r <Plug>VimwikiRenameLink'
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
||||
@ -560,7 +555,7 @@ endif
|
||||
noremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRemoveCBInList :VimwikiRemoveCBInList<CR>
|
||||
|
||||
for s:char in keys(g:vimwiki_bullet_types)
|
||||
for s:char in vimwiki#vars#get_syntaxlocal('bullet_types')
|
||||
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
|
||||
exe 'noremap <silent><buffer> gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'<CR>'
|
||||
endif
|
||||
@ -569,7 +564,7 @@ for s:char in keys(g:vimwiki_bullet_types)
|
||||
endif
|
||||
endfor
|
||||
|
||||
for s:typ in g:vimwiki_number_types
|
||||
for s:typ in vimwiki#vars#get_syntaxlocal('number_types')
|
||||
if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'<CR>')
|
||||
exe 'noremap <silent><buffer> gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'<CR>'
|
||||
endif
|
||||
@ -581,7 +576,7 @@ endfor
|
||||
|
||||
|
||||
function! s:CR(normal, just_mrkr) "{{{
|
||||
if g:vimwiki_table_mappings
|
||||
if vimwiki#vars#get_global('table_mappings')
|
||||
let res = vimwiki#tbl#kbd_cr()
|
||||
if res != ""
|
||||
exe "normal! " . res . "\<Right>"
|
||||
@ -602,7 +597,7 @@ if !hasmapto('VimwikiReturn', 'i')
|
||||
endif
|
||||
|
||||
"Table mappings
|
||||
if g:vimwiki_table_mappings
|
||||
if vimwiki#vars#get_global('table_mappings')
|
||||
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
|
||||
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
|
||||
endif
|
||||
@ -667,23 +662,23 @@ nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
|
||||
" KEYBINDINGS }}}
|
||||
|
||||
" AUTOCOMMANDS {{{
|
||||
if VimwikiGet('auto_export')
|
||||
if vimwiki#vars#get_wikilocal('auto_export')
|
||||
" Automatically generate HTML on page write.
|
||||
augroup vimwiki
|
||||
au BufWritePost <buffer>
|
||||
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||
\ call vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
|
||||
\ expand('%'))
|
||||
augroup END
|
||||
endif
|
||||
|
||||
if VimwikiGet('auto_toc')
|
||||
if vimwiki#vars#get_wikilocal('auto_toc')
|
||||
" Automatically update the TOC *before* the file is written
|
||||
augroup vimwiki
|
||||
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
|
||||
augroup END
|
||||
endif
|
||||
|
||||
if VimwikiGet('auto_tags')
|
||||
if vimwiki#vars#get_wikilocal('auto_tags')
|
||||
" Automatically update tags metadata on page write.
|
||||
augroup vimwiki
|
||||
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
|
||||
@ -696,8 +691,3 @@ endif
|
||||
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
|
||||
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
|
||||
" }}}
|
||||
|
||||
" DEBUGGING {{{
|
||||
command! VimwikiPrintWikiState call vimwiki#base#print_wiki_state()
|
||||
command! VimwikiReadLocalOptions call vimwiki#base#read_wiki_options(1)
|
||||
" }}}
|
||||
|
@ -12,189 +12,87 @@ let s:old_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
" HELPER functions {{{
|
||||
function! s:default(varname, value) "{{{
|
||||
if !exists('g:vimwiki_'.a:varname)
|
||||
let g:vimwiki_{a:varname} = a:value
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:path_html(idx) "{{{
|
||||
let path_html = VimwikiGet('path_html', a:idx)
|
||||
if !empty(path_html)
|
||||
return path_html
|
||||
else
|
||||
let path = VimwikiGet('path', a:idx)
|
||||
return substitute(path, '[/\\]\+$', '', '').'_html/'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:normalize_path(path) "{{{
|
||||
" resolve doesn't work quite right with symlinks ended with / or \
|
||||
let path = substitute(a:path, '[/\\]\+$', '', '')
|
||||
if path !~# '^scp:'
|
||||
return resolve(expand(path)).'/'
|
||||
else
|
||||
return path.'/'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! Validate_wiki_options(idx) " {{{
|
||||
call VimwikiSet('path', s:normalize_path(VimwikiGet('path', a:idx)), a:idx)
|
||||
call VimwikiSet('path_html', s:normalize_path(s:path_html(a:idx)), a:idx)
|
||||
call VimwikiSet('template_path',
|
||||
\ s:normalize_path(VimwikiGet('template_path', a:idx)), a:idx)
|
||||
call VimwikiSet('diary_rel_path',
|
||||
\ s:normalize_path(VimwikiGet('diary_rel_path', a:idx)), a:idx)
|
||||
endfunction " }}}
|
||||
|
||||
function! s:vimwiki_idx() " {{{
|
||||
if exists('b:vimwiki_idx')
|
||||
return b:vimwiki_idx
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" this is called when the cursor leaves the buffer
|
||||
function! s:setup_buffer_leave() "{{{
|
||||
if &filetype ==? 'vimwiki'
|
||||
" cache global vars of current state XXX: SLOW!?
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endif
|
||||
|
||||
let &autowriteall = s:vimwiki_autowriteall
|
||||
|
||||
" Set up menu
|
||||
if g:vimwiki_menu != ""
|
||||
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_filetype() "{{{
|
||||
" Find what wiki current buffer belongs to.
|
||||
let path = expand('%:p:h')
|
||||
let idx = vimwiki#base#find_wiki(path)
|
||||
|
||||
if idx == -1 && g:vimwiki_global_ext == 0
|
||||
" 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_bufferlocal('wiki_nr') == -1
|
||||
return
|
||||
endif
|
||||
"XXX when idx = -1? (an orphan page has been detected)
|
||||
|
||||
"TODO: refactor (same code in setup_buffer_enter)
|
||||
" The buffer's file is not in the path and user *does* want his wiki
|
||||
" extension(s) to be global -- Add new wiki.
|
||||
if idx == -1
|
||||
let ext = '.'.expand('%:e')
|
||||
" lookup syntax using g:vimwiki_ext2syntax
|
||||
if has_key(g:vimwiki_ext2syntax, ext)
|
||||
let syn = g:vimwiki_ext2syntax[ext]
|
||||
else
|
||||
let syn = s:vimwiki_defaults.syntax
|
||||
endif
|
||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
||||
let idx = len(g:vimwiki_list) - 1
|
||||
call Validate_wiki_options(idx)
|
||||
let &autowriteall = s:vimwiki_autowriteall_saved
|
||||
|
||||
if vimwiki#vars#get_global('menu') != ""
|
||||
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
|
||||
endif
|
||||
" initialize and cache global vars of current state
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
|
||||
unlet! b:vimwiki_fs_rescan
|
||||
set filetype=vimwiki
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_buffer_enter() "{{{
|
||||
if !vimwiki#base#recall_buffer_state()
|
||||
" Find what wiki current buffer belongs to.
|
||||
" If wiki does not exist in g:vimwiki_list -- add new wiki there with
|
||||
" buffer's path and ext.
|
||||
" Else set g:vimwiki_current_idx to that wiki index.
|
||||
let path = expand('%:p:h')
|
||||
let idx = vimwiki#base#find_wiki(path)
|
||||
|
||||
" The buffer's file is not in the path and user *does NOT* want his wiki
|
||||
" extension to be global -- Do not add new wiki.
|
||||
if idx == -1 && g:vimwiki_global_ext == 0
|
||||
" create a new temporary wiki for the current buffer
|
||||
function! s:create_temporary_wiki()
|
||||
let path = expand('%:p:h')
|
||||
let ext = '.'.expand('%:e')
|
||||
|
||||
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
|
||||
if has_key(syntax_mapping, ext)
|
||||
let syntax = syntax_mapping[ext]
|
||||
else
|
||||
let syntax = vimwiki#vars#get_wikilocal_default('syntax')
|
||||
endif
|
||||
|
||||
let new_temp_wiki_settings = {'path': path,
|
||||
\ 'ext': ext,
|
||||
\ 'syntax': syntax,
|
||||
\ }
|
||||
|
||||
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
|
||||
endfunction
|
||||
|
||||
|
||||
" This function is called when Vim opens a new buffer with a known wiki
|
||||
" extension. Both when the buffer has never been opened in this session and
|
||||
" when it has.
|
||||
function! s:setup_new_wiki_buffer() "{{{
|
||||
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||
if wiki_nr == -1 " it's not in a known wiki directory
|
||||
if vimwiki#vars#get_global('global_ext')
|
||||
call s:create_temporary_wiki()
|
||||
else
|
||||
" the user does not want a temporary wiki, so do nothing
|
||||
return
|
||||
endif
|
||||
|
||||
"TODO: refactor (same code in setup_filetype)
|
||||
" The buffer's file is not in the path and user *does* want his wiki
|
||||
" extension(s) to be global -- Add new wiki.
|
||||
if idx == -1
|
||||
let ext = '.'.expand('%:e')
|
||||
" lookup syntax using g:vimwiki_ext2syntax
|
||||
if has_key(g:vimwiki_ext2syntax, ext)
|
||||
let syn = g:vimwiki_ext2syntax[ext]
|
||||
else
|
||||
let syn = s:vimwiki_defaults.syntax
|
||||
endif
|
||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
|
||||
let idx = len(g:vimwiki_list) - 1
|
||||
call Validate_wiki_options(idx)
|
||||
endif
|
||||
" initialize and cache global vars of current state
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
|
||||
endif
|
||||
|
||||
" If you have
|
||||
" au GUIEnter * VimwikiIndex
|
||||
" Then change it to
|
||||
" au GUIEnter * nested VimwikiIndex
|
||||
if vimwiki#vars#get_wikilocal('maxhi')
|
||||
call vimwiki#vars#set_bufferlocal('existing_wikifiles', vimwiki#base#get_wikilinks(wiki_nr, 1))
|
||||
call vimwiki#vars#set_bufferlocal('existing_wikidirs',
|
||||
\ vimwiki#base#get_wiki_directories(wiki_nr))
|
||||
endif
|
||||
|
||||
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
|
||||
" sourced
|
||||
setfiletype vimwiki
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" this is called when the cursor enters the buffer
|
||||
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_bufferlocal('wiki_nr') == -1
|
||||
return
|
||||
endif
|
||||
|
||||
if &filetype == ''
|
||||
set filetype=vimwiki
|
||||
elseif &syntax ==? 'vimwiki'
|
||||
" to force a rescan of the filesystem which may have changed
|
||||
" and update VimwikiLinks syntax group that depends on it;
|
||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
||||
if exists("b:vimwiki_fs_rescan") && VimwikiGet('maxhi')
|
||||
set syntax=vimwiki
|
||||
endif
|
||||
let b:vimwiki_fs_rescan = 1
|
||||
setfiletype vimwiki
|
||||
endif
|
||||
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding ==? 'expr'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding ==? 'syntax'
|
||||
setlocal fdm=syntax
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding ==? 'custom'
|
||||
" do nothing
|
||||
else
|
||||
setlocal fdm=manual
|
||||
normal! zE
|
||||
endif
|
||||
call s:set_global_options()
|
||||
|
||||
" And conceal level too.
|
||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
||||
let &conceallevel = g:vimwiki_conceallevel
|
||||
endif
|
||||
|
||||
" Set up menu
|
||||
if g:vimwiki_menu != ""
|
||||
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
|
||||
endif
|
||||
call s:set_windowlocal_options()
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_buffer_reenter() "{{{
|
||||
if !vimwiki#base#recall_buffer_state()
|
||||
" Do not repeat work of s:setup_buffer_enter() and s:setup_filetype()
|
||||
" Once should be enough ...
|
||||
endif
|
||||
if !exists("s:vimwiki_autowriteall")
|
||||
let s:vimwiki_autowriteall = &autowriteall
|
||||
endif
|
||||
let &autowriteall = g:vimwiki_autowriteall
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
||||
" on colorscheme change because they are not linked to Vim-predefined groups
|
||||
@ -202,103 +100,85 @@ function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
||||
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
||||
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
|
||||
hi def VimwikiUnderline gui=underline
|
||||
if g:vimwiki_hl_headers == 1
|
||||
if vimwiki#vars#get_global('hl_headers') == 1
|
||||
for i in range(1,6)
|
||||
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
|
||||
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='
|
||||
\ . vimwiki#vars#get_global('hcolor_guifg_'.&bg)[i-1]
|
||||
\ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[i-1]
|
||||
\ .' term=bold cterm=bold'
|
||||
endfor
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" OPTION get/set functions {{{
|
||||
" return complete list of options
|
||||
function! VimwikiGetOptionNames() "{{{
|
||||
return keys(s:vimwiki_defaults)
|
||||
endfunction "}}}
|
||||
|
||||
function! VimwikiGetOptions(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
let option_dict = {}
|
||||
for kk in keys(s:vimwiki_defaults)
|
||||
let option_dict[kk] = VimwikiGet(kk, idx)
|
||||
endfor
|
||||
return option_dict
|
||||
endfunction "}}}
|
||||
|
||||
" Return value of option for current wiki or if second parameter exists for
|
||||
" wiki with a given index.
|
||||
" If the option is not found, it is assumed to have been previously cached in a
|
||||
" buffer local dictionary, that acts as a cache.
|
||||
" If the option is not found in the buffer local dictionary, an error is thrown
|
||||
function! VimwikiGet(option, ...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
|
||||
if has_key(g:vimwiki_list[idx], a:option)
|
||||
let val = g:vimwiki_list[idx][a:option]
|
||||
elseif has_key(s:vimwiki_defaults, a:option)
|
||||
let val = s:vimwiki_defaults[a:option]
|
||||
let g:vimwiki_list[idx][a:option] = val
|
||||
else
|
||||
let val = b:vimwiki_list[a:option]
|
||||
endif
|
||||
|
||||
" XXX no call to vimwiki#base here or else the whole autoload/base gets loaded!
|
||||
return val
|
||||
endfunction "}}}
|
||||
|
||||
" Set option for current wiki or if third parameter exists for
|
||||
" wiki with a given index.
|
||||
" If the option is not found or recognized (i.e. does not exist in
|
||||
" s:vimwiki_defaults), it is saved in a buffer local dictionary, that acts
|
||||
" as a cache.
|
||||
" If the option is not found in the buffer local dictionary, an error is thrown
|
||||
function! VimwikiSet(option, value, ...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
|
||||
if has_key(s:vimwiki_defaults, a:option) ||
|
||||
\ has_key(g:vimwiki_list[idx], a:option)
|
||||
let g:vimwiki_list[idx][a:option] = a:value
|
||||
elseif exists('b:vimwiki_list')
|
||||
let b:vimwiki_list[a:option] = a:value
|
||||
else
|
||||
let b:vimwiki_list = {}
|
||||
let b:vimwiki_list[a:option] = a:value
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
" Clear option for current wiki or if second parameter exists for
|
||||
" wiki with a given index.
|
||||
" Currently, only works if option was previously saved in the buffer local
|
||||
" dictionary, that acts as a cache.
|
||||
function! VimwikiClear(option, ...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
|
||||
if exists('b:vimwiki_list') && has_key(b:vimwiki_list, a:option)
|
||||
call remove(b:vimwiki_list, a:option)
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
function! s:vimwiki_get_known_extensions() " {{{
|
||||
" Getting all extensions that different wikis could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
for idx in range(vimwiki#vars#number_of_wikis())
|
||||
let ext = vimwiki#vars#get_wikilocal('ext', idx)
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for ext in keys(g:vimwiki_ext2syntax)
|
||||
" append extensions from g:vimwiki_ext2syntax
|
||||
for ext in keys(vimwiki#vars#get_global('ext2syntax'))
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
return keys(extensions)
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
" Set settings which are global for Vim, but should only be executed for
|
||||
" Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer
|
||||
" and reset when the cursor leaves the buffer.
|
||||
function! s:set_global_options()
|
||||
let s:vimwiki_autowriteall_saved = &autowriteall
|
||||
let &autowriteall = vimwiki#vars#get_global('autowriteall')
|
||||
|
||||
if vimwiki#vars#get_global('menu') !=# ''
|
||||
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" Set settings which are local to a window. In a new tab they would be reset to
|
||||
" Vim defaults. So we enforce our settings here when the cursor enters a
|
||||
" Vimwiki buffer.
|
||||
function! s:set_windowlocal_options()
|
||||
let foldmethod = vimwiki#vars#get_global('folding')
|
||||
if foldmethod ==? 'expr'
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif foldmethod ==? 'list' || foldmethod ==? 'lists'
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif foldmethod ==? 'syntax'
|
||||
setlocal foldmethod=syntax
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif foldmethod ==? 'custom'
|
||||
" do nothing
|
||||
else
|
||||
setlocal foldmethod=manual
|
||||
normal! zE
|
||||
endif
|
||||
|
||||
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
||||
let &conceallevel = vimwiki#vars#get_global('conceallevel')
|
||||
endif
|
||||
|
||||
if vimwiki#vars#get_global('auto_chdir')
|
||||
exe 'lcd' vimwiki#vars#get_wikilocal('path')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
|
||||
|
||||
" Initialization of Vimwiki starts here. Make sure everything below does not
|
||||
" cause autoload/vimwiki/base.vim to be loaded
|
||||
|
||||
call vimwiki#vars#init()
|
||||
|
||||
" CALLBACK functions "{{{
|
||||
" User can redefine it.
|
||||
if !exists("*VimwikiLinkHandler") "{{{
|
||||
@ -321,132 +201,28 @@ if !exists("*VimwikiWikiIncludeHandler") "{{{
|
||||
endif "}}}
|
||||
" CALLBACK }}}
|
||||
|
||||
" DEFAULT wiki {{{
|
||||
let s:vimwiki_defaults = {}
|
||||
let s:vimwiki_defaults.path = '~/vimwiki/'
|
||||
let s:vimwiki_defaults.path_html = '' " '' is replaced by derived path.'_html/'
|
||||
let s:vimwiki_defaults.css_name = 'style.css'
|
||||
let s:vimwiki_defaults.index = 'index'
|
||||
let s:vimwiki_defaults.ext = '.wiki'
|
||||
let s:vimwiki_defaults.maxhi = 0
|
||||
let s:vimwiki_defaults.syntax = 'default'
|
||||
|
||||
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
|
||||
let s:vimwiki_defaults.template_default = 'default'
|
||||
let s:vimwiki_defaults.template_ext = '.tpl'
|
||||
|
||||
let s:vimwiki_defaults.nested_syntaxes = {}
|
||||
let s:vimwiki_defaults.automatic_nested_syntaxes = 1
|
||||
let s:vimwiki_defaults.auto_export = 0
|
||||
let s:vimwiki_defaults.auto_toc = 0
|
||||
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
|
||||
" file.
|
||||
let s:vimwiki_defaults.temp = 0
|
||||
|
||||
" diary
|
||||
let s:vimwiki_defaults.diary_rel_path = 'diary/'
|
||||
let s:vimwiki_defaults.diary_index = 'diary'
|
||||
let s:vimwiki_defaults.diary_header = 'Diary'
|
||||
let s:vimwiki_defaults.diary_sort = 'desc'
|
||||
|
||||
" Do not change this! Will wait till vim become more datetime awareable.
|
||||
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
|
||||
|
||||
" NEW! in v2.0
|
||||
" custom_wiki2html
|
||||
let s:vimwiki_defaults.custom_wiki2html = ''
|
||||
"
|
||||
let s:vimwiki_defaults.list_margin = -1
|
||||
|
||||
let s:vimwiki_defaults.auto_tags = 0
|
||||
"}}}
|
||||
|
||||
" DEFAULT options {{{
|
||||
call s:default('list', [s:vimwiki_defaults])
|
||||
call s:default('use_mouse', 0)
|
||||
call s:default('folding', '')
|
||||
call s:default('menu', 'Vimwiki')
|
||||
call s:default('global_ext', 1)
|
||||
call s:default('ext2syntax', {}) " syntax map keyed on extension
|
||||
call s:default('hl_headers', 0)
|
||||
call s:default('hl_cb_checked', 0)
|
||||
call s:default('list_ignore_newline', 1)
|
||||
call s:default('text_ignore_newline', 1)
|
||||
call s:default('listsyms', ' .oOX')
|
||||
call s:default('listsym_rejected', '-')
|
||||
call s:default('use_calendar', 1)
|
||||
call s:default('table_mappings', 1)
|
||||
call s:default('table_auto_fmt', 1)
|
||||
call s:default('w32_dir_enc', '')
|
||||
call s:default('CJK_length', 0)
|
||||
call s:default('dir_link', '')
|
||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
|
||||
call s:default('user_htmls', '')
|
||||
call s:default('autowriteall', 1)
|
||||
call s:default('toc_header', 'Contents')
|
||||
|
||||
call s:default('html_header_numbering', 0)
|
||||
call s:default('html_header_numbering_sym', '')
|
||||
call s:default('conceallevel', 2)
|
||||
call s:default('url_maxsave', 15)
|
||||
|
||||
call s:default('diary_months',
|
||||
\ {
|
||||
\ 1: 'January', 2: 'February', 3: 'March',
|
||||
\ 4: 'April', 5: 'May', 6: 'June',
|
||||
\ 7: 'July', 8: 'August', 9: 'September',
|
||||
\ 10: 'October', 11: 'November', 12: 'December'
|
||||
\ })
|
||||
|
||||
call s:default('map_prefix', '<Leader>w')
|
||||
|
||||
call s:default('current_idx', 0)
|
||||
|
||||
call s:default('auto_chdir', 0)
|
||||
|
||||
" Scheme regexes should be defined even if syntax file is not loaded yet
|
||||
" cause users should be able to <leader>w<leader>w without opening any
|
||||
" vimwiki file first
|
||||
" Scheme regexes {{{
|
||||
call s:default('schemes', 'wiki\d\+,diary,local')
|
||||
call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'.
|
||||
\ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp')
|
||||
call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel,data')
|
||||
|
||||
let s:rxSchemes = '\%('.
|
||||
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
|
||||
\ '\)'
|
||||
|
||||
call s:default('rxSchemeUrl', s:rxSchemes.':.*')
|
||||
call s:default('rxSchemeUrlMatchScheme', '\zs'.s:rxSchemes.'\ze:.*')
|
||||
call s:default('rxSchemeUrlMatchUrl', s:rxSchemes.':\zs.*\ze')
|
||||
" scheme regexes }}}
|
||||
|
||||
for s:idx in range(len(g:vimwiki_list))
|
||||
call Validate_wiki_options(s:idx)
|
||||
endfor
|
||||
"}}}
|
||||
|
||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||
|
||||
augroup filetypedetect
|
||||
" clear FlexWiki's stuff
|
||||
au! * *.wiki
|
||||
augroup end
|
||||
let s:known_extensions = s:vimwiki_get_known_extensions()
|
||||
|
||||
if index(s:known_extensions, '.wiki') > -1
|
||||
augroup filetypedetect
|
||||
" clear FlexWiki's stuff
|
||||
au! * *.wiki
|
||||
augroup end
|
||||
endif
|
||||
|
||||
augroup vimwiki
|
||||
autocmd!
|
||||
for s:ext in s:vimwiki_get_known_extensions()
|
||||
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()'
|
||||
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'
|
||||
exe 'autocmd BufNewFile,BufRead, *'.s:ext.' call s:setup_filetype()'
|
||||
for s:ext in s:known_extensions
|
||||
exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()'
|
||||
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()'
|
||||
exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()'
|
||||
" Format tables when exit from insert mode. Do not use textwidth to
|
||||
" autowrap tables.
|
||||
if g:vimwiki_table_auto_fmt
|
||||
if vimwiki#vars#get_global('table_auto_fmt')
|
||||
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
|
||||
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
|
||||
endif
|
||||
@ -470,51 +246,53 @@ command! -count=1 VimwikiMakeDiaryNote
|
||||
command! -count=1 VimwikiTabMakeDiaryNote
|
||||
\ call vimwiki#diary#make_note(v:count1, 1)
|
||||
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
||||
\ call vimwiki#diary#make_note(v:count1, 0, strftime(VimwikiGet('diary_link_fmt', v:count1 - 1), localtime() - 60*60*24))
|
||||
\ call vimwiki#diary#make_note(v:count1, 0, vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
||||
|
||||
command! VimwikiDiaryGenerateLinks
|
||||
\ call vimwiki#diary#generate_diary_section()
|
||||
"}}}
|
||||
|
||||
" MAPPINGS {{{
|
||||
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
|
||||
|
||||
if !hasmapto('<Plug>VimwikiIndex')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'w <Plug>VimwikiIndex'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'w <Plug>VimwikiIndex'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabIndex')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'t <Plug>VimwikiTabIndex'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'t <Plug>VimwikiTabIndex'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiUISelect')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'s <Plug>VimwikiUISelect'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'s <Plug>VimwikiUISelect'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryIndex')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'i <Plug>VimwikiDiaryIndex'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'i <Plug>VimwikiDiaryIndex'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
||||
\ :VimwikiTabMakeDiaryNote<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote')
|
||||
exe 'nmap <silent><unique> '.g:vimwiki_map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
|
||||
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
|
||||
\ :VimwikiMakeYesterdayDiaryNote<CR>
|
||||
@ -523,16 +301,14 @@ nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
|
||||
|
||||
" MENU {{{
|
||||
function! s:build_menu(topmenu)
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
|
||||
for idx in range(vimwiki#vars#number_of_wikis())
|
||||
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
|
||||
let norm_path = escape(norm_path, '\ \.')
|
||||
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
||||
\ ' :call vimwiki#base#goto_index('.(idx + 1).')<CR>'
|
||||
\ ' :call vimwiki#base#goto_index('.idx.')<CR>'
|
||||
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
||||
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
|
||||
let idx += 1
|
||||
endwhile
|
||||
\ ' :call vimwiki#diary#make_note('.idx.')<CR>'
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:build_table_menu(topmenu)
|
||||
@ -544,15 +320,15 @@ function! s:build_table_menu(topmenu)
|
||||
exe 'nmenu disable '.a:topmenu.'.Table'
|
||||
endfunction
|
||||
|
||||
"XXX make sure anything below does not cause autoload/base to be loaded
|
||||
if !empty(g:vimwiki_menu)
|
||||
call s:build_menu(g:vimwiki_menu)
|
||||
call s:build_table_menu(g:vimwiki_menu)
|
||||
|
||||
if !empty(vimwiki#vars#get_global('menu'))
|
||||
call s:build_menu(vimwiki#vars#get_global('menu'))
|
||||
call s:build_table_menu(vimwiki#vars#get_global('menu'))
|
||||
endif
|
||||
" }}}
|
||||
|
||||
" CALENDAR Hook "{{{
|
||||
if g:vimwiki_use_calendar
|
||||
if vimwiki#vars#get_global('use_calendar')
|
||||
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
||||
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
||||
endif
|
||||
|
@ -1,35 +0,0 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Desc: Syntax definitions which are always available
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
|
||||
" Define Regexes of anchors for every syntax.
|
||||
" This has to be separated from vimwiki_default.vim, vimwiki_markdown.vim, etc.
|
||||
" because the latter are only loaded and available if the current wiki has the
|
||||
" corresponding syntax
|
||||
let g:vimwiki_default_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||
let g:vimwiki_default_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
||||
let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||
let g:vimwiki_default_tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||
let g:vimwiki_default_tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||
|
||||
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_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[: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_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*$'
|
||||
let g:vimwiki_media_bold_search = "'''\\zs[^']\\+\\ze'''"
|
||||
let g:vimwiki_media_bold_match = '''''''__Text__'''''''
|
||||
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
|
||||
" 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?
|
@ -3,173 +3,17 @@
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" Quit if syntax file is already loaded
|
||||
if version < 600
|
||||
if v:version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
"TODO do nothing if ...? (?)
|
||||
if VimwikiGet('maxhi')
|
||||
let b:existing_wikifiles =
|
||||
\ vimwiki#base#get_wikilinks(g:vimwiki_current_idx, 1)
|
||||
let b:existing_wikidirs =
|
||||
\ vimwiki#base#get_wiki_directories(g:vimwiki_current_idx)
|
||||
endif
|
||||
"let b:xxx = 1
|
||||
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
|
||||
"if VimwikiGet('maxhi')
|
||||
" ...
|
||||
"endif
|
||||
|
||||
" LINKS: assume this is common to all syntaxes "{{{
|
||||
let s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
|
||||
|
||||
" LINKS: WebLinks {{{
|
||||
" match URL for common protocols;
|
||||
" see http://en.wikipedia.org/wiki/URI_scheme http://tools.ietf.org/html/rfc3986
|
||||
let g:vimwiki_rxWebProtocols = ''.
|
||||
\ '\%('.
|
||||
\ '\%('.
|
||||
\ '\%('.join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\):'.
|
||||
\ '\%(//\)'.
|
||||
\ '\)'.
|
||||
\ '\|'.
|
||||
\ '\%('.join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').'\):'.
|
||||
\ '\)'
|
||||
"
|
||||
let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
|
||||
\ '\S\{-1,}'. '\%(([^ \t()]*)\)\='
|
||||
" }}}
|
||||
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
||||
|
||||
" }}}
|
||||
|
||||
call vimwiki#u#reload_regexes()
|
||||
|
||||
" 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 = '\<'. g:vimwiki_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) " {{{
|
||||
@ -195,144 +39,123 @@ function! s:highlight_existing_links() "{{{
|
||||
" Conditional highlighting that depends on the existence of a wiki file or
|
||||
" directory is only available for *schemeless* wiki links
|
||||
" Links are set up upon BufEnter (see plugin/...)
|
||||
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
|
||||
let safe_links = '\%('.vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
|
||||
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
||||
" Wikilink Dirs set up upon BufEnter (see plugin/...)
|
||||
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
|
||||
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
|
||||
|
||||
" 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 "}}}
|
||||
|
||||
|
||||
" use max highlighting - could be quite slow if there are too many wikifiles
|
||||
if VimwikiGet('maxhi')
|
||||
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_syntaxlocal('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_syntaxlocal('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_syntaxlocal('rxWeblink'), 'VimwikiLink')
|
||||
|
||||
" WikiLink
|
||||
" All remaining schemes are highlighted automatically
|
||||
let s:rxSchemes = '\%('.
|
||||
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
|
||||
\ join(split(vimwiki#vars#get_global('schemes'), '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(vimwiki#vars#get_global('web_schemes1'), '\s*,\s*'), '\|').
|
||||
\ '\):'
|
||||
|
||||
" 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'.s:i, 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 " {{{
|
||||
@ -344,45 +167,44 @@ let s:options = ' contained transparent contains=NONE'
|
||||
"
|
||||
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
|
||||
" VimwikiLinkRest group is left undefined if link shortening is not desired
|
||||
if exists("+conceallevel") && g:vimwiki_url_maxsave > 0
|
||||
if exists("+conceallevel") && vimwiki#vars#get_global('url_maxsave') > 0
|
||||
let s:options .= s:conceal
|
||||
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
|
||||
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.s:options
|
||||
\.'\%([/#?]\w\|\S\{'.vimwiki#vars#get_global('url_maxsave').'}\)`'.' cchar=~'.s:options
|
||||
endif
|
||||
|
||||
" VimwikiLinkChar is for syntax markers (and also URL when a description
|
||||
" 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 {{{
|
||||
@ -408,53 +230,54 @@ 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 g:vimwiki_hl_cb_checked == 1
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[-1].'\]\s.*$/ '.
|
||||
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
elseif g:vimwiki_hl_cb_checked == 2
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
if vimwiki#vars#get_global('hl_cb_checked') == 1
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
|
||||
\ .'\s*\['.vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
|
||||
\ .'\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemAndChildren').'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
endif
|
||||
|
||||
|
||||
execute 'syntax match VimwikiEqIn /'.g:vimwiki_rxEqIn.'/ contains=VimwikiEqInChar'
|
||||
execute 'syntax match VimwikiEqInT /'.g:vimwiki_rxEqIn.'/ contained contains=VimwikiEqInCharT'
|
||||
execute 'syntax match VimwikiEqIn /'.vimwiki#vars#get_syntaxlocal('rxEqIn').'/ contains=VimwikiEqInChar'
|
||||
execute 'syntax match VimwikiEqInT /'.vimwiki#vars#get_syntaxlocal('rxEqIn').'/ contained contains=VimwikiEqInCharT'
|
||||
|
||||
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
|
||||
execute 'syntax match VimwikiBold /'.vimwiki#vars#get_syntaxlocal('rxBold').'/ contains=VimwikiBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiBoldT /'.vimwiki#vars#get_syntaxlocal('rxBold').'/ contained contains=VimwikiBoldCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar,@Spell'
|
||||
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT,@Spell'
|
||||
execute 'syntax match VimwikiItalic /'.vimwiki#vars#get_syntaxlocal('rxItalic').'/ contains=VimwikiItalicChar,@Spell'
|
||||
execute 'syntax match VimwikiItalicT /'.vimwiki#vars#get_syntaxlocal('rxItalic').'/ contained contains=VimwikiItalicCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
||||
execute 'syntax match VimwikiBoldItalic /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiBoldItalicT /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
|
||||
execute 'syntax match VimwikiItalicBold /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar,@Spell'
|
||||
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
|
||||
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').'/ contains=VimwikiDelTextChar,@Spell'
|
||||
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').'/ contained contains=VimwikiDelTextChar,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar,@Spell'
|
||||
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT,@Spell'
|
||||
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').'/ contains=VimwikiSuperScriptChar,@Spell'
|
||||
execute 'syntax match VimwikiSuperScriptT /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').'/ contained contains=VimwikiSuperScriptCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar,@Spell'
|
||||
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT,@Spell'
|
||||
execute 'syntax match VimwikiSubScript /'.vimwiki#vars#get_syntaxlocal('rxSubScript').'/ contains=VimwikiSubScriptChar,@Spell'
|
||||
execute 'syntax match VimwikiSubScriptT /'.vimwiki#vars#get_syntaxlocal('rxSubScript').'/ contained contains=VimwikiSubScriptCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
|
||||
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
|
||||
execute 'syntax match VimwikiCode /'.vimwiki#vars#get_syntaxlocal('rxCode').'/ contains=VimwikiCodeChar'
|
||||
execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').'/ contained contains=VimwikiCodeCharT'
|
||||
|
||||
" <hr> horizontal rule
|
||||
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
|
||||
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
|
||||
|
||||
execute 'syntax region VimwikiPre start=/'.g:vimwiki_rxPreStart.
|
||||
\ '/ end=/'.g:vimwiki_rxPreEnd.'/ contains=@Spell'
|
||||
execute 'syntax region VimwikiPre start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart').
|
||||
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell'
|
||||
|
||||
execute 'syntax region VimwikiMath start=/'.g:vimwiki_rxMathStart.
|
||||
\ '/ end=/'.g:vimwiki_rxMathEnd.'/ contains=@Spell'
|
||||
execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart').
|
||||
\ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@Spell'
|
||||
|
||||
|
||||
" placeholders
|
||||
@ -465,24 +288,24 @@ syntax match VimwikiPlaceholder /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=Vimwiki
|
||||
syntax match VimwikiPlaceholderParam /.*/ contained
|
||||
|
||||
" html tags
|
||||
if g:vimwiki_valid_html_tags != ''
|
||||
let s:html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
if vimwiki#vars#get_global('valid_html_tags') != ''
|
||||
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
|
||||
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
|
||||
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
||||
|
||||
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
|
||||
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').'/ contains=@Spell'
|
||||
endif
|
||||
|
||||
" tags
|
||||
execute 'syntax match VimwikiTag /'.g:vimwiki_rxTags.'/'
|
||||
execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
|
||||
|
||||
" }}}
|
||||
|
||||
" header groups highlighting "{{{
|
||||
|
||||
if g:vimwiki_hl_headers == 0
|
||||
if vimwiki#vars#get_global('hl_headers') == 0
|
||||
" Strangely in default colorscheme Title group is not set to bold for cterm...
|
||||
if !exists("g:colors_name")
|
||||
hi Title cterm=bold
|
||||
@ -491,14 +314,10 @@ if g:vimwiki_hl_headers == 0
|
||||
execute 'hi def link VimwikiHeader'.s:i.' Title'
|
||||
endfor
|
||||
else
|
||||
" default colors when headers of different levels are highlighted differently
|
||||
" not making it yet another option; needed by ColorScheme autocommand
|
||||
let g:vimwiki_hcolor_guifg_light = ['#aa5858','#507030','#1030a0','#103040','#505050','#636363']
|
||||
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black']
|
||||
let g:vimwiki_hcolor_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
|
||||
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
|
||||
for s:i in range(1,6)
|
||||
execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[s:i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[s:i-1].' term=bold cterm=bold'
|
||||
execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='
|
||||
\ .vimwiki#vars#get_global('hcolor_guifg_'.&bg)[s:i-1].' gui=bold ctermfg='
|
||||
\ .vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold'
|
||||
endfor
|
||||
endif
|
||||
"}}}
|
||||
@ -594,23 +413,23 @@ call vimwiki#u#reload_regexes_custom()
|
||||
let b:current_syntax="vimwiki"
|
||||
|
||||
" EMBEDDED syntax setup "{{{
|
||||
let s:nested = VimwikiGet('nested_syntaxes')
|
||||
if VimwikiGet('automatic_nested_syntaxes')
|
||||
let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes')
|
||||
if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes')
|
||||
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), "keep")
|
||||
endif
|
||||
if !empty(s:nested)
|
||||
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
|
||||
call vimwiki#base#nested_syntax(s:vim_syntax,
|
||||
\ g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ vimwiki#vars#get_syntaxlocal('rxPreStart').'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ g:vimwiki_rxPreEnd, 'VimwikiPre')
|
||||
\ vimwiki#vars#get_syntaxlocal('rxPreEnd'), 'VimwikiPre')
|
||||
endfor
|
||||
endif
|
||||
" LaTeX
|
||||
call vimwiki#base#nested_syntax('tex',
|
||||
\ g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ '\%([[:blank:][:punct:]].*\)\?',
|
||||
\ g:vimwiki_rxMathEnd, 'VimwikiMath')
|
||||
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
|
||||
"}}}
|
||||
|
||||
|
||||
|
@ -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 . '\+\%(\[\(['.g:vimwiki_listsyms.g:vimwiki_listsym_rejected.']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\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\|$\)'
|
||||
|
@ -3,89 +3,97 @@
|
||||
" Desc: Defines markdown syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" see the comments in vimwiki_default.vim for some info about this file
|
||||
|
||||
let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
let g:vimwiki_char_eqin = '\$'
|
||||
let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$'
|
||||
let s:markdown_syntax.char_eqin = '\$'
|
||||
|
||||
" text: *strong*
|
||||
" let g:vimwiki_rxBold = '\*[^*]\+\*'
|
||||
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
" let s:markdown_syntax.rxBold = '\*[^*]\+\*'
|
||||
let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'\*'.
|
||||
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
|
||||
\'\*'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_bold = '*'
|
||||
let s:markdown_syntax.char_bold = '*'
|
||||
|
||||
" text: _emphasis_
|
||||
" let g:vimwiki_rxItalic = '_[^_]\+_'
|
||||
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
" let s:markdown_syntax.rxItalic = '_[^_]\+_'
|
||||
let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'_'.
|
||||
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
|
||||
\'_'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_italic = '_'
|
||||
let s:markdown_syntax.char_italic = '_'
|
||||
|
||||
" text: *_bold italic_* or _*italic bold*_
|
||||
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'\*_'.
|
||||
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
|
||||
\'_\*'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_bolditalic = '\*_'
|
||||
let s:markdown_syntax.char_bolditalic = '\*_'
|
||||
|
||||
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'_\*'.
|
||||
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
|
||||
\'\*_'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_italicbold = '_\*'
|
||||
let s:markdown_syntax.char_italicbold = '_\*'
|
||||
|
||||
" text: `code`
|
||||
let g:vimwiki_rxCode = '`[^`]\+`'
|
||||
let g:vimwiki_char_code = '`'
|
||||
let s:markdown_syntax.rxCode = '`[^`]\+`'
|
||||
let s:markdown_syntax.char_code = '`'
|
||||
|
||||
" text: ~~deleted text~~
|
||||
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
|
||||
let g:vimwiki_char_deltext = '\~\~'
|
||||
let s:markdown_syntax.rxDelText = '\~\~[^~`]\+\~\~'
|
||||
let s:markdown_syntax.char_deltext = '\~\~'
|
||||
|
||||
" text: ^superscript^
|
||||
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
|
||||
let g:vimwiki_char_superscript = '^'
|
||||
let s:markdown_syntax.rxSuperScript = '\^[^^`]\+\^'
|
||||
let s:markdown_syntax.char_superscript = '^'
|
||||
|
||||
" text: ,,subscript,,
|
||||
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
|
||||
let g:vimwiki_char_subscript = ',,'
|
||||
let s:markdown_syntax.rxSubScript = ',,[^,`]\+,,'
|
||||
let s:markdown_syntax.char_subscript = ',,'
|
||||
|
||||
" generic headers
|
||||
let g:vimwiki_rxH = '#'
|
||||
let g:vimwiki_symH = 0
|
||||
let s:markdown_syntax.rxH = '#'
|
||||
let s:markdown_syntax.symH = 0
|
||||
|
||||
|
||||
|
||||
" <hr>, horizontal rule
|
||||
let g:vimwiki_rxHR = '^-----*$'
|
||||
let s:markdown_syntax.rxHR = '^-----*$'
|
||||
|
||||
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
let s:markdown_syntax.rxTableSep = '|'
|
||||
|
||||
" Lists
|
||||
let g:vimwiki_bullet_types = { '-':0, '*':0, '+':0 }
|
||||
let g:vimwiki_number_types = ['1.']
|
||||
let g:vimwiki_list_markers = ['-', '*', '+', '1.']
|
||||
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 . '\+\%(\[\(['.g:vimwiki_listsyms.g:vimwiki_listsym_rejected.']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
|
||||
let s:markdown_syntax.bullet_types = ['-', '*', '+']
|
||||
let s:markdown_syntax.recurring_bullets = 0
|
||||
let s:markdown_syntax.number_types = ['1.']
|
||||
let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
|
||||
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '```'
|
||||
let g:vimwiki_rxPreEnd = '```'
|
||||
let s:markdown_syntax.rxPreStart = '```'
|
||||
let s:markdown_syntax.rxPreEnd = '```'
|
||||
|
||||
" Math block
|
||||
let g:vimwiki_rxMathStart = '\$\$'
|
||||
let g:vimwiki_rxMathEnd = '\$\$'
|
||||
let s:markdown_syntax.rxMathStart = '\$\$'
|
||||
let s:markdown_syntax.rxMathEnd = '\$\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
let s:markdown_syntax.rxComment = '^\s*%%.*$'
|
||||
let s:markdown_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
|
||||
let s:markdown_syntax.header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
|
||||
let s:markdown_syntax.header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
|
||||
let s:markdown_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let s:markdown_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
||||
let s:markdown_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]' "XXX plus markdown-style links
|
||||
let s:markdown_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||
let s:markdown_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||
|
@ -1,207 +1,10 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Desc: Special stuff for markdown syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" LINKS: assume this is common to all syntaxes "{{{
|
||||
|
||||
" }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load concrete Wiki syntax: sets regexes and templates for headers and links
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
" LINKS: setup of larger regexes {{{
|
||||
|
||||
" LINKS: setup wikilink0 regexps {{{
|
||||
" 0. [[URL]], or [[URL|DESCRIPTION]]
|
||||
|
||||
" 0a) match [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLink0 = g:vimwiki_rxWikiLink
|
||||
" 0b) match URL within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLink0MatchUrl = g:vimwiki_rxWikiLinkMatchUrl
|
||||
" 0c) match DESCRIPTION within [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
|
||||
" }}}
|
||||
|
||||
" LINKS: setup wikilink1 regexps {{{
|
||||
" 1. [URL][], or [DESCRIPTION][URL]
|
||||
|
||||
let s:wikilink_md_prefix = '['
|
||||
let s:wikilink_md_suffix = ']'
|
||||
let s:wikilink_md_separator = ']['
|
||||
let s:rx_wikilink_md_prefix = vimwiki#u#escape(s:wikilink_md_prefix)
|
||||
let s:rx_wikilink_md_suffix = vimwiki#u#escape(s:wikilink_md_suffix)
|
||||
let s:rx_wikilink_md_separator = vimwiki#u#escape(s:wikilink_md_separator)
|
||||
|
||||
" [URL][]
|
||||
let g:vimwiki_WikiLink1Template1 = s:wikilink_md_prefix . '__LinkUrl__'.
|
||||
\ s:wikilink_md_separator. s:wikilink_md_suffix
|
||||
" [DESCRIPTION][URL]
|
||||
let g:vimwiki_WikiLink1Template2 = s:wikilink_md_prefix. '__LinkDescription__'.
|
||||
\ s:wikilink_md_separator. '__LinkUrl__'.
|
||||
\ s:wikilink_md_suffix
|
||||
"
|
||||
let g:vimwiki_WikiLinkMatchUrlTemplate .=
|
||||
\ '\|' .
|
||||
\ s:rx_wikilink_md_prefix .
|
||||
\ '.*' .
|
||||
\ s:rx_wikilink_md_separator .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_md_suffix .
|
||||
\ '\|' .
|
||||
\ s:rx_wikilink_md_prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ s:rx_wikilink_md_separator .
|
||||
\ s:rx_wikilink_md_suffix
|
||||
|
||||
let s:valid_chars = '[^\\\[\]]'
|
||||
let g:vimwiki_rxWikiLink1Url = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLink1Descr = s:valid_chars.'\{-}'
|
||||
|
||||
let g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
|
||||
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
|
||||
let s:rx_wikilink_md_prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
|
||||
\ s:rx_wikilink_md_prefix
|
||||
let s:rx_wikilink_md_suffix = s:rx_wikilink_md_suffix.
|
||||
\ g:vimwiki_rxWikiLink1InvalidSuffix
|
||||
|
||||
"
|
||||
" 1. [URL][], [DESCRIPTION][URL]
|
||||
" 1a) match [URL][], [DESCRIPTION][URL]
|
||||
let g:vimwiki_rxWikiLink1 = s:rx_wikilink_md_prefix.
|
||||
\ g:vimwiki_rxWikiLink1Url. s:rx_wikilink_md_separator.
|
||||
\ s:rx_wikilink_md_suffix.
|
||||
\ '\|'. s:rx_wikilink_md_prefix.
|
||||
\ g:vimwiki_rxWikiLink1Descr.s:rx_wikilink_md_separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
|
||||
" 1b) match URL within [URL][], [DESCRIPTION][URL]
|
||||
let g:vimwiki_rxWikiLink1MatchUrl = s:rx_wikilink_md_prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_separator.
|
||||
\ s:rx_wikilink_md_suffix.
|
||||
\ '\|'. s:rx_wikilink_md_prefix.
|
||||
\ g:vimwiki_rxWikiLink1Descr. s:rx_wikilink_md_separator.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_suffix
|
||||
" 1c) match DESCRIPTION within [DESCRIPTION][URL]
|
||||
let g:vimwiki_rxWikiLink1MatchDescr = s:rx_wikilink_md_prefix.
|
||||
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. s:rx_wikilink_md_separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
|
||||
" }}}
|
||||
|
||||
" LINKS: Syntax helper {{{
|
||||
let g:vimwiki_rxWikiLink1Prefix1 = s:rx_wikilink_md_prefix
|
||||
let g:vimwiki_rxWikiLink1Suffix1 = s:rx_wikilink_md_separator.
|
||||
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
|
||||
" }}}
|
||||
|
||||
" *. ANY wikilink {{{
|
||||
" *a) match ANY wikilink
|
||||
let g:vimwiki_rxWikiLink = ''.
|
||||
\ g:vimwiki_rxWikiLink0.'\|'.
|
||||
\ g:vimwiki_rxWikiLink1
|
||||
" *b) match URL within ANY wikilink
|
||||
let g:vimwiki_rxWikiLinkMatchUrl = ''.
|
||||
\ g:vimwiki_rxWikiLink0MatchUrl.'\|'.
|
||||
\ g:vimwiki_rxWikiLink1MatchUrl
|
||||
" *c) match DESCRIPTION within ANY wikilink
|
||||
let g:vimwiki_rxWikiLinkMatchDescr = ''.
|
||||
\ g:vimwiki_rxWikiLink0MatchDescr.'\|'.
|
||||
\ g:vimwiki_rxWikiLink1MatchDescr
|
||||
" }}}
|
||||
|
||||
" LINKS: setup of wikiincl regexps {{{
|
||||
" }}}
|
||||
|
||||
" LINKS: Syntax helper {{{
|
||||
" }}}
|
||||
|
||||
" LINKS: Setup weblink0 regexps {{{
|
||||
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
|
||||
let g:vimwiki_rxWeblink0 = g:vimwiki_rxWeblink
|
||||
" 0a) match URL within URL
|
||||
let g:vimwiki_rxWeblinkMatchUrl0 = g:vimwiki_rxWeblinkMatchUrl
|
||||
" 0b) match DESCRIPTION within URL
|
||||
let g:vimwiki_rxWeblinkMatchDescr0 = g:vimwiki_rxWeblinkMatchDescr
|
||||
" }}}
|
||||
|
||||
" LINKS: Setup weblink1 regexps {{{
|
||||
let g:vimwiki_rxWeblink1Prefix = '['
|
||||
let g:vimwiki_rxWeblink1Suffix = ')'
|
||||
let g:vimwiki_rxWeblink1Separator = ']('
|
||||
" [DESCRIPTION](URL)
|
||||
let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWeblink1Suffix
|
||||
|
||||
let s:valid_chars = '[^\\]'
|
||||
|
||||
let g:vimwiki_rxWeblink1Prefix = vimwiki#u#escape(g:vimwiki_rxWeblink1Prefix)
|
||||
let g:vimwiki_rxWeblink1Suffix = vimwiki#u#escape(g:vimwiki_rxWeblink1Suffix)
|
||||
let g:vimwiki_rxWeblink1Separator = vimwiki#u#escape(g:vimwiki_rxWeblink1Separator)
|
||||
let g:vimwiki_rxWeblink1Url = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWeblink1Descr = s:valid_chars.'\{-}'
|
||||
|
||||
"
|
||||
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
|
||||
" 1. [DESCRIPTION](URL)
|
||||
" 1a) match [DESCRIPTION](URL)
|
||||
let g:vimwiki_rxWeblink1 = g:vimwiki_rxWeblink1Prefix.
|
||||
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Separator.
|
||||
\ g:vimwiki_rxWeblink1Descr.g:vimwiki_rxWeblink1Suffix
|
||||
" 1b) match URL within [DESCRIPTION](URL)
|
||||
let g:vimwiki_rxWeblink1MatchUrl = g:vimwiki_rxWeblink1Prefix.
|
||||
\ g:vimwiki_rxWeblink1Descr. g:vimwiki_rxWeblink1Separator.
|
||||
\ '\zs'.g:vimwiki_rxWeblink1Url.'\ze'. g:vimwiki_rxWeblink1Suffix
|
||||
" 1c) match DESCRIPTION within [DESCRIPTION](URL)
|
||||
let g:vimwiki_rxWeblink1MatchDescr = g:vimwiki_rxWeblink1Prefix.
|
||||
\ '\zs'.g:vimwiki_rxWeblink1Descr.'\ze'. g:vimwiki_rxWeblink1Separator.
|
||||
\ g:vimwiki_rxWeblink1Url. g:vimwiki_rxWeblink1Suffix
|
||||
" }}}
|
||||
|
||||
" Syntax helper {{{
|
||||
" TODO: image links too !!
|
||||
" let g:vimwiki_rxWeblink1Prefix1 = '!\?'. g:vimwiki_rxWeblink1Prefix
|
||||
let g:vimwiki_rxWeblink1Prefix1 = g:vimwiki_rxWeblink1Prefix
|
||||
let g:vimwiki_rxWeblink1Suffix1 = g:vimwiki_rxWeblink1Separator.
|
||||
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Suffix
|
||||
" }}}
|
||||
|
||||
" *. ANY weblink {{{
|
||||
" *a) match ANY weblink
|
||||
let g:vimwiki_rxWeblink = ''.
|
||||
\ g:vimwiki_rxWeblink1.'\|'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
" *b) match URL within ANY weblink
|
||||
let g:vimwiki_rxWeblinkMatchUrl = ''.
|
||||
\ g:vimwiki_rxWeblink1MatchUrl.'\|'.
|
||||
\ g:vimwiki_rxWeblinkMatchUrl0
|
||||
" *c) match DESCRIPTION within ANY weblink
|
||||
let g:vimwiki_rxWeblinkMatchDescr = ''.
|
||||
\ g:vimwiki_rxWeblink1MatchDescr.'\|'.
|
||||
\ g:vimwiki_rxWeblinkMatchDescr0
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: Setup anylink regexps {{{
|
||||
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
|
||||
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: setup wikilink1 reference link definitions {{{
|
||||
let g:vimwiki_rxMkdRef = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
let g:vimwiki_rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
|
||||
\ g:vimwiki_rxWeblink0.'\ze'
|
||||
" }}}
|
||||
|
||||
" }}} end of Links
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
||||
function! s:add_target_syntax_ON(target, type) " {{{
|
||||
let prefix0 = 'syntax match '.a:type.' `'
|
||||
@ -222,13 +25,12 @@ function! s:add_target_syntax_OFF(target, type) " {{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:wrap_wikilink1_rx(target) "{{{
|
||||
return g:vimwiki_rxWikiLink1InvalidPrefix.a:target.
|
||||
\ g:vimwiki_rxWikiLink1InvalidSuffix
|
||||
return vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidPrefix') . a:target.
|
||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidSuffix')
|
||||
endfunction "}}}
|
||||
|
||||
function! s:existing_mkd_refs() "{{{
|
||||
call vimwiki#markdown_base#reset_mkd_refs()
|
||||
return keys(vimwiki#markdown_base#get_reflinks())
|
||||
return keys(vimwiki#markdown_base#scan_reflinks())
|
||||
endfunction "}}}
|
||||
|
||||
function! s:highlight_existing_links() "{{{
|
||||
@ -236,80 +38,80 @@ function! s:highlight_existing_links() "{{{
|
||||
" Conditional highlighting that depends on the existence of a wiki file or
|
||||
" directory is only available for *schemeless* wiki links
|
||||
" Links are set up upon BufEnter (see plugin/...)
|
||||
let safe_links = '\%('.vimwiki#base#file_pattern(b:existing_wikifiles) .
|
||||
let safe_links = '\%('.vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
|
||||
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
||||
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
|
||||
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
|
||||
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
|
||||
" Ref links are cached
|
||||
let safe_reflinks = vimwiki#base#file_pattern(s:existing_mkd_refs())
|
||||
|
||||
|
||||
" match [URL][]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
|
||||
\ safe_links, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][URL]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
||||
\ safe_links, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [DIRURL][]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
|
||||
\ safe_dirs, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][DIRURL]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
||||
\ safe_dirs, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [MKDREF][]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
|
||||
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][MKDREF]
|
||||
let target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
||||
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" use max highlighting - could be quite slow if there are too many wikifiles
|
||||
if VimwikiGet('maxhi')
|
||||
if vimwiki#vars#get_wikilocal('maxhi')
|
||||
" WikiLink
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
|
||||
call s:add_target_syntax_OFF(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
|
||||
|
||||
" 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_rxWikiLink1, 'VimwikiWikiLink1')
|
||||
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
|
||||
endif
|
||||
|
||||
" Weblink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
|
||||
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink1'), 'VimwikiWeblink1')
|
||||
|
||||
" WikiLink
|
||||
" All remaining schemes are highlighted automatically
|
||||
let s:rxSchemes = '\%('.
|
||||
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
|
||||
\ join(split(vimwiki#vars#get_global('schemes'), '\s*,\s*'), '\|').'\|'.
|
||||
\ join(split(vimwiki#vars#get_global('web_schemes1'), '\s*,\s*'), '\|').
|
||||
\ '\):'
|
||||
|
||||
" a) match [nonwiki-scheme-URL]
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
|
||||
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'), vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||
" b) match [DESCRIPTION][nonwiki-scheme-URL]
|
||||
let s:target = vimwiki#base#apply_template(
|
||||
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
|
||||
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
|
||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
||||
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'), vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||
" }}}
|
||||
|
||||
@ -318,7 +120,7 @@ call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||
|
||||
" 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,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
||||
execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i).'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
||||
endfor
|
||||
|
||||
" }}}
|
||||
@ -334,14 +136,14 @@ syntax spell toplevel
|
||||
" is present) and may be concealed
|
||||
let s:options = ' contained transparent contains=NONE'
|
||||
" conceal wikilink1
|
||||
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_prefix.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_suffix.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rx_wikilink_md_prefix').'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rx_wikilink_md_suffix').'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rxWikiLink1Prefix1').'/'.s:options
|
||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rxWikiLink1Suffix1').'/'.s:options
|
||||
|
||||
" conceal weblink1
|
||||
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.s:options
|
||||
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.s:options
|
||||
execute 'syn match VimwikiWeblink1Char "'.vimwiki#vars#get_syntaxlocal('rxWeblink1Prefix1').'"'.s:options
|
||||
execute 'syn match VimwikiWeblink1Char "'.vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options
|
||||
|
||||
if exists("+conceallevel")
|
||||
syntax conceal off
|
||||
|
@ -3,70 +3,80 @@
|
||||
" Desc: Defines mediaWiki syntax
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" see the comments in vimwiki_default.vim for some info about this file
|
||||
|
||||
let s:media_syntax = g:vimwiki_syntax_variables['media']
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
let g:vimwiki_char_eqin = '\$'
|
||||
let s:media_syntax.rxEqIn = '\$[^$`]\+\$'
|
||||
let s:media_syntax.char_eqin = '\$'
|
||||
|
||||
" text: '''strong'''
|
||||
let g:vimwiki_rxBold = "'''[^']\\+'''"
|
||||
let g:vimwiki_char_bold = "'''"
|
||||
let s:media_syntax.rxBold = "'''[^']\\+'''"
|
||||
let s:media_syntax.char_bold = "'''"
|
||||
|
||||
" text: ''emphasis''
|
||||
let g:vimwiki_rxItalic = "''[^']\\+''"
|
||||
let g:vimwiki_char_italic = "''"
|
||||
let s:media_syntax.rxItalic = "''[^']\\+''"
|
||||
let s:media_syntax.char_italic = "''"
|
||||
|
||||
" text: '''''strong italic'''''
|
||||
let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''"
|
||||
let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic
|
||||
let g:vimwiki_char_bolditalic = "'''''"
|
||||
let g:vimwiki_char_italicbold = g:vimwiki_char_bolditalic
|
||||
let s:media_syntax.rxBoldItalic = "'''''[^']\\+'''''"
|
||||
let s:media_syntax.rxItalicBold = s:media_syntax.rxBoldItalic
|
||||
let s:media_syntax.char_bolditalic = "'''''"
|
||||
let s:media_syntax.char_italicbold = s:media_syntax.char_bolditalic
|
||||
|
||||
" text: `code`
|
||||
let g:vimwiki_rxCode = '`[^`]\+`'
|
||||
let g:vimwiki_char_code = '`'
|
||||
let s:media_syntax.rxCode = '`[^`]\+`'
|
||||
let s:media_syntax.char_code = '`'
|
||||
|
||||
" text: ~~deleted text~~
|
||||
let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~'
|
||||
let g:vimwiki_char_deltext = '\~\~'
|
||||
let s:media_syntax.rxDelText = '\~\~[^~]\+\~\~'
|
||||
let s:media_syntax.char_deltext = '\~\~'
|
||||
|
||||
" text: ^superscript^
|
||||
let g:vimwiki_rxSuperScript = '\^[^^]\+\^'
|
||||
let g:vimwiki_char_superscript = '^'
|
||||
let s:media_syntax.rxSuperScript = '\^[^^]\+\^'
|
||||
let s:media_syntax.char_superscript = '^'
|
||||
|
||||
" text: ,,subscript,,
|
||||
let g:vimwiki_rxSubScript = ',,[^,]\+,,'
|
||||
let g:vimwiki_char_subscript = ',,'
|
||||
let s:media_syntax.rxSubScript = ',,[^,]\+,,'
|
||||
let s:media_syntax.char_subscript = ',,'
|
||||
|
||||
" generic headers
|
||||
let g:vimwiki_rxH = '='
|
||||
let g:vimwiki_symH = 1
|
||||
let s:media_syntax.rxH = '='
|
||||
let s:media_syntax.symH = 1
|
||||
|
||||
|
||||
|
||||
" <hr>, horizontal rule
|
||||
let g:vimwiki_rxHR = '^-----*$'
|
||||
let s:media_syntax.rxHR = '^-----*$'
|
||||
|
||||
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
|
||||
let g:vimwiki_rxTableSep = '|'
|
||||
let s:media_syntax.rxTableSep = '|'
|
||||
|
||||
" Lists
|
||||
let g:vimwiki_bullet_types = { '*':1, '#':1 }
|
||||
let g:vimwiki_number_types = []
|
||||
let g:vimwiki_list_markers = ['*', '#']
|
||||
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 . '\+\%(\[\(['.g:vimwiki_listsyms.g:vimwiki_listsym_rejected.']\)\]\s\)\?'
|
||||
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*'
|
||||
let s:media_syntax.bullet_types = ['*', '#']
|
||||
let s:media_syntax.recurring_bullets = 1
|
||||
let s:media_syntax.number_types = []
|
||||
let s:media_syntax.list_markers = ['*', '#']
|
||||
let s:media_syntax.rxListDefine = '^\%(;\|:\)\s'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '<pre>'
|
||||
let g:vimwiki_rxPreEnd = '<\/pre>'
|
||||
let s:media_syntax.rxPreStart = '<pre>'
|
||||
let s:media_syntax.rxPreEnd = '<\/pre>'
|
||||
|
||||
" Math block
|
||||
let g:vimwiki_rxMathStart = '{{\$'
|
||||
let g:vimwiki_rxMathEnd = '}}\$'
|
||||
let s:media_syntax.rxMathStart = '{{\$'
|
||||
let s:media_syntax.rxMathEnd = '}}\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
let s:media_syntax.rxComment = '^\s*%%.*$'
|
||||
let s:media_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
|
||||
|
||||
let s:media_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||
let s:media_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
||||
let s:media_syntax.bold_search = "'''\\zs[^']\\+\\ze'''"
|
||||
let s:media_syntax.bold_match = '''''''__Text__'''''''
|
||||
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
|
||||
" want to call escape() on this string, we must keep it in single quotes
|
||||
let s:media_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||
let s:media_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)' " XXX rework to mediawiki categories format?
|
||||
let s:media_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)' " XXX rework to mediawiki categories format?
|
||||
|
Loading…
Reference in New Issue
Block a user