pull in vimwiki 2.1 from vim.org
This commit is contained in:
@ -166,9 +166,9 @@ function! vimwiki#base#validate_wiki_options(idx) " {{{ Validate wiki options
|
||||
" update normalized path & path_html
|
||||
call VimwikiSet('path', s:normalize_path(VimwikiGet('path', a:idx)), a:idx)
|
||||
call VimwikiSet('path_html', s:normalize_path(s:path_html(a:idx)), a:idx)
|
||||
call VimwikiSet('template_path',
|
||||
call VimwikiSet('template_path',
|
||||
\ 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)
|
||||
|
||||
" XXX: It's too early to update global / buffer variables, because they are
|
||||
@ -236,7 +236,7 @@ endfunction "}}}
|
||||
|
||||
" vimwiki#base#mkdir
|
||||
" 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, ...) "{{{
|
||||
let path = expand(a:path)
|
||||
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
|
||||
" encounter (e.g. filesystem, wiki conventions, other syntaxes, ...).
|
||||
" 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 ...
|
||||
" e.g. "File$", "^File", "Fi]le", "Fi[le", "Fi\le", "Fi/le"
|
||||
" 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 is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl
|
||||
let lnk = (is_schemeless ? 'wiki'.g:vimwiki_current_idx.':'.lnk : lnk)
|
||||
|
||||
|
||||
" Get scheme
|
||||
let scheme = matchstr(lnk, g:vimwiki_rxSchemeUrlMatchScheme)
|
||||
" Get link (without scheme)
|
||||
@ -328,7 +328,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
let idx = -1
|
||||
|
||||
" do nothing if scheme is unknown to vimwiki
|
||||
if !(scheme =~ 'wiki.*' || scheme =~ 'diary' || scheme =~ 'local'
|
||||
if !(scheme =~ 'wiki.*' || scheme =~ 'diary' || scheme =~ 'local'
|
||||
\ || scheme =~ 'file')
|
||||
return [idx, scheme, path, subdir, lnk, ext, scheme.':'.lnk]
|
||||
endif
|
||||
@ -441,10 +441,10 @@ function! vimwiki#base#system_open_link(url) "{{{
|
||||
execute '!open ' . shellescape(a:url, 1)
|
||||
endfunction
|
||||
function! s:linux_handler(url)
|
||||
execute 'silent !xdg-open ' . shellescape(a:url, 1)
|
||||
call system('xdg-open ' . shellescape(a:url, 1).' &')
|
||||
endfunction
|
||||
let success = 0
|
||||
try
|
||||
try
|
||||
if vimwiki#u#is_windows()
|
||||
call s:win32_handler(a:url)
|
||||
return
|
||||
@ -461,7 +461,7 @@ endfunction "}}}
|
||||
|
||||
" vimwiki#base#open_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)
|
||||
|
||||
if url == ''
|
||||
@ -473,13 +473,13 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
endif
|
||||
|
||||
let update_prev_link = (
|
||||
\ scheme == '' ||
|
||||
\ scheme =~ 'wiki' ||
|
||||
\ scheme == '' ||
|
||||
\ scheme =~ 'wiki' ||
|
||||
\ scheme =~ 'diary' ? 1 : 0)
|
||||
|
||||
let use_system_open = (
|
||||
\ scheme == '' ||
|
||||
\ scheme =~ 'wiki' ||
|
||||
\ scheme == '' ||
|
||||
\ scheme =~ 'wiki' ||
|
||||
\ scheme =~ 'diary' ? 0 : 1)
|
||||
|
||||
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
|
||||
let orig_pwd = getcwd()
|
||||
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"
|
||||
" remove extensions
|
||||
let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\ze\n', '', 'g')
|
||||
@ -549,7 +549,7 @@ endfunction "}}}
|
||||
function! vimwiki#base#backlinks() "{{{
|
||||
execute 'lvimgrep "\%(^\|[[:blank:][:punct:]]\)'.
|
||||
\ expand("%:t:r").
|
||||
\ '\([[:blank:][:punct:]]\|$\)" '.
|
||||
\ '\([[:blank:][:punct:]]\|$\)\C" '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
endfunction "}}}
|
||||
|
||||
@ -560,7 +560,7 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
|
||||
|
||||
let time1 = reltime() " start the clock
|
||||
|
||||
" XXX:
|
||||
" XXX:
|
||||
" if maxhi = 1 and <leader>w<leader>w before loading any vimwiki file
|
||||
" cached 'subdir' is not set up
|
||||
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
|
||||
" not search wiki files in subdirectories. Or it would hang the system if
|
||||
" wiki file was created in $HOME or C:/ dirs.
|
||||
if VimwikiGet('temp')
|
||||
if VimwikiGet('temp')
|
||||
let search_dirs = ''
|
||||
else
|
||||
let search_dirs = '**/'
|
||||
endif
|
||||
" let globlinks = "\n".glob(VimwikiGet('path').search_dirs.a:pat,1)."\n"
|
||||
|
||||
|
||||
"save pwd, do lcd %:h, restore old pwd; getcwd()
|
||||
" change to the directory of the current file
|
||||
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_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
|
||||
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"
|
||||
" remove extensions
|
||||
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
|
||||
" for directories: add ./ (instead of now empty) and invsubdir (if distinct)
|
||||
if a:pat == '*/'
|
||||
let globlinks = substitute(globlinks, "\n\n", "\n./\n",'')
|
||||
let globlinks = substitute(globlinks, "\n\n", "\n./\n",'')
|
||||
if invsubdir != ''
|
||||
let globlinks .= invsubdir."\n"
|
||||
else
|
||||
@ -639,7 +639,7 @@ function! vimwiki#base#edit_file(command, filename, ...) "{{{
|
||||
" then
|
||||
" [[test*file]]...
|
||||
" 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")
|
||||
if vimwiki#base#mkdir(dir, 1)
|
||||
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 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', '.*', '').
|
||||
\ '\|'. vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
\ '\|'. vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
\ '\zs'.old_fname.'\ze', '.*', '')
|
||||
|
||||
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)
|
||||
let dir = dirs_keys[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)
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
@ -872,12 +872,12 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{
|
||||
" regular one.
|
||||
" 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
|
||||
" included as 'contained' into specific group.
|
||||
" included as 'contained' into specific group.
|
||||
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
|
||||
" the rest syntax rules as now it has effect being really 'contained'.
|
||||
" Clear it!
|
||||
if ft =~ 'perl'
|
||||
syntax clear perlFunctionName
|
||||
syntax clear perlFunctionName
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
@ -895,7 +895,7 @@ function! vimwiki#base#find_prev_link() "{{{
|
||||
endfunction " }}}
|
||||
|
||||
" 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
|
||||
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#follow_link')
|
||||
" Syntax-specific links
|
||||
@ -941,7 +941,7 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
|
||||
|
||||
if a:0 > 0
|
||||
execute "normal! ".a:1
|
||||
else
|
||||
else
|
||||
call vimwiki#base#normalize_link(0)
|
||||
endif
|
||||
endif
|
||||
@ -1051,7 +1051,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
if url != ''
|
||||
let new_link = url
|
||||
endif
|
||||
|
||||
|
||||
let new_link = subdir.new_link
|
||||
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')
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
let sel_start = line("'<")
|
||||
let sel_end = 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 is_header_selected = sel_start == block_start
|
||||
let is_header_selected = sel_start == block_start
|
||||
\ && sel_start != sel_end
|
||||
|
||||
if a:visual && is_header_selected
|
||||
@ -1374,7 +1374,7 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
call setline(lnum, line)
|
||||
endif
|
||||
else
|
||||
let line = substitute(line, '^\s*', '&'.rxHdr.' ', '')
|
||||
let line = substitute(line, '^\s*', '&'.rxHdr.' ', '')
|
||||
if g:vimwiki_symH
|
||||
let line = substitute(line, '\s*$', ' '.rxHdr.'&', '')
|
||||
endif
|
||||
@ -1427,7 +1427,7 @@ function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
|
||||
let magic_chars = '.*[\^$'
|
||||
let lnk = escape(a:template, magic_chars)
|
||||
if a:rxUrl != ""
|
||||
let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", '')
|
||||
let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", '')
|
||||
endif
|
||||
if a:rxDesc != ""
|
||||
let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", '')
|
||||
@ -1492,7 +1492,7 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
" try WikiIncl
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
|
||||
if !empty(lnk)
|
||||
@ -1567,7 +1567,7 @@ endfunction "}}}
|
||||
" Load syntax-specific Wiki functionality
|
||||
for syn in vimwiki#base#get_known_syntaxes()
|
||||
execute 'runtime! autoload/vimwiki/'.syn.'_base.vim'
|
||||
endfor
|
||||
endfor
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -4,7 +4,15 @@
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" 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 {{{
|
||||
if exists("g:loaded_vimwiki_html_auto") || &cp
|
||||
@ -137,22 +145,12 @@ endfunction "}}}
|
||||
|
||||
function! s:safe_html(line) "{{{
|
||||
" escape & < > when producing HTML text
|
||||
" uses variables s:lt_pattern, s:gt_pattern that are
|
||||
" set in vimwiki#html#Wiki2HTML() according to g:vimwiki_valid_html_tags
|
||||
"" htmlize symbols: < > &
|
||||
|
||||
" s:lt_pattern, s:gt_pattern depend on g:vimwiki_valid_html_tags
|
||||
" and are set in vimwiki#html#Wiki2HTML()
|
||||
let line = substitute(a:line, '&', '\&', 'g')
|
||||
" the following depends on g:vimwiki_valid_html_tags
|
||||
let line = substitute(line,s:lt_pattern,'\<', 'g')
|
||||
let line = substitute(line,s:gt_pattern,'\>', 'g')
|
||||
|
||||
"let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
"let line = substitute(line,'<\%(/\?\%('
|
||||
" \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!',
|
||||
" \'\<', 'g')
|
||||
"let line = substitute(line,'\%(</\?\%('
|
||||
" \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>',
|
||||
" \'\>', 'g')
|
||||
return line
|
||||
endfunction "}}}
|
||||
|
||||
@ -379,8 +377,8 @@ function! vimwiki#html#linkify_link(src, descr) "{{{
|
||||
let src_str = ' href="'.a:src.'"'
|
||||
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
|
||||
let descr = (descr == "" ? a:src : descr)
|
||||
let descr_str = (descr =~ g:vimwiki_rxWikiIncl
|
||||
\ ? s:tag_wikiincl(descr)
|
||||
let descr_str = (descr =~ g:vimwiki_rxWikiIncl
|
||||
\ ? s:tag_wikiincl(descr)
|
||||
\ : descr)
|
||||
return '<a'.src_str.'>'.descr_str.'</a>'
|
||||
endfunction "}}}
|
||||
@ -415,7 +413,7 @@ function! s:tag_wikiincl(value) "{{{
|
||||
let descr = matchstr(str, vimwiki#html#incl_match_arg(1))
|
||||
let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2))
|
||||
" 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)
|
||||
" generate html output
|
||||
" 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)
|
||||
|
||||
" resolve url
|
||||
let [idx, scheme, path, subdir, lnk, ext, url] =
|
||||
let [idx, scheme, path, subdir, lnk, ext, url] =
|
||||
\ vimwiki#base#resolve_scheme(url, 1)
|
||||
|
||||
" generate html output
|
||||
@ -456,11 +454,10 @@ function! s:tag_wikilink(value) "{{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '[[idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.']]'
|
||||
endif
|
||||
let url = escape(url, '#')
|
||||
let line = vimwiki#html#linkify_link(url, descr)
|
||||
return line
|
||||
endfunction "}}}
|
||||
"}}} v1.3 links
|
||||
"}}}
|
||||
|
||||
|
||||
function! s:tag_remove_internal_link(value) "{{{
|
||||
@ -511,7 +508,7 @@ endfunction "}}}
|
||||
function! s:make_tag(line, regexp, func) "{{{
|
||||
" Make tags for a given matched regexp.
|
||||
" Exclude preformatted text and href links.
|
||||
" FIXME
|
||||
" FIXME
|
||||
let patt_splitter = '\(`[^`]\+`\)\|'.
|
||||
\ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'.
|
||||
\ '\(<a href.\{-}</a>\)\|'.
|
||||
@ -612,7 +609,7 @@ endfunction "}}}
|
||||
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 rest elements are rows which are lists of columns:
|
||||
" ['center',
|
||||
" ['center',
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
@ -623,7 +620,7 @@ function! s:close_tag_table(table, ldest) "{{{
|
||||
let table = a:table
|
||||
|
||||
" Get max cells
|
||||
let max_cells = 0
|
||||
let max_cells = 0
|
||||
for row in table[1:]
|
||||
let n_cells = len(row)
|
||||
if n_cells > max_cells
|
||||
@ -669,14 +666,14 @@ function! s:close_tag_table(table, ldest) "{{{
|
||||
function! s:close_tag_row(row, header, ldest) "{{{
|
||||
call add(a:ldest, '<tr>')
|
||||
|
||||
" Set tag element of columns
|
||||
" Set tag element of columns
|
||||
if a:header
|
||||
let tag_name = 'th'
|
||||
else
|
||||
let tag_name = 'td'
|
||||
end
|
||||
|
||||
" Close tag of columns
|
||||
" Close tag of columns
|
||||
for cell in a:row
|
||||
if cell.rowspan == 0 || cell.colspan == 0
|
||||
continue
|
||||
@ -859,7 +856,7 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
endif
|
||||
" let completion = match(g:vimwiki_listsyms, '\C' . 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.'">'
|
||||
endif
|
||||
endif
|
||||
@ -1028,7 +1025,7 @@ function! s:process_tag_h(line, id) "{{{
|
||||
let h_text = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
|
||||
|
||||
if g:vimwiki_html_header_numbering
|
||||
let num = matchstr(h_number,
|
||||
let num = matchstr(h_number,
|
||||
\ '^\(\d.\)\{'.(g:vimwiki_html_header_numbering-1).'}\zs.*')
|
||||
if !empty(num)
|
||||
let num .= g:vimwiki_html_header_numbering_sym
|
||||
@ -1352,13 +1349,17 @@ endfunction " }}}
|
||||
|
||||
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
|
||||
call vimwiki#base#mkdir(a:path)
|
||||
execute '!'.VimwikiGet('custom_wiki2html'). ' '
|
||||
echomsg system(VimwikiGet('custom_wiki2html'). ' '.
|
||||
\ a:force. ' '.
|
||||
\ VimwikiGet('syntax'). ' '.
|
||||
\ strpart(VimwikiGet('ext'), 1). ' '.
|
||||
\ a:path. ' '.
|
||||
\ a:wikifile. ' '.
|
||||
\ s:default_CSS_full_name(a:path)
|
||||
\ shellescape(a:path, 1). ' '.
|
||||
\ shellescape(a:wikifile, 1). ' '.
|
||||
\ 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 " }}}
|
||||
|
||||
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 path_html = expand(a:path_html).VimwikiGet('subdir')
|
||||
let path_html = expand(a:path_html).VimwikiGet('subdir')
|
||||
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
|
||||
|
||||
if s:use_custom_wiki2html()
|
||||
@ -1415,8 +1416,8 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
let s:gt_pattern = '>'
|
||||
if g:vimwiki_valid_html_tags != ''
|
||||
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
let s:lt_pattern = '<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
|
||||
let s:gt_pattern = '\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
|
||||
let s:lt_pattern = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
|
||||
let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
|
||||
endif
|
||||
|
||||
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")')
|
||||
|
||||
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
|
||||
|
||||
|
||||
"" make html file.
|
||||
call writefile(html_lines, path_html.htmlfile)
|
||||
let done = 1
|
||||
@ -1499,7 +1500,7 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
" measure the elapsed time
|
||||
" measure the elapsed time
|
||||
let time1 = vimwiki#u#time(starttime) "XXX
|
||||
call VimwikiLog_extend('html',[htmlfile,time1])
|
||||
"if g:vimwiki_debug
|
||||
@ -1566,7 +1567,7 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:file_exists(fname) "{{{
|
||||
return !empty(getftype(a:fname))
|
||||
return !empty(getftype(expand(a:fname)))
|
||||
endfunction "}}}
|
||||
|
||||
" uses VimwikiGet('path')
|
||||
|
@ -183,7 +183,7 @@ function! s:get_child_items(lnum) "{{{
|
||||
call add(result, lnum)
|
||||
let lnum = s:next_list_item(lnum)
|
||||
endwhile
|
||||
|
||||
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
@ -207,7 +207,7 @@ function! s:get_sibling_items(lnum) "{{{
|
||||
endif
|
||||
let lnum = s:prev_list_item(lnum)
|
||||
endwhile
|
||||
|
||||
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
@ -407,12 +407,12 @@ function s:get_list_nesting_level(lnum) "{{{
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
if getline(a:lnum) !~ s:rx_list_item()
|
||||
let level = 0
|
||||
else
|
||||
else
|
||||
let level = vimwiki#u#count_first_sym(getline(a:lnum)) - 1
|
||||
let level = level < 0 ? 0 : level
|
||||
endif
|
||||
else
|
||||
let level = indent(a:lnum)
|
||||
let level = indent(a:lnum)
|
||||
endif
|
||||
return level
|
||||
endfunction "}}}
|
||||
@ -477,7 +477,7 @@ function! vimwiki#lst#change_level(...) "{{{
|
||||
let li_bullet_and_content = strpart(line, n_nesting + n_indent)
|
||||
|
||||
" 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())
|
||||
|
||||
" 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
|
||||
|
||||
" change level
|
||||
if cmd == '--'
|
||||
if cmd == '--'
|
||||
let cb_bullet = s:compose_cb_bullet(cb_bullet, sym)
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
let sym_nest = sym
|
||||
endif
|
||||
elseif cmd == '>>'
|
||||
elseif cmd == '>>'
|
||||
if cb_bullet == ''
|
||||
let cb_bullet = sym
|
||||
else
|
||||
let n_nesting = n_nesting + list_sw
|
||||
endif
|
||||
elseif cmd == '<<'
|
||||
elseif cmd == '<<'
|
||||
let n_nesting = n_nesting - list_sw
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
if n_nesting < 0
|
||||
|
@ -21,7 +21,7 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{
|
||||
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
||||
"Ignore it, and move on to the next file
|
||||
endtry
|
||||
"
|
||||
"
|
||||
for d in getqflist()
|
||||
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
|
||||
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
|
||||
@ -108,7 +108,7 @@ endfunction " }}}
|
||||
" vimwiki#base#find_prev_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
|
||||
" echom "markdown_base#follow_link"
|
||||
|
||||
@ -153,7 +153,7 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
|
||||
|
||||
if a:0 > 0
|
||||
execute "normal! ".a:1
|
||||
else
|
||||
else
|
||||
call vimwiki#base#normalize_link(0)
|
||||
endif
|
||||
endif
|
||||
@ -210,7 +210,7 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
" try WikiLink1: replace with WikiLink0
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
|
||||
if !empty(lnk)
|
||||
@ -223,7 +223,7 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
" try Weblink
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
|
||||
if !empty(lnk)
|
||||
|
@ -16,10 +16,13 @@ let g:loaded_vimwiki_tbl_auto = 1
|
||||
"}}}
|
||||
|
||||
let s:textwidth = &tw
|
||||
let s:rxSep = g:vimwiki_rxTableSep
|
||||
|
||||
|
||||
" Misc functions {{{
|
||||
function! s:rxSep() "{{{
|
||||
return g:vimwiki_rxTableSep
|
||||
endfunction "}}}
|
||||
|
||||
function! s:wide_len(str) "{{{
|
||||
" vim73 has new function that gives correct string width.
|
||||
if exists("*strdisplaywidth")
|
||||
@ -43,36 +46,36 @@ function! s:wide_len(str) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:cell_splitter() "{{{
|
||||
return '\s*'.s:rxSep.'\s*'
|
||||
return '\s*'.s:rxSep().'\s*'
|
||||
endfunction "}}}
|
||||
|
||||
function! s:sep_splitter() "{{{
|
||||
return '-'.s:rxSep.'-'
|
||||
return '-'.s:rxSep().'-'
|
||||
endfunction "}}}
|
||||
|
||||
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 "}}}
|
||||
|
||||
function! s:is_separator(line) "{{{
|
||||
return a:line =~ '^\s*'.s:rxSep.'\(--\+'.s:rxSep.'\)\+\s*$'
|
||||
return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
|
||||
endfunction "}}}
|
||||
|
||||
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 "}}}
|
||||
|
||||
function! s:is_last_column(lnum, cnum) "{{{
|
||||
let line = strpart(getline(a:lnum), a:cnum - 1)
|
||||
"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*$'
|
||||
|
||||
"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*$'
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_first_column(lnum, cnum) "{{{
|
||||
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)
|
||||
return line =~ '^\s*$' || (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())
|
||||
endfunction "}}}
|
||||
|
||||
function! s:count_separators_up(lnum) "{{{
|
||||
@ -100,8 +103,8 @@ function! s:count_separators_down(lnum) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:create_empty_row(cols) "{{{
|
||||
let row = s:rxSep
|
||||
let cell = " ".s:rxSep
|
||||
let row = s:rxSep()
|
||||
let cell = " ".s:rxSep()
|
||||
|
||||
for c in range(a:cols)
|
||||
let row .= cell
|
||||
@ -111,8 +114,8 @@ function! s:create_empty_row(cols) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:create_row_sep(cols) "{{{
|
||||
let row = s:rxSep
|
||||
let cell = "---".s:rxSep
|
||||
let row = s:rxSep()
|
||||
let cell = "---".s:rxSep()
|
||||
|
||||
for c in range(a:cols)
|
||||
let row .= cell
|
||||
@ -274,10 +277,10 @@ function! s:cur_column() "{{{
|
||||
" TODO: do we need conditional: if s:is_separator(line)
|
||||
|
||||
let curs_pos = col('.')
|
||||
let mpos = match(line, s:rxSep, 0)
|
||||
let mpos = match(line, s:rxSep(), 0)
|
||||
let col = -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
|
||||
let col += 1
|
||||
endif
|
||||
@ -301,7 +304,7 @@ function! s:fmt_cell(cell, max_len) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
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)
|
||||
for idx in range(len(cells))
|
||||
if idx == a:col1
|
||||
@ -310,12 +313,12 @@ function! s:fmt_row(line, max_lens, col1, col2) "{{{
|
||||
let idx = a:col1
|
||||
endif
|
||||
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
|
||||
|
||||
let idx = len(cells)
|
||||
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
|
||||
endwhile
|
||||
return new_line
|
||||
@ -330,14 +333,14 @@ function! s:fmt_cell_sep(max_len) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
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))
|
||||
if idx == a:col1
|
||||
let idx = a:col2
|
||||
elseif idx == a:col2
|
||||
let idx = a:col1
|
||||
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
|
||||
return new_line
|
||||
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>0"
|
||||
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
|
||||
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
|
||||
let cmd .= "a"
|
||||
|
||||
@ -361,16 +364,16 @@ endfunction "}}}
|
||||
|
||||
function! s:kbd_goto_next_row() "{{{
|
||||
let cmd = "\<ESC>j"
|
||||
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()."\\)', 'c', line('.'))\<CR>"
|
||||
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
|
||||
let cmd .= "a"
|
||||
return cmd
|
||||
endfunction "}}}
|
||||
|
||||
function! s:kbd_goto_prev_row() "{{{
|
||||
let cmd = "\<ESC>k"
|
||||
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()."\\)', 'c', line('.'))\<CR>"
|
||||
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
|
||||
let cmd .= "a"
|
||||
return cmd
|
||||
endfunction "}}}
|
||||
@ -408,7 +411,7 @@ function! vimwiki#tbl#goto_prev_col() "{{{
|
||||
let newcol = s:get_indent(lnum)
|
||||
let max_lens = s:get_cell_max_lens(lnum)
|
||||
let prev_cell_len = 0
|
||||
echom string(max_lens)
|
||||
echom string(max_lens)
|
||||
for cell_len in values(max_lens)
|
||||
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
|
||||
if newcol + delta > curcol-1
|
||||
@ -432,7 +435,7 @@ function! s:kbd_goto_prev_col(jumpup) "{{{
|
||||
let cmd .= "$"
|
||||
endif
|
||||
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"
|
||||
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
|
||||
return cmd
|
||||
@ -487,6 +490,9 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
@ -506,7 +512,7 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
let row = repeat(' ', indent).row
|
||||
call setline(lnum, row)
|
||||
endfor
|
||||
|
||||
|
||||
let &tw = s:textwidth
|
||||
endfunction "}}}
|
||||
|
||||
@ -541,7 +547,7 @@ function! vimwiki#tbl#create(...) "{{{
|
||||
for r in range(rows - 1)
|
||||
call add(lines, row)
|
||||
endfor
|
||||
|
||||
|
||||
call append(line('.'), lines)
|
||||
endfunction "}}}
|
||||
|
||||
@ -554,11 +560,14 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
let s:textwidth = &tw
|
||||
let &tw = 0
|
||||
endfunction "}}}
|
||||
@ -581,17 +590,17 @@ function! vimwiki#tbl#move_column_left() "{{{
|
||||
endif
|
||||
|
||||
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)
|
||||
|
||||
let sep = '\('.s:rxSep.'\).\zs'
|
||||
let sep = '\('.s:rxSep().'\).\zs'
|
||||
let mpos = -1
|
||||
let col = -1
|
||||
while col < cur_col-1
|
||||
let mpos = match(line, sep, mpos+1)
|
||||
if mpos != -1
|
||||
let col += 1
|
||||
else
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
@ -614,17 +623,17 @@ function! vimwiki#tbl#move_column_right() "{{{
|
||||
endif
|
||||
|
||||
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)
|
||||
|
||||
let sep = '\('.s:rxSep.'\).\zs'
|
||||
let sep = '\('.s:rxSep().'\).\zs'
|
||||
let mpos = -1
|
||||
let col = -1
|
||||
while col < cur_col+1
|
||||
let mpos = match(line, sep, mpos+1)
|
||||
if mpos != -1
|
||||
let col += 1
|
||||
else
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
Reference in New Issue
Block a user