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
|
||||
let g:loaded_vimwiki_auto = 1
|
||||
|
||||
" MISC helper functions {{{
|
||||
|
||||
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() " {{{
|
||||
" s:vimwiki_get_known_syntaxes
|
||||
function! s:vimwiki_get_known_syntaxes() " {{{
|
||||
" Getting all syntaxes that different wikis could have
|
||||
let syntaxes = {}
|
||||
let syntaxes['default'] = 1
|
||||
@ -42,7 +24,6 @@ function! vimwiki#base#get_known_syntaxes() " {{{
|
||||
endfor
|
||||
return keys(syntaxes)
|
||||
endfunction " }}}
|
||||
" }}}
|
||||
|
||||
" vimwiki#base#apply_wiki_options
|
||||
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
|
||||
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
|
||||
endif
|
||||
"
|
||||
@ -105,7 +86,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
if a:check > 0
|
||||
echo "\n\nFound wiki options\n g:local_wiki = ".string(g:local_wiki)
|
||||
let query = "Vimwiki: Apply these options [Y]es/[n]o? "
|
||||
if tolower(input(query)) !~ "y"
|
||||
if input(query) =~? '^n'
|
||||
let g:local_wiki = {}
|
||||
continue
|
||||
endif
|
||||
@ -149,7 +130,10 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable
|
||||
let subdir = vimwiki#base#current_subdir(a:idx)
|
||||
call VimwikiSet('subdir', 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
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
@ -246,7 +230,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
||||
let lnk = a:lnk
|
||||
|
||||
" 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)
|
||||
|
||||
" Get scheme
|
||||
@ -260,7 +244,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
||||
let anchor = ''
|
||||
|
||||
"extract anchor
|
||||
if scheme =~ 'wiki' || scheme =~ 'diary'
|
||||
if scheme =~# 'wiki' || scheme =~# 'diary'
|
||||
let split_lnk = split(lnk, '#', 1)
|
||||
let lnk = split_lnk[0]
|
||||
if len(split_lnk) <= 1 || split_lnk[-1] == ''
|
||||
@ -271,13 +255,13 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
||||
endif
|
||||
|
||||
" do nothing if scheme is unknown to vimwiki
|
||||
if !(scheme =~ 'wiki.*' || scheme =~ 'diary' || scheme =~ 'local'
|
||||
\ || scheme =~ 'file')
|
||||
if !(scheme =~# 'wiki.*' || scheme =~# 'diary' || scheme =~# 'local'
|
||||
\ || scheme =~# 'file')
|
||||
return [idx, scheme, path, subdir, lnk, ext, scheme.':'.lnk, anchor]
|
||||
endif
|
||||
|
||||
" scheme behaviors
|
||||
if scheme =~ 'wiki\d\+'
|
||||
if scheme =~# 'wiki\d\+'
|
||||
let idx = eval(matchstr(scheme, '\D\+\zs\d\+\ze'))
|
||||
if idx < 0 || idx >= len(g:vimwiki_list)
|
||||
if !quiet
|
||||
@ -319,9 +303,9 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
||||
|
||||
" default link for directories
|
||||
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
|
||||
elseif scheme =~ 'diary'
|
||||
elseif scheme =~# 'diary'
|
||||
if a:as_html
|
||||
" use cached value (save time when converting diary index!)
|
||||
let path = VimwikiGet('invsubdir')
|
||||
@ -332,7 +316,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
||||
endif
|
||||
let idx = g:vimwiki_current_idx
|
||||
let subdir = VimwikiGet('diary_rel_path')
|
||||
elseif scheme =~ 'local'
|
||||
elseif scheme =~# 'local'
|
||||
" revisiting the 'lcd'-bug ...
|
||||
let path = VimwikiGet('path')
|
||||
let subdir = VimwikiGet('subdir')
|
||||
@ -340,7 +324,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme
|
||||
" prepend browser-specific file: scheme
|
||||
let path = 'file://'.fnamemodify(path, ":p")
|
||||
endif
|
||||
elseif scheme =~ 'file'
|
||||
elseif scheme =~# 'file'
|
||||
" RM repeated leading "/"'s within a link
|
||||
let lnk = substitute(lnk, '^/*', '/', '')
|
||||
" convert "/~..." into "~..." for fnamemodify
|
||||
@ -438,21 +422,21 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
let update_prev_link = ( (scheme == '' || scheme =~ 'wiki' || scheme =~ 'diary')
|
||||
\ && lnk != expand('%:t:r')
|
||||
let update_prev_link = ( (scheme == '' || scheme =~# 'wiki' || scheme =~# 'diary')
|
||||
\ && !vimwiki#path#is_equal(lnk, expand('%:t:r'))
|
||||
\ ? 1 : 0)
|
||||
|
||||
let use_system_open = (
|
||||
\ scheme == '' ||
|
||||
\ scheme =~ 'wiki' ||
|
||||
\ scheme =~ 'diary' ? 0 : 1)
|
||||
\ scheme =~# 'wiki' ||
|
||||
\ scheme =~# 'diary' ? 0 : 1)
|
||||
|
||||
let vimwiki_prev_link = []
|
||||
" update previous link for wiki pages
|
||||
if update_prev_link
|
||||
if a:0
|
||||
let vimwiki_prev_link = [a:1, []]
|
||||
elseif &ft == 'vimwiki'
|
||||
elseif &ft ==# 'vimwiki'
|
||||
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
||||
endif
|
||||
endif
|
||||
@ -535,7 +519,8 @@ function! vimwiki#base#backlinks() "{{{
|
||||
let links = s:get_links(source_file, idx)
|
||||
for [target_file, _, lnum, col] in links
|
||||
" 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})
|
||||
endif
|
||||
endfor
|
||||
@ -652,7 +637,7 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
||||
endif
|
||||
|
||||
" collect bold text (there can be several in one line)
|
||||
let bold_count = 0
|
||||
let bold_count = 1
|
||||
while 1
|
||||
let bold_text = matchstr(line, rxbold, 0, bold_count)
|
||||
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)
|
||||
let source_dir = fnamemodify(a:source_file, ':p:h').'/'
|
||||
|
||||
if lnk =~ '/$' " link to a directory
|
||||
if lnk =~# '/$' " link to a directory
|
||||
return []
|
||||
elseif url == '' && anchor != '' " only anchor
|
||||
return [fnamemodify(a:source_file, ':p'), anchor]
|
||||
elseif scheme == 'file'
|
||||
elseif scheme ==# 'file'
|
||||
return [url, '']
|
||||
elseif scheme == 'local'
|
||||
elseif scheme ==# 'local'
|
||||
return [vimwiki#path#normalize(source_dir.lnk), '']
|
||||
elseif target_idx >= len(g:vimwiki_list) " a malformed link
|
||||
return ['', '']
|
||||
elseif scheme !~ '^wiki\d\+\|diary' " unknown scheme
|
||||
elseif scheme !~# '^wiki\d\+\|diary' " unknown scheme
|
||||
return []
|
||||
endif
|
||||
|
||||
if scheme == 'diary'
|
||||
if scheme ==# 'diary'
|
||||
let root_dir = VimwikiGet('path',a:wiki_nr).
|
||||
\ VimwikiGet('diary_rel_path', a:wiki_nr)
|
||||
let ext = VimwikiGet('ext', a:wiki_nr)
|
||||
else
|
||||
" 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
|
||||
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.
|
||||
" This hack is necessary because apparently Vim messes up the result of
|
||||
" 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
|
||||
endif
|
||||
if a:anchor != ''
|
||||
@ -1064,7 +1049,7 @@ function! s:get_wiki_buffers() "{{{
|
||||
while bcount<=bufnr("$")
|
||||
if bufexists(bcount)
|
||||
let bname = fnamemodify(bufname(bcount), ":p")
|
||||
if bname =~ VimwikiGet('ext')."$"
|
||||
if bname =~# VimwikiGet('ext')."$"
|
||||
let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
|
||||
call add(blist, bitem)
|
||||
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
|
||||
" the rest syntax rules as now it has effect being really 'contained'.
|
||||
" Clear it!
|
||||
if ft =~ 'perl'
|
||||
if ft =~? 'perl'
|
||||
syntax clear perlFunctionName
|
||||
endif
|
||||
endfunction "}}}
|
||||
@ -1140,8 +1125,8 @@ endfunction " }}}
|
||||
" vimwiki#base#find_prev_link
|
||||
function! vimwiki#base#find_prev_link() "{{{
|
||||
"Jump 2 times if the cursor is in the middle of a link
|
||||
if synIDattr(synID(line('.'), col('.'), 0), "name") =~ "VimwikiLink.*" &&
|
||||
\ synIDattr(synID(line('.'), col('.')-1, 0), "name") =~ "VimwikiLink.*"
|
||||
if synIDattr(synID(line('.'), col('.'), 0), "name") =~# "VimwikiLink.*" &&
|
||||
\ synIDattr(synID(line('.'), col('.')-1, 0), "name") =~# "VimwikiLink.*"
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||
endif
|
||||
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)
|
||||
endif
|
||||
else
|
||||
if a:split == "split"
|
||||
if a:split ==# "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
elseif a:split ==# "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
elseif a:split ==# "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
@ -1247,8 +1232,8 @@ endfunction "}}}
|
||||
function! vimwiki#base#delete_link() "{{{
|
||||
"" file system funcs
|
||||
"" Delete wiki link you are in from filesystem
|
||||
let val = input('Delete ['.expand('%').'] (y/n)? ', "")
|
||||
if val != 'y'
|
||||
let val = input('Delete "'.expand('%').'" [y]es/[N]o? ')
|
||||
if val !~? '^y'
|
||||
return
|
||||
endif
|
||||
let fname = expand('%:p')
|
||||
@ -1281,14 +1266,14 @@ function! vimwiki#base#rename_link() "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
let val = input('Rename "'.expand('%:t:r').'" (y/n)? ', "")
|
||||
if val!='y'
|
||||
let val = input('Rename "'.expand('%:t:r').'" [y]es/[N]o? ')
|
||||
if val !~? '^y'
|
||||
return
|
||||
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.
|
||||
echomsg 'vimwiki: Cannot rename to a filename with path!'
|
||||
return
|
||||
@ -1355,7 +1340,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
|
||||
" restore wiki buffers
|
||||
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)
|
||||
endif
|
||||
endfor
|
||||
@ -1419,7 +1404,7 @@ function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||
call cursor(line('$'), 0)
|
||||
endif
|
||||
|
||||
if a:inner && getline(line('.')) =~ '^\s*$'
|
||||
if a:inner && getline(line('.')) =~# '^\s*$'
|
||||
let lnum = prevnonblank(line('.') - 1)
|
||||
call cursor(lnum, 0)
|
||||
endif
|
||||
@ -1515,7 +1500,7 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||
" | bla | bla |
|
||||
" |-------+-------|
|
||||
" or it will select wrong column.
|
||||
if strpart(getline('.'), virtcol('.')-1) =~ '^-+'
|
||||
if strpart(getline('.'), virtcol('.')-1) =~# '^-+'
|
||||
let s_flag = 'b'
|
||||
else
|
||||
let s_flag = 'cb'
|
||||
@ -1538,7 +1523,7 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||
normal! `>
|
||||
if !firsttime && getline('.')[virtcol('.')] == '|'
|
||||
normal! l
|
||||
elseif a:inner && getline('.')[virtcol('.')+1] =~ '[|+]'
|
||||
elseif a:inner && getline('.')[virtcol('.')+1] =~# '[|+]'
|
||||
normal! 2l
|
||||
endif
|
||||
" search for the next column separator
|
||||
@ -1569,7 +1554,7 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||
" | bla | bla |
|
||||
" |-------+-------|
|
||||
" or it will select wrong column.
|
||||
if strpart(getline('.'), virtcol('.')-1) =~ '^-+'
|
||||
if strpart(getline('.'), virtcol('.')-1) =~# '^-+'
|
||||
let s_flag = 'b'
|
||||
else
|
||||
let s_flag = 'cb'
|
||||
@ -1612,11 +1597,11 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
let rxHdr = g:vimwiki_rxH
|
||||
if line =~ '^\s*$'
|
||||
if line =~# '^\s*$'
|
||||
return
|
||||
endif
|
||||
|
||||
if line =~ g:vimwiki_rxHeader
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
let level = vimwiki#u#count_first_sym(line)
|
||||
if level < 6
|
||||
if g:vimwiki_symH
|
||||
@ -1640,16 +1625,16 @@ function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
let rxHdr = g:vimwiki_rxH
|
||||
if line =~ '^\s*$'
|
||||
if line =~# '^\s*$'
|
||||
return
|
||||
endif
|
||||
|
||||
if line =~ g:vimwiki_rxHeader
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
let level = vimwiki#u#count_first_sym(line)
|
||||
let old = repeat(rxHdr, level)
|
||||
let new = repeat(rxHdr, level - 1)
|
||||
|
||||
let chomp = line =~ rxHdr.'\s'
|
||||
let chomp = line =~# rxHdr.'\s'
|
||||
|
||||
if g:vimwiki_symH
|
||||
let line = substitute(line, old, new, 'g')
|
||||
@ -1701,7 +1686,7 @@ function! vimwiki#base#table_of_contents(create)
|
||||
" delete old TOC
|
||||
if toc_line > 0
|
||||
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
|
||||
endwhile
|
||||
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]]
|
||||
for lnum in range(1, line('$'))
|
||||
let line_content = getline(lnum)
|
||||
if line_content !~ g:vimwiki_rxHeader
|
||||
if line_content !~# g:vimwiki_rxHeader
|
||||
continue
|
||||
endif
|
||||
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)
|
||||
let toc_line += 1
|
||||
endfor
|
||||
if getline(toc_line+1) !~ '^\s*$'
|
||||
if getline(toc_line+1) !~# '^\s*$'
|
||||
call append(toc_line, '')
|
||||
endif
|
||||
call setpos('.', old_cursor_pos)
|
||||
@ -1787,16 +1772,16 @@ endfunction " }}}
|
||||
" s:clean_url
|
||||
function! s:clean_url(url) " {{{
|
||||
let url = split(a:url, '/\|=\|-\|&\|?\|\.')
|
||||
let url = filter(url, 'v:val != ""')
|
||||
let url = filter(url, 'v:val != "www"')
|
||||
let url = filter(url, 'v:val != "com"')
|
||||
let url = filter(url, 'v:val != "org"')
|
||||
let url = filter(url, 'v:val != "net"')
|
||||
let url = filter(url, 'v:val != "edu"')
|
||||
let url = filter(url, 'v:val != "http\:"')
|
||||
let url = filter(url, 'v:val != "https\:"')
|
||||
let url = filter(url, 'v:val != "file\:"')
|
||||
let url = filter(url, 'v:val != "xml\:"')
|
||||
let url = filter(url, 'v:val !=# ""')
|
||||
let url = filter(url, 'v:val !=# "www"')
|
||||
let url = filter(url, 'v:val !=# "com"')
|
||||
let url = filter(url, 'v:val !=# "org"')
|
||||
let url = filter(url, 'v:val !=# "net"')
|
||||
let url = filter(url, 'v:val !=# "edu"')
|
||||
let url = filter(url, 'v:val !=# "http\:"')
|
||||
let url = filter(url, 'v:val !=# "https\:"')
|
||||
let url = filter(url, 'v:val !=# "file\:"')
|
||||
let url = filter(url, 'v:val !=# "xml\:"')
|
||||
return join(url, " ")
|
||||
endfunction " }}}
|
||||
|
||||
@ -2236,7 +2221,7 @@ endfunction " }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" 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'
|
||||
endfor
|
||||
" -------------------------------------------------------------------------
|
||||
|
@ -25,17 +25,6 @@ function! s:get_date_link(fmt) "{{{
|
||||
return strftime(a:fmt)
|
||||
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(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
|
||||
@ -54,7 +43,7 @@ endfunction "}}}
|
||||
function! s:get_position_links(link) "{{{
|
||||
let idx = -1
|
||||
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())
|
||||
" include 'today' into links
|
||||
if index(links, s:diary_date_link()) == -1
|
||||
@ -81,7 +70,7 @@ fun! s:read_captions(files) "{{{
|
||||
|
||||
if filereadable(fl)
|
||||
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))
|
||||
endif
|
||||
endfor
|
||||
@ -99,10 +88,10 @@ fun! s:get_diary_links(...) "{{{
|
||||
let rx = '^\d\{4}-\d\d-\d\d'
|
||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||
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~)
|
||||
call filter(files, 'v:val !~ ''.*\~$''')
|
||||
call filter(files, 'v:val !~# ''.*\~$''')
|
||||
|
||||
if a:0
|
||||
call add(files, a:1)
|
||||
@ -134,7 +123,7 @@ fun! s:group_links(links) "{{{
|
||||
endfun "}}}
|
||||
|
||||
fun! s:sort(lst) "{{{
|
||||
if VimwikiGet("diary_sort") == 'desc'
|
||||
if VimwikiGet("diary_sort") ==? 'desc'
|
||||
return reverse(sort(a:lst))
|
||||
else
|
||||
return sort(a:lst)
|
||||
@ -311,7 +300,7 @@ endfunction "}}}
|
||||
function! vimwiki#diary#generate_diary_section() "{{{
|
||||
let current_file = vimwiki#path#path_norm(expand("%:p"))
|
||||
let diary_file = vimwiki#path#path_norm(s:diary_index())
|
||||
if current_file == diary_file
|
||||
if vimwiki#path#is_equal(current_file, diary_file)
|
||||
call s:delete_diary_section()
|
||||
call s:insert_diary_section()
|
||||
else
|
||||
@ -327,7 +316,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
|
||||
let link = a:year.'-'.month.'-'.day
|
||||
if winnr('#') == 0
|
||||
if a:dir == 'V'
|
||||
if a:dir ==? 'V'
|
||||
vsplit
|
||||
else
|
||||
split
|
||||
|
@ -27,31 +27,31 @@ function! s:root_path(subdir) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:syntax_supported() " {{{
|
||||
return VimwikiGet('syntax') == "default"
|
||||
return VimwikiGet('syntax') ==? "default"
|
||||
endfunction " }}}
|
||||
|
||||
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)
|
||||
endwhile
|
||||
endfunction "}}}
|
||||
|
||||
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
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_img_link(lnk) "{{{
|
||||
if tolower(a:lnk) =~ '\.\%(png\|jpg\|gif\|jpeg\)$'
|
||||
if tolower(a:lnk) =~# '\.\%(png\|jpg\|gif\|jpeg\)$'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:has_abs_path(fname) "{{{
|
||||
if a:fname =~ '\(^.:\)\|\(^/\)'
|
||||
if a:fname =~# '\(^.:\)\|\(^/\)'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
@ -103,7 +103,7 @@ function! s:template_full_name(name) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_html_template(wikifile, template) "{{{
|
||||
function! s:get_html_template(template) "{{{
|
||||
" TODO: refactor it!!!
|
||||
let lines=[]
|
||||
|
||||
@ -204,7 +204,7 @@ function! s:subst_func(line, regexp, func, ...) " {{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:save_vimwiki_buffer() "{{{
|
||||
if &filetype == 'vimwiki' && filewritable(expand('%'))
|
||||
if &filetype ==? 'vimwiki' && filewritable(expand('%'))
|
||||
silent update
|
||||
endif
|
||||
endfunction "}}}
|
||||
@ -214,7 +214,7 @@ function! s:process_title(placeholders, default_title) "{{{
|
||||
if !empty(a:placeholders)
|
||||
for [placeholder, row, idx] in a:placeholders
|
||||
let [type, param] = placeholder
|
||||
if type == 'title' && !empty(param)
|
||||
if type ==# 'title' && !empty(param)
|
||||
return param
|
||||
endif
|
||||
endfor
|
||||
@ -243,7 +243,7 @@ endfunction "}}}
|
||||
function! s:html_insert_contents(html_lines, content) "{{{
|
||||
let lines = []
|
||||
for line in a:html_lines
|
||||
if line =~ '%content%'
|
||||
if line =~# '%content%'
|
||||
let parts = split(line, '%content%', 1)
|
||||
if empty(parts)
|
||||
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 descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
|
||||
let descr = (descr == "" ? a:src : descr)
|
||||
let descr_str = (descr =~ g:vimwiki_rxWikiIncl
|
||||
let descr_str = (descr =~# g:vimwiki_rxWikiIncl
|
||||
\ ? s:tag_wikiincl(descr)
|
||||
\ : descr)
|
||||
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 line = ''
|
||||
if value =~ '|'
|
||||
if value =~# '|'
|
||||
let link_parts = split(value, "|", 1)
|
||||
else
|
||||
let link_parts = split(value, "][", 1)
|
||||
@ -457,8 +457,8 @@ function! s:tag_remove_external_link(value) "{{{
|
||||
let lnkElements = split(value)
|
||||
let head = lnkElements[0]
|
||||
let rest = join(lnkElements[1:])
|
||||
if rest==""
|
||||
let rest=head
|
||||
if rest == ""
|
||||
let rest = head
|
||||
endif
|
||||
let line = rest
|
||||
elseif s:is_img_link(value)
|
||||
@ -484,7 +484,8 @@ function! s:make_tag(line, regexp, func, ...) "{{{
|
||||
|
||||
"FIXME FIXME !!! these can easily occur on the same line!
|
||||
"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)
|
||||
else
|
||||
let pos = 0
|
||||
@ -675,7 +676,7 @@ function! s:close_tag_table(table, ldest, header_ids) "{{{
|
||||
call s:sum_rowspan(table)
|
||||
call s:sum_colspan(table)
|
||||
|
||||
if table[0] == 'center'
|
||||
if table[0] ==# 'center'
|
||||
call add(ldest, "<table class='center'>")
|
||||
else
|
||||
call add(ldest, "<table>")
|
||||
@ -734,8 +735,8 @@ function! s:process_tag_pre(line, pre) "{{{
|
||||
let pre = a:pre
|
||||
let processed = 0
|
||||
"XXX huh?
|
||||
"if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
|
||||
if !pre[0] && a:line =~ '^\s*{{{'
|
||||
"if !pre[0] && a:line =~# '^\s*{{{[^\(}}}\)]*\s*$'
|
||||
if !pre[0] && a:line =~# '^\s*{{{'
|
||||
let class = matchstr(a:line, '{{{\zs.*$')
|
||||
"FIXME class cannot contain arbitrary strings
|
||||
let class = substitute(class, '\s\+$', '', 'g')
|
||||
@ -746,7 +747,7 @@ function! s:process_tag_pre(line, pre) "{{{
|
||||
endif
|
||||
let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
|
||||
let processed = 1
|
||||
elseif pre[0] && a:line =~ '^\s*}}}\s*$'
|
||||
elseif pre[0] && a:line =~# '^\s*}}}\s*$'
|
||||
let pre = [0, 0]
|
||||
call add(lines, "</pre>")
|
||||
let processed = 1
|
||||
@ -764,13 +765,14 @@ function! s:process_tag_math(line, math) "{{{
|
||||
let lines = []
|
||||
let math = a:math
|
||||
let processed = 0
|
||||
if !math[0] && a:line =~ '^\s*{{\$[^\(}}$\)]*\s*$'
|
||||
if !math[0] && a:line =~# '^\s*{{\$[^\(}}$\)]*\s*$'
|
||||
let class = matchstr(a:line, '{{$\zs.*$')
|
||||
"FIXME class cannot be any string!
|
||||
let class = substitute(class, '\s\+$', '', 'g')
|
||||
" Check the math placeholder (default: displaymath)
|
||||
let b:vimwiki_mathEnv = matchstr(class, '^%\zs\S\+\ze%')
|
||||
if b:vimwiki_mathEnv != ""
|
||||
" store the environment name in a global variable in order to close the
|
||||
" environment properly
|
||||
let s:current_math_env = matchstr(class, '^%\zs\S\+\ze%')
|
||||
if s:current_math_env != ""
|
||||
call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', ''))
|
||||
elseif class != ""
|
||||
call add(lines, "\\\[".class)
|
||||
@ -779,10 +781,10 @@ function! s:process_tag_math(line, math) "{{{
|
||||
endif
|
||||
let math = [1, len(matchstr(a:line, '^\s*\ze{{\$'))]
|
||||
let processed = 1
|
||||
elseif math[0] && a:line =~ '^\s*}}\$\s*$'
|
||||
elseif math[0] && a:line =~# '^\s*}}\$\s*$'
|
||||
let math = [0, 0]
|
||||
if b:vimwiki_mathEnv != ""
|
||||
call add(lines, "\\end{".b:vimwiki_mathEnv."}")
|
||||
if s:current_math_env != ""
|
||||
call add(lines, "\\end{".s:current_math_env."}")
|
||||
else
|
||||
call add(lines, "\\\]")
|
||||
endif
|
||||
@ -798,7 +800,7 @@ function! s:process_tag_quote(line, quote) "{{{
|
||||
let lines = []
|
||||
let quote = a:quote
|
||||
let processed = 0
|
||||
if a:line =~ '^\s\{4,}\S'
|
||||
if a:line =~# '^\s\{4,}\S'
|
||||
if !quote
|
||||
call add(lines, "<blockquote>")
|
||||
let quote = 1
|
||||
@ -841,12 +843,12 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
let lines = []
|
||||
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 lstTagOpen = '<ul>'
|
||||
let lstTagClose = '</ul>'
|
||||
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 lstTagOpen = '<ol>'
|
||||
let lstTagClose = '</ol>'
|
||||
@ -891,7 +893,7 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
call add(lines,
|
||||
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
|
||||
let processed = 1
|
||||
elseif in_list && a:line =~ '^\s\+\S\+'
|
||||
elseif in_list && a:line =~# '^\s\+\S\+'
|
||||
if g:vimwiki_list_ignore_newline
|
||||
call add(lines, a:line)
|
||||
else
|
||||
@ -932,14 +934,14 @@ function! s:process_tag_para(line, para) "{{{
|
||||
let lines = []
|
||||
let para = a:para
|
||||
let processed = 0
|
||||
if a:line =~ '^\s\{,3}\S'
|
||||
if a:line =~# '^\s\{,3}\S'
|
||||
if !para
|
||||
call add(lines, "<p>")
|
||||
let para = 1
|
||||
endif
|
||||
let processed = 1
|
||||
call add(lines, a:line)
|
||||
elseif para && a:line =~ '^\s*$'
|
||||
elseif para && a:line =~# '^\s*$'
|
||||
call add(lines, "</p>")
|
||||
let para = 0
|
||||
endif
|
||||
@ -953,7 +955,7 @@ function! s:process_tag_h(line, id) "{{{
|
||||
let h_text = ''
|
||||
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)
|
||||
endif
|
||||
if h_level > 0
|
||||
@ -962,9 +964,9 @@ function! s:process_tag_h(line, id) "{{{
|
||||
let h_number = ''
|
||||
let h_complete_id = ''
|
||||
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]
|
||||
|
||||
@ -1016,7 +1018,7 @@ endfunction "}}}
|
||||
function! s:process_tag_hr(line) "{{{
|
||||
let line = a:line
|
||||
let processed = 0
|
||||
if a:line =~ '^-----*$'
|
||||
if a:line =~# '^-----*$'
|
||||
let line = '<hr />'
|
||||
let processed = 1
|
||||
endif
|
||||
@ -1027,15 +1029,15 @@ function! s:process_tag_table(line, table, header_ids) "{{{
|
||||
function! s:table_empty_cell(value) "{{{
|
||||
let cell = {}
|
||||
|
||||
if a:value =~ '^\s*\\/\s*$'
|
||||
if a:value =~# '^\s*\\/\s*$'
|
||||
let cell.body = ''
|
||||
let cell.rowspan = 0
|
||||
let cell.colspan = 1
|
||||
elseif a:value =~ '^\s*>\s*$'
|
||||
elseif a:value =~# '^\s*>\s*$'
|
||||
let cell.body = ''
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 0
|
||||
elseif a:value =~ '^\s*$'
|
||||
elseif a:value =~# '^\s*$'
|
||||
let cell.body = ' '
|
||||
let cell.rowspan = 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) "{{{
|
||||
if empty(a:table)
|
||||
if a:line =~ '^\s\+'
|
||||
if a:line =~# '^\s\+'
|
||||
let row = ['center', []]
|
||||
else
|
||||
let row = ['normal', []]
|
||||
@ -1132,14 +1134,14 @@ function! s:parse_line(line, state) " {{{
|
||||
"}}}
|
||||
|
||||
if !processed
|
||||
if line =~ g:vimwiki_rxComment
|
||||
if line =~# g:vimwiki_rxComment
|
||||
let processed = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
" nohtml -- placeholder
|
||||
if !processed
|
||||
if line =~ '^\s*%nohtml'
|
||||
if line =~# '^\s*%nohtml'
|
||||
let processed = 1
|
||||
let state.placeholder = ['nohtml']
|
||||
endif
|
||||
@ -1147,7 +1149,7 @@ function! s:parse_line(line, state) " {{{
|
||||
|
||||
" title -- placeholder
|
||||
if !processed
|
||||
if line =~ '^\s*%title'
|
||||
if line =~# '^\s*%title'
|
||||
let processed = 1
|
||||
let param = matchstr(line, '^\s*%title\s\zs.*')
|
||||
let state.placeholder = ['title', param]
|
||||
@ -1156,7 +1158,7 @@ function! s:parse_line(line, state) " {{{
|
||||
|
||||
" html template -- placeholder "{{{
|
||||
if !processed
|
||||
if line =~ '^\s*%template'
|
||||
if line =~# '^\s*%template'
|
||||
let processed = 1
|
||||
let param = matchstr(line, '^\s*%template\s\zs.*')
|
||||
let state.placeholder = ['template', param]
|
||||
@ -1401,10 +1403,10 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
endif
|
||||
|
||||
if !empty(state.placeholder)
|
||||
if state.placeholder[0] == 'nohtml'
|
||||
if state.placeholder[0] ==# 'nohtml'
|
||||
let nohtml = 1
|
||||
break
|
||||
elseif state.placeholder[0] == 'template'
|
||||
elseif state.placeholder[0] ==# 'template'
|
||||
let template_name = state.placeholder[1]
|
||||
else
|
||||
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 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)
|
||||
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
|
||||
@ -1543,17 +1545,17 @@ function! s:binary_exists(fname) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
" uses VimwikiGet('path')
|
||||
function! vimwiki#html#get_wikifile_url(wikifile) "{{{
|
||||
function! s:get_wikifile_url(wikifile) "{{{
|
||||
return VimwikiGet('path_html').
|
||||
\ vimwiki#base#subdir(VimwikiGet('path'), a:wikifile).
|
||||
\ fnamemodify(a:wikifile, ":t:r").'.html'
|
||||
endfunction "}}}
|
||||
|
||||
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 "}}}
|
||||
|
||||
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 "}}}
|
||||
"}}}
|
||||
|
@ -185,10 +185,10 @@ endfunction "}}}
|
||||
"Returns: level of the line
|
||||
"0 is the 'highest' level
|
||||
function! s:get_level(lnum) "{{{
|
||||
if getline(a:lnum) =~ '^\s*$'
|
||||
if getline(a:lnum) =~# '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
if VimwikiGet('syntax') != 'media'
|
||||
if VimwikiGet('syntax') !=? 'media'
|
||||
let level = indent(a:lnum)
|
||||
else
|
||||
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 divisor = a:item.mrkr[-1:]
|
||||
|
||||
if number_chars =~ '\d\+'
|
||||
if number_chars =~# '\d\+'
|
||||
return '1'
|
||||
endif
|
||||
if number_chars =~# '\l\+'
|
||||
@ -840,7 +840,7 @@ function! vimwiki#lst#toggle_cb(from_line, to_line) "{{{
|
||||
|
||||
"if from_line has CB, toggle it and set all siblings to the same new state
|
||||
let rate_first_line = s:get_rate(from_item)
|
||||
let new_rate = rate_first_line==100 ? 0 : 100
|
||||
let new_rate = rate_first_line == 100 ? 0 : 100
|
||||
|
||||
for cur_ln in range(from_item.lnum, a:to_line)
|
||||
let cur_item = s:get_item(cur_ln)
|
||||
@ -922,7 +922,7 @@ endfunction "}}}
|
||||
|
||||
function! s:decrease_level(item) "{{{
|
||||
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
|
||||
if s:string_length(a:item.mrkr) >= 2
|
||||
call s:substitute_string_in_line(a:item.lnum,
|
||||
@ -944,7 +944,7 @@ endfunction "}}}
|
||||
|
||||
function! s:increase_level(item) "{{{
|
||||
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
|
||||
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
|
||||
\ s:first_char(a:item.mrkr))
|
||||
@ -966,7 +966,7 @@ endfunction "}}}
|
||||
"a:indent_by can be negative
|
||||
function! s:indent_line_by(lnum, indent_by) "{{{
|
||||
let item = s:get_item(a:lnum)
|
||||
if VimwikiGet('syntax') == 'media' && item.type == 1 &&
|
||||
if VimwikiGet('syntax') ==? 'media' && item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(item.mrkr)) > -1
|
||||
if a:indent_by > 0
|
||||
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) "{{{
|
||||
let from_item = s:get_corresponding_item(a:from_line)
|
||||
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))
|
||||
"that's because :> doesn't work on an empty line
|
||||
normal! gi
|
||||
else
|
||||
execute a:from_line.','.a:to_line.(a:direction == 'increase' ? '>' : '<')
|
||||
execute a:from_line.','.a:to_line.(a:direction ==# 'increase' ? '>' : '<')
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
if a:direction == 'decrease' && s:get_level(from_item.lnum) == 0
|
||||
if a:direction ==# 'decrease' && s:get_level(from_item.lnum) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1026,7 +1026,7 @@ function! s:change_level(from_line, to_line, direction, plus_children) "{{{
|
||||
let more_than_one_level_concerned = 0
|
||||
|
||||
let first_line_indented_by =
|
||||
\ (a:direction == 'increase') ?
|
||||
\ (a:direction ==# 'increase') ?
|
||||
\ s:increase_level(from_item) : s:decrease_level(from_item)
|
||||
|
||||
let cur_ln = s:get_next_line(from_item.lnum)
|
||||
@ -1112,7 +1112,7 @@ endfunction "}}}
|
||||
function! s:set_new_mrkr(item, new_mrkr) "{{{
|
||||
if a:item.type == 0
|
||||
call s:substitute_rx_in_line(a:item.lnum, '^\s*\zs\ze', a:new_mrkr.' ')
|
||||
if indent(a:item.lnum) == 0 && VimwikiGet('syntax') != 'media'
|
||||
if indent(a:item.lnum) == 0 && VimwikiGet('syntax') !=? 'media'
|
||||
call s:set_indent(a:item.lnum, vimwiki#lst#get_list_margin())
|
||||
endif
|
||||
else
|
||||
@ -1121,7 +1121,7 @@ function! s:set_new_mrkr(item, new_mrkr) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
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 cur_ln = a:from_line
|
||||
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
|
||||
let item_above = s:get_prev_list_item(cur_item, 1)
|
||||
if item_above.type == 1 &&
|
||||
\ s:first_char(item_above.mrkr) ==s:first_char(new_mrkr)
|
||||
\ s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr)
|
||||
let new_mrkr = item_above.mrkr
|
||||
else
|
||||
"use *** if the item below has *** too
|
||||
let item_below = s:get_next_list_item(cur_item, 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
|
||||
else
|
||||
"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 **
|
||||
let parent_item = s:get_parent(cur_item)
|
||||
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),
|
||||
\ s:string_length(parent_item.mrkr)+1)
|
||||
endif
|
||||
@ -1193,7 +1193,7 @@ endfunction "}}}
|
||||
|
||||
"sets kind of the item depending on neighbor items and the parent item
|
||||
function! s:adjust_mrkr(item) "{{{
|
||||
if a:item.type == 0 || VimwikiGet('syntax') == 'media'
|
||||
if a:item.type == 0 || VimwikiGet('syntax') ==? 'media'
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1208,7 +1208,7 @@ function! s:adjust_mrkr(item) "{{{
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
let parent_item = s:get_parent(a:item)
|
||||
if parent_item.type == 1 &&
|
||||
\ s:first_char(parent_item.mrkr) == s:first_char(a:item.mrkr)
|
||||
\ s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr)
|
||||
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
||||
\ s:string_length(parent_item.mrkr)+1)
|
||||
endif
|
||||
@ -1223,7 +1223,7 @@ function! s:clone_marker_from_to(from, to) "{{{
|
||||
if item_from.type == 0 | return | endif
|
||||
let new_mrkr = item_from.mrkr . ' '
|
||||
call s:substitute_rx_in_line(a:to, '^\s*', new_mrkr)
|
||||
let new_indent = ( VimwikiGet('syntax') != 'media' ? indent(a:from) : 0 )
|
||||
let new_indent = ( VimwikiGet('syntax') !=? 'media' ? indent(a:from) : 0 )
|
||||
call s:set_indent(a:to, new_indent)
|
||||
if item_from.cb != ''
|
||||
call s:create_cb(s:get_item(a:to))
|
||||
@ -1286,7 +1286,7 @@ endfunction "}}}
|
||||
function! vimwiki#lst#kbd_O() "{{{
|
||||
normal! Ox
|
||||
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)
|
||||
else
|
||||
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
|
||||
call s:clone_marker_from_to(a:lnum, a:lnum+1)
|
||||
"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)
|
||||
endif
|
||||
else
|
||||
@ -1393,17 +1393,17 @@ function! vimwiki#lst#kbd_cr(normal, just_mrkr) "{{{
|
||||
endif
|
||||
|
||||
let insert_new_marker = (a:normal == 1 || a:normal == 3)
|
||||
if getline('.')[col("'^")-1:] =~ '^\s\+$'
|
||||
if getline('.')[col("'^")-1:] =~# '^\s\+$'
|
||||
let cur_col = 0
|
||||
else
|
||||
let cur_col = col("$") - col("'^")
|
||||
if getline('.')[col("'^")-1] =~ '\s' && exists("*strdisplaywidth")
|
||||
if getline('.')[col("'^")-1] =~# '\s' && exists("*strdisplaywidth")
|
||||
let ws_behind_cursor =
|
||||
\ strdisplaywidth(matchstr(getline('.')[col("'^")-1:], '\s\+'),
|
||||
\ virtcol("'^")-1)
|
||||
let cur_col -= ws_behind_cursor
|
||||
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
|
||||
endif
|
||||
endif
|
||||
@ -1450,7 +1450,7 @@ function! vimwiki#lst#toggle_list_item() "{{{
|
||||
let new_cur_col = col("$") - cur_col_from_eol
|
||||
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!
|
||||
else
|
||||
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
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
else
|
||||
if a:split == "split"
|
||||
if a:split ==# "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
elseif a:split ==# "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
elseif a:split ==# "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
|
@ -9,12 +9,24 @@ function! vimwiki#path#chomp_slash(str) "{{{
|
||||
return substitute(a:str, '[/\\]\+$', '', '')
|
||||
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
|
||||
function! vimwiki#path#normalize(path) "{{{
|
||||
let path = a:path
|
||||
while 1
|
||||
let result = substitute(path, '/[^/]\+/\.\.', '', '')
|
||||
if result == path
|
||||
if result ==# path
|
||||
break
|
||||
endif
|
||||
let path = result
|
||||
@ -38,7 +50,7 @@ endfunction "}}}
|
||||
function! vimwiki#path#is_link_to_dir(link) "{{{
|
||||
" Check if link is to a directory.
|
||||
" It should be ended with \ or /.
|
||||
if a:link =~ '.\+[/\\]$'
|
||||
if a:link =~# '.\+[/\\]$'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
@ -56,7 +68,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
|
||||
|
||||
let idx = 0
|
||||
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
|
||||
endwhile
|
||||
if idx == 0
|
||||
@ -80,7 +92,7 @@ function! vimwiki#path#relpath(dir, file) "{{{
|
||||
let result = []
|
||||
let dir = split(a:dir, '/')
|
||||
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(file, 0)
|
||||
endwhile
|
||||
@ -116,7 +128,8 @@ function! vimwiki#path#mkdir(path, ...) "{{{
|
||||
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
||||
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
|
||||
endif
|
||||
|
||||
|
@ -54,28 +54,28 @@ function! s:sep_splitter() "{{{
|
||||
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) "{{{
|
||||
@ -134,11 +134,11 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
for idx in range(strlen(a:line))
|
||||
" The only way I know Vim can do Unicode...
|
||||
let ch = a:line[idx]
|
||||
if state == 'NONE'
|
||||
if state ==# 'NONE'
|
||||
if ch == '|'
|
||||
let state = 'CELL'
|
||||
endif
|
||||
elseif state == 'CELL'
|
||||
elseif state ==# 'CELL'
|
||||
if ch == '[' || ch == '{'
|
||||
let state = 'BEFORE_QUOTE_START'
|
||||
let quote = ch
|
||||
@ -148,7 +148,7 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
else
|
||||
let cell .= ch
|
||||
endif
|
||||
elseif state == 'BEFORE_QUOTE_START'
|
||||
elseif state ==# 'BEFORE_QUOTE_START'
|
||||
if ch == '[' || ch == '{'
|
||||
let state = 'QUOTE'
|
||||
let quote .= ch
|
||||
@ -157,12 +157,12 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
let cell .= quote.ch
|
||||
let quote = ''
|
||||
endif
|
||||
elseif state == 'QUOTE'
|
||||
elseif state ==# 'QUOTE'
|
||||
if ch == ']' || ch == '}'
|
||||
let state = 'BEFORE_QUOTE_END'
|
||||
endif
|
||||
let quote .= ch
|
||||
elseif state == 'BEFORE_QUOTE_END'
|
||||
elseif state ==# 'BEFORE_QUOTE_END'
|
||||
if ch == ']' || ch == '}'
|
||||
let state = 'CELL'
|
||||
endif
|
||||
@ -495,7 +495,7 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
if !(&filetype ==? 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
@ -570,7 +570,7 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
if !(&filetype ==? 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
|
@ -964,7 +964,7 @@ In HTML the following part >
|
||||
| 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.
|
||||
|
||||
@ -1917,7 +1917,7 @@ See |vimwiki-option-template_path| for details.
|
||||
*vimwiki-option-template_ext*
|
||||
------------------------------------------------------------------------------
|
||||
Key Default value~
|
||||
template_ext .html
|
||||
template_ext .tpl
|
||||
|
||||
Description~
|
||||
Setup template filename extension.
|
||||
@ -2625,6 +2625,19 @@ before the plugin loads. >
|
||||
|
||||
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*
|
||||
@ -2665,6 +2678,7 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
|
||||
???~
|
||||
|
||||
* Support for tags.
|
||||
* Spport for |g:vimwiki_auto_chdir| option.
|
||||
* Support for anchors, see |vimwiki-anchors|
|
||||
* in this context, add support for TOC, see |vimwiki-toc|
|
||||
* remove the now useless %toc placeholder
|
||||
|
@ -46,7 +46,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
let s:line_context = '['
|
||||
return startoflink
|
||||
endif
|
||||
if VimwikiGet('syntax') == 'markdown'
|
||||
if VimwikiGet('syntax') ==? 'markdown'
|
||||
let startofinlinelink = match(line, '\[.*\](\zs[^)]*$')
|
||||
if startofinlinelink != -1
|
||||
let s:line_context = '['
|
||||
@ -75,7 +75,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
|
||||
endif
|
||||
return tags
|
||||
elseif a:base !~ '#'
|
||||
elseif a:base !~# '#'
|
||||
" we look for wiki files
|
||||
|
||||
if a:base =~# '^wiki\d:'
|
||||
@ -108,7 +108,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
" we look for anchors in the given wikifile
|
||||
|
||||
let segments = split(a:base, '#', 1)
|
||||
let given_wikifile = segments[0]=='' ? expand('%:t:r') : segments[0]
|
||||
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
|
||||
let link_infos = vimwiki#base#resolve_scheme(given_wikifile.'#', 0, 1)
|
||||
let wikifile = link_infos[6]
|
||||
let syntax = VimwikiGet('syntax', link_infos[0])
|
||||
@ -172,12 +172,12 @@ function! VimwikiFoldLevel(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
|
||||
" Header/section folding...
|
||||
if line =~ g:vimwiki_rxHeader
|
||||
if line =~# g:vimwiki_rxHeader
|
||||
return '>'.vimwiki#u#count_first_sym(line)
|
||||
" Code block folding...
|
||||
elseif line =~ '^\s*'.g:vimwiki_rxPreStart
|
||||
elseif line =~# '^\s*'.g:vimwiki_rxPreStart
|
||||
return 'a1'
|
||||
elseif line =~ '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||
elseif line =~# '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||
return 's1'
|
||||
else
|
||||
return "="
|
||||
@ -218,7 +218,7 @@ function! VimwikiFoldText() "{{{
|
||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||
let fold_len = v:foldend - v:foldstart + 1
|
||||
let len_text = ' ['.fold_len.'] '
|
||||
if line !~ '^\s*'.g:vimwiki_rxPreStart
|
||||
if line !~# '^\s*'.g:vimwiki_rxPreStart
|
||||
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
||||
return main_text.len_text
|
||||
else
|
||||
|
@ -39,7 +39,8 @@ function! s:find_wiki(path) "{{{
|
||||
while idx < len(g:vimwiki_list)
|
||||
let idx_path = expand(VimwikiGet('path', idx))
|
||||
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
|
||||
endif
|
||||
let idx += 1
|
||||
@ -88,14 +89,14 @@ function! s:vimwiki_idx() " {{{
|
||||
endfunction " }}}
|
||||
|
||||
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().""
|
||||
endif
|
||||
if &filetype == 'vimwiki'
|
||||
if &filetype ==? 'vimwiki'
|
||||
" cache global vars of current state XXX: SLOW!?
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endif
|
||||
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().""
|
||||
endif
|
||||
|
||||
@ -108,7 +109,7 @@ function! s:setup_buffer_leave() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_filetype() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
if g:vimwiki_debug == 3
|
||||
echom "Setup_filetype g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
let time0 = reltime() " start the clock "XXX
|
||||
@ -116,7 +117,7 @@ function! s:setup_filetype() "{{{
|
||||
let path = expand('%:p:h')
|
||||
" XXX: find_wiki() does not (yet) take into consideration the ext
|
||||
let idx = s:find_wiki(path)
|
||||
if g:vimwiki_debug ==3
|
||||
if g:vimwiki_debug == 3
|
||||
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
@ -210,7 +211,7 @@ function! s:setup_buffer_enter() "{{{
|
||||
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().""
|
||||
endif
|
||||
elseif &syntax == 'vimwiki'
|
||||
elseif &syntax ==? 'vimwiki'
|
||||
" to force a rescan of the filesystem which may have changed
|
||||
" and update VimwikiLinks syntax group that depends on it;
|
||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
||||
@ -227,15 +228,15 @@ function! s:setup_buffer_enter() "{{{
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding == 'expr'
|
||||
if g:vimwiki_folding ==? 'expr'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding == 'list' || g:vimwiki_folding == 'lists'
|
||||
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding == 'syntax'
|
||||
elseif g:vimwiki_folding ==? 'syntax'
|
||||
setlocal fdm=syntax
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
else
|
||||
@ -357,6 +358,23 @@ function! VimwikiClear(option, ...) "{{{
|
||||
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 "{{{
|
||||
@ -385,9 +403,9 @@ let s:vimwiki_defaults.ext = '.wiki'
|
||||
let s:vimwiki_defaults.maxhi = 0
|
||||
let s:vimwiki_defaults.syntax = 'default'
|
||||
|
||||
let s:vimwiki_defaults.template_path = ''
|
||||
let s:vimwiki_defaults.template_default = ''
|
||||
let s:vimwiki_defaults.template_ext = ''
|
||||
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
|
||||
let s:vimwiki_defaults.template_default = 'default'
|
||||
let s:vimwiki_defaults.template_ext = '.tpl'
|
||||
|
||||
let s:vimwiki_defaults.nested_syntaxes = {}
|
||||
let s:vimwiki_defaults.auto_export = 0
|
||||
@ -454,6 +472,8 @@ call s:default('map_prefix', '<Leader>w')
|
||||
|
||||
call s:default('current_idx', 0)
|
||||
|
||||
call s:default('auto_chdir', 0)
|
||||
|
||||
" Scheme regexes should be defined even if syntax file is not loaded yet
|
||||
" cause users should be able to <leader>w<leader>w without opening any
|
||||
" vimwiki file first
|
||||
@ -488,7 +508,7 @@ augroup end
|
||||
|
||||
augroup vimwiki
|
||||
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 BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
|
||||
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_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]]
|
||||
|
@ -4,9 +4,6 @@
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" placeholder for math environments
|
||||
let b:vimwiki_mathEnv = ""
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
let g:vimwiki_char_eqin = '\$'
|
||||
|
@ -4,9 +4,6 @@
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" placeholder for math environments
|
||||
let b:vimwiki_mathEnv = ""
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
let g:vimwiki_char_eqin = '\$'
|
||||
|
@ -4,9 +4,6 @@
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" placeholder for math environments
|
||||
let b:vimwiki_mathEnv = ""
|
||||
|
||||
" text: $ equation_inline $
|
||||
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
|
||||
let g:vimwiki_char_eqin = '\$'
|
||||
|
Loading…
Reference in New Issue
Block a user