4 Commits

Author SHA1 Message Date
Michael F. Schönitzer bfc3aa06fd Fix bug 2019-01-17 21:59:43 +01:00
Michael F. Schönitzer a597875dce Update documentation 2019-01-17 21:59:43 +01:00
Michael F. Schönitzer 5d38b8ddc2 Allow list symbols to be configured per wiki 2019-01-17 21:59:43 +01:00
Michael F. Schönitzer 37f54d92c3 Allow to specify additional chars for lists
See also #390 and #479 for earlier attempts
2019-01-17 21:59:43 +01:00
13 changed files with 590 additions and 866 deletions
-13
View File
@@ -105,19 +105,6 @@ Commands
* `:Vimwiki2HTML` -- Convert current wiki link to HTML
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
* `:help vimwiki-commands` -- list all commands
* `:help vimwiki` -- General vimwiki help docs
Changing Wiki Syntax
------------------------------------------------------------------------------
Vimwiki currently ships with 3 syntaxes: Vimwiki (default), Markdown (markdown), and MediaWiki (media)
If you would prefer to use either Markdown or MediaWiki syntaxes, set the following option in your .vimrc:
```
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
Installation
+104 -86
View File
@@ -43,17 +43,55 @@ function! vimwiki#base#file_pattern(files)
endfunction
"FIXME TODO slow and faulty
function! vimwiki#base#subdir(path, filename)
let path = a:path
" ensure that we are not fooled by a symbolic link
"FIXME if we are not "fooled", we end up in a completely different wiki?
if a:filename !~# '^scp:'
let filename = resolve(a:filename)
else
let filename = a:filename
endif
let idx = 0
"FIXME this can terminate in the middle of a path component!
while path[idx] ==? filename[idx]
let idx = idx + 1
endwhile
let p = split(strpart(filename, idx), '[/\\]')
let res = join(p[:-2], '/')
if len(res) > 0
let res = res.'/'
endif
return res
endfunction
function! vimwiki#base#current_subdir()
return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), expand('%:p'))
endfunction
function! vimwiki#base#invsubdir(subdir)
return substitute(a:subdir, '[^/\.]\+/', '../', 'g')
endfunction
" Returns: the number of the wiki a file belongs to or -1 if it doesn't belong
" to any registered wiki.
function! vimwiki#base#find_wiki(file)
" The path can be the full path or just the directory of the file
function! vimwiki#base#find_wiki(path)
let bestmatch = -1
let bestlen = 0
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
for idx in range(vimwiki#vars#number_of_wikis())
let wiki_path = expand(vimwiki#vars#get_wikilocal('path', idx))
let common_prefix = vimwiki#path#path_common_pfx(wiki_path, a:file)
if vimwiki#path#is_equal(common_prefix, wiki_path)
if len(common_prefix) > bestlen
let bestlen = len(common_prefix)
let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx))
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
let common_pfx = vimwiki#path#path_common_pfx(idx_path, path)
if vimwiki#path#is_equal(common_pfx, idx_path)
if len(common_pfx) > bestlen
let bestlen = len(common_pfx)
let bestmatch = idx
endif
endif
@@ -63,9 +101,10 @@ function! vimwiki#base#find_wiki(file)
endfunction
" Extract infos about the target from a link. If the second parameter is present, which should be a
" file object, it is assumed that the link appears in that file. Without it, the current file is
" used.
" THE central function of Vimwiki. Extract infos about the target from a link.
" If the second parameter is present, which should be an absolute file path, it
" is assumed that the link appears in that file. Without it, the current file
" is used.
function! vimwiki#base#resolve_link(link_text, ...)
if a:0
let source_wiki = vimwiki#base#find_wiki(a:1)
@@ -79,16 +118,13 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos = {
\ 'index': 0,
\ 'index': -1,
\ 'scheme': '',
\ 'is_file': 0, " 1 for a file, 0 for a URL (e.g. when the link was [[http://foo.bar]]),
\ " -1 if the whole link was malformed
\ 'target': '', " this is a file or dir object if is_file == 1, otherwise a string
\ 'filename': '',
\ 'anchor': '',
\ }
if link_text == ''
let link_infos.is_file = -1
return link_infos
endif
@@ -99,14 +135,10 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos.scheme = scheme
if link_infos.scheme !~# '\mwiki\d\+\|diary\|local\|file'
" unknown scheme, may be a weblink
let link_infos.is_file = 0
let link_infos.target = link_text
let link_infos.filename = link_text " unknown scheme, may be a weblink
return link_infos
endif
let link_infos.is_file = 1
let link_text = matchstr(link_text, '^'.vimwiki#vars#get_global('rxSchemes').':\zs.*\ze')
endif
@@ -120,12 +152,10 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos.anchor = join(split_lnk[1:], '#')
endif
if link_text == '' " because the link was of the form '#anchor'
let link_text = vimwiki#path#filename_without_extension(source_file)
let link_text = fnamemodify(source_file, ':p:t:r')
endif
endif
let link_tail = vimwiki#path#file_segment(link_text)
" check if absolute or relative path
if is_wiki_link && link_text[0] == '/'
if link_text != '/'
@@ -136,7 +166,7 @@ function! vimwiki#base#resolve_link(link_text, ...)
let is_relative = 0
else
let is_relative = 1
let root_dir = vimwiki#path#directory_of_file(source_file)
let root_dir = fnamemodify(source_file, ':p:h') . '/'
endif
@@ -144,52 +174,45 @@ function! vimwiki#base#resolve_link(link_text, ...)
if link_infos.scheme =~# '\mwiki\d\+'
let link_infos.index = eval(matchstr(link_infos.scheme, '\D\+\zs\d\+\ze'))
if link_infos.index < 0 || link_infos.index >= vimwiki#vars#number_of_wikis()
let link_infos.is_file = -1
let link_infos.index = -1
let link_infos.filename = ''
return link_infos
endif
if link_text[0] == '/' || link_infos.index != source_wiki
if !is_relative || link_infos.index != source_wiki
let root_dir = vimwiki#vars#get_wikilocal('path', link_infos.index)
if link_text != '/'
let link_text = link_text[1:]
endif
else
let root_dir = vimwiki#path#directory_of_file(source_file)
endif
if link_text =~# '\m[/\\]$'
if vimwiki#vars#get_global('dir_link') == ''
let target_dir = vimwiki#path#dir_segment(link_text)
let link_infos.target = vimwiki#path#join_dir(root_dir, target_dir)
else
let link_text .= vimwiki#vars#get_global('dir_link') .
let link_infos.filename = root_dir . link_text
if vimwiki#path#is_link_to_dir(link_text)
if vimwiki#vars#get_global('dir_link') != ''
let link_infos.filename .= vimwiki#vars#get_global('dir_link') .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
let target_file = vimwiki#path#file_segment(link_text)
let link_infos.target = vimwiki#path#join(root_dir, target_file)
endif
else
let link_text .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
let target_file = vimwiki#path#file_segment(link_text)
let link_infos.target = vimwiki#path#join(root_dir, target_file)
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
endif
elseif link_infos.scheme ==# 'diary'
let link_infos.index = source_wiki
let root_dir = vimwiki#vars#get_wikilocal('diary_path', link_infos.index)
let target_file = vimwiki#path#file_segment(link_text .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index))
let link_infos.target = vimwiki#path#join(root_dir, target_file)
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') &&
\ vimwiki#path#is_absolute(link_text)
let link_infos.target = vimwiki#path#file_obj(link_text)
else " relative file link
let root_dir = vimwiki#path#directory_of_file(source_file)
let target_file = vimwiki#path#file_segment(link_text)
let link_infos.target = vimwiki#path#join(root_dir, target_file)
let link_infos.filename =
\ vimwiki#vars#get_wikilocal('path', link_infos.index) .
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
\ link_text .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') && is_relative
let link_infos.filename = simplify(root_dir . link_text)
else " absolute file link
" collapse repeated leading "/"'s within a link
let link_text = substitute(link_text, '\m^/\+', '/', '')
" expand ~/
let link_text = fnamemodify(link_text, ':p')
let link_infos.filename = simplify(link_text)
endif
let link_infos.filename = vimwiki#path#normalize(link_infos.filename)
return link_infos
endfunction
@@ -255,7 +278,7 @@ function! vimwiki#base#open_link(cmd, link, ...)
let link_infos = vimwiki#base#resolve_link(a:link)
endif
if link_infos.is_file == -1
if link_infos.filename == ''
if link_infos.index == -1
echomsg 'Vimwiki Error: No registered wiki ''' . link_infos.scheme . '''.'
else
@@ -267,7 +290,7 @@ function! vimwiki#base#open_link(cmd, link, ...)
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' || link_infos.scheme =~# 'diary'
let update_prev_link = is_wiki_link &&
\ !vimwiki#path#is_equal(link_infos.target, vimwiki#path#current_wiki_file())
\ !vimwiki#path#is_equal(link_infos.filename, vimwiki#path#current_wiki_file())
let vimwiki_prev_link = []
" update previous link for wiki pages
@@ -281,10 +304,10 @@ function! vimwiki#base#open_link(cmd, link, ...)
" open/edit
if is_wiki_link
call vimwiki#base#edit_file(a:cmd, link_infos.target, link_infos.anchor,
call vimwiki#base#edit_file(a:cmd, link_infos.filename, link_infos.anchor,
\ vimwiki_prev_link, update_prev_link)
else
call vimwiki#base#system_open_link(link_infos.target)
call vimwiki#base#system_open_link(link_infos.filename)
endif
endfunction
@@ -314,7 +337,7 @@ endfunction
function! vimwiki#base#generate_links()
let lines = []
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0, 0)
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
call sort(links)
let bullet = repeat(' ', vimwiki#lst#get_list_margin()) . vimwiki#lst#default_symbol().' '
@@ -370,9 +393,7 @@ function! vimwiki#base#backlinks()
endfunction
" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX kann das weg?
" Returns: a list containing all files of the given wiki as file objects.
" Returns: a list containing all files of the given wiki as absolute file path.
" If the given wiki number is negative, the diary of the current wiki is used
" If the second argument is not zero, only directories are found
function! vimwiki#base#find_files(wiki_nr, directories_only)
@@ -380,7 +401,8 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
if wiki_nr >= 0
let root_directory = vimwiki#vars#get_wikilocal('path', wiki_nr)
else
let root_directory = vimwiki#vars#get_wikilocal('diary_path')
let root_directory = vimwiki#vars#get_wikilocal('path') .
\ vimwiki#vars#get_wikilocal('diary_rel_path')
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
endif
if a:directories_only
@@ -402,18 +424,14 @@ endfunction
" Returns: a list containing the links to get from the current file to all wiki
" files in the given wiki.
" If a:diary_only is nonzero, the diary of the wiki is used.
" If a:also_absolute_links is nonzero, also return links of the form /file.
function! vimwiki#base#get_wikilinks(wiki_nr, diary_only, also_absolute_links)
if a:diary_only
let files = vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('diary_path'))
else
let files = vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('path'))
endif
" If the given wiki number is negative, the diary of the current wiki is used.
" If also_absolute_links is nonzero, also return links of the form /file
function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
let files = vimwiki#base#find_files(a:wiki_nr, 0)
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
let cwd = vimwiki#path#wikify_path(expand('%:p:h'))
elseif a:wiki_nr < 0
let cwd = vimwiki#vars#get_wikilocal('diary_path')
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
else
let cwd = vimwiki#vars#get_wikilocal('path', a:wiki_nr)
endif
@@ -428,7 +446,7 @@ function! vimwiki#base#get_wikilinks(wiki_nr, diary_only, also_absolute_links)
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
let cwd = vimwiki#vars#get_wikilocal('path')
elseif a:wiki_nr < 0
let cwd = vimwiki#vars#get_wikilocal('diary_path')
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
endif
let wikifile = fnamemodify(wikifile, ':r') " strip extension
let wikifile = '/'.vimwiki#path#relpath(cwd, wikifile)
@@ -590,7 +608,7 @@ function! s:get_links(wikifile, idx)
endif
let link_count += 1
let target = vimwiki#base#resolve_link(link_text, a:wikifile)
if target.is_file != -1 && target.scheme =~# '\mwiki\d\+\|diary\|file\|local'
if target.filename != '' && target.scheme =~# '\mwiki\d\+\|diary\|file\|local'
call add(links, [target.filename, target.anchor, lnum, col])
endif
endwhile
@@ -1838,14 +1856,15 @@ function! vimwiki#base#table_of_contents(create)
let indentstring = repeat(' ', vimwiki#u#sw())
let bullet = vimwiki#lst#default_symbol().' '
for [lvl, link, desc] in complete_header_infos
let esc_link = substitute(link, "'", "''", 'g')
let esc_desc = substitute(desc, "'", "''", 'g')
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template')
else
let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2')
endif
let link = s:safesubstitute(link_tpl, '__LinkUrl__',
\ '#'.link, '')
let link = s:safesubstitute(link, '__LinkDescription__', desc, '')
\ '#'.esc_link, '')
let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '')
call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
endfor
@@ -1897,11 +1916,11 @@ endfunction
function! s:is_diary_file(filename)
let file_path = vimwiki#path#path_norm(a:filename)
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('diary_path'))
return !vimwiki#path#equal(vimwiki#vars#get_wikilocal('path'),
\ vimwiki#vars#get_wikilocal('diary_path'))
\ && file_path =~# '^'.vimwiki#u#escape(diary_path)
endfunction " }}}
let rel_path = vimwiki#vars#get_wikilocal('diary_rel_path')
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('path') . rel_path)
return rel_path != '' && file_path =~# '^'.vimwiki#u#escape(diary_path)
endfunction
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
let url = matchstr(a:str, a:rxUrl)
@@ -1926,7 +1945,8 @@ endfunction
function! s:normalize_link_in_diary(lnk)
let link = a:lnk . vimwiki#vars#get_wikilocal('ext')
let link_wiki = vimwiki#vars#get_wikilocal('path') . '/' . link
let link_diary = vimwiki#vars#get_wikilocal('diary_path') . '/' . link
let link_diary = vimwiki#vars#get_wikilocal('path') . '/'
\ . vimwiki#vars#get_wikilocal('diary_rel_path') . '/' . link
let link_exists_in_diary = filereadable(link_diary)
let link_exists_in_wiki = filereadable(link_wiki)
let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d'
@@ -1937,10 +1957,8 @@ function! s:normalize_link_in_diary(lnk)
let rxDesc = ''
let template = vimwiki#vars#get_global('WikiLinkTemplate1')
elseif link_exists_in_wiki
let relative_link =
\ vimwiki#path#relpath(vimwiki#vars#get_wikilocal('diary_path'),
\ vimwiki#vars#get_wikilocal('path'))
let str = relative_link . a:lnk . '|' . a:lnk
let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/'))
let str = repeat('../', depth) . a:lnk . '|' . a:lnk
let rxUrl = '^.*\ze|'
let rxDesc = '|\zs.*$'
let template = vimwiki#vars#get_global('WikiLinkTemplate2')
+6 -4
View File
@@ -23,7 +23,7 @@ endfunction
function! s:diary_path(...)
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
return vimwiki#vars#get_wikilocal('diary_path', idx)
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
endfunction
@@ -90,7 +90,8 @@ endfunction
function! s:get_diary_files()
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(vimwiki#vars#get_wikilocal('diary_path') . '*' . vimwiki#vars#get_wikilocal('ext'))
let s_files = glob(vimwiki#vars#get_wikilocal('path').
\ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
@@ -193,7 +194,8 @@ function! vimwiki#diary#make_note(wnum, ...)
" TODO: refactor it. base#goto_index uses the same
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('diary_path', wiki_nr))
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', wiki_nr).
\ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr))
let cmd = 'edit'
if a:0
@@ -318,7 +320,7 @@ endfunction
function vimwiki#diary#calendar_sign(day, month, year)
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = vimwiki#vars#get_wikilocal('diary_path') .
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction
+196 -139
View File
@@ -10,8 +10,8 @@ endif
let g:loaded_vimwiki_html_auto = 1
function! s:path_from_subdir_to_root(subdir)
return vimwiki#path#relpath(a:subdir, vimwiki#vars#get_wikilocal('path_html'))
function! s:root_path(subdir)
return repeat('../', len(split(a:subdir, '[/\\]')))
endfunction
@@ -43,67 +43,87 @@ function! s:is_img_link(lnk)
endfunction
function! s:corresponding_html_file(wiki_file)
let relative_wiki_path = vimwiki#path#subtract(vimwiki#vars#get_wikilocal('path'), a:wiki_file)
let html_file = vimwiki#path#join(vimwiki#vars#get_wikilocal('path_html'), relative_wiki_path)
let html_file = vimwiki#path#set_extension(html_file, 'html')
return html_file
endfunction
function! s:corresponding_wiki_file(html_file)
let html_path = vimwiki#path#subtract(vimwiki#vars#get_wikilocal('path_html'), a:html_file)
let wiki_file = vimwiki#path#join(vimwiki#vars#get_wikilocal('path'), html_path)
let wiki_file = vimwiki#path#set_extension(wiki_file, vimwiki#vars#get_wikilocal('ext'))
return wiki_file
endfunction
function! s:default_CSS_full_name()
return vimwiki#path#join(vimwiki#vars#get_wikilocal('path_html'),
\ vimwiki#vars#get_wikilocal('css_name'))
endfunction
" Returns: 1 if it was created, 0 if it already existed
function! s:create_default_CSS()
let css_full_name = s:default_CSS_full_name()
if vimwiki#path#exists(css_full_name)
return 0
else
let default_css = vimwiki#path#find_autoload_file('style.css')
call vimwiki#path#copy_file(default_css, css_full_name)
function! s:has_abs_path(fname)
if a:fname =~# '\(^.:\)\|\(^/\)'
return 1
endif
return 0
endfunction
function! s:find_autoload_file(name)
for path in split(&runtimepath, ',')
let fname = path.'/autoload/vimwiki/'.a:name
if glob(fname) != ''
return fname
endif
endfor
return ''
endfunction
function! s:default_CSS_full_name(path)
let path = expand(a:path)
let css_full_name = path . vimwiki#vars#get_wikilocal('css_name')
return css_full_name
endfunction
function! s:create_default_CSS(path)
let css_full_name = s:default_CSS_full_name(a:path)
if glob(css_full_name) == ""
call vimwiki#path#mkdir(fnamemodify(css_full_name, ':p:h'))
let default_css = s:find_autoload_file('style.css')
if default_css != ''
let lines = readfile(default_css)
call writefile(lines, css_full_name)
return 1
endif
endif
return 0
endfunction
function! s:template_full_name(name)
let filename = vimwiki#path#file_segment(name . vimwiki#vars#get_wikilocal('template_ext'))
let template_file = vimwiki#path#join(vimwiki#vars#get_wikilocal('template_path'), filename)
return template_file
if a:name == ''
let name = vimwiki#vars#get_wikilocal('template_default')
else
let name = a:name
endif
let fname = expand(vimwiki#vars#get_wikilocal('template_path').
\ name . vimwiki#vars#get_wikilocal('template_ext'))
if filereadable(fname)
return fname
else
return ''
endif
endfunction
function! s:get_html_template(template_name)
if a:template_name != ''
let template_file = s:template_full_name(a:template)
function! s:get_html_template(template)
" TODO: refactor it!!!
let lines=[]
if a:template != ''
let template_name = s:template_full_name(a:template)
try
let lines = readfile(vimwiki#path#to_string(template_file))
let lines = readfile(template_name)
return lines
catch /E484/
echomsg 'Vimwiki: HTML template '.vimwiki#path#to_string(template_file). ' does not exist!'
echomsg 'Vimwiki: HTML template '.template_name. ' does not exist!'
endtry
return []
else
let default_template_file =
\ s:template_full_name(vimwiki#vars#get_wikilocal('template_default'))
if !vimwiki#path#exists(default_template_file)
let default_template_file = vimwiki#path#find_autoload_file('default.tpl')
endif
let lines = readfile(default_tpl)
return lines
endif
let default_tpl = s:template_full_name('')
if default_tpl == ''
let default_tpl = s:find_autoload_file('default.tpl')
endif
let lines = readfile(default_tpl)
return lines
endfunction
@@ -131,25 +151,26 @@ function! s:safe_html_line(line)
endfunction
function! s:delete_html_files()
let htmlfiles =
\ vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('path_html'), 'html')
for html_file in htmlfiles
function! s:delete_html_files(path)
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
for fname in htmlfiles
" ignore user html files, e.g. search.html,404.html
if index(vimwiki#vars#get_global('user_htmls'), vimwiki#path#filename(html_file)) >= 0
if stridx(vimwiki#vars#get_global('user_htmls'), fnamemodify(fname, ":t")) >= 0
continue
endif
" delete if there is no corresponding wiki file
if vimwiki#path#exists(s:corresponding_wiki_file(html_file))
let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path_html'), fname)
let wikifile = vimwiki#vars#get_wikilocal('path').subdir.
\fnamemodify(fname, ":t:r").vimwiki#vars#get_wikilocal('ext')
if filereadable(wikifile)
continue
endif
try
call delete(vimwiki#path#to_string(html_file))
call delete(fname)
catch
echomsg 'Vimwiki Error: Cannot delete '.vimwiki#path#to_string(html_file)
echomsg 'Vimwiki Error: Cannot delete '.fname
endtry
endfor
endfunction
@@ -210,15 +231,21 @@ endfunction
function! s:is_html_uptodate(wikifile)
let htmlfile_ftime = getftime(vimwiki#path#to_string(s:corresponding_html_file(a:wikifile)))
let tpl_time = -1
" The HTML file should also be considered out of date if the default template has been changed in
" the meantime. This is not completely correct, because the wiki file could use a template which
" is not the default one. But it's better than nothing.
let tpl_file = s:template_full_name(vimwiki#vars#get_wikilocal('template_default'))
let tpl_time = getftime(tpl_file)
let tpl_file = s:template_full_name('')
if tpl_file != ''
let tpl_time = getftime(tpl_file)
endif
return getftime(wikifile) <= htmlfile_ftime && tpl_time <= htmlfile_ftime
let wikifile = fnamemodify(a:wikifile, ":p")
let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') .
\ vimwiki#vars#get_bufferlocal('subdir') . fnamemodify(wikifile, ":t:r").".html")
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
return 1
endif
return 0
endfunction
@@ -383,18 +410,17 @@ function! s:tag_wikiincl(value)
let link_infos = vimwiki#base#resolve_link(url_0)
if link_infos.scheme =~# '\mlocal\|wiki\d\+\|diary'
let url = vimwiki#path#relpath(vimwiki#path#directory_of_file(s:current_html_file),
\ link_infos.target)
let url = vimwiki#path#relpath(fnamemodify(s:current_html_file, ':h'), link_infos.filename)
" strip the .html extension when we have wiki links, so that the user can
" simply write {{image.png}} to include an image from the wiki directory
if link_infos.scheme =~# '\mwiki\d\+\|diary'
let url = vimwiki#path#filename_without_extension(url)
let url = fnamemodify(url, ':r')
endif
else
let url = link_infos.target
let url = link_infos.filename
endif
let url = escape(vimwiki#path#to_string(url), '#')
let url = escape(url, '#')
let line = s:linkify_image(url, descr, verbatim_str)
endif
return line
@@ -421,17 +447,20 @@ function! s:tag_wikilink(value)
if link_infos.scheme ==# 'file'
" external file links are always absolute
let html_link = vimwiki#path#to_string(link_infos.target)
let html_link = link_infos.filename
elseif link_infos.scheme ==# 'local'
let html_link = vimwiki#path#to_string(vimwiki#path#relpath(
\ vimwiki#path#directory_of_file(s:current_html_file), link_infos.target))
let html_link = vimwiki#path#relpath(fnamemodify(s:current_html_file, ':h'),
\ link_infos.filename)
elseif link_infos.scheme =~# '\mwiki\d\+\|diary'
" wiki links are always relative to the current file
let target_html_file = s:corresponding_html_file(link_infos.target)
let html_link = vimwiki#path#to_string(vimwiki#path#relpath(
\ vimwiki#path#directory_of_file(s:current_html_file), target_html_file))
let html_link = vimwiki#path#relpath(
\ fnamemodify(s:current_wiki_file, ':h'),
\ fnamemodify(link_infos.filename, ':r'))
if html_link !~ '\m/$'
let html_link .= '.html'
endif
else " other schemes, like http, are left untouched
let html_link = link_infos.target
let html_link = link_infos.filename
endif
if link_infos.anchor != ''
@@ -857,8 +886,8 @@ function! s:process_tag_list(line, lists)
let st_tag = '<li>'
let chk = matchlist(a:line, a:rx_list)
if !empty(chk) && len(chk[1]) > 0
let completion = index(vimwiki#vars#get_syntaxlocal('listsyms_list'), chk[1])
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let completion = index(vimwiki#vars#get_wikilocal('listsyms_list'), chk[1])
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
if completion == 0
let st_tag = '<li class="done0">'
elseif completion == -1 && chk[1] == vimwiki#vars#get_global('listsym_rejected')
@@ -1363,61 +1392,57 @@ endfunction
function! s:use_custom_wiki2html()
let custom_wiki2html = vimwiki#vars#get_wikilocal('custom_wiki2html')
return vimwiki#path#is_executable(custom_wiki2html)
return !empty(custom_wiki2html) &&
\ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html))
endfunction
function! s:call_custom_wiki2HTML(output_dir, wikifile, force)
call vimwiki#path#mkdir(a:output_dir)
let arguments = [
\ a:force,
\ vimwiki#vars#get_wikilocal('syntax'),
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1),
\ vimwiki#path#to_string(a:output_dir),
\ vimwiki#path#to_string(a:wikifile),
\ vimwiki#path#to_string(s:default_CSS_full_name()),
\ vimwiki#path#to_string(vimwiki#vars#get_wikilocal('template_path')),
\ vimwiki#vars#get_wikilocal('template_default'),
\ vimwiki#vars#get_wikilocal('template_ext'),
\ vimwiki#path#to_string(s:path_from_subdir_to_root(a:output_dir)),
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args')
\ ]
for i in range(len(arguments))
if arguments[i] =~# '\m^\s*$'
let arguments[i] = '-'
endif
let arguments[i] = shellescape(arguments[i])
endfor
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '. join(arguments, ' '))
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force)
call vimwiki#path#mkdir(a:path)
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '.
\ a:force. ' '.
\ vimwiki#vars#get_wikilocal('syntax'). ' '.
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '.
\ shellescape(a:path). ' '.
\ shellescape(a:wikifile). ' '.
\ shellescape(s:default_CSS_full_name(a:path)). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ?
\ shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_default') : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '.
\ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ?
\ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ?
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-'))
endfunction
function! s:convert_file(wikifile)
function! s:convert_file(path_html, wikifile)
let done = 0
let html_file = s:corresponding_html_file(a:wikifile)
let wikifile = fnamemodify(a:wikifile, ":p")
let path_html = expand(a:path_html).vimwiki#vars#get_bufferlocal('subdir')
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
" the currently processed file name is needed when processing links
" yeah yeah, shame on me for using (quasi-) global variables
let s:current_wiki_file = a:wikifile
let s:current_html_file = html_file
let output_dir = vimwiki#path#directory_of_file(html_file)
let s:current_wiki_file = wikifile
let s:current_html_file = path_html . htmlfile
if s:use_custom_wiki2html()
let force = 1
call s:call_custom_wiki2HTML(output_dir, wikifile, force)
call vimwiki#html#CustomWiki2HTML(path_html, wikifile, force)
let done = 1
endif
if s:syntax_supported() && done == 0
let lsource = readfile(vimwiki#path#to_string(a:wikifile))
let lsource = readfile(wikifile)
let ldest = []
call vimwiki#path#mkdir(output_dir)
call vimwiki#path#mkdir(path_html)
" nohtml placeholder -- to skip html generation.
let nohtml = 0
@@ -1451,7 +1476,7 @@ function! s:convert_file(wikifile)
endif
" prepare regexps for lists
let s:bullets = '[*-]'
let s:bullets = vimwiki#vars#get_wikilocal('rx_bullet_char')
let s:numbers = '\C\%(#\|\d\+)\|\d\+\.\|[ivxlcdm]\+)\|[IVXLCDM]\+)\|\l\{1,2})\|\u\{1,2})\)'
for line in lsource
@@ -1483,7 +1508,7 @@ function! s:convert_file(wikifile)
if nohtml
echon "\r"."%nohtml placeholder found"
return vimwiki#path#null_file()
return ''
endif
call s:remove_blank_lines(ldest)
@@ -1500,7 +1525,7 @@ function! s:convert_file(wikifile)
call s:close_tag_table(state.table, lines, state.header_ids)
call extend(ldest, lines)
let title = s:process_title(placeholders, vimwiki#path#filename(a:wikifile))
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
let html_lines = s:get_html_template(template_name)
@@ -1509,9 +1534,10 @@ function! s:convert_file(wikifile)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:path_from_subdir_to_root(output_dir) .'", "g")')
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
let css_name = vimwiki#path#to_string(vimwiki#vars#get_wikilocal('css_name'))
let css_name = expand(vimwiki#vars#get_wikilocal('css_name'))
let css_name = substitute(css_name, '\', '/', 'g')
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
let enc = &fileencoding
@@ -1522,30 +1548,30 @@ function! s:convert_file(wikifile)
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
call writefile(html_lines, vimwiki#path#to_string(html_file))
call writefile(html_lines, path_html.htmlfile)
let done = 1
endif
if done == 0
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax'
return vimwiki#path#null_file()
return ''
endif
return html_file
return path_html.htmlfile
endfunction
function! vimwiki#html#Wiki2HTML(wikifile)
let result = s:convert_file(a:wikifile)
if !vimwiki#path#is_null(result)
call s:create_default_CSS()
function! vimwiki#html#Wiki2HTML(path_html, wikifile)
let result = s:convert_file(a:path_html, a:wikifile)
if result != ''
call s:create_default_CSS(a:path_html)
endif
return result
endfunction
function! vimwiki#html#WikiAll2HTML()
function! vimwiki#html#WikiAll2HTML(path_html)
if !s:syntax_supported() && !s:use_custom_wiki2html()
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax'
return
@@ -1561,45 +1587,76 @@ function! vimwiki#html#WikiAll2HTML()
endtry
let &eventignore = save_eventignore
let path_html = vimwiki#vars#get_wikilocal('path_html')
let path_html = expand(a:path_html)
call vimwiki#path#mkdir(path_html)
echomsg 'Vimwiki: Deleting non-wiki html files ...'
call s:delete_html_files()
call s:delete_html_files(path_html)
echomsg 'Vimwiki: Converting wiki to html files ...'
let setting_more = &more
setlocal nomore
let wikifiles = vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('path'),
\ vimwiki#vars#get_wikilocal('ext'))
" temporarily adjust current_subdir global state variable
let current_subdir = vimwiki#vars#get_bufferlocal('subdir')
let current_invsubdir = vimwiki#vars#get_bufferlocal('invsubdir')
let wikifiles = split(glob(vimwiki#vars#get_wikilocal('path').'**/*'.
\ vimwiki#vars#get_wikilocal('ext')), '\n')
for wikifile in wikifiles
let wikifile = fnamemodify(wikifile, ":p")
" temporarily adjust 'subdir' and 'invsubdir' state variables
let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), wikifile)
call vimwiki#vars#set_bufferlocal('subdir', subdir)
call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir))
if !s:is_html_uptodate(wikifile)
echomsg 'Vimwiki: Processing '.vimwiki#path#to_string(wikifile)
call s:convert_file(wikifile)
echomsg 'Vimwiki: Processing '.wikifile
call s:convert_file(path_html, wikifile)
else
echomsg 'Vimwiki: Skipping '.vimwiki#path#to_string(wikifile)
echomsg 'Vimwiki: Skipping '.wikifile
endif
endfor
" reset 'subdir' state variable
call vimwiki#vars#set_bufferlocal('subdir', current_subdir)
call vimwiki#vars#set_bufferlocal('invsubdir', current_invsubdir)
let created = s:create_default_CSS()
let created = s:create_default_CSS(path_html)
if created
echomsg 'Vimwiki: Default style.css has been created'
endif
echomsg 'Vimwiki: HTML exported to '.vimwiki#path#to_string(path_html)
echomsg 'Vimwiki: HTML exported to '.path_html
echomsg 'Vimwiki: Done!'
let &more = setting_more
endfunction
function! s:file_exists(fname)
return !empty(getftype(expand(a:fname)))
endfunction
function! s:binary_exists(fname)
return executable(expand(a:fname))
endfunction
function! s:get_wikifile_url(wikifile)
return vimwiki#vars#get_wikilocal('path_html') .
\ vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), a:wikifile).
\ fnamemodify(a:wikifile, ":t:r").'.html'
endfunction
function! vimwiki#html#PasteUrl(wikifile)
execute 'r !echo file://'.s:corresponding_html_file(a:wikifile)
execute 'r !echo file://'.s:get_wikifile_url(a:wikifile)
endfunction
function! vimwiki#html#CatUrl(wikifile)
execute '!echo file://'.s:corresponding_html_file(a:wikifile)
execute '!echo file://'.s:get_wikifile_url(a:wikifile)
endfunction
+17 -16
View File
@@ -137,7 +137,7 @@ endfunction
"Returns: the column where the text of a line starts (possible list item
"markers and checkboxes are skipped)
function! s:text_begin(lnum)
return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')))
return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem')))
endfunction
@@ -145,9 +145,9 @@ endfunction
" 1 for a marker and no text
" 0 for no marker at all (empty line or only text)
function! s:line_has_marker(lnum)
if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$'
if getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*$'
return 1
elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S'
elseif getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*\S'
return 2
else
return 0
@@ -172,7 +172,7 @@ function! s:get_item(lnum)
return item
endif
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem'))
if matches == [] ||
\ (matches[1] == '' && matches[2] == '') ||
\ (matches[1] != '' && matches[2] != '')
@@ -209,7 +209,7 @@ function! s:get_level(lnum)
let level = indent(a:lnum)
else
let level = s:string_length(matchstr(getline(a:lnum),
\ vimwiki#vars#get_syntaxlocal(rx_bullet_chars)))-1
\ vimwiki#vars#get_wikilocal(rx_bullet_chars)))-1
if level < 0
let level = (indent(a:lnum) == 0) ? 0 : 9999
endif
@@ -744,8 +744,8 @@ function! s:get_rate(item)
if state == vimwiki#vars#get_global('listsym_rejected')
return -1
endif
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 100/(n-1)
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
return index(vimwiki#vars#get_wikilocal('listsyms_list'), state) * 100/(n-1)
endfunction
@@ -784,7 +784,7 @@ function! s:set_state_plus_children(item, new_rate, ...)
if child_item.cb != vimwiki#vars#get_global('listsym_rejected')
let all_children_are_rejected = 0
endif
if child_item.cb != vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
if child_item.cb != vimwiki#vars#get_wikilocal('listsyms_list')[-1]
let all_children_are_done = 0
endif
if !all_children_are_done && !all_children_are_rejected
@@ -820,7 +820,7 @@ endfunction
"Returns: the appropriate symbol for a given percent rate
function! s:rate_to_state(rate)
let listsyms_list = vimwiki#vars#get_syntaxlocal('listsyms_list')
let listsyms_list = vimwiki#vars#get_wikilocal('listsyms_list')
let state = ''
let n = len(listsyms_list)
if a:rate == 100
@@ -997,7 +997,7 @@ function! vimwiki#lst#decrement_cb(from_line, to_line)
"if from_line has CB, decrement it and set all siblings to the same new state
let rate_first_line = s:get_rate(from_item)
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
let new_rate = max([rate_first_line - 100/(n-1)-1, 0])
call s:change_cb(a:from_line, a:to_line, new_rate)
@@ -1015,7 +1015,7 @@ function! vimwiki#lst#increment_cb(from_line, to_line)
"if from_line has CB, increment it and set all siblings to the same new state
let rate_first_line = s:get_rate(from_item)
let n = len(vimwiki#vars#get_syntaxlocal('listsyms_list'))
let n = len(vimwiki#vars#get_wikilocal('listsyms_list'))
let new_rate = min([rate_first_line + 100/(n-1)+1, 100])
call s:change_cb(a:from_line, a:to_line, new_rate)
@@ -1034,6 +1034,7 @@ endfunction
"in the lines of the given range
function! vimwiki#lst#toggle_rejected_cb(from_line, to_line)
return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1)
endfunction
@@ -1101,7 +1102,7 @@ endfunction
function! s:decrease_level(item)
let removed_indent = 0
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(a:item.mrkr)) > -1
if s:string_length(a:item.mrkr) >= 2
call s:substitute_string_in_line(a:item.lnum, s:first_char(a:item.mrkr), '')
@@ -1124,7 +1125,7 @@ endfunction
function! s:increase_level(item)
let additional_indent = 0
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(a:item.mrkr)) > -1
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
\ s:first_char(a:item.mrkr))
@@ -1148,7 +1149,7 @@ endfunction
function! s:indent_line_by(lnum, indent_by)
let item = s:get_item(a:lnum)
if vimwiki#vars#get_syntaxlocal('recurring_bullets') && item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(item.mrkr)) > -1
if a:indent_by > 0
call s:substitute_string_in_line(a:lnum, item.mrkr, item.mrkr . s:first_char(item.mrkr))
@@ -1323,7 +1324,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode)
endif
"handle markers like ***
if index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1
if index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'), s:first_char(new_mrkr)) > -1
"use *** if the item above has *** too
let item_above = s:get_prev_list_item(cur_item, 1)
if item_above.type == 1 && s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr)
@@ -1394,7 +1395,7 @@ function! s:adjust_mrkr(item)
"if possible, set e.g. *** if parent has ** as marker
if neighbor_item.type == 0 && a:item.type == 1 &&
\ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'),
\ index(vimwiki#vars#get_wikilocal('multiple_bullet_chars'),
\ s:first_char(a:item.mrkr)) > -1
let parent_item = s:get_parent(a:item)
if parent_item.type == 1 && s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr)
+15 -275
View File
@@ -49,6 +49,13 @@ function! vimwiki#path#path_norm(path)
endfunction
function! vimwiki#path#is_link_to_dir(link)
" Check if link is to a directory.
" It should be ended with \ or /.
return a:link =~# '\m[/\\]$'
endfunction
function! vimwiki#path#abs_path_of_link(link)
return vimwiki#path#normalize(expand("%:p:h").'/'.a:link)
endfunction
@@ -117,21 +124,22 @@ endfunction
" If the optional argument provided and nonzero,
" it will ask before creating a directory
" Returns: 1 iff directory exists or successfully created
function! vimwiki#path#mkdir(dir_obj, ...)
function! vimwiki#path#mkdir(path, ...)
let path = expand(a:path)
if a:dir_obj.protocoll ==# 'scp'
if path =~# '^scp:'
" we can not do much, so let's pretend everything is ok
return 1
endif
if vimwiki#path#exists(a:dir_obj)
if isdirectory(path)
return 1
else
if !exists("*mkdir")
return 0
endif
let path = vimwiki#path#to_string(a:dir_obj)
let path = vimwiki#path#chomp_slash(path)
if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc'))
let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc'))
endif
@@ -146,11 +154,11 @@ function! vimwiki#path#mkdir(dir_obj, ...)
endfunction
function! vimwiki#path#is_absolute(path_string)
function! vimwiki#path#is_absolute(path)
if vimwiki#u#is_windows()
return a:path_string =~? '\m^\a:'
return a:path =~? '\m^\a:'
else
return a:path_string =~# '\m^/\|\~/'
return a:path =~# '\m^/\|\~/'
endif
endfunction
@@ -173,271 +181,3 @@ else
endfunction
endif
"----------------------------------------------------------
" Path manipulation, i.e. functions which do stuff with the paths of (not necessarily existing) files
"----------------------------------------------------------
" The used data types are
"
" - directory object:
" - used for an absolute path to a directory
" - internally, it is a dictionary with the following entries:
" - 'protocoll' -- how to access the file. Supported are 'scp' or 'file'
" - 'is_unix' -- 1 if it's supposed to be a unix-like path
" - 'path' -- a list containing the directory names starting at the root
" - file object:
" - for an absolute path to a file
" - internally a list [dir_obj, file name]
" - file segment:
" - for a relative path to a file or a part of an absolute path
" - internally a list where the first element is a list of directory names and the second the
" file name
" - directory segment:
" - for a relative path to a directory or a part of an absolute path
" - internally a list of directory names
" create and return a file object from a string. It is assumed that the given
" path is absolute and points to a file (not a directory)
function! vimwiki#path#file_obj(filepath)
if a:filepath == ''
return vimwiki#path#null_file()
else
let filename = fnamemodify(a:filepath, ':p:t')
let path = fnamemodify(a:filepath, ':p:h')
return [vimwiki#path#dir_obj(path), filename]
endif
endfunction
function! vimwiki#path#null_file()
return []
endfunction
function! vimwiki#path#is_null(file)
return empty(a:file)
endfunction
" create and return a dir object from a string. The given path should be
" absolute and point to a directory.
function! vimwiki#path#dir_obj(dirpath)
if a:dirpath =~# '^scp:'
let dirpath = a:dirpath[4:]
let protocoll = 'scp'
else
let dirpath = resolve(fnamemodify(a:dirpath, ':p'))
let protocoll = 'file'
endif
let path = split(vimwiki#path#chomp_slash(dirpath), '\m[/\\]', 1)
let is_unix = dirpath[0] ==# '/'
let result = {
\ 'is_unix' : is_unix,
\ 'protocoll' : protocoll,
\ 'path' : path,
\}
return result
endfunction
" Assume it is not an absolute path
function! vimwiki#path#file_segment(path_segment)
let filename = fnamemodify(a:path_segment, ':t')
let path = fnamemodify(a:path_segment, ':h')
let path_list = (path ==# '.' ? [] : split(path, '\m[/\\]', 1))
return [path_list, filename]
endfunction
" Assume it is not an absolute path
function! vimwiki#path#dir_segment(path_segment)
return split(a:path_segment, '\m[/\\]', 1)
endfunction
function! vimwiki#path#extension(file_object)
return fnamemodify(a:file_object[1], ':e')
endfunction
function! vimwiki#path#set_extension(file_obj, new_ext)
let new_filename = vimwiki#path#filename_without_extension(a:file_obj) . '.' . a:new_ext
let a:file_obj[1] = new_filename
return a:file_obj
endfunction
function! vimwiki#path#filename_without_extension(file_object)
return fnamemodify(a:file_object[1], ':r')
endfunction
" Returns: the dir of the file object as dir object
function! vimwiki#path#directory_of_file(file_object)
return copy(a:file_object[0])
endfunction
" Returns: the file_obj's file name as a string
function! vimwiki#path#filename(file_object)
return a:file_object[1]
endfunction
" Returns: the dir_obj, file_obj, file segment or dir segment as string, ready
" to be used with the regular path handling functions in Vim
function! vimwiki#path#to_string(obj)
if type(a:obj) == 4 " dir object
let separator = a:obj.is_unix ? '/' : '\'
let address = join(dir_obj.path, separator) . separator
return address
elseif type(a:obj[0]) == 4 " file object
let dir_obj = type(a:obj) == 4 ? a:obj : a:obj[0]
let separator = a:obj[0].is_unix ? '/' : '\'
let address = join(a:obj[0].path, separator) . separator . a:obj[1]
return address
elseif type(a:obj[0]) == 3 " file segment
" XXX: what about the separator?
return join(a:obj[0], '/') . '/' . a:obj[1]
elseif type(a:obj[0]) == 1 " directory segment
return join(a:obj, '/') . '/'
else
call vimwiki#u#error('Invalid argument ' . string(a:obj))
endif
endfunction
" Returns: the given a:dir_obj with a:str appended to the dir name
function! vimwiki#path#append_to_dirname(dir_obj, str)
let a:dir_obj.path[-1] .= a:str
return a:dir_obj
endfunction
" Returns a file object made from a dir object plus a file semgent
function! vimwiki#path#join(dir_obj, file_segment)
let new_dir_object = copy(a:dir_obj)
let new_dir_object.path += a:file_segment[0]
return [new_dir_object, a:file_segment[1]]
endfunction
" Returns a dir object made from a dir object plus a dir semgent
function! vimwiki#path#join_dir(dir_path, dir_segment)
let new_dir_object = copy(a:dir_path)
let new_dir_object.path += a:dir_segment
return new_dir_object
endfunction
" returns the file segment fs, so that join(dir, fs) == file
" we just assume the file is somewhere in dir
function! vimwiki#path#subtract(dir_object, file_object)
let path_rest = a:file_object[0].path[len(a:dir_object.path):]
return [path_rest, file_object[1]]
endfunction
" Returns: the relative path from a:dir to a:file
" XXX wenn die beiden identisch sind, sollte . rauskommen
function! vimwiki#path#relpath(dir1_object, dir2_object)
let dir1_path = copy(a:dir1_object.path)
let dir2_path = copy(a:dir2_object.path)
let result_path = []
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir1_path[0], dir2_path[0])
call remove(dir1_path, 0)
call remove(dir2_path, 0)
endwhile
for segment in dir1_path
let result += ['..']
endfor
for segment in dir2_path
let result += [segment]
endfor
let result = {
\ 'is_unix' : a:dir1_object.is_unix,
\ 'protocoll' : a:dir1_object.protocoll,
\ 'path' : result_path,
\}
return result
endfunction
function! vimwiki#path#is_file_in_dir(file, dir)
let file_path_segments = a:file[0].path
let dir_path_segments = a:dir.path
if len(dir_path_segments) > len(file_path_segments)
return 0
endif
for i in range(len(a:dir.path))
if !vimwiki#path#is_equal(a:dir.path[i], file_path_segments[i])
return 0
endif
endfor
return 1
endfunction
"-----------------
" File manipulation, i.e. do stuff with actually existing files
"-----------------
function! vimwiki#path#current_file()
return vimwiki#path#file_obj(expand('%:p'))
endfunction
function! vimwiki#path#exists(object)
if type(a:object) == 4
return isdirectory(vimwiki#path#to_string(a:object))
else
if vimwiki#path#is_null(a:object)
return 0
endif
" glob() checks whether or not a file exists (readable or writable)
return glob(vimwiki#path#to_string(a:object)) != ''
endif
endfunction
function! vimwiki#path#is_executable(file)
return vimwiki#path#exists(a:file) && executable(vimwiki#path#to_string(a:file))
endfunction
" this must be outside a function, because only outside a function <sfile> expands
" to the directory where this file is in
let s:vimwiki_autoload_dir = expand('<sfile>:p:h')
function! vimwiki#path#find_autoload_file(filename)
let autoload_dir = vimwiki#path#dir_obj(s:vimwiki_autoload_dir)
let filename_obj = vimwiki#path#file_segment(a:filename)
let file = vimwiki#path#join(autoload_dir, filename_obj)
if !vimwiki#path#exists(file)
echom 'Vimwiki Error: ' . vimwiki#path#to_string(file) . ' not found'
endif
return file
endfunction
function! vimwiki#path#copy_file(file_obj, dir_obj)
call vimwiki#path#mkdir(a:dir_obj)
let new_file = deepcopy(a:file_obj)
let new_file[0] = copy(a:dir_obj)
let lines = readfile(vimwiki#path#to_string(a:file_obj))
let ok = writefile(lines, vimwiki#path#to_string(new_file))
if ok < 0
call vimwiki#u#error('Could not write ' . vimwiki#path#to_string(new_file))
endif
endfunction
" Returns: a list of all files somewhere in a:dir_obj with extension a:ext
function! vimwiki#path#files_in_dir_recursive(dir_obj, ext)
let separator = a:dir_obj.is_unix ? '/' : '\'
let glob_expression = vimwiki#path#to_string(a:dir_obj) . '**' . separator . '*.' . a:ext
let file_strings = split(glob(glob_expression), '\n')
return map(file_strings, 'vimwiki#path#file_obj(v:val)')
endfunction
+8 -14
View File
@@ -31,7 +31,7 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files)
let all_files = a:all_files != ''
if !a:full_rebuild
" Updating for one page (current)
let page_name = s:page_name(vimwiki#path#current_file())
let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r')
" Collect tags in current file
let tags = s:scan_tags(getline(1, '$'), page_name)
" Load metadata file
@@ -44,12 +44,13 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files)
call s:write_tags_metadata(metadata)
else " full rebuild
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
let tags_file_last_modification =
\ getftime(vimwiki#path#to_string(vimwiki#tags#metadata_file_path()))
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let tags_file_last_modification = getftime(vimwiki#tags#metadata_file_path())
let metadata = s:load_tags_metadata()
for file in files
if all_files || getftime(vimwiki#path#to_string(file)) >= tags_file_last_modification
let page_name = s:page_name(file)
if all_files || getftime(file) >= tags_file_last_modification
let subdir = vimwiki#base#subdir(wiki_base_dir, file)
let page_name = subdir . fnamemodify(file, ':t:r')
let tags = s:scan_tags(readfile(file), page_name)
let metadata = s:remove_page_from_tags(metadata, page_name)
let metadata = s:merge_tags(metadata, page_name, tags)
@@ -60,13 +61,6 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files)
endfunction
function! s:page_name(file_obj)
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let segment = vimwiki#path#subtract(wiki_base_dir, a:file_obj)
return vimwiki#path#to_string(segment)
endfunction
" Scans the list of text lines (argument) and produces tags metadata as a list of tag entries.
function! s:scan_tags(lines, page_name)
@@ -148,8 +142,8 @@ endfunction
" Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort
return vimwiki#path#join(vimwiki#vars#get_wikilocal('path'),
\ vimwiki#path#file_segment(s:TAGS_METADATA_FILE_NAME))
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'),
\ s:TAGS_METADATA_FILE_NAME), ':p')
endfunction
-4
View File
@@ -70,7 +70,3 @@ else
endfunc
endif
function vimwiki#u#error(message)
echom 'Vimwiki Error: ' . a:message
endfunction
+153 -273
View File
@@ -13,7 +13,7 @@
" global user variables and syntax stuff which is the same for every syntax.
"
" - wiki-local variables. They are stored in g:vimwiki_wikilocal_vars which is a list of
" dictionaries, one dict for every registered wiki. The last dictionary contains default values
" dictionaries. One dict for every registered wiki. The last dictionary contains default values
" (used for temporary wikis).
"
" - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and
@@ -28,10 +28,50 @@
function! s:populate_global_variables()
let g:vimwiki_global_vars = {}
let g:vimwiki_global_vars = {
\ 'CJK_length': 0,
\ 'auto_chdir': 0,
\ 'autowriteall': 1,
\ 'conceallevel': 2,
\ 'diary_months':
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ },
\ 'dir_link': '',
\ 'ext2syntax': {},
\ 'folding': '',
\ 'global_ext': 1,
\ 'hl_cb_checked': 0,
\ 'hl_headers': 0,
\ 'html_header_numbering': 0,
\ 'html_header_numbering_sym': '',
\ 'list_ignore_newline': 1,
\ 'text_ignore_newline': 1,
\ 'listsyms': ' .oOX',
\ 'listsym_rejected': '-',
\ 'map_prefix': '<Leader>w',
\ 'menu': 'Vimwiki',
\ 'table_auto_fmt': 1,
\ 'table_mappings': 1,
\ 'toc_header': 'Contents',
\ 'url_maxsave': 15,
\ 'use_calendar': 1,
\ 'use_mouse': 0,
\ 'user_htmls': '',
\ 'valid_html_tags': 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em',
\ 'w32_dir_enc': '',
\ }
call s:read_global_settings_from_user()
call s:normalize_global_settings()
" copy the user's settings from variables of the form g:vimwiki_<option> into the dict
" g:vimwiki_global_vars (or set a default value)
for key in keys(g:vimwiki_global_vars)
if exists('g:vimwiki_'.key)
let g:vimwiki_global_vars[key] = g:vimwiki_{key}
endif
endfor
" non-configurable global variables:
@@ -139,141 +179,34 @@ function! s:populate_global_variables()
endfunction
function! s:read_global_settings_from_user()
let global_settings = {
\ 'CJK_length': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_chdir': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'autowriteall': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'conceallevel': {'type': type(0), 'default': 2, 'min': 0, 'max': 3},
\ 'diary_months': {'type': type({}), 'default':
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ }},
\ 'dir_link': {'type': type(''), 'default': ''},
\ 'ext2syntax': {'type': type({}), 'default': {}},
\ 'folding': {'type': type(''), 'default': '', 'possible_values': ['', 'expr', 'syntax',
\ 'list', 'custom', ':quick', 'expr:quick', 'syntax:quick', 'list:quick',
\ 'custom:quick']},
\ 'global_ext': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'hl_cb_checked': {'type': type(0), 'default': 0, 'min': 0, 'max': 2},
\ 'hl_headers': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'html_header_numbering': {'type': type(0), 'default': 0, 'min': 0, 'max': 6},
\ 'html_header_numbering_sym': {'type': type(''), 'default': ''},
\ 'list_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'text_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'listsyms': {'type': type(''), 'default': ' .oOX', 'min_length': 2},
\ 'listsym_rejected': {'type': type(''), 'default': '-', 'length': 1},
\ 'map_prefix': {'type': type(''), 'default': '<Leader>w'},
\ 'menu': {'type': type(''), 'default': 'Vimwiki'},
\ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'table_mappings': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'toc_header': {'type': type(''), 'default': 'Contents', 'min_length': 1},
\ 'url_maxsave': {'type': type(0), 'default': 15, 'min': 0},
\ 'use_calendar': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'use_mouse': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'user_htmls': {'type': type(''), 'default': ''},
\ 'valid_html_tags': {'type': type(''), 'default':
\ 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em'},
\ 'w32_dir_enc': {'type': type(''), 'default': ''},
\ }
" copy the user's settings from variables of the form g:vimwiki_<option> into the dict
" g:vimwiki_global_vars (or set a default value)
for key in keys(global_settings)
if exists('g:vimwiki_'.key)
let users_value = g:vimwiki_{key}
let value_infos = global_settings[key]
call s:check_users_value(key, users_value, value_infos, 1)
let g:vimwiki_global_vars[key] = users_value
else
let g:vimwiki_global_vars[key] = global_settings[key].default
endif
endfor
" validate some settings individually
let key = 'diary_months'
let users_value = g:vimwiki_global_vars[key]
for month in range(1, 12)
if !has_key(users_value, month) || type(users_value[month]) != type('') ||
\ empty(users_value[month])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
let key = 'ext2syntax'
let users_value = g:vimwiki_global_vars[key]
for ext in keys(users_value)
if empty(ext) || index(['markdown', 'media', 'mediawiki', 'default'], users_value[ext]) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
endfunction
function! s:normalize_global_settings()
let g:vimwiki_global_vars.dir_link =
\ vimwiki#path#file_segment(g:vimwiki_global_vars.dir_link)
let keys = keys(g:vimwiki_global_vars.ext2syntax)
for ext in keys
" ensure the file extensions in ext2syntax start with a dot
if ext[0] != '.'
let new_ext = '.' . ext
let g:vimwiki_global_vars.ext2syntax[new_ext] = g:vimwiki_global_vars.ext2syntax[ext]
call remove(g:vimwiki_global_vars.ext2syntax, ext)
endif
" for convenience, we also allow the term 'mediawiki'
if g:vimwiki_global_vars.ext2syntax[ext] ==# 'mediawiki'
let g:vimwiki_global_vars.ext2syntax[ext] = 'media'
endif
endfor
let new_user_htmls = []
for file_name in split(g:vimwiki_global_vars.user_htmls, ',')
let trimmed = vimwiki#u#trim(file_name)
call add(new_user_htmls, vimwiki#path#file_segment(trimmed))
endfor
let g:vimwiki_global_vars.user_htmls = new_user_htmls
endfunction
function! s:populate_wikilocal_options()
let default_values = {
\ 'auto_diary_index': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_export': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_tags': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'auto_toc': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'automatic_nested_syntaxes': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'css_name': {'type': type(''), 'default': 'style.css', 'min_length': 1},
\ 'custom_wiki2html': {'type': type(''), 'default': ''},
\ 'custom_wiki2html_args': {'type': type(''), 'default': ''},
\ 'diary_header': {'type': type(''), 'default': 'Diary', 'min_length': 1},
\ 'diary_index': {'type': type(''), 'default': 'diary', 'min_length': 1},
\ 'diary_rel_path': {'type': type(''), 'default': 'diary/', 'min_length': 1},
\ 'diary_sort': {'type': type(''), 'default': 'desc', 'possible_values': ['asc', 'desc']},
\ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1},
\ 'index': {'type': type(''), 'default': 'index', 'min_length': 1},
\ 'list_margin': {'type': type(0), 'default': -1, 'min': -1},
\ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'nested_syntaxes': {'type': type({}), 'default': {}},
\ 'path': {'type': type(''), 'default': $HOME . '/vimwiki/', 'min_length': 1},
\ 'path_html': {'type': type(''), 'default': ''},
\ 'syntax': {'type': type(''), 'default': 'default',
\ 'possible_values': ['default', 'markdown', 'media', 'mediawiki']},
\ 'template_default': {'type': type(''), 'default': 'default', 'min_length': 1},
\ 'template_ext': {'type': type(''), 'default': '.tpl'},
\ 'template_path': {'type': type(''), 'default': $HOME . '/vimwiki/templates/'},
\ 'auto_diary_index': 0,
\ 'auto_export': 0,
\ 'auto_tags': 0,
\ 'auto_toc': 0,
\ 'automatic_nested_syntaxes': 1,
\ 'css_name': 'style.css',
\ 'custom_wiki2html': '',
\ 'custom_wiki2html_args': '',
\ 'diary_header': 'Diary',
\ 'diary_index': 'diary',
\ 'diary_rel_path': 'diary/',
\ 'diary_sort': 'desc',
\ 'ext': '.wiki',
\ 'index': 'index',
\ 'list_margin': -1,
\ 'maxhi': 0,
\ 'nested_syntaxes': {},
\ 'path': $HOME . '/vimwiki/',
\ 'path_html': '',
\ 'syntax': 'default',
\ 'template_default': 'default',
\ 'template_ext': '.tpl',
\ 'template_path': $HOME . '/vimwiki/templates/',
\ 'bullet_types': [],
\ 'listsyms': vimwiki#vars#get_global("listsyms"),
\ 'listsym_rejected': vimwiki#vars#get_global("listsym_rejected"),
\ }
let g:vimwiki_wikilocal_vars = []
@@ -281,10 +214,9 @@ function! s:populate_wikilocal_options()
let default_wiki_settings = {}
for key in keys(default_values)
if exists('g:vimwiki_'.key)
call s:check_users_value(key, g:vimwiki_{key}, default_values[key], 1)
let default_wiki_settings[key] = g:vimwiki_{key}
else
let default_wiki_settings[key] = default_values[key].default
let default_wiki_settings[key] = default_values[key]
endif
endfor
@@ -294,10 +226,11 @@ function! s:populate_wikilocal_options()
let new_wiki_settings = {}
for key in keys(default_values)
if has_key(users_wiki_settings, key)
call s:check_users_value(key, users_wiki_settings[key], default_values[key], 0)
let new_wiki_settings[key] = users_wiki_settings[key]
elseif exists('g:vimwiki_'.key)
let new_wiki_settings[key] = g:vimwiki_{key}
else
let new_wiki_settings[key] = default_wiki_settings[key]
let new_wiki_settings[key] = default_values[key]
endif
endfor
@@ -316,108 +249,37 @@ function! s:populate_wikilocal_options()
let temporary_wiki_settings = deepcopy(default_wiki_settings)
let temporary_wiki_settings.is_temporary_wiki = 1
call add(g:vimwiki_wikilocal_vars, temporary_wiki_settings)
" check some values individually
let key = 'nested_syntaxes'
for wiki_settings in g:vimwiki_wikilocal_vars
let users_value = wiki_settings[key]
for keyword in keys(users_value)
if type(keyword) != type('') || empty(keyword) || type(users_value[keyword]) != type('') ||
\ empty(users_value[keyword])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
break
endif
endfor
" Set up variables for the lists, depending on config and syntax
for wiki in g:vimwiki_wikilocal_vars
if len(wiki.bullet_types) == 0
let wiki.bullet_types = vimwiki#vars#get_syntaxlocal('bullet_types', wiki.syntax)
endif
call vimwiki#vars#populate_list_vars(wiki)
endfor
call s:normalize_wikilocal_settings()
call s:validate_settings()
endfunction
function! s:check_users_value(key, users_value, value_infos, comes_from_global_variable)
let type_code_to_name = {
\ type(0): 'number',
\ type(''): 'string',
\ type([]): 'list',
\ type({}): 'dictionary'}
let setting_origin = a:comes_from_global_variable ?
\ printf('''g:vimwiki_%s''', a:key) :
\ printf('''%s'' in g:vimwiki_list', a:key)
if has_key(a:value_infos, 'type') && type(a:users_value) != a:value_infos.type
echom printf('Vimwiki Error: The provided value of the option %s is a %s, ' .
\ 'but expected is a %s. See '':h g:vimwiki_%s''.', setting_origin,
\ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key)
endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'min') &&
\ a:users_value < a:value_infos.min
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
\ . ' too small. The minimum value is %i. See '':h g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.min, a:key)
endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'max') &&
\ a:users_value > a:value_infos.max
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
\ . ' too large. The maximum value is %i. See '':h g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.max, a:key)
endif
if has_key(a:value_infos, 'possible_values') &&
\ index(a:value_infos.possible_values, a:users_value) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s is'
\ . ' invalid. Allowed values are %s. See ''g:vimwiki_%s''.', a:users_value,
\ setting_origin, string(a:value_infos.possible_values), a:key)
endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'length') &&
\ strwidth(a:users_value) != a:value_infos.length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
\ . ' contain exactly %i character(s) but has %i. See '':h g:vimwiki_%s''.',
\ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key)
endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'min_length') &&
\ strwidth(a:users_value) < a:value_infos.min_length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
\ . ' have at least %d character(s) but has %d. See '':h g:vimwiki_%s''.', a:users_value,
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key)
endif
endfunction
function! s:normalize_wikilocal_settings()
function! s:validate_settings()
for wiki_settings in g:vimwiki_wikilocal_vars
let wiki_settings.css_name = vimwiki#path#file_segment(wiki_settings.css_name)
let wiki_settings.custom_wiki2html = vimwiki#path#file_object(wiki_settings.custom_wiki2html)
let wiki_settings['path'] = vimwiki#path#dir_obj(wiki_settings['path'])
let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
let path_html = wiki_settings['path_html']
if !empty(path_html)
let wiki_settings['path_html'] = vimwiki#path#dir_obj(path_html)
let wiki_settings['path_html'] = s:normalize_path(path_html)
else
let wiki_settings['path_html'] = vimwiki#path#append_to_dirname(wiki_settings['path'],
\ '_html')
let wiki_settings['path_html'] = s:normalize_path(
\ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/')
endif
let wiki_settings['template_path'] = vimwiki#path#dir_obj(wiki_settings['template_path'])
let wiki_settings['diary_path'] = vimwiki#path#join_dir(wiki_settings['path'],
\ vimwiki#path#dir_segment(wiki_settings['diary_rel_path']))
let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path'])
let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path'])
let ext = wiki_settings['ext']
if !empty(ext) && ext[0] != '.'
let wiki_settings['ext'] = '.' . ext
endif
" for convenience, we also allow the term 'mediawiki'
if wiki_settings.syntax ==# 'mediawiki'
let wiki_settings.syntax = 'media'
endif
endfor
endfunction
@@ -491,20 +353,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
let g:vimwiki_syntax_variables[a:syntax].rxMathEnd =
\ '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$'
" list stuff
let g:vimwiki_syntax_variables[a:syntax].rx_bullet_chars =
\ '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+'
let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars =
\ g:vimwiki_syntax_variables[a:syntax].recurring_bullets
\ ? g:vimwiki_syntax_variables[a:syntax].bullet_types : []
let g:vimwiki_syntax_variables[a:syntax].number_kinds = []
let g:vimwiki_syntax_variables[a:syntax].number_divisors = ''
for i in g:vimwiki_syntax_variables[a:syntax].number_types
call add(g:vimwiki_syntax_variables[a:syntax].number_kinds, i[0])
let g:vimwiki_syntax_variables[a:syntax].number_divisors .= vimwiki#u#escape(i[1])
endfor
let char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+',
\ 'a': '\l\{1,2}', 'A': '\u\{1,2}'}
@@ -536,36 +384,6 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '$^'
endif
"the user can set the listsyms as string, but vimwiki needs a list
let g:vimwiki_syntax_variables[a:syntax].listsyms_list =
\ split(vimwiki#vars#get_global('listsyms'), '\zs')
if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1
echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected ('''
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ''') must not be a part of g:vimwiki_listsyms (''' .
\ . vimwiki#vars#get_global('listsyms') . ''')'
endif
let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB =
\ '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\('
\ .g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s'
let g:vimwiki_syntax_variables[a:syntax].rxListItem =
\ g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB
\ . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms')
\ . vimwiki#vars#get_global('listsym_rejected').']\)\]\s\)\?'
if g:vimwiki_syntax_variables[a:syntax].recurring_bullets
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
\ '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\[['
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1]
\ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\%('
\ .g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*'
else
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren =
\ '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|'
\ . g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\[['
\ . g:vimwiki_syntax_variables[a:syntax].listsyms_list[-1]
\ . vimwiki#vars#get_global('listsym_rejected') . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
endif
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
@@ -614,6 +432,63 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
endfunction
function! vimwiki#vars#populate_list_vars(wiki)
let syntax = a:wiki.syntax
let a:wiki.rx_bullet_char = '['.escape(join(a:wiki.bullet_types, ''), ']^-\').']'
let a:wiki.rx_bullet_chars = a:wiki.rx_bullet_char.'\+'
let recurring_bullets = vimwiki#vars#get_syntaxlocal('recurring_bullets')
let rxListNumber = vimwiki#vars#get_syntaxlocal('rxListNumber')
let a:wiki.multiple_bullet_chars =
\ recurring_bullets
\ ? a:wiki.bullet_types : []
"create regexp for bulleted list items
if !empty(a:wiki.bullet_types)
let rxListBullet =
\ join( map(a:wiki.bullet_types,
\'vimwiki#u#escape(v:val).'
\ .'repeat("\\+", recurring_bullets)'
\ ) , '\|')
else
"regex that matches nothing
let rxListBullet = '$^'
endif
"the user can set the listsyms as string, but vimwiki needs a list
let a:wiki.listsyms_list = split(a:wiki.listsyms, '\zs')
if match(a:wiki.listsyms, a:wiki.listsym_rejected) != -1
echomsg 'Vimwiki Warning: the value of listsym_rejected ('''
\ . a:wiki.listsym_rejected . ''') must not be a part of listsyms ('''
\ . a:wiki.listsyms . ''')'
endif
let a:wiki.rxListItemWithoutCB =
\ '^\s*\%(\('.rxListBullet.'\)\|\('
\ .rxListNumber.'\)\)\s'
let a:wiki.rxListItem =
\ a:wiki.rxListItemWithoutCB
\ . '\+\%(\[\(['.a:wiki.listsyms
\ . a:wiki.listsym_rejected.']\)\]\s\)\?'
if recurring_bullets
let a:wiki.rxListItemAndChildren =
\ '^\('.rxListBullet.'\)\s\+\[['
\ . a:wiki.listsyms_list[-1]
\ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\%('
\ .rxListBullet.'\).*\|^$\|\s.*\)\)*'
else
let a:wiki.rxListItemAndChildren =
\ '^\(\s*\)\%('.rxListBullet.'\|'
\ . rxListNumber.'\)\s\+\[['
\ . a:wiki.listsyms_list[-1]
\ . a:wiki.listsym_rejected . ']\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
endif
endfunction
function! s:populate_extra_markdown_vars()
let mkd_syntax = g:vimwiki_syntax_variables['markdown']
@@ -789,10 +664,15 @@ function! vimwiki#vars#get_bufferlocal(key, ...)
if type(value) != 1 || value !=# '/\/\'
return value
elseif a:key ==# 'wiki_nr'
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(vimwiki#path#current_file()))
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
elseif a:key ==# 'subdir'
call setbufvar(buffer, 'vimwiki_subdir', vimwiki#base#current_subdir())
elseif a:key ==# 'invsubdir'
let subdir = vimwiki#vars#get_bufferlocal('subdir')
call setbufvar(buffer, 'vimwiki_invsubdir', vimwiki#base#invsubdir(subdir))
elseif a:key ==# 'existing_wikifiles'
call setbufvar(buffer, 'vimwiki_existing_wikifiles',
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0, 1))
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 1))
elseif a:key ==# 'existing_wikidirs'
call setbufvar(buffer, 'vimwiki_existing_wikidirs',
\ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr')))
@@ -849,7 +729,7 @@ function! vimwiki#vars#add_temporary_wiki(settings)
let new_temp_wiki_settings[key] = value
endfor
call insert(g:vimwiki_wikilocal_vars, new_temp_wiki_settings, -1)
call s:normalize_wikilocal_settings()
call s:validate_settings()
endfunction
+60 -8
View File
@@ -1656,7 +1656,7 @@ parent items: >
Parent items should change when their child items change. If not, use
|vimwiki_glr|. The symbol between [ ] depends on the percentage of toggled
child items (see also |g:vimwiki_listsyms|): >
child items (see also |vimwiki-listsyms|): >
[ ] -- 0%
[.] -- 1-33%
[o] -- 34-66%
@@ -2284,6 +2284,53 @@ Note: if you use MediaWiki syntax, you probably would like to set this option
to 0, because every indented line is considered verbatim text.
*vimwiki-bullet_types*
------------------------------------------------------------------------------
Key Default value~
bullet_types ['-', '*', '#'] (default-syntax)
['-', '*', '+'] (markdown-syntax)
['*', '#'] (mediawiki-syntax)
List of the characters that can be used as bullets of lists. The default value
depends on the chosen syntax.
You can set it to include more fancy symbols like this:
>
let g:vimwiki_list = [{'path': '~/path/', 'bullet_types' = ['-', '•', '→']}]
*vimwiki-listsyms*
------------------------------------------------------------------------------
Key Default value~
listsyms ' .oOX'
String of at least two symbols to show the progression of todo list items.
Default value is ' .oOX'. This overwrites the global |g:vimwiki_listsyms| on a
per wiki base.
The first char is for 0% done items.
The last is for 100% done items.
You can set it to some more fancy symbols like this:
>
let g:vimwiki_list = [{'path': '~/path/', 'listsyms' = '✗○◐●✓'}]
*vimwiki-listsym_rejected*
------------------------------------------------------------------------------
Character that is used to show that an item of a todo list will not be done.
Default value is '-'. This overwrites the global |g:vimwiki_listsym_rejected| on a
per wiki base.
The character used here must not be part of |vimwiki-listsyms|.
You can set it to a more fancy symbol like this:
>
let g:vimwiki_list = [{'path': '~/path/', 'listsym_rejected' = '✗'}]
*vimwiki-option-auto_tags*
------------------------------------------------------------------------------
Key Default value Values~
@@ -2409,7 +2456,8 @@ Default: 'Vimwiki'
*g:vimwiki_listsyms*
String of at least two symbols to show the progression of todo list items.
Default value is ' .oOX'.
Default value is ' .oOX'. You can also set this on a per-wiki level with
|vimwiki-listsyms|.
The first char is for 0% done items.
The last is for 100% done items.
@@ -2423,7 +2471,9 @@ You can set it to some more fancy symbols like this:
*g:vimwiki_listsym_rejected*
Character that is used to show that an item of a todo list will not be done.
Default value is '-'.
Default value is '-'. You can also set this on a per-wiki level with
|vimwiki-listsym_rejected|.
The character used here must not be part of |g:vimwiki_listsyms|.
@@ -2548,11 +2598,11 @@ A second example handles a new scheme, "vfile:", which behaves similar to
return 0
endif
let link_infos = vimwiki#base#resolve_link(link)
if link_infos.is_file == -1
if link_infos.filename == ''
echomsg 'Vimwiki Error: Unable to resolve link!'
return 0
else
exe 'tabnew ' . fnameescape(vimwiki#path#to_string(link_infos.target))
exe 'tabnew ' . fnameescape(link_infos.filename)
return 1
endif
endfunction
@@ -2577,12 +2627,11 @@ right place. >
function! VimwikiLinkConverter(link, source_wiki_file, target_html_file)
if a:link =~# '^local:'
let link_infos = vimwiki#base#resolve_link(a:link)
let target_file = vimwiki#path#to_string(link_infos.target)
let html_link = vimwiki#path#relpath(
\ fnamemodify(a:source_wiki_file, ':h'), target_file)
\ fnamemodify(a:source_wiki_file, ':h'), link_infos.filename)
let relative_link =
\ fnamemodify(a:target_html_file, ':h') . '/' . html_link
call system('cp ' . fnameescape(target_file) .
call system('cp ' . fnameescape(link_infos.filename) .
\ ' ' . fnameescape(relative_link))
return html_link
endif
@@ -2992,6 +3041,9 @@ New:~
* glx on a list item marks a checkbox as won't do, see |vimwiki_glx|.
* Add the option |g:vimwiki_listsym_rejected| to set the character used
for won't-do list items.
* The effect of |g:vimwiki_listsyms| and |g:vimwiki_listsym_rejected| can
be set on a per wiki level, see |vimwiki-listsyms| and
|vimwili-listsym_rejected|
* gln and glp change the "done" status of a checkbox, see |vimwiki_gln|.
* |:VimwikiSplitLink| and |:VimwikiVSplitLink| can now reuse an existing
split window and not move the cursor.
+19 -21
View File
@@ -19,7 +19,7 @@ endif
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
setlocal isfname-=[,]
exe "setlocal tags+=" . escape(vimwiki#path#to_string(vimwiki#tags#metadata_file_path()), ' \|"')
exe "setlocal tags+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"')
@@ -68,22 +68,19 @@ function! Complete_wikifiles(findstart, base)
if wikinumber >= vimwiki#vars#number_of_wikis()
return []
endif
let diary = 0
let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*')
let scheme = matchstr(a:base, '\m^wiki\d\+:\ze')
elseif a:base =~# '^diary:'
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
let diary = 1
let wikinumber = -1
let prefix = matchstr(a:base, '^diary:\zs.*')
let scheme = matchstr(a:base, '^diary:\ze')
else " current wiki
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
let diary = 0
let prefix = a:base
let scheme = ''
endif
let links = vimwiki#base#get_wikilinks(wikinumber, diary, 1)
let links = vimwiki#base#get_wikilinks(wikinumber, 1)
let result = []
for wikifile in links
if wikifile =~ '^'.vimwiki#u#escape(prefix)
@@ -96,11 +93,9 @@ function! Complete_wikifiles(findstart, base)
" we look for anchors in the given wikifile
let segments = split(a:base, '#', 1)
let given_wikifile = segments[0] == '' ?
\ vimwiki#path#filename_without_extension(vimwiki#path#current_file())
\ : segments[0]
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
let wikifile = link_infos.target
let wikifile = link_infos.filename
let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index)
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
@@ -132,7 +127,7 @@ setlocal formatoptions-=o
setlocal formatoptions-=2
setlocal formatoptions+=n
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem')
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
@@ -242,18 +237,19 @@ endfunction
command! -buffer Vimwiki2HTML
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ let res = vimwiki#html#Wiki2HTML(vimwiki#path#current_file())
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
\ <bar>
\ if !vimwiki#path#is_null(res) | echo 'Vimwiki: HTML conversion is done, output: '
\ . vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path_html')) | endif
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
command! -buffer Vimwiki2HTMLBrowse
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ let result = vimwiki#html#Wiki2HTML(vimwiki#path#current_file())
\ <bar>
\ if !vimwiki#path#is_null(result) | call vimwiki#base#system_open_link(result) | endif
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%')))
command! -buffer VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML()
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')))
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
@@ -276,10 +272,10 @@ command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
\ escape(vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path')).'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
\ escape(vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path')).'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
command! -buffer -nargs=+ -complete=custom,vimwiki#base#complete_links_escaped
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
@@ -681,7 +677,9 @@ nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader :
if vimwiki#vars#get_wikilocal('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer> call vimwiki#html#Wiki2HTML(vimwiki#path#current_file())
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
augroup END
endif
+7 -8
View File
@@ -31,7 +31,7 @@ function! s:setup_buffer_leave()
let &autowriteall = s:vimwiki_autowriteall_saved
if !empty(vimwiki#vars#get_global('menu'))
if vimwiki#vars#get_global('menu') != ""
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
@@ -39,9 +39,8 @@ endfunction
" create a new temporary wiki for the current buffer
function! s:create_temporary_wiki()
let current_file = vimwiki#path#current_file()
let path = vimwiki#path#directory_of_file(current_file)
let ext = '.'.vimwiki#path#extension(current_file)
let path = expand('%:p:h')
let ext = '.'.expand('%:e')
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
if has_key(syntax_mapping, ext)
@@ -148,7 +147,7 @@ function! s:set_global_options()
let s:vimwiki_autowriteall_saved = &autowriteall
let &autowriteall = vimwiki#vars#get_global('autowriteall')
if !empty(vimwiki#vars#get_global('menu'))
if vimwiki#vars#get_global('menu') !=# ''
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
endif
endfunction
@@ -184,7 +183,7 @@ function! s:set_windowlocal_options()
endif
if vimwiki#vars#get_global('auto_chdir')
exe 'lcd' vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path'))
exe 'lcd' vimwiki#vars#get_wikilocal('path')
endif
endfunction
@@ -339,8 +338,8 @@ nnoremap <unique><script> <Plug>VimwikiMakeTomorrowDiaryNote
function! s:build_menu(topmenu)
for idx in range(vimwiki#vars#number_of_wikis())
let norm_path = vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path', idx))
let norm_path = escape(norm_path, '\ .')
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ \.')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#base#goto_index('.(idx+1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
+5 -5
View File
@@ -253,18 +253,18 @@ syntax match VimwikiCellSeparator
" Lists
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_wikilocal('rxListItemWithoutCB').'/'
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_wikilocal('rxListItem').'/'
if vimwiki#vars#get_global('hl_cb_checked') == 1
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
\ . '\s*\[['.vimwiki#vars#get_syntaxlocal('listsyms_list')[-1]
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_wikilocal('rxListItemWithoutCB')
\ . '\s*\[['.vimwiki#vars#get_wikilocal('listsyms_list')[-1]
\ . vimwiki#vars#get_global('listsym_rejected')
\ . ']\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
execute 'syntax match VimwikiCheckBoxDone /'
\ . vimwiki#vars#get_syntaxlocal('rxListItemAndChildren')
\ . vimwiki#vars#get_wikilocal('rxListItemAndChildren')
\ .'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
endif