Merge remote-tracking branch 'vimwiki/dev' into 'vimwiki/tags'
Conflicts: doc/vimwiki.txt ftplugin/vimwiki.vim
This commit is contained in:
commit
7bc2fcb3a7
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.sw*
|
||||||
|
doc/tags
|
||||||
|
.netrwhist
|
@ -8,26 +8,8 @@ if exists("g:loaded_vimwiki_auto") || &cp
|
|||||||
endif
|
endif
|
||||||
let g:loaded_vimwiki_auto = 1
|
let g:loaded_vimwiki_auto = 1
|
||||||
|
|
||||||
" MISC helper functions {{{
|
" s:vimwiki_get_known_syntaxes
|
||||||
|
function! s:vimwiki_get_known_syntaxes() " {{{
|
||||||
function! vimwiki#base#get_known_extensions() " {{{
|
|
||||||
" Getting all extensions that different wikis could have
|
|
||||||
let extensions = {}
|
|
||||||
for wiki in g:vimwiki_list
|
|
||||||
if has_key(wiki, 'ext')
|
|
||||||
let extensions[wiki.ext] = 1
|
|
||||||
else
|
|
||||||
let extensions['.wiki'] = 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
" append map g:vimwiki_ext2syntax
|
|
||||||
for ext in keys(g:vimwiki_ext2syntax)
|
|
||||||
let extensions[ext] = 1
|
|
||||||
endfor
|
|
||||||
return keys(extensions)
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! vimwiki#base#get_known_syntaxes() " {{{
|
|
||||||
" Getting all syntaxes that different wikis could have
|
" Getting all syntaxes that different wikis could have
|
||||||
let syntaxes = {}
|
let syntaxes = {}
|
||||||
let syntaxes['default'] = 1
|
let syntaxes['default'] = 1
|
||||||
@ -42,7 +24,6 @@ function! vimwiki#base#get_known_syntaxes() " {{{
|
|||||||
endfor
|
endfor
|
||||||
return keys(syntaxes)
|
return keys(syntaxes)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vimwiki#base#apply_wiki_options
|
" vimwiki#base#apply_wiki_options
|
||||||
function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
||||||
@ -90,7 +71,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
|||||||
"
|
"
|
||||||
echo "\nFound file : ".local_wiki_options_filename
|
echo "\nFound file : ".local_wiki_options_filename
|
||||||
let query = "Vimwiki: Check for options in this file [Y]es/[n]o? "
|
let query = "Vimwiki: Check for options in this file [Y]es/[n]o? "
|
||||||
if a:check > 0 && (tolower(input(query)) !~ "y")
|
if a:check > 0 && input(query) =~? '^n')
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
"
|
"
|
||||||
@ -105,7 +86,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
|||||||
if a:check > 0
|
if a:check > 0
|
||||||
echo "\n\nFound wiki options\n g:local_wiki = ".string(g:local_wiki)
|
echo "\n\nFound wiki options\n g:local_wiki = ".string(g:local_wiki)
|
||||||
let query = "Vimwiki: Apply these options [Y]es/[n]o? "
|
let query = "Vimwiki: Apply these options [Y]es/[n]o? "
|
||||||
if tolower(input(query)) !~ "y"
|
if input(query) =~? '^n'
|
||||||
let g:local_wiki = {}
|
let g:local_wiki = {}
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
@ -149,7 +130,10 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable
|
|||||||
let subdir = vimwiki#base#current_subdir(a:idx)
|
let subdir = vimwiki#base#current_subdir(a:idx)
|
||||||
call VimwikiSet('subdir', subdir, a:idx)
|
call VimwikiSet('subdir', subdir, a:idx)
|
||||||
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx)
|
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx)
|
||||||
call VimwikiSet('url', vimwiki#html#get_wikifile_url(expand('%:p')), a:idx)
|
|
||||||
|
if g:vimwiki_auto_chdir == 1
|
||||||
|
exe 'lcd' VimwikiGet('path')
|
||||||
|
endif
|
||||||
|
|
||||||
" update cache
|
" update cache
|
||||||
call vimwiki#base#cache_buffer_state()
|
call vimwiki#base#cache_buffer_state()
|
||||||
@ -246,7 +230,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
|||||||
let lnk = a:lnk
|
let lnk = a:lnk
|
||||||
|
|
||||||
" if link is schemeless add wikiN: scheme
|
" if link is schemeless add wikiN: scheme
|
||||||
let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl
|
let is_schemeless = lnk !~# g:vimwiki_rxSchemeUrl
|
||||||
let lnk = (is_schemeless ? 'wiki'.g:vimwiki_current_idx.':'.lnk : lnk)
|
let lnk = (is_schemeless ? 'wiki'.g:vimwiki_current_idx.':'.lnk : lnk)
|
||||||
|
|
||||||
" Get scheme
|
" Get scheme
|
||||||
@ -260,7 +244,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
|||||||
let anchor = ''
|
let anchor = ''
|
||||||
|
|
||||||
"extract anchor
|
"extract anchor
|
||||||
if scheme =~ 'wiki' || scheme =~ 'diary'
|
if scheme =~# 'wiki' || scheme =~# 'diary'
|
||||||
let split_lnk = split(lnk, '#', 1)
|
let split_lnk = split(lnk, '#', 1)
|
||||||
let lnk = split_lnk[0]
|
let lnk = split_lnk[0]
|
||||||
if len(split_lnk) <= 1 || split_lnk[-1] == ''
|
if len(split_lnk) <= 1 || split_lnk[-1] == ''
|
||||||
@ -271,13 +255,13 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" do nothing if scheme is unknown to vimwiki
|
" do nothing if scheme is unknown to vimwiki
|
||||||
if !(scheme =~ 'wiki.*' || scheme =~ 'diary' || scheme =~ 'local'
|
if !(scheme =~# 'wiki.*' || scheme =~# 'diary' || scheme =~# 'local'
|
||||||
\ || scheme =~ 'file')
|
\ || scheme =~# 'file')
|
||||||
return [idx, scheme, path, subdir, lnk, ext, scheme.':'.lnk, anchor]
|
return [idx, scheme, path, subdir, lnk, ext, scheme.':'.lnk, anchor]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" scheme behaviors
|
" scheme behaviors
|
||||||
if scheme =~ 'wiki\d\+'
|
if scheme =~# 'wiki\d\+'
|
||||||
let idx = eval(matchstr(scheme, '\D\+\zs\d\+\ze'))
|
let idx = eval(matchstr(scheme, '\D\+\zs\d\+\ze'))
|
||||||
if idx < 0 || idx >= len(g:vimwiki_list)
|
if idx < 0 || idx >= len(g:vimwiki_list)
|
||||||
if !quiet
|
if !quiet
|
||||||
@ -321,7 +305,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
|||||||
if vimwiki#path#is_link_to_dir(lnk)
|
if vimwiki#path#is_link_to_dir(lnk)
|
||||||
let ext = (g:vimwiki_dir_link != '' ? g:vimwiki_dir_link . ext : '')
|
let ext = (g:vimwiki_dir_link != '' ? g:vimwiki_dir_link . ext : '')
|
||||||
endif
|
endif
|
||||||
elseif scheme =~ 'diary'
|
elseif scheme =~# 'diary'
|
||||||
if a:as_html
|
if a:as_html
|
||||||
" use cached value (save time when converting diary index!)
|
" use cached value (save time when converting diary index!)
|
||||||
let path = VimwikiGet('invsubdir')
|
let path = VimwikiGet('invsubdir')
|
||||||
@ -332,7 +316,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
|||||||
endif
|
endif
|
||||||
let idx = g:vimwiki_current_idx
|
let idx = g:vimwiki_current_idx
|
||||||
let subdir = VimwikiGet('diary_rel_path')
|
let subdir = VimwikiGet('diary_rel_path')
|
||||||
elseif scheme =~ 'local'
|
elseif scheme =~# 'local'
|
||||||
" revisiting the 'lcd'-bug ...
|
" revisiting the 'lcd'-bug ...
|
||||||
let path = VimwikiGet('path')
|
let path = VimwikiGet('path')
|
||||||
let subdir = VimwikiGet('subdir')
|
let subdir = VimwikiGet('subdir')
|
||||||
@ -340,7 +324,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
|||||||
" prepend browser-specific file: scheme
|
" prepend browser-specific file: scheme
|
||||||
let path = 'file://'.fnamemodify(path, ":p")
|
let path = 'file://'.fnamemodify(path, ":p")
|
||||||
endif
|
endif
|
||||||
elseif scheme =~ 'file'
|
elseif scheme =~# 'file'
|
||||||
" RM repeated leading "/"'s within a link
|
" RM repeated leading "/"'s within a link
|
||||||
let lnk = substitute(lnk, '^/*', '/', '')
|
let lnk = substitute(lnk, '^/*', '/', '')
|
||||||
" convert "/~..." into "~..." for fnamemodify
|
" convert "/~..." into "~..." for fnamemodify
|
||||||
@ -438,21 +422,21 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let update_prev_link = ( (scheme == '' || scheme =~ 'wiki' || scheme =~ 'diary')
|
let update_prev_link = ( (scheme == '' || scheme =~# 'wiki' || scheme =~# 'diary')
|
||||||
\ && lnk != expand('%:t:r')
|
\ && !vimwiki#path#is_equal(lnk, expand('%:t:r'))
|
||||||
\ ? 1 : 0)
|
\ ? 1 : 0)
|
||||||
|
|
||||||
let use_system_open = (
|
let use_system_open = (
|
||||||
\ scheme == '' ||
|
\ scheme == '' ||
|
||||||
\ scheme =~ 'wiki' ||
|
\ scheme =~# 'wiki' ||
|
||||||
\ scheme =~ 'diary' ? 0 : 1)
|
\ scheme =~# 'diary' ? 0 : 1)
|
||||||
|
|
||||||
let vimwiki_prev_link = []
|
let vimwiki_prev_link = []
|
||||||
" update previous link for wiki pages
|
" update previous link for wiki pages
|
||||||
if update_prev_link
|
if update_prev_link
|
||||||
if a:0
|
if a:0
|
||||||
let vimwiki_prev_link = [a:1, []]
|
let vimwiki_prev_link = [a:1, []]
|
||||||
elseif &ft == 'vimwiki'
|
elseif &ft ==# 'vimwiki'
|
||||||
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -535,7 +519,8 @@ function! vimwiki#base#backlinks() "{{{
|
|||||||
let links = s:get_links(source_file, idx)
|
let links = s:get_links(source_file, idx)
|
||||||
for [target_file, _, lnum, col] in links
|
for [target_file, _, lnum, col] in links
|
||||||
" don't include links from the current file to itself
|
" don't include links from the current file to itself
|
||||||
if target_file == current_filename && target_file != source_file
|
if vimwiki#path#is_equal(target_file, current_filename) &&
|
||||||
|
\ !vimwiki#path#is_equal(target_file, source_file)
|
||||||
call add(locations, {'filename':source_file, 'lnum':lnum, 'col':col})
|
call add(locations, {'filename':source_file, 'lnum':lnum, 'col':col})
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -652,7 +637,7 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" collect bold text (there can be several in one line)
|
" collect bold text (there can be several in one line)
|
||||||
let bold_count = 0
|
let bold_count = 1
|
||||||
while 1
|
while 1
|
||||||
let bold_text = matchstr(line, rxbold, 0, bold_count)
|
let bold_text = matchstr(line, rxbold, 0, bold_count)
|
||||||
if bold_text == ''
|
if bold_text == ''
|
||||||
@ -722,27 +707,27 @@ function! s:link_target(source_file, wiki_nr, link_text) "{{{
|
|||||||
\ vimwiki#base#resolve_scheme(a:link_text, 0, 1)
|
\ vimwiki#base#resolve_scheme(a:link_text, 0, 1)
|
||||||
let source_dir = fnamemodify(a:source_file, ':p:h').'/'
|
let source_dir = fnamemodify(a:source_file, ':p:h').'/'
|
||||||
|
|
||||||
if lnk =~ '/$' " link to a directory
|
if lnk =~# '/$' " link to a directory
|
||||||
return []
|
return []
|
||||||
elseif url == '' && anchor != '' " only anchor
|
elseif url == '' && anchor != '' " only anchor
|
||||||
return [fnamemodify(a:source_file, ':p'), anchor]
|
return [fnamemodify(a:source_file, ':p'), anchor]
|
||||||
elseif scheme == 'file'
|
elseif scheme ==# 'file'
|
||||||
return [url, '']
|
return [url, '']
|
||||||
elseif scheme == 'local'
|
elseif scheme ==# 'local'
|
||||||
return [vimwiki#path#normalize(source_dir.lnk), '']
|
return [vimwiki#path#normalize(source_dir.lnk), '']
|
||||||
elseif target_idx >= len(g:vimwiki_list) " a malformed link
|
elseif target_idx >= len(g:vimwiki_list) " a malformed link
|
||||||
return ['', '']
|
return ['', '']
|
||||||
elseif scheme !~ '^wiki\d\+\|diary' " unknown scheme
|
elseif scheme !~# '^wiki\d\+\|diary' " unknown scheme
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if scheme == 'diary'
|
if scheme ==# 'diary'
|
||||||
let root_dir = VimwikiGet('path',a:wiki_nr).
|
let root_dir = VimwikiGet('path',a:wiki_nr).
|
||||||
\ VimwikiGet('diary_rel_path', a:wiki_nr)
|
\ VimwikiGet('diary_rel_path', a:wiki_nr)
|
||||||
let ext = VimwikiGet('ext', a:wiki_nr)
|
let ext = VimwikiGet('ext', a:wiki_nr)
|
||||||
else
|
else
|
||||||
" a schemeless link is like a link to the current wiki
|
" a schemeless link is like a link to the current wiki
|
||||||
if a:link_text !~ '^wiki\d\+:'
|
if a:link_text !~# '^wiki\d\+:'
|
||||||
let target_idx = a:wiki_nr
|
let target_idx = a:wiki_nr
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -895,7 +880,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
|||||||
" which happens if we jump to an achor in the current file.
|
" which happens if we jump to an achor in the current file.
|
||||||
" This hack is necessary because apparently Vim messes up the result of
|
" This hack is necessary because apparently Vim messes up the result of
|
||||||
" getpos() directly after this command. Strange.
|
" getpos() directly after this command. Strange.
|
||||||
if !(a:command == ':e ' && a:filename == expand('%:p'))
|
if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p')))
|
||||||
execute a:command.' '.fname
|
execute a:command.' '.fname
|
||||||
endif
|
endif
|
||||||
if a:anchor != ''
|
if a:anchor != ''
|
||||||
@ -1064,7 +1049,7 @@ function! s:get_wiki_buffers() "{{{
|
|||||||
while bcount<=bufnr("$")
|
while bcount<=bufnr("$")
|
||||||
if bufexists(bcount)
|
if bufexists(bcount)
|
||||||
let bname = fnamemodify(bufname(bcount), ":p")
|
let bname = fnamemodify(bufname(bcount), ":p")
|
||||||
if bname =~ VimwikiGet('ext')."$"
|
if bname =~# VimwikiGet('ext')."$"
|
||||||
let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
|
let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
|
||||||
call add(blist, bitem)
|
call add(blist, bitem)
|
||||||
endif
|
endif
|
||||||
@ -1126,7 +1111,7 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{
|
|||||||
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
|
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
|
||||||
" the rest syntax rules as now it has effect being really 'contained'.
|
" the rest syntax rules as now it has effect being really 'contained'.
|
||||||
" Clear it!
|
" Clear it!
|
||||||
if ft =~ 'perl'
|
if ft =~? 'perl'
|
||||||
syntax clear perlFunctionName
|
syntax clear perlFunctionName
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@ -1140,8 +1125,8 @@ endfunction " }}}
|
|||||||
" vimwiki#base#find_prev_link
|
" vimwiki#base#find_prev_link
|
||||||
function! vimwiki#base#find_prev_link() "{{{
|
function! vimwiki#base#find_prev_link() "{{{
|
||||||
"Jump 2 times if the cursor is in the middle of a link
|
"Jump 2 times if the cursor is in the middle of a link
|
||||||
if synIDattr(synID(line('.'), col('.'), 0), "name") =~ "VimwikiLink.*" &&
|
if synIDattr(synID(line('.'), col('.'), 0), "name") =~# "VimwikiLink.*" &&
|
||||||
\ synIDattr(synID(line('.'), col('.')-1, 0), "name") =~ "VimwikiLink.*"
|
\ synIDattr(synID(line('.'), col('.')-1, 0), "name") =~# "VimwikiLink.*"
|
||||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||||
endif
|
endif
|
||||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||||
@ -1161,11 +1146,11 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
|
|||||||
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split)
|
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if a:split == "split"
|
if a:split ==# "split"
|
||||||
let cmd = ":split "
|
let cmd = ":split "
|
||||||
elseif a:split == "vsplit"
|
elseif a:split ==# "vsplit"
|
||||||
let cmd = ":vsplit "
|
let cmd = ":vsplit "
|
||||||
elseif a:split == "tabnew"
|
elseif a:split ==# "tabnew"
|
||||||
let cmd = ":tabnew "
|
let cmd = ":tabnew "
|
||||||
else
|
else
|
||||||
let cmd = ":e "
|
let cmd = ":e "
|
||||||
@ -1247,8 +1232,8 @@ endfunction "}}}
|
|||||||
function! vimwiki#base#delete_link() "{{{
|
function! vimwiki#base#delete_link() "{{{
|
||||||
"" file system funcs
|
"" file system funcs
|
||||||
"" Delete wiki link you are in from filesystem
|
"" Delete wiki link you are in from filesystem
|
||||||
let val = input('Delete ['.expand('%').'] (y/n)? ', "")
|
let val = input('Delete "'.expand('%').'" [y]es/[N]o? ')
|
||||||
if val != 'y'
|
if val !~? '^y'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let fname = expand('%:p')
|
let fname = expand('%:p')
|
||||||
@ -1281,14 +1266,14 @@ function! vimwiki#base#rename_link() "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let val = input('Rename "'.expand('%:t:r').'" (y/n)? ', "")
|
let val = input('Rename "'.expand('%:t:r').'" [y]es/[N]o? ')
|
||||||
if val!='y'
|
if val !~? '^y'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let new_link = input('Enter new name: ', "")
|
let new_link = input('Enter new name: ')
|
||||||
|
|
||||||
if new_link =~ '[/\\]'
|
if new_link =~# '[/\\]'
|
||||||
" It is actually doable but I do not have free time to do it.
|
" It is actually doable but I do not have free time to do it.
|
||||||
echomsg 'vimwiki: Cannot rename to a filename with path!'
|
echomsg 'vimwiki: Cannot rename to a filename with path!'
|
||||||
return
|
return
|
||||||
@ -1355,7 +1340,7 @@ function! vimwiki#base#rename_link() "{{{
|
|||||||
|
|
||||||
" restore wiki buffers
|
" restore wiki buffers
|
||||||
for bitem in blist
|
for bitem in blist
|
||||||
if bitem[0] != cur_buffer[0]
|
if !vimwiki#path#is_equal(bitem[0], cur_buffer[0])
|
||||||
call s:open_wiki_buffer(bitem)
|
call s:open_wiki_buffer(bitem)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -1419,7 +1404,7 @@ function! vimwiki#base#TO_header(inner, visual) "{{{
|
|||||||
call cursor(line('$'), 0)
|
call cursor(line('$'), 0)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:inner && getline(line('.')) =~ '^\s*$'
|
if a:inner && getline(line('.')) =~# '^\s*$'
|
||||||
let lnum = prevnonblank(line('.') - 1)
|
let lnum = prevnonblank(line('.') - 1)
|
||||||
call cursor(lnum, 0)
|
call cursor(lnum, 0)
|
||||||
endif
|
endif
|
||||||
@ -1515,7 +1500,7 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
|||||||
" | bla | bla |
|
" | bla | bla |
|
||||||
" |-------+-------|
|
" |-------+-------|
|
||||||
" or it will select wrong column.
|
" or it will select wrong column.
|
||||||
if strpart(getline('.'), virtcol('.')-1) =~ '^-+'
|
if strpart(getline('.'), virtcol('.')-1) =~# '^-+'
|
||||||
let s_flag = 'b'
|
let s_flag = 'b'
|
||||||
else
|
else
|
||||||
let s_flag = 'cb'
|
let s_flag = 'cb'
|
||||||
@ -1538,7 +1523,7 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
|||||||
normal! `>
|
normal! `>
|
||||||
if !firsttime && getline('.')[virtcol('.')] == '|'
|
if !firsttime && getline('.')[virtcol('.')] == '|'
|
||||||
normal! l
|
normal! l
|
||||||
elseif a:inner && getline('.')[virtcol('.')+1] =~ '[|+]'
|
elseif a:inner && getline('.')[virtcol('.')+1] =~# '[|+]'
|
||||||
normal! 2l
|
normal! 2l
|
||||||
endif
|
endif
|
||||||
" search for the next column separator
|
" search for the next column separator
|
||||||
@ -1569,7 +1554,7 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
|||||||
" | bla | bla |
|
" | bla | bla |
|
||||||
" |-------+-------|
|
" |-------+-------|
|
||||||
" or it will select wrong column.
|
" or it will select wrong column.
|
||||||
if strpart(getline('.'), virtcol('.')-1) =~ '^-+'
|
if strpart(getline('.'), virtcol('.')-1) =~# '^-+'
|
||||||
let s_flag = 'b'
|
let s_flag = 'b'
|
||||||
else
|
else
|
||||||
let s_flag = 'cb'
|
let s_flag = 'cb'
|
||||||
@ -1612,11 +1597,11 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
|||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
let rxHdr = g:vimwiki_rxH
|
let rxHdr = g:vimwiki_rxH
|
||||||
if line =~ '^\s*$'
|
if line =~# '^\s*$'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if line =~ g:vimwiki_rxHeader
|
if line =~# g:vimwiki_rxHeader
|
||||||
let level = vimwiki#u#count_first_sym(line)
|
let level = vimwiki#u#count_first_sym(line)
|
||||||
if level < 6
|
if level < 6
|
||||||
if g:vimwiki_symH
|
if g:vimwiki_symH
|
||||||
@ -1640,16 +1625,16 @@ function! vimwiki#base#RemoveHeaderLevel() "{{{
|
|||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
let rxHdr = g:vimwiki_rxH
|
let rxHdr = g:vimwiki_rxH
|
||||||
if line =~ '^\s*$'
|
if line =~# '^\s*$'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if line =~ g:vimwiki_rxHeader
|
if line =~# g:vimwiki_rxHeader
|
||||||
let level = vimwiki#u#count_first_sym(line)
|
let level = vimwiki#u#count_first_sym(line)
|
||||||
let old = repeat(rxHdr, level)
|
let old = repeat(rxHdr, level)
|
||||||
let new = repeat(rxHdr, level - 1)
|
let new = repeat(rxHdr, level - 1)
|
||||||
|
|
||||||
let chomp = line =~ rxHdr.'\s'
|
let chomp = line =~# rxHdr.'\s'
|
||||||
|
|
||||||
if g:vimwiki_symH
|
if g:vimwiki_symH
|
||||||
let line = substitute(line, old, new, 'g')
|
let line = substitute(line, old, new, 'g')
|
||||||
@ -1701,7 +1686,7 @@ function! vimwiki#base#table_of_contents(create)
|
|||||||
" delete old TOC
|
" delete old TOC
|
||||||
if toc_line > 0
|
if toc_line > 0
|
||||||
let endoftoc = toc_line+1
|
let endoftoc = toc_line+1
|
||||||
while endoftoc <= line('$') && getline(endoftoc) =~ '^\s*'.rx_bullet.g:vimwiki_rxWikiLink.'\s*$'
|
while endoftoc <= line('$') && getline(endoftoc) =~# '^\s*'.rx_bullet.g:vimwiki_rxWikiLink.'\s*$'
|
||||||
let endoftoc += 1
|
let endoftoc += 1
|
||||||
endwhile
|
endwhile
|
||||||
silent exe toc_line.','.string(endoftoc-1).'delete _'
|
silent exe toc_line.','.string(endoftoc-1).'delete _'
|
||||||
@ -1714,7 +1699,7 @@ function! vimwiki#base#table_of_contents(create)
|
|||||||
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
||||||
for lnum in range(1, line('$'))
|
for lnum in range(1, line('$'))
|
||||||
let line_content = getline(lnum)
|
let line_content = getline(lnum)
|
||||||
if line_content !~ g:vimwiki_rxHeader
|
if line_content !~# g:vimwiki_rxHeader
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
let h_level = vimwiki#u#count_first_sym(line_content)
|
let h_level = vimwiki#u#count_first_sym(line_content)
|
||||||
@ -1756,7 +1741,7 @@ function! vimwiki#base#table_of_contents(create)
|
|||||||
call append(toc_line, startindent.repeat(indentstring, lvl-1).bullet.link)
|
call append(toc_line, startindent.repeat(indentstring, lvl-1).bullet.link)
|
||||||
let toc_line += 1
|
let toc_line += 1
|
||||||
endfor
|
endfor
|
||||||
if getline(toc_line+1) !~ '^\s*$'
|
if getline(toc_line+1) !~# '^\s*$'
|
||||||
call append(toc_line, '')
|
call append(toc_line, '')
|
||||||
endif
|
endif
|
||||||
call setpos('.', old_cursor_pos)
|
call setpos('.', old_cursor_pos)
|
||||||
@ -1787,16 +1772,16 @@ endfunction " }}}
|
|||||||
" s:clean_url
|
" s:clean_url
|
||||||
function! s:clean_url(url) " {{{
|
function! s:clean_url(url) " {{{
|
||||||
let url = split(a:url, '/\|=\|-\|&\|?\|\.')
|
let url = split(a:url, '/\|=\|-\|&\|?\|\.')
|
||||||
let url = filter(url, 'v:val != ""')
|
let url = filter(url, 'v:val !=# ""')
|
||||||
let url = filter(url, 'v:val != "www"')
|
let url = filter(url, 'v:val !=# "www"')
|
||||||
let url = filter(url, 'v:val != "com"')
|
let url = filter(url, 'v:val !=# "com"')
|
||||||
let url = filter(url, 'v:val != "org"')
|
let url = filter(url, 'v:val !=# "org"')
|
||||||
let url = filter(url, 'v:val != "net"')
|
let url = filter(url, 'v:val !=# "net"')
|
||||||
let url = filter(url, 'v:val != "edu"')
|
let url = filter(url, 'v:val !=# "edu"')
|
||||||
let url = filter(url, 'v:val != "http\:"')
|
let url = filter(url, 'v:val !=# "http\:"')
|
||||||
let url = filter(url, 'v:val != "https\:"')
|
let url = filter(url, 'v:val !=# "https\:"')
|
||||||
let url = filter(url, 'v:val != "file\:"')
|
let url = filter(url, 'v:val !=# "file\:"')
|
||||||
let url = filter(url, 'v:val != "xml\:"')
|
let url = filter(url, 'v:val !=# "xml\:"')
|
||||||
return join(url, " ")
|
return join(url, " ")
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
@ -2236,7 +2221,7 @@ endfunction " }}}
|
|||||||
|
|
||||||
" -------------------------------------------------------------------------
|
" -------------------------------------------------------------------------
|
||||||
" Load syntax-specific Wiki functionality
|
" Load syntax-specific Wiki functionality
|
||||||
for s:syn in vimwiki#base#get_known_syntaxes()
|
for s:syn in s:vimwiki_get_known_syntaxes()
|
||||||
execute 'runtime! autoload/vimwiki/'.s:syn.'_base.vim'
|
execute 'runtime! autoload/vimwiki/'.s:syn.'_base.vim'
|
||||||
endfor
|
endfor
|
||||||
" -------------------------------------------------------------------------
|
" -------------------------------------------------------------------------
|
||||||
|
@ -25,17 +25,6 @@ function! s:get_date_link(fmt) "{{{
|
|||||||
return strftime(a:fmt)
|
return strftime(a:fmt)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:link_exists(lines, link) "{{{
|
|
||||||
let link_exists = 0
|
|
||||||
for line in a:lines
|
|
||||||
if line =~ escape(a:link, '[]\')
|
|
||||||
let link_exists = 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return link_exists
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! s:diary_path(...) "{{{
|
function! s:diary_path(...) "{{{
|
||||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||||
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
|
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
|
||||||
@ -54,7 +43,7 @@ endfunction "}}}
|
|||||||
function! s:get_position_links(link) "{{{
|
function! s:get_position_links(link) "{{{
|
||||||
let idx = -1
|
let idx = -1
|
||||||
let links = []
|
let links = []
|
||||||
if a:link =~ '^\d\{4}-\d\d-\d\d'
|
if a:link =~# '^\d\{4}-\d\d-\d\d'
|
||||||
let links = keys(s:get_diary_links())
|
let links = keys(s:get_diary_links())
|
||||||
" include 'today' into links
|
" include 'today' into links
|
||||||
if index(links, s:diary_date_link()) == -1
|
if index(links, s:diary_date_link()) == -1
|
||||||
@ -81,7 +70,7 @@ fun! s:read_captions(files) "{{{
|
|||||||
|
|
||||||
if filereadable(fl)
|
if filereadable(fl)
|
||||||
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
|
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
|
||||||
if line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
|
if line =~# g:vimwiki_rxHeader && !has_key(result, fl_key)
|
||||||
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
|
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -99,10 +88,10 @@ fun! s:get_diary_links(...) "{{{
|
|||||||
let rx = '^\d\{4}-\d\d-\d\d'
|
let rx = '^\d\{4}-\d\d-\d\d'
|
||||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||||
let files = split(s_files, '\n')
|
let files = split(s_files, '\n')
|
||||||
call filter(files, 'fnamemodify(v:val, ":t") =~ "'.escape(rx, '\').'"')
|
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
|
||||||
|
|
||||||
" remove backup files (.wiki~)
|
" remove backup files (.wiki~)
|
||||||
call filter(files, 'v:val !~ ''.*\~$''')
|
call filter(files, 'v:val !~# ''.*\~$''')
|
||||||
|
|
||||||
if a:0
|
if a:0
|
||||||
call add(files, a:1)
|
call add(files, a:1)
|
||||||
@ -134,7 +123,7 @@ fun! s:group_links(links) "{{{
|
|||||||
endfun "}}}
|
endfun "}}}
|
||||||
|
|
||||||
fun! s:sort(lst) "{{{
|
fun! s:sort(lst) "{{{
|
||||||
if VimwikiGet("diary_sort") == 'desc'
|
if VimwikiGet("diary_sort") ==? 'desc'
|
||||||
return reverse(sort(a:lst))
|
return reverse(sort(a:lst))
|
||||||
else
|
else
|
||||||
return sort(a:lst)
|
return sort(a:lst)
|
||||||
@ -311,7 +300,7 @@ endfunction "}}}
|
|||||||
function! vimwiki#diary#generate_diary_section() "{{{
|
function! vimwiki#diary#generate_diary_section() "{{{
|
||||||
let current_file = vimwiki#path#path_norm(expand("%:p"))
|
let current_file = vimwiki#path#path_norm(expand("%:p"))
|
||||||
let diary_file = vimwiki#path#path_norm(s:diary_index())
|
let diary_file = vimwiki#path#path_norm(s:diary_index())
|
||||||
if current_file == diary_file
|
if vimwiki#path#is_equal(current_file, diary_file)
|
||||||
call s:delete_diary_section()
|
call s:delete_diary_section()
|
||||||
call s:insert_diary_section()
|
call s:insert_diary_section()
|
||||||
else
|
else
|
||||||
@ -327,7 +316,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
|||||||
|
|
||||||
let link = a:year.'-'.month.'-'.day
|
let link = a:year.'-'.month.'-'.day
|
||||||
if winnr('#') == 0
|
if winnr('#') == 0
|
||||||
if a:dir == 'V'
|
if a:dir ==? 'V'
|
||||||
vsplit
|
vsplit
|
||||||
else
|
else
|
||||||
split
|
split
|
||||||
|
@ -27,31 +27,31 @@ function! s:root_path(subdir) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:syntax_supported() " {{{
|
function! s:syntax_supported() " {{{
|
||||||
return VimwikiGet('syntax') == "default"
|
return VimwikiGet('syntax') ==? "default"
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:remove_blank_lines(lines) " {{{
|
function! s:remove_blank_lines(lines) " {{{
|
||||||
while !empty(a:lines) && a:lines[-1] =~ '^\s*$'
|
while !empty(a:lines) && a:lines[-1] =~# '^\s*$'
|
||||||
call remove(a:lines, -1)
|
call remove(a:lines, -1)
|
||||||
endwhile
|
endwhile
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_web_link(lnk) "{{{
|
function! s:is_web_link(lnk) "{{{
|
||||||
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\|mailto:\)'
|
if a:lnk =~# '^\%(https://\|http://\|www.\|ftp://\|file://\|mailto:\)'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_img_link(lnk) "{{{
|
function! s:is_img_link(lnk) "{{{
|
||||||
if tolower(a:lnk) =~ '\.\%(png\|jpg\|gif\|jpeg\)$'
|
if tolower(a:lnk) =~# '\.\%(png\|jpg\|gif\|jpeg\)$'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:has_abs_path(fname) "{{{
|
function! s:has_abs_path(fname) "{{{
|
||||||
if a:fname =~ '\(^.:\)\|\(^/\)'
|
if a:fname =~# '\(^.:\)\|\(^/\)'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@ -103,7 +103,7 @@ function! s:template_full_name(name) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:get_html_template(wikifile, template) "{{{
|
function! s:get_html_template(template) "{{{
|
||||||
" TODO: refactor it!!!
|
" TODO: refactor it!!!
|
||||||
let lines=[]
|
let lines=[]
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ function! s:subst_func(line, regexp, func, ...) " {{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:save_vimwiki_buffer() "{{{
|
function! s:save_vimwiki_buffer() "{{{
|
||||||
if &filetype == 'vimwiki' && filewritable(expand('%'))
|
if &filetype ==? 'vimwiki' && filewritable(expand('%'))
|
||||||
silent update
|
silent update
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@ -214,7 +214,7 @@ function! s:process_title(placeholders, default_title) "{{{
|
|||||||
if !empty(a:placeholders)
|
if !empty(a:placeholders)
|
||||||
for [placeholder, row, idx] in a:placeholders
|
for [placeholder, row, idx] in a:placeholders
|
||||||
let [type, param] = placeholder
|
let [type, param] = placeholder
|
||||||
if type == 'title' && !empty(param)
|
if type ==# 'title' && !empty(param)
|
||||||
return param
|
return param
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -243,7 +243,7 @@ endfunction "}}}
|
|||||||
function! s:html_insert_contents(html_lines, content) "{{{
|
function! s:html_insert_contents(html_lines, content) "{{{
|
||||||
let lines = []
|
let lines = []
|
||||||
for line in a:html_lines
|
for line in a:html_lines
|
||||||
if line =~ '%content%'
|
if line =~# '%content%'
|
||||||
let parts = split(line, '%content%', 1)
|
let parts = split(line, '%content%', 1)
|
||||||
if empty(parts)
|
if empty(parts)
|
||||||
call extend(lines, a:content)
|
call extend(lines, a:content)
|
||||||
@ -338,7 +338,7 @@ function! vimwiki#html#linkify_link(src, descr) "{{{
|
|||||||
let src_str = ' href="'.s:safe_html_anchor(a:src).'"'
|
let src_str = ' href="'.s:safe_html_anchor(a:src).'"'
|
||||||
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
|
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
|
||||||
let descr = (descr == "" ? a:src : descr)
|
let descr = (descr == "" ? a:src : descr)
|
||||||
let descr_str = (descr =~ g:vimwiki_rxWikiIncl
|
let descr_str = (descr =~# g:vimwiki_rxWikiIncl
|
||||||
\ ? s:tag_wikiincl(descr)
|
\ ? s:tag_wikiincl(descr)
|
||||||
\ : descr)
|
\ : descr)
|
||||||
return '<a'.src_str.'>'.descr_str.'</a>'
|
return '<a'.src_str.'>'.descr_str.'</a>'
|
||||||
@ -430,7 +430,7 @@ function! s:tag_remove_internal_link(value) "{{{
|
|||||||
let value = s:mid(a:value, 2)
|
let value = s:mid(a:value, 2)
|
||||||
|
|
||||||
let line = ''
|
let line = ''
|
||||||
if value =~ '|'
|
if value =~# '|'
|
||||||
let link_parts = split(value, "|", 1)
|
let link_parts = split(value, "|", 1)
|
||||||
else
|
else
|
||||||
let link_parts = split(value, "][", 1)
|
let link_parts = split(value, "][", 1)
|
||||||
@ -484,7 +484,8 @@ function! s:make_tag(line, regexp, func, ...) "{{{
|
|||||||
|
|
||||||
"FIXME FIXME !!! these can easily occur on the same line!
|
"FIXME FIXME !!! these can easily occur on the same line!
|
||||||
"XXX {{{ }}} ??? obsolete
|
"XXX {{{ }}} ??? obsolete
|
||||||
if '`[^`]\+`' == a:regexp || '{{{.\+}}}' == a:regexp || g:vimwiki_rxEqIn == a:regexp
|
if '`[^`]\+`' ==# a:regexp || '{{{.\+}}}' ==# a:regexp ||
|
||||||
|
\ g:vimwiki_rxEqIn ==# a:regexp
|
||||||
let res_line = s:subst_func(a:line, a:regexp, a:func)
|
let res_line = s:subst_func(a:line, a:regexp, a:func)
|
||||||
else
|
else
|
||||||
let pos = 0
|
let pos = 0
|
||||||
@ -675,7 +676,7 @@ function! s:close_tag_table(table, ldest, header_ids) "{{{
|
|||||||
call s:sum_rowspan(table)
|
call s:sum_rowspan(table)
|
||||||
call s:sum_colspan(table)
|
call s:sum_colspan(table)
|
||||||
|
|
||||||
if table[0] == 'center'
|
if table[0] ==# 'center'
|
||||||
call add(ldest, "<table class='center'>")
|
call add(ldest, "<table class='center'>")
|
||||||
else
|
else
|
||||||
call add(ldest, "<table>")
|
call add(ldest, "<table>")
|
||||||
@ -734,8 +735,8 @@ function! s:process_tag_pre(line, pre) "{{{
|
|||||||
let pre = a:pre
|
let pre = a:pre
|
||||||
let processed = 0
|
let processed = 0
|
||||||
"XXX huh?
|
"XXX huh?
|
||||||
"if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
|
"if !pre[0] && a:line =~# '^\s*{{{[^\(}}}\)]*\s*$'
|
||||||
if !pre[0] && a:line =~ '^\s*{{{'
|
if !pre[0] && a:line =~# '^\s*{{{'
|
||||||
let class = matchstr(a:line, '{{{\zs.*$')
|
let class = matchstr(a:line, '{{{\zs.*$')
|
||||||
"FIXME class cannot contain arbitrary strings
|
"FIXME class cannot contain arbitrary strings
|
||||||
let class = substitute(class, '\s\+$', '', 'g')
|
let class = substitute(class, '\s\+$', '', 'g')
|
||||||
@ -746,7 +747,7 @@ function! s:process_tag_pre(line, pre) "{{{
|
|||||||
endif
|
endif
|
||||||
let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
|
let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
|
||||||
let processed = 1
|
let processed = 1
|
||||||
elseif pre[0] && a:line =~ '^\s*}}}\s*$'
|
elseif pre[0] && a:line =~# '^\s*}}}\s*$'
|
||||||
let pre = [0, 0]
|
let pre = [0, 0]
|
||||||
call add(lines, "</pre>")
|
call add(lines, "</pre>")
|
||||||
let processed = 1
|
let processed = 1
|
||||||
@ -764,13 +765,14 @@ function! s:process_tag_math(line, math) "{{{
|
|||||||
let lines = []
|
let lines = []
|
||||||
let math = a:math
|
let math = a:math
|
||||||
let processed = 0
|
let processed = 0
|
||||||
if !math[0] && a:line =~ '^\s*{{\$[^\(}}$\)]*\s*$'
|
if !math[0] && a:line =~# '^\s*{{\$[^\(}}$\)]*\s*$'
|
||||||
let class = matchstr(a:line, '{{$\zs.*$')
|
let class = matchstr(a:line, '{{$\zs.*$')
|
||||||
"FIXME class cannot be any string!
|
"FIXME class cannot be any string!
|
||||||
let class = substitute(class, '\s\+$', '', 'g')
|
let class = substitute(class, '\s\+$', '', 'g')
|
||||||
" Check the math placeholder (default: displaymath)
|
" store the environment name in a global variable in order to close the
|
||||||
let b:vimwiki_mathEnv = matchstr(class, '^%\zs\S\+\ze%')
|
" environment properly
|
||||||
if b:vimwiki_mathEnv != ""
|
let s:current_math_env = matchstr(class, '^%\zs\S\+\ze%')
|
||||||
|
if s:current_math_env != ""
|
||||||
call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', ''))
|
call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', ''))
|
||||||
elseif class != ""
|
elseif class != ""
|
||||||
call add(lines, "\\\[".class)
|
call add(lines, "\\\[".class)
|
||||||
@ -779,10 +781,10 @@ function! s:process_tag_math(line, math) "{{{
|
|||||||
endif
|
endif
|
||||||
let math = [1, len(matchstr(a:line, '^\s*\ze{{\$'))]
|
let math = [1, len(matchstr(a:line, '^\s*\ze{{\$'))]
|
||||||
let processed = 1
|
let processed = 1
|
||||||
elseif math[0] && a:line =~ '^\s*}}\$\s*$'
|
elseif math[0] && a:line =~# '^\s*}}\$\s*$'
|
||||||
let math = [0, 0]
|
let math = [0, 0]
|
||||||
if b:vimwiki_mathEnv != ""
|
if s:current_math_env != ""
|
||||||
call add(lines, "\\end{".b:vimwiki_mathEnv."}")
|
call add(lines, "\\end{".s:current_math_env."}")
|
||||||
else
|
else
|
||||||
call add(lines, "\\\]")
|
call add(lines, "\\\]")
|
||||||
endif
|
endif
|
||||||
@ -798,7 +800,7 @@ function! s:process_tag_quote(line, quote) "{{{
|
|||||||
let lines = []
|
let lines = []
|
||||||
let quote = a:quote
|
let quote = a:quote
|
||||||
let processed = 0
|
let processed = 0
|
||||||
if a:line =~ '^\s\{4,}\S'
|
if a:line =~# '^\s\{4,}\S'
|
||||||
if !quote
|
if !quote
|
||||||
call add(lines, "<blockquote>")
|
call add(lines, "<blockquote>")
|
||||||
let quote = 1
|
let quote = 1
|
||||||
@ -841,12 +843,12 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
let lines = []
|
let lines = []
|
||||||
let processed = 0
|
let processed = 0
|
||||||
|
|
||||||
if a:line =~ '^\s*'.s:bullets.'\s'
|
if a:line =~# '^\s*'.s:bullets.'\s'
|
||||||
let lstSym = matchstr(a:line, s:bullets)
|
let lstSym = matchstr(a:line, s:bullets)
|
||||||
let lstTagOpen = '<ul>'
|
let lstTagOpen = '<ul>'
|
||||||
let lstTagClose = '</ul>'
|
let lstTagClose = '</ul>'
|
||||||
let lstRegExp = '^\s*'.s:bullets.'\s'
|
let lstRegExp = '^\s*'.s:bullets.'\s'
|
||||||
elseif a:line =~ '^\s*'.s:numbers.'\s'
|
elseif a:line =~# '^\s*'.s:numbers.'\s'
|
||||||
let lstSym = matchstr(a:line, s:numbers)
|
let lstSym = matchstr(a:line, s:numbers)
|
||||||
let lstTagOpen = '<ol>'
|
let lstTagOpen = '<ol>'
|
||||||
let lstTagClose = '</ol>'
|
let lstTagClose = '</ol>'
|
||||||
@ -891,7 +893,7 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
call add(lines,
|
call add(lines,
|
||||||
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
|
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
|
||||||
let processed = 1
|
let processed = 1
|
||||||
elseif in_list && a:line =~ '^\s\+\S\+'
|
elseif in_list && a:line =~# '^\s\+\S\+'
|
||||||
if g:vimwiki_list_ignore_newline
|
if g:vimwiki_list_ignore_newline
|
||||||
call add(lines, a:line)
|
call add(lines, a:line)
|
||||||
else
|
else
|
||||||
@ -932,14 +934,14 @@ function! s:process_tag_para(line, para) "{{{
|
|||||||
let lines = []
|
let lines = []
|
||||||
let para = a:para
|
let para = a:para
|
||||||
let processed = 0
|
let processed = 0
|
||||||
if a:line =~ '^\s\{,3}\S'
|
if a:line =~# '^\s\{,3}\S'
|
||||||
if !para
|
if !para
|
||||||
call add(lines, "<p>")
|
call add(lines, "<p>")
|
||||||
let para = 1
|
let para = 1
|
||||||
endif
|
endif
|
||||||
let processed = 1
|
let processed = 1
|
||||||
call add(lines, a:line)
|
call add(lines, a:line)
|
||||||
elseif para && a:line =~ '^\s*$'
|
elseif para && a:line =~# '^\s*$'
|
||||||
call add(lines, "</p>")
|
call add(lines, "</p>")
|
||||||
let para = 0
|
let para = 0
|
||||||
endif
|
endif
|
||||||
@ -953,7 +955,7 @@ function! s:process_tag_h(line, id) "{{{
|
|||||||
let h_text = ''
|
let h_text = ''
|
||||||
let h_id = ''
|
let h_id = ''
|
||||||
|
|
||||||
if a:line =~ g:vimwiki_rxHeader
|
if a:line =~# g:vimwiki_rxHeader
|
||||||
let h_level = vimwiki#u#count_first_sym(a:line)
|
let h_level = vimwiki#u#count_first_sym(a:line)
|
||||||
endif
|
endif
|
||||||
if h_level > 0
|
if h_level > 0
|
||||||
@ -962,9 +964,9 @@ function! s:process_tag_h(line, id) "{{{
|
|||||||
let h_number = ''
|
let h_number = ''
|
||||||
let h_complete_id = ''
|
let h_complete_id = ''
|
||||||
let h_id = s:safe_html_anchor(h_text)
|
let h_id = s:safe_html_anchor(h_text)
|
||||||
let centered = (a:line =~ '^\s')
|
let centered = (a:line =~# '^\s')
|
||||||
|
|
||||||
if h_text != g:vimwiki_toc_header
|
if h_text !=# g:vimwiki_toc_header
|
||||||
|
|
||||||
let a:id[h_level-1] = [h_text, a:id[h_level-1][1]+1]
|
let a:id[h_level-1] = [h_text, a:id[h_level-1][1]+1]
|
||||||
|
|
||||||
@ -1016,7 +1018,7 @@ endfunction "}}}
|
|||||||
function! s:process_tag_hr(line) "{{{
|
function! s:process_tag_hr(line) "{{{
|
||||||
let line = a:line
|
let line = a:line
|
||||||
let processed = 0
|
let processed = 0
|
||||||
if a:line =~ '^-----*$'
|
if a:line =~# '^-----*$'
|
||||||
let line = '<hr />'
|
let line = '<hr />'
|
||||||
let processed = 1
|
let processed = 1
|
||||||
endif
|
endif
|
||||||
@ -1027,15 +1029,15 @@ function! s:process_tag_table(line, table, header_ids) "{{{
|
|||||||
function! s:table_empty_cell(value) "{{{
|
function! s:table_empty_cell(value) "{{{
|
||||||
let cell = {}
|
let cell = {}
|
||||||
|
|
||||||
if a:value =~ '^\s*\\/\s*$'
|
if a:value =~# '^\s*\\/\s*$'
|
||||||
let cell.body = ''
|
let cell.body = ''
|
||||||
let cell.rowspan = 0
|
let cell.rowspan = 0
|
||||||
let cell.colspan = 1
|
let cell.colspan = 1
|
||||||
elseif a:value =~ '^\s*>\s*$'
|
elseif a:value =~# '^\s*>\s*$'
|
||||||
let cell.body = ''
|
let cell.body = ''
|
||||||
let cell.rowspan = 1
|
let cell.rowspan = 1
|
||||||
let cell.colspan = 0
|
let cell.colspan = 0
|
||||||
elseif a:value =~ '^\s*$'
|
elseif a:value =~# '^\s*$'
|
||||||
let cell.body = ' '
|
let cell.body = ' '
|
||||||
let cell.rowspan = 1
|
let cell.rowspan = 1
|
||||||
let cell.colspan = 1
|
let cell.colspan = 1
|
||||||
@ -1050,7 +1052,7 @@ function! s:process_tag_table(line, table, header_ids) "{{{
|
|||||||
|
|
||||||
function! s:table_add_row(table, line) "{{{
|
function! s:table_add_row(table, line) "{{{
|
||||||
if empty(a:table)
|
if empty(a:table)
|
||||||
if a:line =~ '^\s\+'
|
if a:line =~# '^\s\+'
|
||||||
let row = ['center', []]
|
let row = ['center', []]
|
||||||
else
|
else
|
||||||
let row = ['normal', []]
|
let row = ['normal', []]
|
||||||
@ -1132,14 +1134,14 @@ function! s:parse_line(line, state) " {{{
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
if !processed
|
if !processed
|
||||||
if line =~ g:vimwiki_rxComment
|
if line =~# g:vimwiki_rxComment
|
||||||
let processed = 1
|
let processed = 1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" nohtml -- placeholder
|
" nohtml -- placeholder
|
||||||
if !processed
|
if !processed
|
||||||
if line =~ '^\s*%nohtml'
|
if line =~# '^\s*%nohtml'
|
||||||
let processed = 1
|
let processed = 1
|
||||||
let state.placeholder = ['nohtml']
|
let state.placeholder = ['nohtml']
|
||||||
endif
|
endif
|
||||||
@ -1147,7 +1149,7 @@ function! s:parse_line(line, state) " {{{
|
|||||||
|
|
||||||
" title -- placeholder
|
" title -- placeholder
|
||||||
if !processed
|
if !processed
|
||||||
if line =~ '^\s*%title'
|
if line =~# '^\s*%title'
|
||||||
let processed = 1
|
let processed = 1
|
||||||
let param = matchstr(line, '^\s*%title\s\zs.*')
|
let param = matchstr(line, '^\s*%title\s\zs.*')
|
||||||
let state.placeholder = ['title', param]
|
let state.placeholder = ['title', param]
|
||||||
@ -1156,7 +1158,7 @@ function! s:parse_line(line, state) " {{{
|
|||||||
|
|
||||||
" html template -- placeholder "{{{
|
" html template -- placeholder "{{{
|
||||||
if !processed
|
if !processed
|
||||||
if line =~ '^\s*%template'
|
if line =~# '^\s*%template'
|
||||||
let processed = 1
|
let processed = 1
|
||||||
let param = matchstr(line, '^\s*%template\s\zs.*')
|
let param = matchstr(line, '^\s*%template\s\zs.*')
|
||||||
let state.placeholder = ['template', param]
|
let state.placeholder = ['template', param]
|
||||||
@ -1401,10 +1403,10 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if !empty(state.placeholder)
|
if !empty(state.placeholder)
|
||||||
if state.placeholder[0] == 'nohtml'
|
if state.placeholder[0] ==# 'nohtml'
|
||||||
let nohtml = 1
|
let nohtml = 1
|
||||||
break
|
break
|
||||||
elseif state.placeholder[0] == 'template'
|
elseif state.placeholder[0] ==# 'template'
|
||||||
let template_name = state.placeholder[1]
|
let template_name = state.placeholder[1]
|
||||||
else
|
else
|
||||||
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
|
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
|
||||||
@ -1437,7 +1439,7 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
|||||||
|
|
||||||
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
|
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
|
||||||
|
|
||||||
let html_lines = s:get_html_template(a:wikifile, template_name)
|
let html_lines = s:get_html_template(template_name)
|
||||||
|
|
||||||
" processing template variables (refactor to a function)
|
" processing template variables (refactor to a function)
|
||||||
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
|
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
|
||||||
@ -1543,17 +1545,17 @@ function! s:binary_exists(fname) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
" uses VimwikiGet('path')
|
" uses VimwikiGet('path')
|
||||||
function! vimwiki#html#get_wikifile_url(wikifile) "{{{
|
function! s:get_wikifile_url(wikifile) "{{{
|
||||||
return VimwikiGet('path_html').
|
return VimwikiGet('path_html').
|
||||||
\ vimwiki#base#subdir(VimwikiGet('path'), a:wikifile).
|
\ vimwiki#base#subdir(VimwikiGet('path'), a:wikifile).
|
||||||
\ fnamemodify(a:wikifile, ":t:r").'.html'
|
\ fnamemodify(a:wikifile, ":t:r").'.html'
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#html#PasteUrl(wikifile) "{{{
|
function! vimwiki#html#PasteUrl(wikifile) "{{{
|
||||||
execute 'r !echo file://'.vimwiki#html#get_wikifile_url(a:wikifile)
|
execute 'r !echo file://'.s:get_wikifile_url(a:wikifile)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#html#CatUrl(wikifile) "{{{
|
function! vimwiki#html#CatUrl(wikifile) "{{{
|
||||||
execute '!echo file://'.vimwiki#html#get_wikifile_url(a:wikifile)
|
execute '!echo file://'.s:get_wikifile_url(a:wikifile)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
"}}}
|
"}}}
|
||||||
|
@ -185,10 +185,10 @@ endfunction "}}}
|
|||||||
"Returns: level of the line
|
"Returns: level of the line
|
||||||
"0 is the 'highest' level
|
"0 is the 'highest' level
|
||||||
function! s:get_level(lnum) "{{{
|
function! s:get_level(lnum) "{{{
|
||||||
if getline(a:lnum) =~ '^\s*$'
|
if getline(a:lnum) =~# '^\s*$'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
if VimwikiGet('syntax') != 'media'
|
if VimwikiGet('syntax') !=? 'media'
|
||||||
let level = indent(a:lnum)
|
let level = indent(a:lnum)
|
||||||
else
|
else
|
||||||
let level = s:string_length(matchstr(getline(a:lnum), s:rx_bullet_chars))-1
|
let level = s:string_length(matchstr(getline(a:lnum), s:rx_bullet_chars))-1
|
||||||
@ -207,7 +207,7 @@ function! s:guess_kind_of_numbered_item(item) "{{{
|
|||||||
let number_chars = a:item.mrkr[:-2]
|
let number_chars = a:item.mrkr[:-2]
|
||||||
let divisor = a:item.mrkr[-1:]
|
let divisor = a:item.mrkr[-1:]
|
||||||
|
|
||||||
if number_chars =~ '\d\+'
|
if number_chars =~# '\d\+'
|
||||||
return '1'
|
return '1'
|
||||||
endif
|
endif
|
||||||
if number_chars =~# '\l\+'
|
if number_chars =~# '\l\+'
|
||||||
@ -922,7 +922,7 @@ endfunction "}}}
|
|||||||
|
|
||||||
function! s:decrease_level(item) "{{{
|
function! s:decrease_level(item) "{{{
|
||||||
let removed_indent = 0
|
let removed_indent = 0
|
||||||
if VimwikiGet('syntax') == 'media' && a:item.type == 1 &&
|
if VimwikiGet('syntax') ==? 'media' && a:item.type == 1 &&
|
||||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||||
if s:string_length(a:item.mrkr) >= 2
|
if s:string_length(a:item.mrkr) >= 2
|
||||||
call s:substitute_string_in_line(a:item.lnum,
|
call s:substitute_string_in_line(a:item.lnum,
|
||||||
@ -944,7 +944,7 @@ endfunction "}}}
|
|||||||
|
|
||||||
function! s:increase_level(item) "{{{
|
function! s:increase_level(item) "{{{
|
||||||
let additional_indent = 0
|
let additional_indent = 0
|
||||||
if VimwikiGet('syntax') == 'media' && a:item.type == 1 &&
|
if VimwikiGet('syntax') ==? 'media' && a:item.type == 1 &&
|
||||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||||
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
|
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
|
||||||
\ s:first_char(a:item.mrkr))
|
\ s:first_char(a:item.mrkr))
|
||||||
@ -966,7 +966,7 @@ endfunction "}}}
|
|||||||
"a:indent_by can be negative
|
"a:indent_by can be negative
|
||||||
function! s:indent_line_by(lnum, indent_by) "{{{
|
function! s:indent_line_by(lnum, indent_by) "{{{
|
||||||
let item = s:get_item(a:lnum)
|
let item = s:get_item(a:lnum)
|
||||||
if VimwikiGet('syntax') == 'media' && item.type == 1 &&
|
if VimwikiGet('syntax') ==? 'media' && item.type == 1 &&
|
||||||
\ index(s:multiple_bullet_chars, s:first_char(item.mrkr)) > -1
|
\ index(s:multiple_bullet_chars, s:first_char(item.mrkr)) > -1
|
||||||
if a:indent_by > 0
|
if a:indent_by > 0
|
||||||
call s:substitute_string_in_line(a:lnum, item.mrkr,
|
call s:substitute_string_in_line(a:lnum, item.mrkr,
|
||||||
@ -983,17 +983,17 @@ endfunction "}}}
|
|||||||
function! s:change_level(from_line, to_line, direction, plus_children) "{{{
|
function! s:change_level(from_line, to_line, direction, plus_children) "{{{
|
||||||
let from_item = s:get_corresponding_item(a:from_line)
|
let from_item = s:get_corresponding_item(a:from_line)
|
||||||
if from_item.type == 0
|
if from_item.type == 0
|
||||||
if a:direction == 'increase' && a:from_line == a:to_line &&
|
if a:direction ==# 'increase' && a:from_line == a:to_line &&
|
||||||
\ empty(getline(a:from_line))
|
\ empty(getline(a:from_line))
|
||||||
"that's because :> doesn't work on an empty line
|
"that's because :> doesn't work on an empty line
|
||||||
normal! gi
|
normal! gi
|
||||||
else
|
else
|
||||||
execute a:from_line.','.a:to_line.(a:direction == 'increase' ? '>' : '<')
|
execute a:from_line.','.a:to_line.(a:direction ==# 'increase' ? '>' : '<')
|
||||||
endif
|
endif
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:direction == 'decrease' && s:get_level(from_item.lnum) == 0
|
if a:direction ==# 'decrease' && s:get_level(from_item.lnum) == 0
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1026,7 +1026,7 @@ function! s:change_level(from_line, to_line, direction, plus_children) "{{{
|
|||||||
let more_than_one_level_concerned = 0
|
let more_than_one_level_concerned = 0
|
||||||
|
|
||||||
let first_line_indented_by =
|
let first_line_indented_by =
|
||||||
\ (a:direction == 'increase') ?
|
\ (a:direction ==# 'increase') ?
|
||||||
\ s:increase_level(from_item) : s:decrease_level(from_item)
|
\ s:increase_level(from_item) : s:decrease_level(from_item)
|
||||||
|
|
||||||
let cur_ln = s:get_next_line(from_item.lnum)
|
let cur_ln = s:get_next_line(from_item.lnum)
|
||||||
@ -1112,7 +1112,7 @@ endfunction "}}}
|
|||||||
function! s:set_new_mrkr(item, new_mrkr) "{{{
|
function! s:set_new_mrkr(item, new_mrkr) "{{{
|
||||||
if a:item.type == 0
|
if a:item.type == 0
|
||||||
call s:substitute_rx_in_line(a:item.lnum, '^\s*\zs\ze', a:new_mrkr.' ')
|
call s:substitute_rx_in_line(a:item.lnum, '^\s*\zs\ze', a:new_mrkr.' ')
|
||||||
if indent(a:item.lnum) == 0 && VimwikiGet('syntax') != 'media'
|
if indent(a:item.lnum) == 0 && VimwikiGet('syntax') !=? 'media'
|
||||||
call s:set_indent(a:item.lnum, vimwiki#lst#get_list_margin())
|
call s:set_indent(a:item.lnum, vimwiki#lst#get_list_margin())
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
@ -1121,7 +1121,7 @@ function! s:set_new_mrkr(item, new_mrkr) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
||||||
let cur_col_from_eol = col("$") - (a:mode == "i" ? col("'^") : col('.'))
|
let cur_col_from_eol = col("$") - (a:mode ==# "i" ? col("'^") : col('.'))
|
||||||
let new_mrkr = a:new_mrkr
|
let new_mrkr = a:new_mrkr
|
||||||
let cur_ln = a:from_line
|
let cur_ln = a:from_line
|
||||||
while 1
|
while 1
|
||||||
@ -1138,13 +1138,13 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
|||||||
"use *** if the item above has *** too
|
"use *** if the item above has *** too
|
||||||
let item_above = s:get_prev_list_item(cur_item, 1)
|
let item_above = s:get_prev_list_item(cur_item, 1)
|
||||||
if item_above.type == 1 &&
|
if item_above.type == 1 &&
|
||||||
\ s:first_char(item_above.mrkr) ==s:first_char(new_mrkr)
|
\ s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr)
|
||||||
let new_mrkr = item_above.mrkr
|
let new_mrkr = item_above.mrkr
|
||||||
else
|
else
|
||||||
"use *** if the item below has *** too
|
"use *** if the item below has *** too
|
||||||
let item_below = s:get_next_list_item(cur_item, 1)
|
let item_below = s:get_next_list_item(cur_item, 1)
|
||||||
if item_below.type == 1 &&
|
if item_below.type == 1 &&
|
||||||
\ s:first_char(item_below.mrkr) == s:first_char(new_mrkr)
|
\ s:first_char(item_below.mrkr) ==# s:first_char(new_mrkr)
|
||||||
let new_mrkr = item_below.mrkr
|
let new_mrkr = item_below.mrkr
|
||||||
else
|
else
|
||||||
"if the old is ### and the new is * use ***
|
"if the old is ### and the new is * use ***
|
||||||
@ -1155,7 +1155,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
|||||||
"use *** if the parent item has **
|
"use *** if the parent item has **
|
||||||
let parent_item = s:get_parent(cur_item)
|
let parent_item = s:get_parent(cur_item)
|
||||||
if parent_item.type == 1 &&
|
if parent_item.type == 1 &&
|
||||||
\ s:first_char(parent_item.mrkr) == s:first_char(new_mrkr)
|
\ s:first_char(parent_item.mrkr) ==# s:first_char(new_mrkr)
|
||||||
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
||||||
\ s:string_length(parent_item.mrkr)+1)
|
\ s:string_length(parent_item.mrkr)+1)
|
||||||
endif
|
endif
|
||||||
@ -1193,7 +1193,7 @@ endfunction "}}}
|
|||||||
|
|
||||||
"sets kind of the item depending on neighbor items and the parent item
|
"sets kind of the item depending on neighbor items and the parent item
|
||||||
function! s:adjust_mrkr(item) "{{{
|
function! s:adjust_mrkr(item) "{{{
|
||||||
if a:item.type == 0 || VimwikiGet('syntax') == 'media'
|
if a:item.type == 0 || VimwikiGet('syntax') ==? 'media'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1208,7 +1208,7 @@ function! s:adjust_mrkr(item) "{{{
|
|||||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||||
let parent_item = s:get_parent(a:item)
|
let parent_item = s:get_parent(a:item)
|
||||||
if parent_item.type == 1 &&
|
if parent_item.type == 1 &&
|
||||||
\ s:first_char(parent_item.mrkr) == s:first_char(a:item.mrkr)
|
\ s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr)
|
||||||
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
||||||
\ s:string_length(parent_item.mrkr)+1)
|
\ s:string_length(parent_item.mrkr)+1)
|
||||||
endif
|
endif
|
||||||
@ -1223,7 +1223,7 @@ function! s:clone_marker_from_to(from, to) "{{{
|
|||||||
if item_from.type == 0 | return | endif
|
if item_from.type == 0 | return | endif
|
||||||
let new_mrkr = item_from.mrkr . ' '
|
let new_mrkr = item_from.mrkr . ' '
|
||||||
call s:substitute_rx_in_line(a:to, '^\s*', new_mrkr)
|
call s:substitute_rx_in_line(a:to, '^\s*', new_mrkr)
|
||||||
let new_indent = ( VimwikiGet('syntax') != 'media' ? indent(a:from) : 0 )
|
let new_indent = ( VimwikiGet('syntax') !=? 'media' ? indent(a:from) : 0 )
|
||||||
call s:set_indent(a:to, new_indent)
|
call s:set_indent(a:to, new_indent)
|
||||||
if item_from.cb != ''
|
if item_from.cb != ''
|
||||||
call s:create_cb(s:get_item(a:to))
|
call s:create_cb(s:get_item(a:to))
|
||||||
@ -1286,7 +1286,7 @@ endfunction "}}}
|
|||||||
function! vimwiki#lst#kbd_O() "{{{
|
function! vimwiki#lst#kbd_O() "{{{
|
||||||
normal! Ox
|
normal! Ox
|
||||||
let cur_ln = line('.')
|
let cur_ln = line('.')
|
||||||
if getline(cur_ln+1) !~ '^\s*$'
|
if getline(cur_ln+1) !~# '^\s*$'
|
||||||
call s:clone_marker_from_to(cur_ln+1, cur_ln)
|
call s:clone_marker_from_to(cur_ln+1, cur_ln)
|
||||||
else
|
else
|
||||||
call s:clone_marker_from_to(cur_ln-1, cur_ln)
|
call s:clone_marker_from_to(cur_ln-1, cur_ln)
|
||||||
@ -1365,7 +1365,7 @@ function! s:cr_on_list_item(lnum, insert_new_marker, not_at_eol) "{{{
|
|||||||
normal! gi
|
normal! gi
|
||||||
call s:clone_marker_from_to(a:lnum, a:lnum+1)
|
call s:clone_marker_from_to(a:lnum, a:lnum+1)
|
||||||
"tiny sweet extra feature: indent next line if current line ends with :
|
"tiny sweet extra feature: indent next line if current line ends with :
|
||||||
if !a:not_at_eol && getline(a:lnum) =~ ':$'
|
if !a:not_at_eol && getline(a:lnum) =~# ':$'
|
||||||
call s:change_level(a:lnum+1, a:lnum+1, 'increase', 0)
|
call s:change_level(a:lnum+1, a:lnum+1, 'increase', 0)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
@ -1393,17 +1393,17 @@ function! vimwiki#lst#kbd_cr(normal, just_mrkr) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let insert_new_marker = (a:normal == 1 || a:normal == 3)
|
let insert_new_marker = (a:normal == 1 || a:normal == 3)
|
||||||
if getline('.')[col("'^")-1:] =~ '^\s\+$'
|
if getline('.')[col("'^")-1:] =~# '^\s\+$'
|
||||||
let cur_col = 0
|
let cur_col = 0
|
||||||
else
|
else
|
||||||
let cur_col = col("$") - col("'^")
|
let cur_col = col("$") - col("'^")
|
||||||
if getline('.')[col("'^")-1] =~ '\s' && exists("*strdisplaywidth")
|
if getline('.')[col("'^")-1] =~# '\s' && exists("*strdisplaywidth")
|
||||||
let ws_behind_cursor =
|
let ws_behind_cursor =
|
||||||
\ strdisplaywidth(matchstr(getline('.')[col("'^")-1:], '\s\+'),
|
\ strdisplaywidth(matchstr(getline('.')[col("'^")-1:], '\s\+'),
|
||||||
\ virtcol("'^")-1)
|
\ virtcol("'^")-1)
|
||||||
let cur_col -= ws_behind_cursor
|
let cur_col -= ws_behind_cursor
|
||||||
endif
|
endif
|
||||||
if insert_new_marker && cur_col == 0 && getline(lnum) =~ '\s$'
|
if insert_new_marker && cur_col == 0 && getline(lnum) =~# '\s$'
|
||||||
let insert_new_marker = 0
|
let insert_new_marker = 0
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -1450,7 +1450,7 @@ function! vimwiki#lst#toggle_list_item() "{{{
|
|||||||
let new_cur_col = col("$") - cur_col_from_eol
|
let new_cur_col = col("$") - cur_col_from_eol
|
||||||
call cursor(cur_item.lnum, new_cur_col >= 1 ? new_cur_col : 1)
|
call cursor(cur_item.lnum, new_cur_col >= 1 ? new_cur_col : 1)
|
||||||
|
|
||||||
if cur_col_from_eol == 0 || getline(cur_item.lnum) =~ '^\s*$'
|
if cur_col_from_eol == 0 || getline(cur_item.lnum) =~# '^\s*$'
|
||||||
startinsert!
|
startinsert!
|
||||||
else
|
else
|
||||||
startinsert
|
startinsert
|
||||||
|
@ -81,11 +81,11 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
|
|||||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||||
else
|
else
|
||||||
if a:split == "split"
|
if a:split ==# "split"
|
||||||
let cmd = ":split "
|
let cmd = ":split "
|
||||||
elseif a:split == "vsplit"
|
elseif a:split ==# "vsplit"
|
||||||
let cmd = ":vsplit "
|
let cmd = ":vsplit "
|
||||||
elseif a:split == "tabnew"
|
elseif a:split ==# "tabnew"
|
||||||
let cmd = ":tabnew "
|
let cmd = ":tabnew "
|
||||||
else
|
else
|
||||||
let cmd = ":e "
|
let cmd = ":e "
|
||||||
|
@ -9,12 +9,24 @@ function! vimwiki#path#chomp_slash(str) "{{{
|
|||||||
return substitute(a:str, '[/\\]\+$', '', '')
|
return substitute(a:str, '[/\\]\+$', '', '')
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
" Define path-compare function, either case-sensitive or not, depending on OS.
|
||||||
|
"{{{ " function! vimwiki#path#is_equal(p1, p2)
|
||||||
|
if vimwiki#u#is_windows()
|
||||||
|
function! vimwiki#path#is_equal(p1, p2)
|
||||||
|
return a:p1 ==? a:p2
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! vimwiki#path#is_equal(p1, p2)
|
||||||
|
return a:p1 ==# a:p2
|
||||||
|
endfunction
|
||||||
|
endif "}}}
|
||||||
|
|
||||||
" collapse sections like /a/b/../c to /a/c
|
" collapse sections like /a/b/../c to /a/c
|
||||||
function! vimwiki#path#normalize(path) "{{{
|
function! vimwiki#path#normalize(path) "{{{
|
||||||
let path = a:path
|
let path = a:path
|
||||||
while 1
|
while 1
|
||||||
let result = substitute(path, '/[^/]\+/\.\.', '', '')
|
let result = substitute(path, '/[^/]\+/\.\.', '', '')
|
||||||
if result == path
|
if result ==# path
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
let path = result
|
let path = result
|
||||||
@ -38,7 +50,7 @@ endfunction "}}}
|
|||||||
function! vimwiki#path#is_link_to_dir(link) "{{{
|
function! vimwiki#path#is_link_to_dir(link) "{{{
|
||||||
" Check if link is to a directory.
|
" Check if link is to a directory.
|
||||||
" It should be ended with \ or /.
|
" It should be ended with \ or /.
|
||||||
if a:link =~ '.\+[/\\]$'
|
if a:link =~# '.\+[/\\]$'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@ -56,7 +68,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
|
|||||||
|
|
||||||
let idx = 0
|
let idx = 0
|
||||||
let minlen = min([len(p1), len(p2)])
|
let minlen = min([len(p1), len(p2)])
|
||||||
while (idx < minlen) && (p1[idx] ==? p2[idx])
|
while (idx < minlen) && vimwiki#path#is_equal(p1[idx], p2[idx])
|
||||||
let idx = idx + 1
|
let idx = idx + 1
|
||||||
endwhile
|
endwhile
|
||||||
if idx == 0
|
if idx == 0
|
||||||
@ -80,7 +92,7 @@ function! vimwiki#path#relpath(dir, file) "{{{
|
|||||||
let result = []
|
let result = []
|
||||||
let dir = split(a:dir, '/')
|
let dir = split(a:dir, '/')
|
||||||
let file = split(a:file, '/')
|
let file = split(a:file, '/')
|
||||||
while (len(dir) > 0 && len(file) > 0) && dir[0] == file[0]
|
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
|
||||||
call remove(dir, 0)
|
call remove(dir, 0)
|
||||||
call remove(file, 0)
|
call remove(file, 0)
|
||||||
endwhile
|
endwhile
|
||||||
@ -116,7 +128,8 @@ function! vimwiki#path#mkdir(path, ...) "{{{
|
|||||||
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:0 && a:1 && tolower(input("Vimwiki: Make new directory: ".path."\n [Y]es/[n]o? ")) !~ "^y"
|
if a:0 && a:1 && input("Vimwiki: Make new directory: "
|
||||||
|
\ .path."\n [y]es/[N]o? ") !~? '^y'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -54,28 +54,28 @@ function! s:sep_splitter() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_table(line) "{{{
|
function! s:is_table(line) "{{{
|
||||||
return s:is_separator(a:line) || (a:line !~ s:rxSep().s:rxSep() && a:line =~ '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
|
return s:is_separator(a:line) || (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_separator(line) "{{{
|
function! s:is_separator(line) "{{{
|
||||||
return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
|
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_separator_tail(line) "{{{
|
function! s:is_separator_tail(line) "{{{
|
||||||
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
|
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_last_column(lnum, cnum) "{{{
|
function! s:is_last_column(lnum, cnum) "{{{
|
||||||
let line = strpart(getline(a:lnum), a:cnum - 1)
|
let line = strpart(getline(a:lnum), a:cnum - 1)
|
||||||
"echomsg "DEBUG is_last_column> ".(line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$')
|
"echomsg "DEBUG is_last_column> ".(line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$')
|
||||||
return line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$'
|
return line =~# s:rxSep().'\s*$' && line !~# s:rxSep().'.*'.s:rxSep().'\s*$'
|
||||||
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:is_first_column(lnum, cnum) "{{{
|
function! s:is_first_column(lnum, cnum) "{{{
|
||||||
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
|
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
|
||||||
"echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
|
"echomsg "DEBUG is_first_column> ".(line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||||
return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
|
return line =~# '^\s*$' || (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:count_separators_up(lnum) "{{{
|
function! s:count_separators_up(lnum) "{{{
|
||||||
@ -134,11 +134,11 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
|||||||
for idx in range(strlen(a:line))
|
for idx in range(strlen(a:line))
|
||||||
" The only way I know Vim can do Unicode...
|
" The only way I know Vim can do Unicode...
|
||||||
let ch = a:line[idx]
|
let ch = a:line[idx]
|
||||||
if state == 'NONE'
|
if state ==# 'NONE'
|
||||||
if ch == '|'
|
if ch == '|'
|
||||||
let state = 'CELL'
|
let state = 'CELL'
|
||||||
endif
|
endif
|
||||||
elseif state == 'CELL'
|
elseif state ==# 'CELL'
|
||||||
if ch == '[' || ch == '{'
|
if ch == '[' || ch == '{'
|
||||||
let state = 'BEFORE_QUOTE_START'
|
let state = 'BEFORE_QUOTE_START'
|
||||||
let quote = ch
|
let quote = ch
|
||||||
@ -148,7 +148,7 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
|||||||
else
|
else
|
||||||
let cell .= ch
|
let cell .= ch
|
||||||
endif
|
endif
|
||||||
elseif state == 'BEFORE_QUOTE_START'
|
elseif state ==# 'BEFORE_QUOTE_START'
|
||||||
if ch == '[' || ch == '{'
|
if ch == '[' || ch == '{'
|
||||||
let state = 'QUOTE'
|
let state = 'QUOTE'
|
||||||
let quote .= ch
|
let quote .= ch
|
||||||
@ -157,12 +157,12 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
|||||||
let cell .= quote.ch
|
let cell .= quote.ch
|
||||||
let quote = ''
|
let quote = ''
|
||||||
endif
|
endif
|
||||||
elseif state == 'QUOTE'
|
elseif state ==# 'QUOTE'
|
||||||
if ch == ']' || ch == '}'
|
if ch == ']' || ch == '}'
|
||||||
let state = 'BEFORE_QUOTE_END'
|
let state = 'BEFORE_QUOTE_END'
|
||||||
endif
|
endif
|
||||||
let quote .= ch
|
let quote .= ch
|
||||||
elseif state == 'BEFORE_QUOTE_END'
|
elseif state ==# 'BEFORE_QUOTE_END'
|
||||||
if ch == ']' || ch == '}'
|
if ch == ']' || ch == '}'
|
||||||
let state = 'CELL'
|
let state = 'CELL'
|
||||||
endif
|
endif
|
||||||
@ -495,7 +495,7 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||||
if !(&filetype == 'vimwiki')
|
if !(&filetype ==? 'vimwiki')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
@ -570,7 +570,7 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||||
if !(&filetype == 'vimwiki')
|
if !(&filetype ==? 'vimwiki')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
|
@ -964,7 +964,7 @@ In HTML the following part >
|
|||||||
| Year | Temperature (low) | Temperature (high) |
|
| Year | Temperature (low) | Temperature (high) |
|
||||||
|------|-------------------|--------------------|
|
|------|-------------------|--------------------|
|
||||||
>
|
>
|
||||||
is higlighted as a table header.
|
is highlighted as a table header.
|
||||||
|
|
||||||
If you indent a table then it will be centered in HTML.
|
If you indent a table then it will be centered in HTML.
|
||||||
|
|
||||||
@ -1917,7 +1917,7 @@ See |vimwiki-option-template_path| for details.
|
|||||||
*vimwiki-option-template_ext*
|
*vimwiki-option-template_ext*
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
Key Default value~
|
Key Default value~
|
||||||
template_ext .html
|
template_ext .tpl
|
||||||
|
|
||||||
Description~
|
Description~
|
||||||
Setup template filename extension.
|
Setup template filename extension.
|
||||||
@ -2625,6 +2625,19 @@ before the plugin loads. >
|
|||||||
|
|
||||||
The default is '<Leader>w'.
|
The default is '<Leader>w'.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*g:vimwiki_auto_chdir*
|
||||||
|
|
||||||
|
When set to 1, enables auto-cd feature. Whenever vimwiki page is opened,
|
||||||
|
vimwiki performs an |:lcd| to the vimwiki folder to where the page belongs.
|
||||||
|
|
||||||
|
|
||||||
|
Value Description~
|
||||||
|
0 Do not change directory.
|
||||||
|
1 Change directory to vimwiki folder on opening page.
|
||||||
|
|
||||||
|
Default: 0
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
13. Miscellaneous *vimwiki-misc*
|
13. Miscellaneous *vimwiki-misc*
|
||||||
@ -2665,6 +2678,7 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
|
|||||||
???~
|
???~
|
||||||
|
|
||||||
* Support for tags.
|
* Support for tags.
|
||||||
|
* Spport for |g:vimwiki_auto_chdir| option.
|
||||||
* Support for anchors, see |vimwiki-anchors|
|
* Support for anchors, see |vimwiki-anchors|
|
||||||
* in this context, add support for TOC, see |vimwiki-toc|
|
* in this context, add support for TOC, see |vimwiki-toc|
|
||||||
* remove the now useless %toc placeholder
|
* remove the now useless %toc placeholder
|
||||||
|
@ -46,7 +46,7 @@ function! Complete_wikifiles(findstart, base)
|
|||||||
let s:line_context = '['
|
let s:line_context = '['
|
||||||
return startoflink
|
return startoflink
|
||||||
endif
|
endif
|
||||||
if VimwikiGet('syntax') == 'markdown'
|
if VimwikiGet('syntax') ==? 'markdown'
|
||||||
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
|
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
|
||||||
if startofinlinelink != -1
|
if startofinlinelink != -1
|
||||||
let s:line_context = '['
|
let s:line_context = '['
|
||||||
@ -75,7 +75,7 @@ function! Complete_wikifiles(findstart, base)
|
|||||||
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
|
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
|
||||||
endif
|
endif
|
||||||
return tags
|
return tags
|
||||||
elseif a:base !~ '#'
|
elseif a:base !~# '#'
|
||||||
" we look for wiki files
|
" we look for wiki files
|
||||||
|
|
||||||
if a:base =~# '^wiki\d:'
|
if a:base =~# '^wiki\d:'
|
||||||
@ -172,12 +172,12 @@ function! VimwikiFoldLevel(lnum) "{{{
|
|||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
|
|
||||||
" Header/section folding...
|
" Header/section folding...
|
||||||
if line =~ g:vimwiki_rxHeader
|
if line =~# g:vimwiki_rxHeader
|
||||||
return '>'.vimwiki#u#count_first_sym(line)
|
return '>'.vimwiki#u#count_first_sym(line)
|
||||||
" Code block folding...
|
" Code block folding...
|
||||||
elseif line =~ '^\s*'.g:vimwiki_rxPreStart
|
elseif line =~# '^\s*'.g:vimwiki_rxPreStart
|
||||||
return 'a1'
|
return 'a1'
|
||||||
elseif line =~ '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
elseif line =~# '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||||
return 's1'
|
return 's1'
|
||||||
else
|
else
|
||||||
return "="
|
return "="
|
||||||
@ -218,7 +218,7 @@ function! VimwikiFoldText() "{{{
|
|||||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||||
let fold_len = v:foldend - v:foldstart + 1
|
let fold_len = v:foldend - v:foldstart + 1
|
||||||
let len_text = ' ['.fold_len.'] '
|
let len_text = ' ['.fold_len.'] '
|
||||||
if line !~ '^\s*'.g:vimwiki_rxPreStart
|
if line !~# '^\s*'.g:vimwiki_rxPreStart
|
||||||
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
||||||
return main_text.len_text
|
return main_text.len_text
|
||||||
else
|
else
|
||||||
|
@ -39,7 +39,8 @@ function! s:find_wiki(path) "{{{
|
|||||||
while idx < len(g:vimwiki_list)
|
while idx < len(g:vimwiki_list)
|
||||||
let idx_path = expand(VimwikiGet('path', idx))
|
let idx_path = expand(VimwikiGet('path', idx))
|
||||||
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
|
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
|
||||||
if vimwiki#path#path_common_pfx(idx_path, path) == idx_path
|
if vimwiki#path#is_equal(
|
||||||
|
\ vimwiki#path#path_common_pfx(idx_path, path), idx_path)
|
||||||
return idx
|
return idx
|
||||||
endif
|
endif
|
||||||
let idx += 1
|
let idx += 1
|
||||||
@ -91,7 +92,7 @@ function! s:setup_buffer_leave() "{{{
|
|||||||
if g:vimwiki_debug == 3
|
if g:vimwiki_debug == 3
|
||||||
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||||
endif
|
endif
|
||||||
if &filetype == 'vimwiki'
|
if &filetype ==? 'vimwiki'
|
||||||
" cache global vars of current state XXX: SLOW!?
|
" cache global vars of current state XXX: SLOW!?
|
||||||
call vimwiki#base#cache_buffer_state()
|
call vimwiki#base#cache_buffer_state()
|
||||||
endif
|
endif
|
||||||
@ -210,7 +211,7 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
if g:vimwiki_debug ==3
|
if g:vimwiki_debug ==3
|
||||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
||||||
endif
|
endif
|
||||||
elseif &syntax == 'vimwiki'
|
elseif &syntax ==? 'vimwiki'
|
||||||
" to force a rescan of the filesystem which may have changed
|
" to force a rescan of the filesystem which may have changed
|
||||||
" and update VimwikiLinks syntax group that depends on it;
|
" and update VimwikiLinks syntax group that depends on it;
|
||||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
||||||
@ -227,15 +228,15 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||||
" insist vimwiki folding here.
|
" insist vimwiki folding here.
|
||||||
if g:vimwiki_folding == 'expr'
|
if g:vimwiki_folding ==? 'expr'
|
||||||
setlocal fdm=expr
|
setlocal fdm=expr
|
||||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||||
setlocal foldtext=VimwikiFoldText()
|
setlocal foldtext=VimwikiFoldText()
|
||||||
elseif g:vimwiki_folding == 'list' || g:vimwiki_folding == 'lists'
|
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
|
||||||
setlocal fdm=expr
|
setlocal fdm=expr
|
||||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||||
setlocal foldtext=VimwikiFoldText()
|
setlocal foldtext=VimwikiFoldText()
|
||||||
elseif g:vimwiki_folding == 'syntax'
|
elseif g:vimwiki_folding ==? 'syntax'
|
||||||
setlocal fdm=syntax
|
setlocal fdm=syntax
|
||||||
setlocal foldtext=VimwikiFoldText()
|
setlocal foldtext=VimwikiFoldText()
|
||||||
else
|
else
|
||||||
@ -357,6 +358,23 @@ function! VimwikiClear(option, ...) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
function! s:vimwiki_get_known_extensions() " {{{
|
||||||
|
" Getting all extensions that different wikis could have
|
||||||
|
let extensions = {}
|
||||||
|
for wiki in g:vimwiki_list
|
||||||
|
if has_key(wiki, 'ext')
|
||||||
|
let extensions[wiki.ext] = 1
|
||||||
|
else
|
||||||
|
let extensions['.wiki'] = 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
" append map g:vimwiki_ext2syntax
|
||||||
|
for ext in keys(g:vimwiki_ext2syntax)
|
||||||
|
let extensions[ext] = 1
|
||||||
|
endfor
|
||||||
|
return keys(extensions)
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" CALLBACK functions "{{{
|
" CALLBACK functions "{{{
|
||||||
@ -385,9 +403,9 @@ let s:vimwiki_defaults.ext = '.wiki'
|
|||||||
let s:vimwiki_defaults.maxhi = 0
|
let s:vimwiki_defaults.maxhi = 0
|
||||||
let s:vimwiki_defaults.syntax = 'default'
|
let s:vimwiki_defaults.syntax = 'default'
|
||||||
|
|
||||||
let s:vimwiki_defaults.template_path = ''
|
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
|
||||||
let s:vimwiki_defaults.template_default = ''
|
let s:vimwiki_defaults.template_default = 'default'
|
||||||
let s:vimwiki_defaults.template_ext = ''
|
let s:vimwiki_defaults.template_ext = '.tpl'
|
||||||
|
|
||||||
let s:vimwiki_defaults.nested_syntaxes = {}
|
let s:vimwiki_defaults.nested_syntaxes = {}
|
||||||
let s:vimwiki_defaults.auto_export = 0
|
let s:vimwiki_defaults.auto_export = 0
|
||||||
@ -454,6 +472,8 @@ call s:default('map_prefix', '<Leader>w')
|
|||||||
|
|
||||||
call s:default('current_idx', 0)
|
call s:default('current_idx', 0)
|
||||||
|
|
||||||
|
call s:default('auto_chdir', 0)
|
||||||
|
|
||||||
" Scheme regexes should be defined even if syntax file is not loaded yet
|
" Scheme regexes should be defined even if syntax file is not loaded yet
|
||||||
" cause users should be able to <leader>w<leader>w without opening any
|
" cause users should be able to <leader>w<leader>w without opening any
|
||||||
" vimwiki file first
|
" vimwiki file first
|
||||||
@ -488,7 +508,7 @@ augroup end
|
|||||||
|
|
||||||
augroup vimwiki
|
augroup vimwiki
|
||||||
autocmd!
|
autocmd!
|
||||||
for s:ext in vimwiki#base#get_known_extensions()
|
for s:ext in s:vimwiki_get_known_extensions()
|
||||||
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()'
|
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()'
|
||||||
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
|
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
|
||||||
exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'
|
exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'
|
||||||
|
@ -83,7 +83,11 @@ let s:valid_chars = '[^\\\]]'
|
|||||||
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
|
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
|
||||||
let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
|
let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
|
||||||
|
|
||||||
let g:vimwiki_rxWord = '[^[:blank:]()\\]\+'
|
" this regexp defines what can form a link when the user presses <CR> in the
|
||||||
|
" buffer (and not on a link) to create a link
|
||||||
|
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
|
||||||
|
" non-Ascii characters
|
||||||
|
let g:vimwiki_rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
|
||||||
|
|
||||||
|
|
||||||
" [[URL]], or [[URL|DESCRIPTION]]
|
" [[URL]], or [[URL|DESCRIPTION]]
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
" Author: Maxim Kim <habamax@gmail.com>
|
" Author: Maxim Kim <habamax@gmail.com>
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
" Home: http://code.google.com/p/vimwiki/
|
||||||
|
|
||||||
" placeholder for math environments
|
|
||||||
let b:vimwiki_mathEnv = ""
|
|
||||||
|
|
||||||
" text: $ equation_inline $
|
" text: $ equation_inline $
|
||||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||||
let g:vimwiki_char_eqin = '\$'
|
let g:vimwiki_char_eqin = '\$'
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
" Author: Maxim Kim <habamax@gmail.com>
|
" Author: Maxim Kim <habamax@gmail.com>
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
" Home: http://code.google.com/p/vimwiki/
|
||||||
|
|
||||||
" placeholder for math environments
|
|
||||||
let b:vimwiki_mathEnv = ""
|
|
||||||
|
|
||||||
" text: $ equation_inline $
|
" text: $ equation_inline $
|
||||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||||
let g:vimwiki_char_eqin = '\$'
|
let g:vimwiki_char_eqin = '\$'
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
" Author: Maxim Kim <habamax@gmail.com>
|
" Author: Maxim Kim <habamax@gmail.com>
|
||||||
" Home: http://code.google.com/p/vimwiki/
|
" Home: http://code.google.com/p/vimwiki/
|
||||||
|
|
||||||
" placeholder for math environments
|
|
||||||
let b:vimwiki_mathEnv = ""
|
|
||||||
|
|
||||||
" text: $ equation_inline $
|
" text: $ equation_inline $
|
||||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||||
let g:vimwiki_char_eqin = '\$'
|
let g:vimwiki_char_eqin = '\$'
|
||||||
|
Loading…
Reference in New Issue
Block a user