pull in vimwiki 2.1 from vim.org

This commit is contained in:
mwcz 2013-04-18 23:46:58 -04:00
parent aea5b41f44
commit a0bd07e629
10 changed files with 489 additions and 346 deletions

View File

@ -166,9 +166,9 @@ function! vimwiki#base#validate_wiki_options(idx) " {{{ Validate wiki options
" update normalized path & path_html " update normalized path & path_html
call VimwikiSet('path', s:normalize_path(VimwikiGet('path', a:idx)), a: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('path_html', s:normalize_path(s:path_html(a:idx)), a:idx)
call VimwikiSet('template_path', call VimwikiSet('template_path',
\ s:normalize_path(VimwikiGet('template_path', a:idx)), a:idx) \ s:normalize_path(VimwikiGet('template_path', a:idx)), a:idx)
call VimwikiSet('diary_rel_path', call VimwikiSet('diary_rel_path',
\ s:normalize_path(VimwikiGet('diary_rel_path', a:idx)), a:idx) \ s:normalize_path(VimwikiGet('diary_rel_path', a:idx)), a:idx)
" XXX: It's too early to update global / buffer variables, because they are " XXX: It's too early to update global / buffer variables, because they are
@ -236,7 +236,7 @@ endfunction "}}}
" vimwiki#base#mkdir " vimwiki#base#mkdir
" If the optional argument 'confirm' == 1 is provided, " If the optional argument 'confirm' == 1 is provided,
" vimwiki#base#mkdir will ask before creating a directory " vimwiki#base#mkdir will ask before creating a directory
function! vimwiki#base#mkdir(path, ...) "{{{ function! vimwiki#base#mkdir(path, ...) "{{{
let path = expand(a:path) let path = expand(a:path)
if !isdirectory(path) && exists("*mkdir") if !isdirectory(path) && exists("*mkdir")
@ -258,7 +258,7 @@ function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
" names that are compatible with any external restrictions that they " names that are compatible with any external restrictions that they
" encounter (e.g. filesystem, wiki conventions, other syntaxes, ...). " encounter (e.g. filesystem, wiki conventions, other syntaxes, ...).
" See: http://code.google.com/p/vimwiki/issues/detail?id=316 " See: http://code.google.com/p/vimwiki/issues/detail?id=316
" Change / to [/\\] to allow "Windows paths" " Change / to [/\\] to allow "Windows paths"
" TODO: boundary cases ... " TODO: boundary cases ...
" e.g. "File$", "^File", "Fi]le", "Fi[le", "Fi\le", "Fi/le" " e.g. "File$", "^File", "Fi]le", "Fi[le", "Fi\le", "Fi/le"
" XXX: (remove my comment if agreed) Maxim: with \V (very nomagic) boundary " XXX: (remove my comment if agreed) Maxim: with \V (very nomagic) boundary
@ -317,7 +317,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
let lnk = a:lnk let lnk = a:lnk
let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl
let lnk = (is_schemeless ? 'wiki'.g:vimwiki_current_idx.':'.lnk : lnk) let lnk = (is_schemeless ? 'wiki'.g:vimwiki_current_idx.':'.lnk : lnk)
" Get scheme " Get scheme
let scheme = matchstr(lnk, g:vimwiki_rxSchemeUrlMatchScheme) let scheme = matchstr(lnk, g:vimwiki_rxSchemeUrlMatchScheme)
" Get link (without scheme) " Get link (without scheme)
@ -328,7 +328,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
let idx = -1 let idx = -1
" do nothing if scheme is unknown to vimwiki " do nothing if scheme is unknown to vimwiki
if !(scheme =~ 'wiki.*' || scheme =~ 'diary' || scheme =~ 'local' if !(scheme =~ 'wiki.*' || scheme =~ 'diary' || scheme =~ 'local'
\ || scheme =~ 'file') \ || scheme =~ 'file')
return [idx, scheme, path, subdir, lnk, ext, scheme.':'.lnk] return [idx, scheme, path, subdir, lnk, ext, scheme.':'.lnk]
endif endif
@ -441,10 +441,10 @@ function! vimwiki#base#system_open_link(url) "{{{
execute '!open ' . shellescape(a:url, 1) execute '!open ' . shellescape(a:url, 1)
endfunction endfunction
function! s:linux_handler(url) function! s:linux_handler(url)
execute 'silent !xdg-open ' . shellescape(a:url, 1) call system('xdg-open ' . shellescape(a:url, 1).' &')
endfunction endfunction
let success = 0 let success = 0
try try
if vimwiki#u#is_windows() if vimwiki#u#is_windows()
call s:win32_handler(a:url) call s:win32_handler(a:url)
return return
@ -461,7 +461,7 @@ endfunction "}}}
" vimwiki#base#open_link " vimwiki#base#open_link
function! vimwiki#base#open_link(cmd, link, ...) "{{{ function! vimwiki#base#open_link(cmd, link, ...) "{{{
let [idx, scheme, path, subdir, lnk, ext, url] = let [idx, scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(a:link, 0) \ vimwiki#base#resolve_scheme(a:link, 0)
if url == '' if url == ''
@ -473,13 +473,13 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
endif endif
let update_prev_link = ( let update_prev_link = (
\ scheme == '' || \ scheme == '' ||
\ scheme =~ 'wiki' || \ scheme =~ 'wiki' ||
\ scheme =~ 'diary' ? 1 : 0) \ scheme =~ 'diary' ? 1 : 0)
let use_system_open = ( let use_system_open = (
\ scheme == '' || \ scheme == '' ||
\ scheme =~ 'wiki' || \ scheme =~ 'wiki' ||
\ scheme =~ 'diary' ? 0 : 1) \ scheme =~ 'diary' ? 0 : 1)
let vimwiki_prev_link = [] let vimwiki_prev_link = []
@ -514,7 +514,7 @@ function! vimwiki#base#generate_links() "{{{only get links from the current dir
" change to the directory of the current file " change to the directory of the current file
let orig_pwd = getcwd() let orig_pwd = getcwd()
lcd! %:h lcd! %:h
" all path are relative to the current file's location " all path are relative to the current file's location
let globlinks = glob('*'.VimwikiGet('ext'),1)."\n" let globlinks = glob('*'.VimwikiGet('ext'),1)."\n"
" remove extensions " remove extensions
let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\ze\n', '', 'g') let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\ze\n', '', 'g')
@ -549,7 +549,7 @@ endfunction "}}}
function! vimwiki#base#backlinks() "{{{ function! vimwiki#base#backlinks() "{{{
execute 'lvimgrep "\%(^\|[[:blank:][:punct:]]\)'. execute 'lvimgrep "\%(^\|[[:blank:][:punct:]]\)'.
\ expand("%:t:r"). \ expand("%:t:r").
\ '\([[:blank:][:punct:]]\|$\)" '. \ '\([[:blank:][:punct:]]\|$\)\C" '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
endfunction "}}} endfunction "}}}
@ -560,7 +560,7 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
let time1 = reltime() " start the clock let time1 = reltime() " start the clock
" XXX: " XXX:
" if maxhi = 1 and <leader>w<leader>w before loading any vimwiki file " if maxhi = 1 and <leader>w<leader>w before loading any vimwiki file
" cached 'subdir' is not set up " cached 'subdir' is not set up
try try
@ -575,18 +575,18 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
" if current wiki is temporary -- was added by an arbitrary wiki file then do " 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 " not search wiki files in subdirectories. Or it would hang the system if
" wiki file was created in $HOME or C:/ dirs. " wiki file was created in $HOME or C:/ dirs.
if VimwikiGet('temp') if VimwikiGet('temp')
let search_dirs = '' let search_dirs = ''
else else
let search_dirs = '**/' let search_dirs = '**/'
endif endif
" let globlinks = "\n".glob(VimwikiGet('path').search_dirs.a:pat,1)."\n" " let globlinks = "\n".glob(VimwikiGet('path').search_dirs.a:pat,1)."\n"
"save pwd, do lcd %:h, restore old pwd; getcwd() "save pwd, do lcd %:h, restore old pwd; getcwd()
" change to the directory of the current file " change to the directory of the current file
let orig_pwd = getcwd() let orig_pwd = getcwd()
" calling from other than vimwiki file " calling from other than vimwiki file
let path_base = vimwiki#u#path_norm(vimwiki#u#chomp_slash(VimwikiGet('path'))) let path_base = vimwiki#u#path_norm(vimwiki#u#chomp_slash(VimwikiGet('path')))
let path_file = vimwiki#u#path_norm(vimwiki#u#chomp_slash(expand('%:p:h'))) let path_file = vimwiki#u#path_norm(vimwiki#u#chomp_slash(expand('%:p:h')))
@ -596,7 +596,7 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
lcd! %:p:h lcd! %:p:h
endif endif
" all path are relative to the current file's location " all path are relative to the current file's location
let globlinks = "\n".glob(invsubdir.search_dirs.a:pat,1)."\n" let globlinks = "\n".glob(invsubdir.search_dirs.a:pat,1)."\n"
" remove extensions " remove extensions
let globlinks = substitute(globlinks,'\'.VimwikiGet('ext').'\ze\n', '', 'g') let globlinks = substitute(globlinks,'\'.VimwikiGet('ext').'\ze\n', '', 'g')
@ -613,7 +613,7 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
endfor endfor
" for directories: add ./ (instead of now empty) and invsubdir (if distinct) " for directories: add ./ (instead of now empty) and invsubdir (if distinct)
if a:pat == '*/' if a:pat == '*/'
let globlinks = substitute(globlinks, "\n\n", "\n./\n",'') let globlinks = substitute(globlinks, "\n\n", "\n./\n",'')
if invsubdir != '' if invsubdir != ''
let globlinks .= invsubdir."\n" let globlinks .= invsubdir."\n"
else else
@ -639,7 +639,7 @@ function! vimwiki#base#edit_file(command, filename, ...) "{{{
" then " then
" [[test*file]]... " [[test*file]]...
" you'll have E77: Too many file names " you'll have E77: Too many file names
let fname = escape(a:filename, '% *|') let fname = escape(a:filename, '% *|#')
let dir = fnamemodify(a:filename, ":p:h") let dir = fnamemodify(a:filename, ":p:h")
if vimwiki#base#mkdir(dir, 1) if vimwiki#base#mkdir(dir, 1)
execute a:command.' '.fname execute a:command.' '.fname
@ -755,9 +755,9 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
let old_fname_r = old_fname let old_fname_r = old_fname
let new_fname_r = new_fname let new_fname_r = new_fname
let old_fname_r = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1, let old_fname_r = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ '\zs'.old_fname.'\ze', '.*', ''). \ '\zs'.old_fname.'\ze', '.*', '').
\ '\|'. vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2, \ '\|'. vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ '\zs'.old_fname.'\ze', '.*', '') \ '\zs'.old_fname.'\ze', '.*', '')
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n') let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
@ -801,7 +801,7 @@ function! s:update_wiki_links(old_fname, new_fname) " {{{
while idx < len(dirs_keys) while idx < len(dirs_keys)
let dir = dirs_keys[idx] let dir = dirs_keys[idx]
let new_dir = dirs_vals[idx] let new_dir = dirs_vals[idx]
call s:update_wiki_links_dir(dir, call s:update_wiki_links_dir(dir,
\ new_dir.old_fname, new_dir.new_fname) \ new_dir.old_fname, new_dir.new_fname)
let idx = idx + 1 let idx = idx + 1
endwhile endwhile
@ -872,12 +872,12 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{
" regular one. " regular one.
" Perl syntax file has perlFunctionName which is usually has no effect due to " Perl syntax file has perlFunctionName which is usually has no effect due to
" 'contained' flag. Now we have 'syntax include' that makes all the groups " 'contained' flag. Now we have 'syntax include' that makes all the groups
" included as 'contained' into specific group. " included as 'contained' into specific group.
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with " Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
" the rest syntax rules as now it has effect being really 'contained'. " the rest syntax rules as now it has effect being really 'contained'.
" Clear it! " Clear it!
if ft =~ 'perl' if ft =~ 'perl'
syntax clear perlFunctionName syntax clear perlFunctionName
endif endif
endfunction "}}} endfunction "}}}
@ -895,7 +895,7 @@ function! vimwiki#base#find_prev_link() "{{{
endfunction " }}} endfunction " }}}
" vimwiki#base#follow_link " vimwiki#base#follow_link
function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pass function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pass
" to VimwikiLinkHandler, or failing that, the default open_link handler " to VimwikiLinkHandler, or failing that, the default open_link handler
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#follow_link') if exists('*vimwiki#'.VimwikiGet('syntax').'_base#follow_link')
" Syntax-specific links " Syntax-specific links
@ -941,7 +941,7 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
if a:0 > 0 if a:0 > 0
execute "normal! ".a:1 execute "normal! ".a:1
else else
call vimwiki#base#normalize_link(0) call vimwiki#base#normalize_link(0)
endif endif
endif endif
@ -1051,7 +1051,7 @@ function! vimwiki#base#rename_link() "{{{
if url != '' if url != ''
let new_link = url let new_link = url
endif endif
let new_link = subdir.new_link let new_link = subdir.new_link
let new_fname = VimwikiGet('path').new_link.VimwikiGet('ext') let new_fname = VimwikiGet('path').new_link.VimwikiGet('ext')
@ -1134,7 +1134,7 @@ function! vimwiki#base#TO_header(inner, visual) "{{{
if !search('^\(=\+\).\+\1\s*$', 'bcW') if !search('^\(=\+\).\+\1\s*$', 'bcW')
return return
endif endif
let sel_start = line("'<") let sel_start = line("'<")
let sel_end = line("'>") let sel_end = line("'>")
let block_start = line(".") let block_start = line(".")
@ -1142,7 +1142,7 @@ function! vimwiki#base#TO_header(inner, visual) "{{{
let level = vimwiki#u#count_first_sym(getline('.')) let level = vimwiki#u#count_first_sym(getline('.'))
let is_header_selected = sel_start == block_start let is_header_selected = sel_start == block_start
\ && sel_start != sel_end \ && sel_start != sel_end
if a:visual && is_header_selected if a:visual && is_header_selected
@ -1374,7 +1374,7 @@ function! vimwiki#base#AddHeaderLevel() "{{{
call setline(lnum, line) call setline(lnum, line)
endif endif
else else
let line = substitute(line, '^\s*', '&'.rxHdr.' ', '') let line = substitute(line, '^\s*', '&'.rxHdr.' ', '')
if g:vimwiki_symH if g:vimwiki_symH
let line = substitute(line, '\s*$', ' '.rxHdr.'&', '') let line = substitute(line, '\s*$', ' '.rxHdr.'&', '')
endif endif
@ -1427,7 +1427,7 @@ function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
let magic_chars = '.*[\^$' let magic_chars = '.*[\^$'
let lnk = escape(a:template, magic_chars) let lnk = escape(a:template, magic_chars)
if a:rxUrl != "" if a:rxUrl != ""
let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", '') let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", '')
endif endif
if a:rxDesc != "" if a:rxDesc != ""
let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", '') let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", '')
@ -1492,7 +1492,7 @@ function! s:normalize_link_syntax_n() " {{{
endif endif
return return
endif endif
" try WikiIncl " try WikiIncl
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl) let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
if !empty(lnk) if !empty(lnk)
@ -1567,7 +1567,7 @@ endfunction "}}}
" Load syntax-specific Wiki functionality " Load syntax-specific Wiki functionality
for syn in vimwiki#base#get_known_syntaxes() for syn in vimwiki#base#get_known_syntaxes()
execute 'runtime! autoload/vimwiki/'.syn.'_base.vim' execute 'runtime! autoload/vimwiki/'.syn.'_base.vim'
endfor endfor
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------

View File

@ -4,7 +4,15 @@
" Author: Maxim Kim <habamax@gmail.com> " Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/ " Home: http://code.google.com/p/vimwiki/
" XXX: This file should be refactored! " TODO: We need vimwiki abstract syntax tree. If properly designed it wourld
" greatly symplify different syntax to HTML generation.
"
" vimwiki -- --> PDF
" \ /
" markdown -----> AST -----> HTML
" / \
" mediawiki -- --> Latex
"
" Load only once {{{ " Load only once {{{
if exists("g:loaded_vimwiki_html_auto") || &cp if exists("g:loaded_vimwiki_html_auto") || &cp
@ -137,22 +145,12 @@ endfunction "}}}
function! s:safe_html(line) "{{{ function! s:safe_html(line) "{{{
" escape & < > when producing HTML text " escape & < > when producing HTML text
" uses variables s:lt_pattern, s:gt_pattern that are " s:lt_pattern, s:gt_pattern depend on g:vimwiki_valid_html_tags
" set in vimwiki#html#Wiki2HTML() according to g:vimwiki_valid_html_tags " and are set in vimwiki#html#Wiki2HTML()
"" htmlize symbols: < > &
let line = substitute(a:line, '&', '\&amp;', 'g') let line = substitute(a:line, '&', '\&amp;', 'g')
" the following depends on g:vimwiki_valid_html_tags
let line = substitute(line,s:lt_pattern,'\&lt;', 'g') let line = substitute(line,s:lt_pattern,'\&lt;', 'g')
let line = substitute(line,s:gt_pattern,'\&gt;', 'g') let line = substitute(line,s:gt_pattern,'\&gt;', 'g')
"let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
"let line = substitute(line,'<\%(/\?\%('
" \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!',
" \'\&lt;', 'g')
"let line = substitute(line,'\%(</\?\%('
" \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>',
" \'\&gt;', 'g')
return line return line
endfunction "}}} endfunction "}}}
@ -379,8 +377,8 @@ function! vimwiki#html#linkify_link(src, descr) "{{{
let src_str = ' href="'.a:src.'"' let src_str = ' href="'.a:src.'"'
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','') let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
let descr = (descr == "" ? a:src : descr) let descr = (descr == "" ? a:src : descr)
let descr_str = (descr =~ g:vimwiki_rxWikiIncl let descr_str = (descr =~ g:vimwiki_rxWikiIncl
\ ? s:tag_wikiincl(descr) \ ? s:tag_wikiincl(descr)
\ : descr) \ : descr)
return '<a'.src_str.'>'.descr_str.'</a>' return '<a'.src_str.'>'.descr_str.'</a>'
endfunction "}}} endfunction "}}}
@ -415,7 +413,7 @@ function! s:tag_wikiincl(value) "{{{
let descr = matchstr(str, vimwiki#html#incl_match_arg(1)) let descr = matchstr(str, vimwiki#html#incl_match_arg(1))
let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2)) let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2))
" resolve url " resolve url
let [idx, scheme, path, subdir, lnk, ext, url] = let [idx, scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(url_0, 1) \ vimwiki#base#resolve_scheme(url_0, 1)
" generate html output " generate html output
" TODO: migrate non-essential debugging messages into g:VimwikiLog " TODO: migrate non-essential debugging messages into g:VimwikiLog
@ -448,7 +446,7 @@ function! s:tag_wikilink(value) "{{{
let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url) let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url)
" resolve url " resolve url
let [idx, scheme, path, subdir, lnk, ext, url] = let [idx, scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(url, 1) \ vimwiki#base#resolve_scheme(url, 1)
" generate html output " generate html output
@ -456,11 +454,10 @@ function! s:tag_wikilink(value) "{{{
if g:vimwiki_debug > 1 if g:vimwiki_debug > 1
echom '[[idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.']]' echom '[[idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.']]'
endif endif
let url = escape(url, '#')
let line = vimwiki#html#linkify_link(url, descr) let line = vimwiki#html#linkify_link(url, descr)
return line return line
endfunction "}}} endfunction "}}}
"}}} v1.3 links "}}}
function! s:tag_remove_internal_link(value) "{{{ function! s:tag_remove_internal_link(value) "{{{
@ -511,7 +508,7 @@ endfunction "}}}
function! s:make_tag(line, regexp, func) "{{{ function! s:make_tag(line, regexp, func) "{{{
" Make tags for a given matched regexp. " Make tags for a given matched regexp.
" Exclude preformatted text and href links. " Exclude preformatted text and href links.
" FIXME " FIXME
let patt_splitter = '\(`[^`]\+`\)\|'. let patt_splitter = '\(`[^`]\+`\)\|'.
\ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'. \ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'.
\ '\(<a href.\{-}</a>\)\|'. \ '\(<a href.\{-}</a>\)\|'.
@ -612,7 +609,7 @@ endfunction "}}}
function! s:close_tag_table(table, ldest) "{{{ function! s:close_tag_table(table, ldest) "{{{
" The first element of table list is a string which tells us if table should be centered. " The first element of table list is a string which tells us if table should be centered.
" The rest elements are rows which are lists of columns: " The rest elements are rows which are lists of columns:
" ['center', " ['center',
" [ CELL1, CELL2, CELL3 ], " [ CELL1, CELL2, CELL3 ],
" [ CELL1, CELL2, CELL3 ], " [ CELL1, CELL2, CELL3 ],
" [ CELL1, CELL2, CELL3 ], " [ CELL1, CELL2, CELL3 ],
@ -623,7 +620,7 @@ function! s:close_tag_table(table, ldest) "{{{
let table = a:table let table = a:table
" Get max cells " Get max cells
let max_cells = 0 let max_cells = 0
for row in table[1:] for row in table[1:]
let n_cells = len(row) let n_cells = len(row)
if n_cells > max_cells if n_cells > max_cells
@ -669,14 +666,14 @@ function! s:close_tag_table(table, ldest) "{{{
function! s:close_tag_row(row, header, ldest) "{{{ function! s:close_tag_row(row, header, ldest) "{{{
call add(a:ldest, '<tr>') call add(a:ldest, '<tr>')
" Set tag element of columns " Set tag element of columns
if a:header if a:header
let tag_name = 'th' let tag_name = 'th'
else else
let tag_name = 'td' let tag_name = 'td'
end end
" Close tag of columns " Close tag of columns
for cell in a:row for cell in a:row
if cell.rowspan == 0 || cell.colspan == 0 if cell.rowspan == 0 || cell.colspan == 0
continue continue
@ -859,7 +856,7 @@ function! s:process_tag_list(line, lists) "{{{
endif endif
" let completion = match(g:vimwiki_listsyms, '\C' . chk[1]) " let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
let completion = s:get_completion_index(chk[1]) let completion = s:get_completion_index(chk[1])
if completion >= 0 && completion <=4 if completion >= 0 && completion <=4
let st_tag = '<li class="done'.completion.'">' let st_tag = '<li class="done'.completion.'">'
endif endif
endif endif
@ -1028,7 +1025,7 @@ function! s:process_tag_h(line, id) "{{{
let h_text = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader)) let h_text = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
if g:vimwiki_html_header_numbering if g:vimwiki_html_header_numbering
let num = matchstr(h_number, let num = matchstr(h_number,
\ '^\(\d.\)\{'.(g:vimwiki_html_header_numbering-1).'}\zs.*') \ '^\(\d.\)\{'.(g:vimwiki_html_header_numbering-1).'}\zs.*')
if !empty(num) if !empty(num)
let num .= g:vimwiki_html_header_numbering_sym let num .= g:vimwiki_html_header_numbering_sym
@ -1352,13 +1349,17 @@ endfunction " }}}
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{ function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
call vimwiki#base#mkdir(a:path) call vimwiki#base#mkdir(a:path)
execute '!'.VimwikiGet('custom_wiki2html'). ' ' echomsg system(VimwikiGet('custom_wiki2html'). ' '.
\ a:force. ' '. \ a:force. ' '.
\ VimwikiGet('syntax'). ' '. \ VimwikiGet('syntax'). ' '.
\ strpart(VimwikiGet('ext'), 1). ' '. \ strpart(VimwikiGet('ext'), 1). ' '.
\ a:path. ' '. \ shellescape(a:path, 1). ' '.
\ a:wikifile. ' '. \ shellescape(a:wikifile, 1). ' '.
\ s:default_CSS_full_name(a:path) \ shellescape(s:default_CSS_full_name(a:path), 1). ' '.
\ (len(VimwikiGet('template_path')) > 1 ? shellescape(expand(VimwikiGet('template_path')), 1) : '-'). ' '.
\ (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')), 1) : '-'))
endfunction " }}} endfunction " }}}
function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
@ -1369,7 +1370,7 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
let wikifile = fnamemodify(a:wikifile, ":p") let wikifile = fnamemodify(a:wikifile, ":p")
let path_html = expand(a:path_html).VimwikiGet('subdir') let path_html = expand(a:path_html).VimwikiGet('subdir')
let htmlfile = fnamemodify(wikifile, ":t:r").'.html' let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
if s:use_custom_wiki2html() if s:use_custom_wiki2html()
@ -1415,8 +1416,8 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
let s:gt_pattern = '>' let s:gt_pattern = '>'
if g:vimwiki_valid_html_tags != '' if g:vimwiki_valid_html_tags != ''
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|') let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
let s:lt_pattern = '<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!' let s:lt_pattern = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
let s:gt_pattern = '\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>' let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
endif endif
for line in lsource for line in lsource
@ -1487,7 +1488,7 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")') call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents% let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
"" make html file. "" make html file.
call writefile(html_lines, path_html.htmlfile) call writefile(html_lines, path_html.htmlfile)
let done = 1 let done = 1
@ -1499,7 +1500,7 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
return return
endif endif
" measure the elapsed time " measure the elapsed time
let time1 = vimwiki#u#time(starttime) "XXX let time1 = vimwiki#u#time(starttime) "XXX
call VimwikiLog_extend('html',[htmlfile,time1]) call VimwikiLog_extend('html',[htmlfile,time1])
"if g:vimwiki_debug "if g:vimwiki_debug
@ -1566,7 +1567,7 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{
endfunction "}}} endfunction "}}}
function! s:file_exists(fname) "{{{ function! s:file_exists(fname) "{{{
return !empty(getftype(a:fname)) return !empty(getftype(expand(a:fname)))
endfunction "}}} endfunction "}}}
" uses VimwikiGet('path') " uses VimwikiGet('path')

View File

@ -183,7 +183,7 @@ function! s:get_child_items(lnum) "{{{
call add(result, lnum) call add(result, lnum)
let lnum = s:next_list_item(lnum) let lnum = s:next_list_item(lnum)
endwhile endwhile
return result return result
endfunction "}}} endfunction "}}}
@ -207,7 +207,7 @@ function! s:get_sibling_items(lnum) "{{{
endif endif
let lnum = s:prev_list_item(lnum) let lnum = s:prev_list_item(lnum)
endwhile endwhile
return result return result
endfunction "}}} endfunction "}}}
@ -407,12 +407,12 @@ function s:get_list_nesting_level(lnum) "{{{
if VimwikiGet('syntax') == 'media' if VimwikiGet('syntax') == 'media'
if getline(a:lnum) !~ s:rx_list_item() if getline(a:lnum) !~ s:rx_list_item()
let level = 0 let level = 0
else else
let level = vimwiki#u#count_first_sym(getline(a:lnum)) - 1 let level = vimwiki#u#count_first_sym(getline(a:lnum)) - 1
let level = level < 0 ? 0 : level let level = level < 0 ? 0 : level
endif endif
else else
let level = indent(a:lnum) let level = indent(a:lnum)
endif endif
return level return level
endfunction "}}} endfunction "}}}
@ -477,7 +477,7 @@ function! vimwiki#lst#change_level(...) "{{{
let li_bullet_and_content = strpart(line, n_nesting + n_indent) let li_bullet_and_content = strpart(line, n_nesting + n_indent)
" list bullet and checkbox " list bullet and checkbox
let cb_bullet = matchstr(li_bullet_and_content, s:rx_list_item()). let cb_bullet = matchstr(li_bullet_and_content, s:rx_list_item()).
\ matchstr(li_bullet_and_content, s:rx_cb_list_item()) \ matchstr(li_bullet_and_content, s:rx_cb_list_item())
" XXX: it could be not unicode proof --> if checkboxes are set up with unicode syms " XXX: it could be not unicode proof --> if checkboxes are set up with unicode syms
@ -505,18 +505,18 @@ function! vimwiki#lst#change_level(...) "{{{
endif endif
" change level " change level
if cmd == '--' if cmd == '--'
let cb_bullet = s:compose_cb_bullet(cb_bullet, sym) let cb_bullet = s:compose_cb_bullet(cb_bullet, sym)
if VimwikiGet('syntax') == 'media' if VimwikiGet('syntax') == 'media'
let sym_nest = sym let sym_nest = sym
endif endif
elseif cmd == '>>' elseif cmd == '>>'
if cb_bullet == '' if cb_bullet == ''
let cb_bullet = sym let cb_bullet = sym
else else
let n_nesting = n_nesting + list_sw let n_nesting = n_nesting + list_sw
endif endif
elseif cmd == '<<' elseif cmd == '<<'
let n_nesting = n_nesting - list_sw let n_nesting = n_nesting - list_sw
if VimwikiGet('syntax') == 'media' if VimwikiGet('syntax') == 'media'
if n_nesting < 0 if n_nesting < 0

View File

@ -21,7 +21,7 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{
catch /^Vim\%((\a\+)\)\=:E480/ " No Match catch /^Vim\%((\a\+)\)\=:E480/ " No Match
"Ignore it, and move on to the next file "Ignore it, and move on to the next file
endtry endtry
" "
for d in getqflist() for d in getqflist()
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ') let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr) let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
@ -108,7 +108,7 @@ endfunction " }}}
" vimwiki#base#find_prev_link " vimwiki#base#find_prev_link
" vimwiki#base#follow_link " vimwiki#base#follow_link
function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
" to VimwikiLinkHandler, or failing that, the default open_link handler " to VimwikiLinkHandler, or failing that, the default open_link handler
" echom "markdown_base#follow_link" " echom "markdown_base#follow_link"
@ -153,7 +153,7 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
if a:0 > 0 if a:0 > 0
execute "normal! ".a:1 execute "normal! ".a:1
else else
call vimwiki#base#normalize_link(0) call vimwiki#base#normalize_link(0)
endif endif
endif endif
@ -210,7 +210,7 @@ function! s:normalize_link_syntax_n() " {{{
endif endif
return return
endif endif
" try WikiLink1: replace with WikiLink0 " try WikiLink1: replace with WikiLink0
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1) let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
if !empty(lnk) if !empty(lnk)
@ -223,7 +223,7 @@ function! s:normalize_link_syntax_n() " {{{
endif endif
return return
endif endif
" try Weblink " try Weblink
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink) let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
if !empty(lnk) if !empty(lnk)

View File

@ -16,10 +16,13 @@ let g:loaded_vimwiki_tbl_auto = 1
"}}} "}}}
let s:textwidth = &tw let s:textwidth = &tw
let s:rxSep = g:vimwiki_rxTableSep
" Misc functions {{{ " Misc functions {{{
function! s:rxSep() "{{{
return g:vimwiki_rxTableSep
endfunction "}}}
function! s:wide_len(str) "{{{ function! s:wide_len(str) "{{{
" vim73 has new function that gives correct string width. " vim73 has new function that gives correct string width.
if exists("*strdisplaywidth") if exists("*strdisplaywidth")
@ -43,36 +46,36 @@ function! s:wide_len(str) "{{{
endfunction "}}} endfunction "}}}
function! s:cell_splitter() "{{{ function! s:cell_splitter() "{{{
return '\s*'.s:rxSep.'\s*' return '\s*'.s:rxSep().'\s*'
endfunction "}}} endfunction "}}}
function! s:sep_splitter() "{{{ function! s:sep_splitter() "{{{
return '-'.s:rxSep.'-' return '-'.s:rxSep().'-'
endfunction "}}} endfunction "}}}
function! s:is_table(line) "{{{ function! s:is_table(line) "{{{
return s:is_separator(a:line) || (a:line !~ s:rxSep.s:rxSep && a:line =~ '^\s*'.s:rxSep.'.\+'.s:rxSep.'\s*$') return s:is_separator(a:line) || (a:line !~ s:rxSep().s:rxSep() && a:line =~ '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
endfunction "}}} endfunction "}}}
function! s:is_separator(line) "{{{ function! s:is_separator(line) "{{{
return a:line =~ '^\s*'.s:rxSep.'\(--\+'.s:rxSep.'\)\+\s*$' return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
endfunction "}}} endfunction "}}}
function! s:is_separator_tail(line) "{{{ function! s:is_separator_tail(line) "{{{
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep.'-\+\)\+'.s:rxSep.'\s*$' return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction "}}} endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{ function! s:is_last_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), a:cnum - 1) let line = strpart(getline(a:lnum), a:cnum - 1)
"echomsg "DEBUG is_last_column> ".(line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$') "echomsg "DEBUG is_last_column> ".(line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$')
return line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$' return line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$'
endfunction "}}} endfunction "}}}
function! s:is_first_column(lnum, cnum) "{{{ function! s:is_first_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), 0, a:cnum - 1) let line = strpart(getline(a:lnum), 0, a:cnum - 1)
"echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep) "echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep) return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction "}}} endfunction "}}}
function! s:count_separators_up(lnum) "{{{ function! s:count_separators_up(lnum) "{{{
@ -100,8 +103,8 @@ function! s:count_separators_down(lnum) "{{{
endfunction "}}} endfunction "}}}
function! s:create_empty_row(cols) "{{{ function! s:create_empty_row(cols) "{{{
let row = s:rxSep let row = s:rxSep()
let cell = " ".s:rxSep let cell = " ".s:rxSep()
for c in range(a:cols) for c in range(a:cols)
let row .= cell let row .= cell
@ -111,8 +114,8 @@ function! s:create_empty_row(cols) "{{{
endfunction "}}} endfunction "}}}
function! s:create_row_sep(cols) "{{{ function! s:create_row_sep(cols) "{{{
let row = s:rxSep let row = s:rxSep()
let cell = "---".s:rxSep let cell = "---".s:rxSep()
for c in range(a:cols) for c in range(a:cols)
let row .= cell let row .= cell
@ -274,10 +277,10 @@ function! s:cur_column() "{{{
" TODO: do we need conditional: if s:is_separator(line) " TODO: do we need conditional: if s:is_separator(line)
let curs_pos = col('.') let curs_pos = col('.')
let mpos = match(line, s:rxSep, 0) let mpos = match(line, s:rxSep(), 0)
let col = -1 let col = -1
while mpos < curs_pos && mpos != -1 while mpos < curs_pos && mpos != -1
let mpos = match(line, s:rxSep, mpos+1) let mpos = match(line, s:rxSep(), mpos+1)
if mpos != -1 if mpos != -1
let col += 1 let col += 1
endif endif
@ -301,7 +304,7 @@ function! s:fmt_cell(cell, max_len) "{{{
endfunction "}}} endfunction "}}}
function! s:fmt_row(line, max_lens, col1, col2) "{{{ function! s:fmt_row(line, max_lens, col1, col2) "{{{
let new_line = s:rxSep let new_line = s:rxSep()
let cells = vimwiki#tbl#get_cells(a:line) let cells = vimwiki#tbl#get_cells(a:line)
for idx in range(len(cells)) for idx in range(len(cells))
if idx == a:col1 if idx == a:col1
@ -310,12 +313,12 @@ function! s:fmt_row(line, max_lens, col1, col2) "{{{
let idx = a:col1 let idx = a:col1
endif endif
let value = cells[idx] let value = cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep()
endfor endfor
let idx = len(cells) let idx = len(cells)
while idx < len(a:max_lens) while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep()
let idx += 1 let idx += 1
endwhile endwhile
return new_line return new_line
@ -330,14 +333,14 @@ function! s:fmt_cell_sep(max_len) "{{{
endfunction "}}} endfunction "}}}
function! s:fmt_sep(max_lens, col1, col2) "{{{ function! s:fmt_sep(max_lens, col1, col2) "{{{
let new_line = s:rxSep let new_line = s:rxSep()
for idx in range(len(a:max_lens)) for idx in range(len(a:max_lens))
if idx == a:col1 if idx == a:col1
let idx = a:col2 let idx = a:col2
elseif idx == a:col2 elseif idx == a:col2
let idx = a:col1 let idx = a:col1
endif endif
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
endfor endfor
return new_line return new_line
endfunction "}}} endfunction "}}}
@ -349,10 +352,10 @@ function! s:kbd_create_new_row(cols, goto_first) "{{{
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>" let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>0" let cmd .= "\<ESC>0"
if a:goto_first if a:goto_first
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'c', line('.'))\<CR>" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>"
else else
let cmd .= (col('.')-1)."l" let cmd .= (col('.')-1)."l"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
endif endif
let cmd .= "a" let cmd .= "a"
@ -361,16 +364,16 @@ endfunction "}}}
function! s:kbd_goto_next_row() "{{{ function! s:kbd_goto_next_row() "{{{
let cmd = "\<ESC>j" let cmd = "\<ESC>j"
let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>" let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a" let cmd .= "a"
return cmd return cmd
endfunction "}}} endfunction "}}}
function! s:kbd_goto_prev_row() "{{{ function! s:kbd_goto_prev_row() "{{{
let cmd = "\<ESC>k" let cmd = "\<ESC>k"
let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>" let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a" let cmd .= "a"
return cmd return cmd
endfunction "}}} endfunction "}}}
@ -408,7 +411,7 @@ function! vimwiki#tbl#goto_prev_col() "{{{
let newcol = s:get_indent(lnum) let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum) let max_lens = s:get_cell_max_lens(lnum)
let prev_cell_len = 0 let prev_cell_len = 0
echom string(max_lens) echom string(max_lens)
for cell_len in values(max_lens) for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space> let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
if newcol + delta > curcol-1 if newcol + delta > curcol-1
@ -432,7 +435,7 @@ function! s:kbd_goto_prev_col(jumpup) "{{{
let cmd .= "$" let cmd .= "$"
endif endif
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a" let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
" let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'b', line('.'))\<CR>" " let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a" " let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd "echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd return cmd
@ -487,6 +490,9 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
endfunction "}}} endfunction "}}}
function! vimwiki#tbl#format(lnum, ...) "{{{ function! vimwiki#tbl#format(lnum, ...) "{{{
if !(&filetype == 'vimwiki')
return
endif
let line = getline(a:lnum) let line = getline(a:lnum)
if !s:is_table(line) if !s:is_table(line)
return return
@ -506,7 +512,7 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
let row = repeat(' ', indent).row let row = repeat(' ', indent).row
call setline(lnum, row) call setline(lnum, row)
endfor endfor
let &tw = s:textwidth let &tw = s:textwidth
endfunction "}}} endfunction "}}}
@ -541,7 +547,7 @@ function! vimwiki#tbl#create(...) "{{{
for r in range(rows - 1) for r in range(rows - 1)
call add(lines, row) call add(lines, row)
endfor endfor
call append(line('.'), lines) call append(line('.'), lines)
endfunction "}}} endfunction "}}}
@ -554,11 +560,14 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
endfunction "}}} endfunction "}}}
function! vimwiki#tbl#reset_tw(lnum) "{{{ function! vimwiki#tbl#reset_tw(lnum) "{{{
if !(&filetype == 'vimwiki')
return
endif
let line = getline(a:lnum) let line = getline(a:lnum)
if !s:is_table(line) if !s:is_table(line)
return return
endif endif
let s:textwidth = &tw let s:textwidth = &tw
let &tw = 0 let &tw = 0
endfunction "}}} endfunction "}}}
@ -581,17 +590,17 @@ function! vimwiki#tbl#move_column_left() "{{{
endif endif
if cur_col > 0 if cur_col > 0
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col) call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1) call cursor(line('.'), 1)
let sep = '\('.s:rxSep.'\).\zs' let sep = '\('.s:rxSep().'\).\zs'
let mpos = -1 let mpos = -1
let col = -1 let col = -1
while col < cur_col-1 while col < cur_col-1
let mpos = match(line, sep, mpos+1) let mpos = match(line, sep, mpos+1)
if mpos != -1 if mpos != -1
let col += 1 let col += 1
else else
break break
endif endif
endwhile endwhile
@ -614,17 +623,17 @@ function! vimwiki#tbl#move_column_right() "{{{
endif endif
if cur_col < s:col_count(line('.'))-1 if cur_col < s:col_count(line('.'))-1
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1) call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1) call cursor(line('.'), 1)
let sep = '\('.s:rxSep.'\).\zs' let sep = '\('.s:rxSep().'\).\zs'
let mpos = -1 let mpos = -1
let col = -1 let col = -1
while col < cur_col+1 while col < cur_col+1
let mpos = match(line, sep, mpos+1) let mpos = match(line, sep, mpos+1)
if mpos != -1 if mpos != -1
let col += 1 let col += 1
else else
break break
endif endif
endwhile endwhile

View File

@ -9,7 +9,7 @@
|___| |___| |_| |_||__| |__||___| |___| |_||___| ~ |___| |___| |_| |_||__| |__||___| |___| |_||___| ~
Version: 2.0.1 'stu' Version: 2.1
============================================================================== ==============================================================================
CONTENTS *vimwiki-contents* CONTENTS *vimwiki-contents*
@ -251,7 +251,7 @@ NORMAL MODE *vimwiki-local-mappings*
:nmap <Leader>wt <Plug>VimwikiTabnewLink :nmap <Leader>wt <Plug>VimwikiTabnewLink
< <
*vimwiki_<Backspace>* *vimwiki_<Backspace>*
<Backspace> Go back to previous wiki page. <Backspace> Go back to previous wiki page.
Maps to |:VimwikiGoBackLink|. Maps to |:VimwikiGoBackLink|.
To remap: > To remap: >
:nmap <Leader>wb <Plug>VimwikiGoBackLink :nmap <Leader>wb <Plug>VimwikiGoBackLink
@ -300,7 +300,7 @@ NORMAL MODE *vimwiki-local-mappings*
:nmap -- <Plug>VimwikiRemoveHeaderLevel :nmap -- <Plug>VimwikiRemoveHeaderLevel
< <
*vimwiki_+* *vimwiki_+*
+ Create and/or decorate links. Depending on the + Create and/or decorate links. Depending on the
context, this command will: convert words into context, this command will: convert words into
Wikilinks; convert raw URLs into Wikilinks; and add Wikilinks; convert raw URLs into Wikilinks; and add
placeholder text to Wiki- or Weblinks that are missing placeholder text to Wiki- or Weblinks that are missing
@ -375,7 +375,7 @@ INSERT MODE *vimwiki-table-mappings*
*vimwiki_i_<CR>* *vimwiki_i_<CR>*
<CR> Go to the table cell beneath the current one, create <CR> Go to the table cell beneath the current one, create
a new row if on the last one. a new row if on the last one.
*vimwiki_i_<Tab>* *vimwiki_i_<Tab>*
<Tab> Go to the next table cell, create a new row if on the <Tab> Go to the next table cell, create a new row if on the
last cell. last cell.
@ -488,7 +488,7 @@ ic An inner column in a table.
*:VimwikiBacklinks* *:VimwikiBacklinks*
*:VWB* *:VWB*
Search for wikilinks to the [[current wiki page]] Search for wikilinks to the [[current wiki page]]
in all files of current wiki. in all files of current wiki.
To display all matches use |:lopen| command. To display all matches use |:lopen| command.
To display next match use |:lnext| command. To display next match use |:lnext| command.
@ -497,10 +497,10 @@ ic An inner column in a table.
*:VimwikiTable* *:VimwikiTable*
Create a table with 5 cols and 2 rows. Create a table with 5 cols and 2 rows.
:VimwikiTable cols rows :VimwikiTable cols rows
Create a table with the given cols and rows Create a table with the given cols and rows
:VimwikiTable cols :VimwikiTable cols
Create a table with the given cols and 2 rows Create a table with the given cols and 2 rows
@ -528,7 +528,7 @@ ic An inner column in a table.
|--------|--------|--------|--------|--------| |--------|--------|--------|--------|--------|
| value2 | value3 | value1 | value4 | value5 | | value2 | value3 | value1 | value4 | value5 |
< <
Commands are mapped to <A-Left> and <A-Right> respectively. Commands are mapped to <A-Left> and <A-Right> respectively.
@ -552,7 +552,7 @@ ic An inner column in a table.
There are a lot of different wikies out there. Most of them have their own There are a lot of different wikies out there. Most of them have their own
syntax and vimwiki's default syntax is not an exception here. syntax and vimwiki's default syntax is not an exception here.
Vimwiki has evolved its own syntax that closely resembles google's wiki Vimwiki has evolved its own syntax that closely resembles google's wiki
markup. This syntax is described in detail below. markup. This syntax is described in detail below.
@ -608,7 +608,7 @@ Raw URLs are also supported: >
Markdown Links~ Markdown Links~
These links are only available for Markdown syntax. See These links are only available for Markdown syntax. See
http://daringfireball.net/projects/markdown/syntax#link. http://daringfireball.net/projects/markdown/syntax#link.
Inline link: > Inline link: >
[Looks like this](URL) [Looks like this](URL)
@ -620,21 +620,21 @@ The URL can be anything recognized by vimwiki as a raw URL.
Reference-style links: > Reference-style links: >
a) [Link Name][Id] a) [Link Name][Id]
b) [Id][], using the "implicit link name" shortcut b) [Id][], using the "implicit link name" shortcut
Reference style links must always include *two* consecutive pairs of Reference style links must always include *two* consecutive pairs of
[-brackets, and field entries can not use "[" or "]". [-brackets, and field entries can not use "[" or "]".
NOTE: (in Vimwiki's current implementation) Reference-style links are a hybrid NOTE: (in Vimwiki's current implementation) Reference-style links are a hybrid
of Vimwiki's default "Wikilink" and the tradition reference-style link. of Vimwiki's default "Wikilink" and the tradition reference-style link.
If the Id is defined elsewhere in the source, as per the Markdown standard: > If the Id is defined elsewhere in the source, as per the Markdown standard: >
[Id]: URL [Id]: URL
then the URL is opened with the system default handler. Otherwise, Vimwiki then the URL is opened with the system default handler. Otherwise, Vimwiki
treats the reference-sytle link as a Wikilink, interpreting the Id field as a treats the reference-style link as a Wikilink, interpreting the Id field as a
wiki page name. wiki page name.
Highlighting of existing links when |vimwiki-option-maxhi| is activated Highlighting of existing links when |vimwiki-option-maxhi| is activated
@ -876,7 +876,7 @@ have two *alternative* options:
1. using the MathJax server for rendering (needs an internet connection). 1. using the MathJax server for rendering (needs an internet connection).
Add to your HTML template the following line: Add to your HTML template the following line:
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
2. installing MathJax locally (faster, no internet required). Choose a 2. installing MathJax locally (faster, no internet required). Choose a
folder on your hard drive and save MathJax in it. Then add to your HTML folder on your hard drive and save MathJax in it. Then add to your HTML
@ -971,7 +971,7 @@ absolute paths and extensions: >
Schemeless:~ Schemeless:~
Schemeless URLs, which are the default, are treated internally as "wiki#:" Schemeless URLs, which are the default, are treated internally as "wiki#:"
URLs in all respects except when converted to Html. URLs in all respects except when converted to Html.
Schemeless links convert to plain relative path URLs, nearly verbatim: > Schemeless links convert to plain relative path URLs, nearly verbatim: >
relpath/wikipage.html relpath/wikipage.html
@ -990,12 +990,12 @@ as regular links even if the files to which they refer do not exist.
Transclusion (Wiki-Include) Links~ Transclusion (Wiki-Include) Links~
Links that use "{{" and "}}" delimiters signify content that is to be Links that use "{{" and "}}" delimiters signify content that is to be
included into the Html output, rather than referenced via hyperlink. included into the Html output, rather than referenced via hyperlink.
Wiki-include URLs may use any of the supported schemes, may be absolute or Wiki-include URLs may use any of the supported schemes, may be absolute or
relative, and need not end with an extension. relative, and need not end with an extension.
The primary purpose for wiki-include links is to include images. The primary purpose for wiki-include links is to include images.
Transclude from a local URL: > Transclude from a local URL: >
{{local:../../images/vimwiki_logo.png}} {{local:../../images/vimwiki_logo.png}}
@ -1005,19 +1005,19 @@ or from a universal URL: >
Transclude image with alternate text: > Transclude image with alternate text: >
{{http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png|Vimwiki}} {{http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png|Vimwiki}}
in HTML: > in HTML: >
<img src="http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png" <img src="http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png"
alt="Vimwiki"/> alt="Vimwiki"/>
Transclude image with alternate text and some style: > Transclude image with alternate text and some style: >
{{http://.../vimwiki_logo.png|cool stuff|style="width:150px; height: 120px;"}} {{http://.../vimwiki_logo.png|cool stuff|style="width:150px; height: 120px;"}}
in HTML: > in HTML: >
<img src="http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png" <img src="http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png"
alt="cool stuff" style="width:150px; height:120px"/> alt="cool stuff" style="width:150px; height:120px"/>
Transclude image _without_ alternate text and with css class: > Transclude image _without_ alternate text and with css class: >
{{http://.../vimwiki_logo.png||class="center flow blabla"}} {{http://.../vimwiki_logo.png||class="center flow blabla"}}
in HTML: > in HTML: >
<img src="http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png" <img src="http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png"
alt="" class="center flow blabla"/> alt="" class="center flow blabla"/>
A trial feature allows you to supply your own handler for wiki-include links. A trial feature allows you to supply your own handler for wiki-include links.
@ -1042,9 +1042,10 @@ in HTML: >
============================================================================== ==============================================================================
6. Folding/Outline *vimwiki-folding* 6. Folding/Outline *vimwiki-folding*
Vimwiki can fold or outline headers and list items. Vimwiki can fold or outline sections using headers and preformatted blocks.
Alternatively, one can fold list subitems instead.
Example: Example for list folding:
= My current task = = My current task =
* [ ] Do stuff 1 * [ ] Do stuff 1
* [ ] Do substuff 1.1 * [ ] Do substuff 1.1
@ -1186,19 +1187,19 @@ between [ ] depends on the percentage of toggled child items (see also
It is possible to toggle several list items using visual mode. It is possible to toggle several list items using visual mode.
*vimwiki-list-manipulation* *vimwiki-list-manipulation*
The indentation and bullet symbols for list items can be manipulated using The indentation and bullet symbols for list items can be manipulated using
several mappings. Examples below demonstrate this behavior for the 'default' several mappings. Examples below demonstrate this behavior for the 'default'
syntax and with |vimwiki-option-list_margin| = 1. > syntax and with |vimwiki-option-list_margin| = 1. >
Mapping | Input | Output Mapping | Input | Output
---------------------------------------------------- ----------------------------------------------------
glm | ^item | ^ - item glm | ^item | ^ - item
glm | ^ item | ^ - item glm | ^ item | ^ - item
gll | ^ - item | ^item gll | ^ - item | ^item
glm | ^ # item | ^ item glm | ^ # item | ^ item
gl* | ^ item | ^ * item gl* | ^ item | ^ * item
gl- | ^ item | ^ - item gl- | ^ item | ^ - item
gl3 | ^ item | ^ # item gl3 | ^ item | ^ # item
See |vimwiki_gll|, |vimwiki_glm|, |vimwiki_glstar|, |vimwiki_gl8| See |vimwiki_gll|, |vimwiki_glm|, |vimwiki_glstar|, |vimwiki_gl8|
|vimwiki_gl#|, |vimwiki_gl3|, |vimwiki_gl-|, |vimwiki_gl1| |vimwiki_gl#|, |vimwiki_gl3|, |vimwiki_gl-|, |vimwiki_gl1|
@ -1207,7 +1208,7 @@ See |vimwiki_gll|, |vimwiki_glm|, |vimwiki_glstar|, |vimwiki_gl8|
Use the :VimwikiTable command to create a default table with 5 columns and 2 Use the :VimwikiTable command to create a default table with 5 columns and 2
rows: > rows: >
| | | | | | | | | | | |
|---|---|---|---|---| |---|---|---|---|---|
| | | | | | | | | | | |
@ -1281,7 +1282,7 @@ See |g:vimwiki_use_calendar| option to turn it off/on.
11. Options *vimwiki-options* 11. Options *vimwiki-options*
There are global options and local (per-wiki) options available to tune There are global options and local (per-wiki) options available to tune
vimwiki. vimwiki.
Global options are configured via global variables. For a complete list of Global options are configured via global variables. For a complete list of
them, see |viwmiki-global-options|. them, see |viwmiki-global-options|.
@ -1339,7 +1340,7 @@ For clarity, in your .vimrc file you can define wiki options using separate
The creation of temporary wikis allows you to open files that would not The creation of temporary wikis allows you to open files that would not
normally be recognized by vimwiki. normally be recognized by vimwiki.
If a file with a registered wiki extension (see |vimwiki-register-extension|) If a file with a registered wiki extension (see |vimwiki-register-extension|)
is opened in a directory that: 1) is not listed in |g:vimwiki_list|, and 2) is is opened in a directory that: 1) is not listed in |g:vimwiki_list|, and 2) is
@ -1438,7 +1439,7 @@ default, Markdown, and MediaWiki), but only vimwiki's default markup will be
converted to HTML at the moment. converted to HTML at the moment.
To use Markdown's wiki markup: > To use Markdown's wiki markup: >
let g:vimwiki_list = [{'path': '~/my_site/', let g:vimwiki_list = [{'path': '~/my_site/',
\ 'syntax': 'markdown', 'ext': '.md'}] \ 'syntax': 'markdown', 'ext': '.md'}]
< <
@ -1475,12 +1476,12 @@ Each template could look like: >
</body> </body>
</html> </html>
where where
%title% is replaced by a wiki page name or by a |vimwiki-title| %title% is replaced by a wiki page name or by a |vimwiki-title|
%root_path% is replaced by a count of ../ for pages buried in subdirs: %root_path% is replaced by a count of ../ for pages buried in subdirs:
if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
%root_path% is replaced by '../../../'. %root_path% is replaced by '../../../'.
%content% is replaced by a wiki file content. %content% is replaced by a wiki file content.
@ -1630,7 +1631,7 @@ custom_wiki2html ''
Description~ Description~
The full path to an user-provided script that converts a wiki page to HTML. The full path to an user-provided script that converts a wiki page to HTML.
Vimwiki calls the provided |vimwiki-option-custom_wiki2html| script from the Vimwiki calls the provided |vimwiki-option-custom_wiki2html| script from the
command-line, using '!' invocation. command-line, using '!' invocation.
The following arguments, in this order, are passed to the The following arguments, in this order, are passed to the
|vimwiki-option-custom_wiki2html| script: |vimwiki-option-custom_wiki2html| script:
@ -1641,13 +1642,24 @@ The following arguments, in this order, are passed to the
4. output_dir : the full path of the output directory, i.e. 'path_html' 4. output_dir : the full path of the output directory, i.e. 'path_html'
5. input_file : the full path of the wiki page 5. input_file : the full path of the wiki page
6. css_file : the full path of the css file for this wiki 6. css_file : the full path of the css file for this wiki
7. template_path : the full path to the wiki's templates
8. template_default : the default template name
9. template_ext : the extension of template files
10. root_path : a count of ../ for pages buried in subdirs
if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
%root_path% is replaced by '../../../'.
Options 7-10 are experimental and may change in the future. If any of these
parameters is empty, then a hyphen "-" is passed to the script in its place.
For an example and further instructions, refer to the following script: For an example and further instructions, refer to the following script:
$VIMHOME/autoload/vimwiki/customwiki2html.sh $VIMHOME/autoload/vimwiki/customwiki2html.sh
To use the internal wiki2html converter, use an empty string (the default). An alternative converter was developed by Jason6Anderson, and can
be located at http://code.google.com/p/vimwiki/issues/detail?id=384
To use the internal wiki2html converter, use an empty string (the default).
*vimwiki-option-list_margin* *vimwiki-option-list_margin*
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -1659,7 +1671,7 @@ Width of left-hand margin for lists. When negative, the current |shiftwidth|
is used. This affects the behavior of the list manipulation commands is used. This affects the behavior of the list manipulation commands
|VimwikiListChangeLevel| and local mappings |vimwiki_gll|, |vimwiki_glm|, |VimwikiListChangeLevel| and local mappings |vimwiki_gll|, |vimwiki_glm|,
|vimwiki_glstar|, |vimwiki_gl8|, |vimwiki_gl#|, |vimwiki_gl3|, |vimwiki_glstar|, |vimwiki_gl8|, |vimwiki_gl#|, |vimwiki_gl3|,
|vimwiki_gl-| and |vimwiki_gl1|. |vimwiki_gl-| and |vimwiki_gl1|.
@ -1714,7 +1726,7 @@ Value Description~
If your preferred wiki extension is .txt then you can > If your preferred wiki extension is .txt then you can >
let g:vimwiki_global_ext = 0 let g:vimwiki_global_ext = 0
to restrict vimwiki's operation to only those paths listed in g:vimwiki_list. to restrict vimwiki's operation to only those paths listed in g:vimwiki_list.
Other text files wouldn't be treated as wiki pages. Other text files wouldn't be treated as wiki pages.
Default: 1 Default: 1
@ -1724,10 +1736,10 @@ Default: 1
*g:vimwiki_ext2syntax* *vimwiki-register-extension* *g:vimwiki_ext2syntax* *vimwiki-register-extension*
A many-to-one map between file extensions and syntaxes whose purpose is to A many-to-one map between file extensions and syntaxes whose purpose is to
register the extensions with vimwiki. register the extensions with vimwiki.
E.g.: > E.g.: >
let g:vimwiki_ext2syntax = {'.md': 'markdown', let g:vimwiki_ext2syntax = {'.md': 'markdown',
\ '.mkd': 'markdown', \ '.mkd': 'markdown',
\ '.wiki': 'media'} \ '.wiki': 'media'}
@ -1736,7 +1748,7 @@ An extension that is registered with vimwiki can trigger creation of a
|g:vimwiki_list| are automatically registered with vimwiki using the default |g:vimwiki_list| are automatically registered with vimwiki using the default
syntax. syntax.
Default: {'.md': 'markdown'} Default: {}
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_auto_checkbox* *g:vimwiki_auto_checkbox*
@ -1796,26 +1808,22 @@ Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_folding* *g:vimwiki_folding*
Enable/disable vimwiki's folding/outline functionality. Folding in vimwiki Enable/disable vimwiki's folding (outline) functionality. Folding in vimwiki
uses the 'expr' foldmethod which is very flexible but really slow. can uses either the 'expr' or the 'syntax' |foldmethod| of Vim.
Value Description~ Value Description~
0 Disable folding. '' Disable folding.
1 Enable folding. 'expr' Folding based on expression (folds sections and code blocks).
'syntax' Folding based on syntax (folds sections; slower than 'expr').
'list' Folding based on expression (folds list subitems; much slower).
Default: 0 Default: ''
Limitations:
------------------------------------------------------------------------------ - Opening very large files may be slow when folding is enabled.
*g:vimwiki_fold_lists* - 'list' folding is particularly slow with larger files.
- 'list' is intended to work with lists nicely indented with 'shiftwidth'.
Enable/disable folding of list subitems. - 'syntax' is only available for the default syntax so far.
Value Description~
0 Disable list subitem's folding.
1 Enable list subitem's folding.
Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -1849,17 +1857,17 @@ Default: 1
A customizable link handler, |VimwikiLinkHandler|, can be defined to override A customizable link handler, |VimwikiLinkHandler|, can be defined to override
Vimwiki's opening of links. Each recognized link, whether it is a wikilink, Vimwiki's opening of links. Each recognized link, whether it is a wikilink,
wiki-include link or a weblink, is first passed to |VimwikiLinkHandler| to see wiki-include link or a weblink, is first passed to |VimwikiLinkHandler| to see
if it can be handled. The return value 1/0 indicates success. if it can be handled. The return value 1/0 indicates success.
If the link is not handled successfully, the behaviour of Vimwiki depends on If the link is not handled successfully, the behaviour of Vimwiki depends on
the scheme. Wiki:, diary: or schemeless links are opened in Vim. All others, the scheme. Wiki:, diary: or schemeless links are opened in Vim. All others,
including local: and file: schemes, are opened with a system default handler; including local: and file: schemes, are opened with a system default handler;
i.e. Linux (!xdg-open), Mac (!open), and Windows (!start). i.e. Linux (!xdg-open), Mac (!open), and Windows (!start).
You can redefine |VimwikiLinkHandler| function to do something else: > You can redefine |VimwikiLinkHandler| function to do something else: >
function! VimwikiLinkHandler(link) function! VimwikiLinkHandler(link)
try try
let browser = 'C:\Program Files\Firefox\firefox.exe' let browser = 'C:\Program Files\Firefox\firefox.exe'
execute '!start "'.browser.'" ' . a:link execute '!start "'.browser.'" ' . a:link
@ -1868,7 +1876,7 @@ You can redefine |VimwikiLinkHandler| function to do something else: >
echo "This can happen for a variety of reasons ..." echo "This can happen for a variety of reasons ..."
endtry endtry
return 0 return 0
endfunction endfunction
A second example handles two new schemes, 'vlocal:' and 'vfile:', which behave A second example handles two new schemes, 'vlocal:' and 'vfile:', which behave
similar to 'local:' and 'file:' schemes, but are always opened with Vim: > similar to 'local:' and 'file:' schemes, but are always opened with Vim: >
@ -1883,7 +1891,7 @@ similar to 'local:' and 'file:' schemes, but are always opened with Vim: >
else else
return 0 return 0
endif endif
let [idx, scheme, path, subdir, lnk, ext, url] = let [idx, scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(link, 0) \ vimwiki#base#resolve_scheme(link, 0)
if g:vimwiki_debug if g:vimwiki_debug
echom 'LinkHandler: idx='.idx.', scheme=[v]'.scheme.', path='.path. echom 'LinkHandler: idx='.idx.', scheme=[v]'.scheme.', path='.path.
@ -1915,7 +1923,7 @@ cannot otherwise convert the link. A customized handler might look like this: >
" complete URL " complete URL
let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl) let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl)
" URL parts " URL parts
let [scheme, path, subdir, lnk, ext, url] = let [scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(url_0, VimwikiGet('ext')) \ vimwiki#base#resolve_scheme(url_0, VimwikiGet('ext'))
let arg1 = matchstr(str, VimwikiWikiInclMatchArg(1)) let arg1 = matchstr(str, VimwikiWikiInclMatchArg(1))
let arg2 = matchstr(str, VimwikiWikiInclMatchArg(2)) let arg2 = matchstr(str, VimwikiWikiInclMatchArg(2))
@ -1974,7 +1982,7 @@ Default: ''
*g:vimwiki_CJK_length* *g:vimwiki_CJK_length*
Use special method to calculate correct length of the strings with double-wide Use special method to calculate correct length of the strings with double-wide
characters (to align table cells properly). characters (to align table cells properly).
Value Description~ Value Description~
0 Do not use it. 0 Do not use it.
@ -2042,14 +2050,14 @@ Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_html_header_numbering_sym* *g:vimwiki_html_header_numbering_sym*
Ending symbol for |g:vimwiki_html_header_numbering|. Ending symbol for |g:vimwiki_html_header_numbering|.
Value Description~ Value Description~
'.' Dot will be added after a header's number. '.' Dot will be added after a header's number.
')' Closing bracket will be added after a header's number. ')' Closing bracket will be added after a header's number.
etc. etc.
With With
let g:vimwiki_html_header_numbering_sym = '.' let g:vimwiki_html_header_numbering_sym = '.'
headers would look like: > headers would look like: >
1. Header1 1. Header1
@ -2068,7 +2076,7 @@ Default: '' (empty)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_valid_html_tags* *g:vimwiki_valid_html_tags*
Comma-separated list of HTML tags that can be used in vimwiki. Case-insensitive comma separated list of HTML tags that can be used in vimwiki.
Default: 'b,i,s,u,sub,sup,kbd,br,hr' Default: 'b,i,s,u,sub,sup,kbd,br,hr'
@ -2097,30 +2105,46 @@ a new tab or window, it would be set to default value.
Vimwiki sets |conceallevel| to g:vimwiki_conceallevel everytime vimwiki buffer Vimwiki sets |conceallevel| to g:vimwiki_conceallevel everytime vimwiki buffer
is entered. is entered.
With default settings, Vimwiki conceals one-character markers, shortens long
URLs and hides markers and URL for links that have a description.
Default: 2 Default: 2
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_url_mingain* *g:vimwiki_autowriteall*
The minimum number of characters that should be gained by concealing URLs. If In vim |autowriteall| is a global setting. With g:vimwiki_autowriteall vimwiki
the length of the concealed part of the URL would be less than makes it local to its buffers.
|g:vimwiki_url_mingain|, the URL is not concealed at all.
The conceal feature works only with vim >= 7.3.
Default: 12 Value Description~
0 autowriteall is off
1 autowriteall is on
Default: 1
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_url_maxsave* *g:vimwiki_url_maxsave*
The maximum number of characters that is retained at the end after concealing Setting the value of |g:vimwiki_url_maxsave| to 0 will prevent any link
URLs. At most there will be |g:vimwiki_url_maxsave| characters left at the end of the URL. shortening: you will see the full URL in all types of links, with no parts
However, it could be less when one of /,#,? can be found at the end. being concealed. Concealing of one-character markers is not affected.
In that case the URL will be concealed right before the last occurrence of one
of these characters. When positive, the value determines the maximum number of characters that
The conceal feature works only with vim >= 7.3. Beware: when using the default are retained at the end after concealing the middle part of a long URL.
'wrap' option, the effect is not always pleasing. It could be less: in case one of the characters /,#,? is found near the end,
the URL will be concealed up to the last occurrence of that character.
Note:
* The conceal feature works only with Vim >= 7.3.
* When using the default |wrap| option of Vim, the effect of concealed links
is not always pleasing, because the visible text on longer lines with
a lot of concealed parts may appear to be strangely broken across several
lines. This is a limitation of Vim's |conceal| feature.
* Many color schemes do not define an unobtrusive color for the Conceal
highlight group - this might be quite noticeable on shortened URLs.
Default: 15 Default: 15
@ -2137,6 +2161,7 @@ Value Description~
Default: 0 Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_diary_months* *g:vimwiki_diary_months*
@ -2145,15 +2170,15 @@ uses it.
Redefine it in your .vimrc to get localized months in your diary: Redefine it in your .vimrc to get localized months in your diary:
let g:vimwiki_diary_months = { let g:vimwiki_diary_months = {
\ 1: 'Январь', 2: 'Февраль', 3: 'Март', \ 1: 'Январь', 2: 'Февраль', 3: 'Март',
\ 4: 'Апрель', 5: 'Май', 6: 'Июнь', \ 4: 'Апрель', 5: 'Май', 6: 'Июнь',
\ 7: 'Июль', 8: 'Август', 9: 'Сентябрь', \ 7: 'Июль', 8: 'Август', 9: 'Сентябрь',
\ 10: 'Октябрь', 11: 'Ноябрь', 12: 'Декабрь' \ 10: 'Октябрь', 11: 'Ноябрь', 12: 'Декабрь'
\ } \ }
Default: Default:
let g:vimwiki_diary_months = { let g:vimwiki_diary_months = {
\ 1: 'January', 2: 'February', 3: 'March', \ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June', \ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September', \ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December' \ 10: 'October', 11: 'November', 12: 'December'
@ -2186,6 +2211,22 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
============================================================================== ==============================================================================
14. Changelog *vimwiki-changelog* 14. Changelog *vimwiki-changelog*
2.1~
* Concealing of links can be turned off - set |g:vimwiki_url_maxsave| to 0.
The option g:vimwiki_url_mingain was removed
* |g:vimwiki_folding| also accepts value 'list'; with 'expr' both sections
and code blocks folded, g:vimwiki_fold_lists option was removed
* Issue 261: Syntax folding is back. |g:vimwiki_folding| values are
changed to '', 'expr', 'syntax'.
* Issue 372: Ignore case in g:vimwiki_valid_html_tags
* Issue 374: Make autowriteall local to vimwiki. It is not 100% local
though.
* Issue 384: Custom_wiki2html script now receives templating arguments
* Issue 393: Custom_wiki2html script path can contain tilde character
* Issue 392: Custom_wiki2html arguments are quoted, e.g names with spaces
* Various small bug fixes.
2.0.1 'stu'~ 2.0.1 'stu'~
* Follow (i.e. open target of) markdown reference-style links. * Follow (i.e. open target of) markdown reference-style links.
@ -2195,7 +2236,7 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
2.0 'stu'~ 2.0 'stu'~
This release is partly incompatible with previous. This release is partly incompatible with previous.
*
Summary ~ Summary ~
* Quick page-link creation. * Quick page-link creation.
@ -2221,7 +2262,7 @@ Summary ~
* Table syntax change. Row separator uses | instead of +. * Table syntax change. Row separator uses | instead of +.
* Fold multilined list items. * Fold multilined list items.
* Custom wiki to HTML converters. See |vimwiki-option-custom_wiki2html|. * Custom wiki to HTML converters. See |vimwiki-option-custom_wiki2html|.
* Conceal long weblinks. See |g:vimwiki_url_mingain|. * Conceal long weblinks. See g:vimwiki_url_mingain.
* Option to disable table mappings. See |g:vimwiki_table_mappings|. * Option to disable table mappings. See |g:vimwiki_table_mappings|.
For detailed information see issues list on For detailed information see issues list on
@ -2250,7 +2291,7 @@ http://code.google.com/p/vimwiki/issues/list
* Fix of g:vimwiki_stripsym = '' (i.e. an empty string) -- it removes bad * Fix of g:vimwiki_stripsym = '' (i.e. an empty string) -- it removes bad
symbols from filenames. symbols from filenames.
* Issue 145: With modeline 'set ft=vimwiki' links are not correctly * Issue 145: With modeline 'set ft=vimwiki' links are not correctly
highlighted when open wiki files. highlighted when open wiki files.
* Issue 146: Filetype difficulty with ".txt" as a vimwiki extension. * Issue 146: Filetype difficulty with ".txt" as a vimwiki extension.
* Issue 148: There are no mailto links. * Issue 148: There are no mailto links.
* Issue 151: Use location list instead of quickfix list for :VimwikiSearch * Issue 151: Use location list instead of quickfix list for :VimwikiSearch

View File

@ -12,18 +12,16 @@ let b:did_ftplugin = 1 " Don't load another plugin for this buffer
" Reset the following options to undo this plugin. " Reset the following options to undo this plugin.
let b:undo_ftplugin = "setlocal ". let b:undo_ftplugin = "setlocal ".
\ "suffixesadd< isfname< comments< ". \ "suffixesadd< isfname< comments< ".
\ "autowriteall< ".
\ "formatoptions< foldtext< ". \ "formatoptions< foldtext< ".
\ "foldmethod< foldexpr< commentstring< " \ "foldmethod< foldexpr< commentstring< "
" UNDO }}} " UNDO }}}
" MISC STUFF {{{ " MISC STUFF {{{
setlocal autowriteall
setlocal commentstring=%%%s setlocal commentstring=%%%s
if g:vimwiki_conceallevel && exists("+conceallevel") if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel let &l:conceallevel = g:vimwiki_conceallevel
endif endif
" MISC }}} " MISC }}}
@ -63,56 +61,8 @@ endif
" COMMENTS }}} " COMMENTS }}}
" FOLDING for headers and list items using expr fold method. {{{ " FOLDING for headers and list items using expr fold method. {{{
function! VimwikiFoldLevel(lnum) "{{{
let line = getline(a:lnum)
" Header folding... " Folding list items using expr fold method. {{{
if line =~ g:vimwiki_rxHeader
let n = vimwiki#u#count_first_sym(line)
return '>'.n
endif
let base_level = s:get_base_level(a:lnum)
" List item folding...
if g:vimwiki_fold_lists
let nnline = getline(a:lnum + 1)
let rx_list_item = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
\ '\)'
if line =~ rx_list_item
let [nnum, nline] = s:find_forward(rx_list_item, a:lnum)
let level = s:get_li_level(a:lnum)
let leveln = s:get_li_level(nnum)
let adj = s:get_li_level(s:get_start_list(rx_list_item, a:lnum))
if leveln > level
return ">".(base_level+leveln-adj)
" check if multilined list item
elseif (nnum-a:lnum) > 1
\ && nline =~ rx_list_item && nnline !~ '^\s*$'
return ">".(base_level+level+1-adj)
else
return (base_level+level-adj)
endif
else
" process multilined list items
let [pnum, pline] = s:find_backward(rx_list_item, a:lnum)
if pline =~ rx_list_item
if indent(a:lnum) >= indent(pnum) && line !~ '^\s*$'
let level = s:get_li_level(pnum)
let adj = s:get_li_level(s:get_start_list(rx_list_item, pnum))
return (base_level+level+1-adj)
endif
endif
endif
endif
return base_level
endfunction "}}}
function! s:get_base_level(lnum) "{{{ function! s:get_base_level(lnum) "{{{
let lnum = a:lnum - 1 let lnum = a:lnum - 1
@ -177,23 +127,137 @@ function! s:get_start_list(rx_item, lnum) "{{{
return 0 return 0
endfunction "}}} endfunction "}}}
function! VimwikiFoldText() "{{{ function! VimwikiFoldListLevel(lnum) "{{{
let line = substitute(getline(v:foldstart), '\t', let line = getline(a:lnum)
\ repeat(' ', &tabstop), 'g')
return line.' ['.(v:foldend - v:foldstart).']' "" XXX Disabled: Header/section folding...
"if line =~ g:vimwiki_rxHeader
" return '>'.vimwiki#u#count_first_sym(line)
"endif
"let nnline = getline(a:lnum+1)
"" Unnecessary?
"if nnline =~ g:vimwiki_rxHeader
" return '<'.vimwiki#u#count_first_sym(nnline)
"endif
"" Very slow when called on every single line!
"let base_level = s:get_base_level(a:lnum)
"FIXME does not work correctly
let base_level = 0
if line =~ g:vimwiki_rxListItem
let [nnum, nline] = s:find_forward(g:vimwiki_rxListItem, a:lnum)
let level = s:get_li_level(a:lnum)
let leveln = s:get_li_level(nnum)
let adj = s:get_li_level(s:get_start_list(g:vimwiki_rxListItem, a:lnum))
if leveln > level
return ">".(base_level+leveln-adj)
" check if multilined list item
elseif (nnum-a:lnum) > 1
\ && (nline =~ g:vimwiki_rxListItem || nnline !~ '^\s*$')
return ">".(base_level+level+1-adj)
else
return (base_level+level-adj)
endif
else
" process multilined list items
let [pnum, pline] = s:find_backward(g:vimwiki_rxListItem, a:lnum)
if pline =~ g:vimwiki_rxListItem
if indent(a:lnum) >= indent(pnum) && line !~ '^\s*$'
let level = s:get_li_level(pnum)
let adj = s:get_li_level(s:get_start_list(g:vimwiki_rxListItem, pnum))
return (base_level+level+1-adj)
endif
endif
endif
return base_level
endfunction "}}}
" Folding list items }}}
" Folding sections and code blocks using expr fold method. {{{
function! VimwikiFoldLevel(lnum) "{{{
let line = getline(a:lnum)
" Header/section folding...
if line =~ g:vimwiki_rxHeader
return '>'.vimwiki#u#count_first_sym(line)
" Code block folding...
elseif line =~ '^\s*'.g:vimwiki_rxPreStart
return 'a1'
elseif line =~ '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
return 's1'
else
return "="
endif
endfunction "}}} endfunction "}}}
" Constants used by VimwikiFoldText {{{
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
let s:ellipsis = (&enc ==? 'utf-8') ? "\u2026" : "..."
let s:ell_len = strlen(s:ellipsis)
let s:newline = (&enc ==? 'utf-8') ? "\u21b2 " : " "
let s:tolerance = 5
" }}}
function! s:shorten_text_simple(text, len) "{{{ unused
let spare_len = a:len - len(a:text)
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
endfunction "}}}
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
" for long enough "text", the string's length is within s:tolerance of "len"
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
function! s:shorten_text(text, len) "{{{ returns [string, spare]
let spare_len = a:len - strlen(a:text)
if (spare_len + s:tolerance >= 0)
return [a:text, spare_len]
endif
" try to break on a space; assumes a:len-s:ell_len >= s:tolerance
let newlen = a:len - s:ell_len
let idx = strridx(a:text, ' ', newlen + s:tolerance)
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
return [a:text[0:break_idx].s:ellipsis, newlen - break_idx]
endfunction "}}}
function! VimwikiFoldText() "{{{
let line = getline(v:foldstart)
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 !~ '^\s*'.g:vimwiki_rxPreStart
let [main_text, spare_len] = s:shorten_text(main_text, 50)
return main_text.len_text
else
" fold-text for code blocks: use one or two of the starting lines
let [main_text, spare_len] = s:shorten_text(main_text, 24)
let line1 = substitute(getline(v:foldstart+1), '^\s*', ' ', '')
let [content_text, spare_len] = s:shorten_text(line1, spare_len+20)
if spare_len > s:tolerance && fold_len > 3
let line2 = substitute(getline(v:foldstart+2), '^\s*', s:newline, '')
let [more_text, spare_len] = s:shorten_text(line2, spare_len+12)
let content_text .= more_text
endif
return main_text.len_text.content_text
endif
endfunction "}}}
" Folding sections and code blocks }}}
" FOLDING }}} " FOLDING }}}
" COMMANDS {{{ " COMMANDS {{{
command! -buffer Vimwiki2HTML command! -buffer Vimwiki2HTML
\ silent w <bar> \ silent w <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')), \ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%')) \ expand('%'))
\<bar> \<bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif \ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
command! -buffer Vimwiki2HTMLBrowse command! -buffer Vimwiki2HTMLBrowse
\ silent w <bar> \ silent w <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML( \ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(VimwikiGet('path_html')), \ expand(VimwikiGet('path_html')),
\ expand('%'))) \ expand('%')))
@ -455,7 +519,7 @@ nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
if VimwikiGet('auto_export') if VimwikiGet('auto_export')
" Automatically generate HTML on page write. " Automatically generate HTML on page write.
augroup vimwiki augroup vimwiki
au BufWritePost <buffer> au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')), \ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%')) \ expand('%'))
augroup END augroup END

View File

@ -69,6 +69,8 @@ function! s:setup_buffer_leave() "{{{
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx()."" echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif endif
let &autowriteall = s:vimwiki_autowriteall
" Set up menu " Set up menu
if g:vimwiki_menu != "" if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table' exe 'nmenu disable '.g:vimwiki_menu.'.Table'
@ -195,13 +197,17 @@ function! s:setup_buffer_enter() "{{{
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a " 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 " new tab with the same buffer folding is reset to vim defaults. So we
" insist vimwiki folding here. " insist vimwiki folding here.
if g:vimwiki_folding == 2 && &fdm != 'expr' if g:vimwiki_folding == 'expr'
" User-defined fold-expression, and fold-text
endif
if g:vimwiki_folding == 1
setlocal fdm=expr setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum) setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText() 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()
endif endif
" And conceal level too. " And conceal level too.
@ -228,6 +234,10 @@ function! s:setup_buffer_reenter() "{{{
if g:vimwiki_debug ==3 if g:vimwiki_debug ==3
echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx()."" echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif endif
if !exists("s:vimwiki_autowriteall")
let s:vimwiki_autowriteall = &autowriteall
endif
let &autowriteall = g:vimwiki_autowriteall
endfunction "}}} endfunction "}}}
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
@ -238,7 +248,7 @@ function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
hi def VimwikiUnderline gui=underline hi def VimwikiUnderline gui=underline
if g:vimwiki_hl_headers == 1 if g:vimwiki_hl_headers == 1
for i in range(1,6) 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='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
endfor endfor
endif endif
endfunction "}}} endfunction "}}}
@ -288,7 +298,7 @@ endfunction "}}}
function! VimwikiSet(option, value, ...) "{{{ function! VimwikiSet(option, value, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1 let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(s:vimwiki_defaults, a:option) || if has_key(s:vimwiki_defaults, a:option) ||
\ has_key(g:vimwiki_list[idx], a:option) \ has_key(g:vimwiki_list[idx], a:option)
let g:vimwiki_list[idx][a:option] = a:value let g:vimwiki_list[idx][a:option] = a:value
elseif exists('b:vimwiki_list') elseif exists('b:vimwiki_list')
@ -372,12 +382,10 @@ let s:vimwiki_defaults.list_margin = -1
call s:default('list', [s:vimwiki_defaults]) call s:default('list', [s:vimwiki_defaults])
call s:default('auto_checkbox', 1) call s:default('auto_checkbox', 1)
call s:default('use_mouse', 0) call s:default('use_mouse', 0)
call s:default('folding', 0) call s:default('folding', '')
call s:default('fold_trailing_empty_lines', 0)
call s:default('fold_lists', 0)
call s:default('menu', 'Vimwiki') call s:default('menu', 'Vimwiki')
call s:default('global_ext', 1) call s:default('global_ext', 1)
call s:default('ext2syntax', {'.md': 'markdown'}) " syntax map keyed on extension call s:default('ext2syntax', {}) " syntax map keyed on extension
call s:default('hl_headers', 0) call s:default('hl_headers', 0)
call s:default('hl_cb_checked', 0) call s:default('hl_cb_checked', 0)
call s:default('list_ignore_newline', 1) call s:default('list_ignore_newline', 1)
@ -390,17 +398,17 @@ call s:default('CJK_length', 0)
call s:default('dir_link', '') 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('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
call s:default('user_htmls', '') call s:default('user_htmls', '')
call s:default('autowriteall', 1)
call s:default('html_header_numbering', 0) call s:default('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '') call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 2) call s:default('conceallevel', 2)
call s:default('url_mingain', 12)
call s:default('url_maxsave', 15) call s:default('url_maxsave', 15)
call s:default('debug', 0) call s:default('debug', 0)
call s:default('diary_months', call s:default('diary_months',
\ { \ {
\ 1: 'January', 2: 'February', 3: 'March', \ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June', \ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September', \ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December' \ 10: 'October', 11: 'November', 12: 'December'
@ -418,9 +426,9 @@ 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') \ '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') call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel')
let rxSchemes = '\%('. let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'. \ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'. \ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|'). \ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
\ '\)' \ '\)'

View File

@ -49,6 +49,9 @@ execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------
let time0 = vimwiki#u#time(starttime) "XXX let time0 = vimwiki#u#time(starttime) "XXX
let g:vimwiki_rxListItem = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
\ '\)'
" LINKS: setup of larger regexes {{{ " LINKS: setup of larger regexes {{{
@ -57,15 +60,15 @@ let g:vimwiki_rxWikiLinkPrefix = '[['
let g:vimwiki_rxWikiLinkSuffix = ']]' let g:vimwiki_rxWikiLinkSuffix = ']]'
let g:vimwiki_rxWikiLinkSeparator = '|' let g:vimwiki_rxWikiLinkSeparator = '|'
" [[URL]] " [[URL]]
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'. let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSuffix \ g:vimwiki_rxWikiLinkSuffix
" [[URL|DESCRIPTION]] " [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'. let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'. \ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
\ g:vimwiki_rxWikiLinkSuffix \ g:vimwiki_rxWikiLinkSuffix
" "
let magic_chars = '.*[]\^$' let magic_chars = '.*[]\^$'
let valid_chars = '[^\\]' let valid_chars = '[^\\\]]'
let g:vimwiki_rxWikiLinkPrefix = escape(g:vimwiki_rxWikiLinkPrefix, magic_chars) let g:vimwiki_rxWikiLinkPrefix = escape(g:vimwiki_rxWikiLinkPrefix, magic_chars)
let g:vimwiki_rxWikiLinkSuffix = escape(g:vimwiki_rxWikiLinkSuffix, magic_chars) let g:vimwiki_rxWikiLinkSuffix = escape(g:vimwiki_rxWikiLinkSuffix, magic_chars)
@ -104,13 +107,15 @@ let g:vimwiki_rxWikiInclSuffix = '}}'
let g:vimwiki_rxWikiInclSeparator = '|' let g:vimwiki_rxWikiInclSeparator = '|'
" "
" '{{__LinkUrl__}}' " '{{__LinkUrl__}}'
let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'. let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiInclSuffix \ g:vimwiki_rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}' " '{{__LinkUrl____LinkDescription__}}'
let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'. let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ '__LinkDescription__'. \ '__LinkDescription__'.
\ g:vimwiki_rxWikiInclSuffix \ g:vimwiki_rxWikiInclSuffix
let valid_chars = '[^\\\}]'
let g:vimwiki_rxWikiInclPrefix = escape(g:vimwiki_rxWikiInclPrefix, magic_chars) let g:vimwiki_rxWikiInclPrefix = escape(g:vimwiki_rxWikiInclPrefix, magic_chars)
let g:vimwiki_rxWikiInclSuffix = escape(g:vimwiki_rxWikiInclSuffix, magic_chars) let g:vimwiki_rxWikiInclSuffix = escape(g:vimwiki_rxWikiInclSuffix, magic_chars)
let g:vimwiki_rxWikiInclSeparator = escape(g:vimwiki_rxWikiInclSeparator, magic_chars) let g:vimwiki_rxWikiInclSeparator = escape(g:vimwiki_rxWikiInclSeparator, magic_chars)
@ -122,7 +127,7 @@ let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_r
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc. " *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]} " *a) match {{URL}[{...}]}
let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix. let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl. \ g:vimwiki_rxWikiInclUrl.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix \ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]} " *b) match URL within {{URL}[{...}]}
let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix. let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix.
@ -138,7 +143,7 @@ let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
" }}} " }}}
" LINKS: Setup weblink regexps {{{ " LINKS: Setup weblink regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L)) " 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl . " let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@=' " \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
" Maxim: " Maxim:
@ -155,7 +160,7 @@ let g:vimwiki_rxWeblinkMatchDescr = ''
" LINKS: Setup anylink regexps {{{ " LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'. let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink \ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}} " }}}
@ -249,8 +254,8 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
" WikiLink " WikiLink
" All remaining schemes are highlighted automatically " All remaining schemes are highlighted automatically
let rxSchemes = '\%('. let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'. \ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|'). \ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):' \ '\):'
@ -281,6 +286,8 @@ if g:vimwiki_symH
for i in range(1,6) for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__ '.repeat(g:vimwiki_rxH, i) let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__ '.repeat(g:vimwiki_rxH, i)
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$' let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
let g:vimwiki_rxH{i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
let g:vimwiki_rxH{i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{1,'.i.'}\s*$'
endfor endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$' let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$'
else else
@ -288,6 +295,8 @@ else
for i in range(1,6) for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__' let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__'
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$' let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
let g:vimwiki_rxH{i}_Start = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
let g:vimwiki_rxH{i}_End = '^\s*'.g:vimwiki_rxH.'\{1,'.i.'}[^'.g:vimwiki_rxH.'].*$'
endfor endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$' let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$'
endif endif
@ -295,29 +304,53 @@ endif
" Header levels, 1-6 " Header levels, 1-6
for i in range(1,6) for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell' execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
execute 'syntax region VimwikiH'.i.'Folding start=/'.g:vimwiki_rxH{i}_Start.
\ '/ end=/'.g:vimwiki_rxH{i}_End.'/me=s-1 transparent fold'
endfor endfor
" }}} " }}}
" concealed chars " {{{ " possibly concealed chars " {{{
let cchar = '' let conceal = exists("+conceallevel") ? ' conceal' : ''
if exists("+conceallevel")
syntax conceal on
let cchar = ' cchar=~ '
endif
syntax spell toplevel execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'.conceal
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'.conceal
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'.conceal
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'.conceal
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'.conceal
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'.conceal
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'.conceal
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'.conceal
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.conceal
" }}}
" concealed link parts " {{{
if g:vimwiki_debug > 1 if g:vimwiki_debug > 1
echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix1 echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix
echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix1 echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix
echom 'WikiLink Prefix1: '.g:vimwiki_rxWikiLinkPrefix1
echom 'WikiLink Suffix1: '.g:vimwiki_rxWikiLinkSuffix1
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1 echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1 echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
endif endif
" define the conceal attribute for links only if Vim is new enough to handle it
" and the user has g:vimwiki_url_maxsave > 0
let 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
let options .= conceal
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
\.'\%([/#?]\w\|\S\{'.g:vimwiki_url_maxsave.'}\)`'.' cchar=~'.options
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description " VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed " is present) and may be concealed
let options = ' contained transparent contains=NONE'
" conceal wikilinks " conceal wikilinks
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.options execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.options execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.options
@ -329,24 +362,6 @@ execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.options execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\{'
\.g:vimwiki_url_mingain.',}\ze\%([/#?]\w\|\S\{'
\.g:vimwiki_url_maxsave.'}\)`'.cchar.options
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'
if exists("+conceallevel")
syntax conceal off
endif
" }}} " }}}
" non concealed chars " {{{ " non concealed chars " {{{
@ -371,7 +386,7 @@ execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" main syntax groups {{{ " main syntax groups {{{
" Tables " Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator, \ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT, \ VimwikiLinkT,
\ VimwikiNoExistsLinkT, \ VimwikiNoExistsLinkT,
@ -387,7 +402,7 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ VimwikiCodeT, \ VimwikiCodeT,
\ VimwikiEqInT, \ VimwikiEqInT,
\ @Spell \ @Spell
syntax match VimwikiCellSeparator syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained \ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" List items " List items
@ -476,20 +491,21 @@ if g:vimwiki_hl_headers == 0
execute 'hi def link VimwikiHeader'.i.' Title' execute 'hi def link VimwikiHeader'.i.' Title'
endfor endfor
else else
" default colors when headers of different levels are highlighted differently " default colors when headers of different levels are highlighted differently
" not making it yet another option; needed by ColorScheme autocommand " 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_guifg_light = ['#aa5858','#507030','#1030a0','#103040','#505050','#636363']
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black'] 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_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White'] let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
for i in range(1,6) 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='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
endfor endfor
endif endif
"}}} "}}}
" syntax group highlighting "{{{
" syntax group highlighting "{{{
hi def link VimwikiMarkers Normal hi def link VimwikiMarkers Normal
@ -578,24 +594,28 @@ hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim' execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
let b:current_syntax="vimwiki" let b:current_syntax="vimwiki"
" EMBEDDED syntax setup "{{{ " EMBEDDED syntax setup "{{{
let nested = VimwikiGet('nested_syntaxes') let nested = VimwikiGet('nested_syntaxes')
if !empty(nested) if !empty(nested)
for [hl_syntax, vim_syntax] in items(nested) for [hl_syntax, vim_syntax] in items(nested)
call vimwiki#base#nested_syntax(vim_syntax, call vimwiki#base#nested_syntax(vim_syntax,
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'. \ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?', \ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre') \ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
endfor endfor
endif endif
" LaTeX " LaTeX
call vimwiki#base#nested_syntax('tex', call vimwiki#base#nested_syntax('tex',
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'. \ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ '\%([[:blank:][:punct:]].*\)\?', \ '\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath') \ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
"}}} "}}}
syntax spell toplevel
let timeend = vimwiki#u#time(starttime) "XXX let timeend = vimwiki#u#time(starttime) "XXX
call VimwikiLog_extend('timing',['syntax:scans',timescans],['syntax:regexloaded',time0],['syntax:beforeHLexisting',time01],['syntax:afterHLexisting',time02],['syntax:end',timeend]) call VimwikiLog_extend('timing',['syntax:scans',timescans],['syntax:regexloaded',time0],['syntax:beforeHLexisting',time01],['syntax:afterHLexisting',time02],['syntax:end',timeend])

View File

@ -35,10 +35,10 @@ let g:vimwiki_rxWikiLink1Suffix = ']'
let g:vimwiki_rxWikiLink1Separator = '][' let g:vimwiki_rxWikiLink1Separator = ']['
" [URL][] " [URL][]
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'. let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix \ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
" [DESCRIPTION][URL] " [DESCRIPTION][URL]
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'. let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'. \ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Suffix \ g:vimwiki_rxWikiLink1Suffix
" "
@ -108,7 +108,7 @@ let g:vimwiki_rxWikiLinkMatchDescr = ''.
" }}} " }}}
" LINKS: Setup weblink0 regexps {{{ " LINKS: Setup weblink0 regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L)) " 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
let g:vimwiki_rxWeblink0 = g:vimwiki_rxWeblink let g:vimwiki_rxWeblink0 = g:vimwiki_rxWeblink
" 0a) match URL within URL " 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl0 = g:vimwiki_rxWeblinkMatchUrl let g:vimwiki_rxWeblinkMatchUrl0 = g:vimwiki_rxWeblinkMatchUrl
@ -121,7 +121,7 @@ let g:vimwiki_rxWeblink1Prefix = '['
let g:vimwiki_rxWeblink1Suffix = ')' let g:vimwiki_rxWeblink1Suffix = ')'
let g:vimwiki_rxWeblink1Separator = '](' let g:vimwiki_rxWeblink1Separator = ']('
" [DESCRIPTION](URL) " [DESCRIPTION](URL)
let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription__'. let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'. \ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWeblink1Suffix \ g:vimwiki_rxWeblink1Suffix
@ -135,7 +135,7 @@ let g:vimwiki_rxWeblink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWeblink1Descr = valid_chars.'\{-}' let g:vimwiki_rxWeblink1Descr = valid_chars.'\{-}'
" "
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\[' " " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
" 1. [DESCRIPTION](URL) " 1. [DESCRIPTION](URL)
" 1a) match [DESCRIPTION](URL) " 1a) match [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1 = g:vimwiki_rxWeblink1Prefix. let g:vimwiki_rxWeblink1 = g:vimwiki_rxWeblink1Prefix.
@ -176,7 +176,7 @@ let g:vimwiki_rxWeblinkMatchDescr = ''.
" LINKS: Setup anylink regexps {{{ " LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'. let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink \ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}} " }}}
@ -289,8 +289,8 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
" WikiLink " WikiLink
" All remaining schemes are highlighted automatically " All remaining schemes are highlighted automatically
let rxSchemes = '\%('. let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'. \ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|'). \ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):' \ '\):'
@ -352,7 +352,7 @@ endif
" main syntax groups {{{ " main syntax groups {{{
" Tables " Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator, \ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT, \ VimwikiLinkT,
\ VimwikiWeblink1T, \ VimwikiWeblink1T,
@ -377,7 +377,7 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
"}}} "}}}
" syntax group highlighting "{{{ " syntax group highlighting "{{{
hi def link VimwikiWeblink1 VimwikiLink hi def link VimwikiWeblink1 VimwikiLink
hi def link VimwikiWeblink1T VimwikiLink hi def link VimwikiWeblink1T VimwikiLink