Remove foldmarkers; general reformatting
This commit is contained in:
parent
90dc1e5871
commit
c1dbf90c29
@ -1,4 +1,4 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: Basic functionality
|
" Desc: Basic functionality
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
@ -8,15 +8,15 @@ if exists("g:loaded_vimwiki_auto") || &cp
|
|||||||
endif
|
endif
|
||||||
let g:loaded_vimwiki_auto = 1
|
let g:loaded_vimwiki_auto = 1
|
||||||
|
|
||||||
" s:safesubstitute
|
|
||||||
function! s:safesubstitute(text, search, replace, mode) "{{{
|
function! s:safesubstitute(text, search, replace, mode)
|
||||||
" Substitute regexp but do not interpret replace
|
" Substitute regexp but do not interpret replace
|
||||||
let escaped = escape(a:replace, '\&')
|
let escaped = escape(a:replace, '\&')
|
||||||
return substitute(a:text, a:search, escaped, a:mode)
|
return substitute(a:text, a:search, escaped, a:mode)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:vimwiki_get_known_syntaxes
|
|
||||||
function! s:vimwiki_get_known_syntaxes() " {{{
|
function! s:vimwiki_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
|
||||||
@ -29,21 +29,22 @@ function! s:vimwiki_get_known_syntaxes() " {{{
|
|||||||
let syntaxes[syn] = 1
|
let syntaxes[syn] = 1
|
||||||
endfor
|
endfor
|
||||||
return keys(syntaxes)
|
return keys(syntaxes)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#file_pattern
|
|
||||||
function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
|
function! vimwiki#base#file_pattern(files)
|
||||||
|
" Get search regex from glob()
|
||||||
" string. Aim to support *all* special characters, forcing the user to choose
|
" string. Aim to support *all* special characters, forcing the user to choose
|
||||||
" names that are compatible with any external restrictions that they
|
" names that are compatible with any external restrictions that they
|
||||||
" encounter (e.g. filesystem, wiki conventions, other syntaxes, ...).
|
" encounter (e.g. filesystem, wiki conventions, other syntaxes, ...).
|
||||||
" See: https://github.com/vimwiki-backup/vimwiki/issues/316
|
" See: https://github.com/vimwiki-backup/vimwiki/issues/316
|
||||||
" Change / to [/\\] to allow "Windows paths"
|
" Change / to [/\\] to allow "Windows paths"
|
||||||
return '\V\%('.join(a:files, '\|').'\)\m'
|
return '\V\%('.join(a:files, '\|').'\)\m'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#base#subdir
|
|
||||||
"FIXME TODO slow and faulty
|
"FIXME TODO slow and faulty
|
||||||
function! vimwiki#base#subdir(path, filename) "{{{
|
function! vimwiki#base#subdir(path, filename)
|
||||||
let path = a:path
|
let path = a:path
|
||||||
" ensure that we are not fooled by a symbolic link
|
" ensure that we are not fooled by a symbolic link
|
||||||
"FIXME if we are not "fooled", we end up in a completely different wiki?
|
"FIXME if we are not "fooled", we end up in a completely different wiki?
|
||||||
@ -64,29 +65,28 @@ function! vimwiki#base#subdir(path, filename) "{{{
|
|||||||
let res = res.'/'
|
let res = res.'/'
|
||||||
endif
|
endif
|
||||||
return res
|
return res
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#current_subdir
|
|
||||||
function! vimwiki#base#current_subdir()"{{{
|
function! vimwiki#base#current_subdir()
|
||||||
return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), expand('%:p'))
|
return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), expand('%:p'))
|
||||||
endfunction"}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#invsubdir
|
|
||||||
function! vimwiki#base#invsubdir(subdir) " {{{
|
function! vimwiki#base#invsubdir(subdir)
|
||||||
return substitute(a:subdir, '[^/\.]\+/', '../', 'g')
|
return substitute(a:subdir, '[^/\.]\+/', '../', 'g')
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Returns: the number of the wiki a file belongs to or -1 if it doesn't belong
|
" Returns: the number of the wiki a file belongs to or -1 if it doesn't belong
|
||||||
" to any registered wiki.
|
" to any registered wiki.
|
||||||
" The path can be the full path or just the directory of the file
|
" The path can be the full path or just the directory of the file
|
||||||
function! vimwiki#base#find_wiki(path) "{{{
|
function! vimwiki#base#find_wiki(path)
|
||||||
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
|
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
|
||||||
for idx in range(vimwiki#vars#number_of_wikis())
|
for idx in range(vimwiki#vars#number_of_wikis())
|
||||||
let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx))
|
let idx_path = expand(vimwiki#vars#get_wikilocal('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#is_equal(
|
if vimwiki#path#is_equal(vimwiki#path#path_common_pfx(idx_path, path), idx_path)
|
||||||
\ vimwiki#path#path_common_pfx(idx_path, path), idx_path)
|
|
||||||
return idx
|
return idx
|
||||||
endif
|
endif
|
||||||
let idx += 1
|
let idx += 1
|
||||||
@ -94,14 +94,14 @@ function! vimwiki#base#find_wiki(path) "{{{
|
|||||||
|
|
||||||
" an orphan page has been detected
|
" an orphan page has been detected
|
||||||
return -1
|
return -1
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" THE central function of Vimwiki. Extract infos about the target from a link.
|
" THE central function of Vimwiki. Extract infos about the target from a link.
|
||||||
" If the second parameter is present, which should be an absolute file path, it
|
" If the second parameter is present, which should be an absolute file path, it
|
||||||
" is assumed that the link appears in that file. Without it, the current file
|
" is assumed that the link appears in that file. Without it, the current file
|
||||||
" is used.
|
" is used.
|
||||||
function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
function! vimwiki#base#resolve_link(link_text, ...)
|
||||||
if a:0
|
if a:0
|
||||||
let source_wiki = vimwiki#base#find_wiki(a:1)
|
let source_wiki = vimwiki#base#find_wiki(a:1)
|
||||||
let source_file = a:1
|
let source_file = a:1
|
||||||
@ -138,8 +138,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
|||||||
endif
|
endif
|
||||||
let link_text = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchUrl'))
|
let link_text = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchUrl'))
|
||||||
|
|
||||||
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' ||
|
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' || link_infos.scheme ==# 'diary'
|
||||||
\ link_infos.scheme ==# 'diary'
|
|
||||||
|
|
||||||
" extract anchor
|
" extract anchor
|
||||||
if is_wiki_link
|
if is_wiki_link
|
||||||
@ -198,8 +197,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
|||||||
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
|
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
|
||||||
\ link_text .
|
\ link_text .
|
||||||
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
|
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
|
||||||
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local')
|
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') && is_relative
|
||||||
\ && is_relative
|
|
||||||
let link_infos.filename = simplify(root_dir . link_text)
|
let link_infos.filename = simplify(root_dir . link_text)
|
||||||
else " absolute file link
|
else " absolute file link
|
||||||
" collapse repeated leading "/"'s within a link
|
" collapse repeated leading "/"'s within a link
|
||||||
@ -211,11 +209,10 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
|||||||
|
|
||||||
let link_infos.filename = vimwiki#path#normalize(link_infos.filename)
|
let link_infos.filename = vimwiki#path#normalize(link_infos.filename)
|
||||||
return link_infos
|
return link_infos
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#base#system_open_link
|
function! vimwiki#base#system_open_link(url)
|
||||||
function! vimwiki#base#system_open_link(url) "{{{
|
|
||||||
" handlers
|
" handlers
|
||||||
function! s:win32_handler(url)
|
function! s:win32_handler(url)
|
||||||
"http://vim.wikia.com/wiki/Opening_current_Vim_file_in_your_Windows_browser
|
"http://vim.wikia.com/wiki/Opening_current_Vim_file_in_your_Windows_browser
|
||||||
@ -255,10 +252,10 @@ function! vimwiki#base#system_open_link(url) "{{{
|
|||||||
endif
|
endif
|
||||||
endtry
|
endtry
|
||||||
echomsg 'Vimwiki Error: Default Vimwiki link handler was unable to open the HTML file!'
|
echomsg 'Vimwiki Error: Default Vimwiki link handler was unable to open the HTML file!'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#open_link
|
|
||||||
function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
function! vimwiki#base#open_link(cmd, link, ...)
|
||||||
let link_infos = {}
|
let link_infos = {}
|
||||||
if a:0
|
if a:0
|
||||||
let link_infos = vimwiki#base#resolve_link(a:link, a:1)
|
let link_infos = vimwiki#base#resolve_link(a:link, a:1)
|
||||||
@ -271,8 +268,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+'
|
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' || link_infos.scheme =~# 'diary'
|
||||||
\ || link_infos.scheme =~# 'diary'
|
|
||||||
|
|
||||||
let update_prev_link = is_wiki_link &&
|
let update_prev_link = is_wiki_link &&
|
||||||
\ !vimwiki#path#is_equal(link_infos.filename, vimwiki#path#current_wiki_file())
|
\ !vimwiki#path#is_equal(link_infos.filename, vimwiki#path#current_wiki_file())
|
||||||
@ -294,14 +290,15 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
|||||||
else
|
else
|
||||||
call vimwiki#base#system_open_link(link_infos.filename)
|
call vimwiki#base#system_open_link(link_infos.filename)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#get_globlinks_escaped
|
|
||||||
function! vimwiki#base#get_globlinks_escaped() abort "{{{only get links from the current dir
|
function! vimwiki#base#get_globlinks_escaped() abort
|
||||||
|
" only get links from the current dir
|
||||||
" change to the directory of the current file
|
" change to the directory of the current file
|
||||||
let orig_pwd = getcwd()
|
let orig_pwd = getcwd()
|
||||||
lcd! %:h
|
lcd! %:h
|
||||||
" all path are relative to the current file's location
|
" all path are relative to the current file's location
|
||||||
let globlinks = glob('*'.vimwiki#vars#get_wikilocal('ext'), 1)."\n"
|
let globlinks = glob('*'.vimwiki#vars#get_wikilocal('ext'), 1)."\n"
|
||||||
" remove extensions
|
" remove extensions
|
||||||
let globlinks = substitute(globlinks, '\'.vimwiki#vars#get_wikilocal('ext').'\ze\n', '', 'g')
|
let globlinks = substitute(globlinks, '\'.vimwiki#vars#get_wikilocal('ext').'\ze\n', '', 'g')
|
||||||
@ -315,17 +312,16 @@ function! vimwiki#base#get_globlinks_escaped() abort "{{{only get links from the
|
|||||||
let globlinks = join(lst, "\n")
|
let globlinks = join(lst, "\n")
|
||||||
" return all escaped links as a single newline-separated string
|
" return all escaped links as a single newline-separated string
|
||||||
return globlinks
|
return globlinks
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#generate_links
|
|
||||||
function! vimwiki#base#generate_links() "{{{
|
function! vimwiki#base#generate_links()
|
||||||
let lines = []
|
let lines = []
|
||||||
|
|
||||||
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
|
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
|
||||||
call sort(links)
|
call sort(links)
|
||||||
|
|
||||||
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
|
let bullet = repeat(' ', vimwiki#lst#get_list_margin()) . vimwiki#lst#default_symbol().' '
|
||||||
\ vimwiki#lst#default_symbol().' '
|
|
||||||
for link in links
|
for link in links
|
||||||
let abs_filepath = vimwiki#path#abs_path_of_link(link)
|
let abs_filepath = vimwiki#path#abs_path_of_link(link)
|
||||||
if !s:is_diary_file(abs_filepath)
|
if !s:is_diary_file(abs_filepath)
|
||||||
@ -337,22 +333,21 @@ function! vimwiki#base#generate_links() "{{{
|
|||||||
|
|
||||||
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
||||||
|
|
||||||
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Links', links_rx,
|
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Links', links_rx, line('$')+1, 1)
|
||||||
\ line('$')+1, 1)
|
endfunction
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
" vimwiki#base#goto
|
|
||||||
function! vimwiki#base#goto(...) "{{{
|
function! vimwiki#base#goto(...)
|
||||||
let key = a:1
|
let key = a:1
|
||||||
let anchor = a:0 > 1 ? a:2 : ''
|
let anchor = a:0 > 1 ? a:2 : ''
|
||||||
|
|
||||||
call vimwiki#base#edit_file(':e',
|
call vimwiki#base#edit_file(':e',
|
||||||
\ vimwiki#vars#get_wikilocal('path') . key . vimwiki#vars#get_wikilocal('ext'),
|
\ vimwiki#vars#get_wikilocal('path') . key . vimwiki#vars#get_wikilocal('ext'),
|
||||||
\ anchor)
|
\ anchor)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#backlinks
|
|
||||||
function! vimwiki#base#backlinks() "{{{
|
function! vimwiki#base#backlinks()
|
||||||
let current_filename = expand("%:p")
|
let current_filename = expand("%:p")
|
||||||
let locations = []
|
let locations = []
|
||||||
for idx in range(vimwiki#vars#number_of_wikis())
|
for idx in range(vimwiki#vars#number_of_wikis())
|
||||||
@ -376,7 +371,8 @@ function! vimwiki#base#backlinks() "{{{
|
|||||||
call setloclist(0, locations, 'r')
|
call setloclist(0, locations, 'r')
|
||||||
lopen
|
lopen
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Returns: a list containing all files of the given wiki as absolute file path.
|
" Returns: a list containing all files of the given wiki as absolute file path.
|
||||||
" If the given wiki number is negative, the diary of the current wiki is used
|
" If the given wiki number is negative, the diary of the current wiki is used
|
||||||
@ -386,7 +382,8 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
|
|||||||
if wiki_nr >= 0
|
if wiki_nr >= 0
|
||||||
let root_directory = vimwiki#vars#get_wikilocal('path', wiki_nr)
|
let root_directory = vimwiki#vars#get_wikilocal('path', wiki_nr)
|
||||||
else
|
else
|
||||||
let root_directory = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
let root_directory = vimwiki#vars#get_wikilocal('path') .
|
||||||
|
\ vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||||
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
endif
|
endif
|
||||||
if a:directories_only
|
if a:directories_only
|
||||||
@ -405,6 +402,7 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
|
|||||||
return split(globpath(root_directory, pattern), '\n')
|
return split(globpath(root_directory, pattern), '\n')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Returns: a list containing the links to get from the current file to all wiki
|
" Returns: a list containing the links to get from the current file to all wiki
|
||||||
" files in the given wiki.
|
" files in the given wiki.
|
||||||
" If the given wiki number is negative, the diary of the current wiki is used.
|
" If the given wiki number is negative, the diary of the current wiki is used.
|
||||||
@ -439,6 +437,7 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
|
|||||||
return result
|
return result
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Returns: a list containing the links to all directories from the current file
|
" Returns: a list containing the links to all directories from the current file
|
||||||
function! vimwiki#base#get_wiki_directories(wiki_nr)
|
function! vimwiki#base#get_wiki_directories(wiki_nr)
|
||||||
let dirs = vimwiki#base#find_files(a:wiki_nr, 1)
|
let dirs = vimwiki#base#find_files(a:wiki_nr, 1)
|
||||||
@ -460,7 +459,8 @@ function! vimwiki#base#get_wiki_directories(wiki_nr)
|
|||||||
return result
|
return result
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
|
||||||
|
function! vimwiki#base#get_anchors(filename, syntax)
|
||||||
if !filereadable(a:filename)
|
if !filereadable(a:filename)
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
@ -531,10 +531,10 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
return anchors
|
return anchors
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" s:jump_to_anchor
|
|
||||||
function! s:jump_to_anchor(anchor) "{{{
|
function! s:jump_to_anchor(anchor)
|
||||||
let oldpos = getpos('.')
|
let oldpos = getpos('.')
|
||||||
call cursor(1, 1)
|
call cursor(1, 1)
|
||||||
|
|
||||||
@ -554,21 +554,20 @@ function! s:jump_to_anchor(anchor) "{{{
|
|||||||
\ vimwiki#vars#get_syntaxlocal('tag_match'),
|
\ vimwiki#vars#get_syntaxlocal('tag_match'),
|
||||||
\ '__Tag__', segment, '')
|
\ '__Tag__', segment, '')
|
||||||
|
|
||||||
if !search(anchor_tag, 'Wc')
|
if !search(anchor_tag, 'Wc') && !search(anchor_header, 'Wc') && !search(anchor_bold, 'Wc')
|
||||||
\ && !search(anchor_header, 'Wc')
|
|
||||||
\ && !search(anchor_bold, 'Wc')
|
|
||||||
call setpos('.', oldpos)
|
call setpos('.', oldpos)
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
let oldpos = getpos('.')
|
let oldpos = getpos('.')
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Params: full path to a wiki file and its wiki number
|
" Params: full path to a wiki file and its wiki number
|
||||||
" Returns: a list of all links inside the wiki file
|
" Returns: a list of all links inside the wiki file
|
||||||
" Every list item has the form
|
" Every list item has the form
|
||||||
" [target file, anchor, line number of the link in source file, column number]
|
" [target file, anchor, line number of the link in source file, column number]
|
||||||
function! s:get_links(wikifile, idx) "{{{
|
function! s:get_links(wikifile, idx)
|
||||||
if !filereadable(a:wikifile)
|
if !filereadable(a:wikifile)
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
@ -590,17 +589,17 @@ function! s:get_links(wikifile, idx) "{{{
|
|||||||
endif
|
endif
|
||||||
let link_count += 1
|
let link_count += 1
|
||||||
let target = vimwiki#base#resolve_link(link_text, a:wikifile)
|
let target = vimwiki#base#resolve_link(link_text, a:wikifile)
|
||||||
if target.filename != '' &&
|
if target.filename != '' && target.scheme =~# '\mwiki\d\+\|diary\|file\|local'
|
||||||
\ target.scheme =~# '\mwiki\d\+\|diary\|file\|local'
|
|
||||||
call add(links, [target.filename, target.anchor, lnum, col])
|
call add(links, [target.filename, target.anchor, lnum, col])
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return links
|
return links
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#base#check_links() "{{{
|
|
||||||
|
function! vimwiki#base#check_links()
|
||||||
let anchors_of_files = {}
|
let anchors_of_files = {}
|
||||||
let links_of_files = {}
|
let links_of_files = {}
|
||||||
let errors = []
|
let errors = []
|
||||||
@ -659,8 +658,8 @@ function! vimwiki#base#check_links() "{{{
|
|||||||
|
|
||||||
" mark every index file as reachable
|
" mark every index file as reachable
|
||||||
for idx in range(vimwiki#vars#number_of_wikis())
|
for idx in range(vimwiki#vars#number_of_wikis())
|
||||||
let index_file = vimwiki#vars#get_wikilocal('path', idx) . vimwiki#vars#get_wikilocal('index', idx) .
|
let index_file = vimwiki#vars#get_wikilocal('path', idx) .
|
||||||
\ vimwiki#vars#get_wikilocal('ext', idx)
|
\ vimwiki#vars#get_wikilocal('index', idx) . vimwiki#vars#get_wikilocal('ext', idx)
|
||||||
if filereadable(index_file)
|
if filereadable(index_file)
|
||||||
let reachable_wikifiles[index_file] = 1
|
let reachable_wikifiles[index_file] = 1
|
||||||
endif
|
endif
|
||||||
@ -697,10 +696,10 @@ function! vimwiki#base#check_links() "{{{
|
|||||||
call setqflist(errors, 'r')
|
call setqflist(errors, 'r')
|
||||||
copen
|
copen
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#edit_file
|
|
||||||
function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
function! vimwiki#base#edit_file(command, filename, anchor, ...)
|
||||||
let fname = escape(a:filename, '% *|#`')
|
let fname = escape(a:filename, '% *|#`')
|
||||||
let dir = fnamemodify(a:filename, ":p:h")
|
let dir = fnamemodify(a:filename, ":p:h")
|
||||||
|
|
||||||
@ -751,19 +750,19 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
|||||||
if a:0 && a:2 && len(a:1) > 0
|
if a:0 && a:2 && len(a:1) > 0
|
||||||
call vimwiki#vars#set_bufferlocal('prev_link', a:1)
|
call vimwiki#vars#set_bufferlocal('prev_link', a:1)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#search_word
|
|
||||||
function! vimwiki#base#search_word(wikiRx, cmd) "{{{
|
function! vimwiki#base#search_word(wikiRx, cmd)
|
||||||
let match_line = search(a:wikiRx, 's'.a:cmd)
|
let match_line = search(a:wikiRx, 's'.a:cmd)
|
||||||
if match_line == 0
|
if match_line == 0
|
||||||
echomsg 'Vimwiki: Wiki link not found'
|
echomsg 'Vimwiki: Wiki link not found'
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#base#matchstr_at_cursor
|
|
||||||
" Returns part of the line that matches wikiRX at cursor
|
" Returns part of the line that matches wikiRX at cursor
|
||||||
function! vimwiki#base#matchstr_at_cursor(wikiRX) "{{{
|
function! vimwiki#base#matchstr_at_cursor(wikiRX)
|
||||||
let col = col('.') - 1
|
let col = col('.') - 1
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let ebeg = -1
|
let ebeg = -1
|
||||||
@ -783,10 +782,10 @@ function! vimwiki#base#matchstr_at_cursor(wikiRX) "{{{
|
|||||||
else
|
else
|
||||||
return ""
|
return ""
|
||||||
endif
|
endif
|
||||||
endf "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#replacestr_at_cursor
|
|
||||||
function! vimwiki#base#replacestr_at_cursor(wikiRX, sub) "{{{
|
function! vimwiki#base#replacestr_at_cursor(wikiRX, sub)
|
||||||
let col = col('.') - 1
|
let col = col('.') - 1
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let ebeg = -1
|
let ebeg = -1
|
||||||
@ -806,10 +805,10 @@ function! vimwiki#base#replacestr_at_cursor(wikiRX, sub) "{{{
|
|||||||
let newline = strpart(line, 0, ebeg).a:sub.strpart(line, ebeg+elen)
|
let newline = strpart(line, 0, ebeg).a:sub.strpart(line, ebeg+elen)
|
||||||
call setline(line('.'), newline)
|
call setline(line('.'), newline)
|
||||||
endif
|
endif
|
||||||
endf "}}}
|
endfunction
|
||||||
|
|
||||||
" s:print_wiki_list
|
|
||||||
function! s:print_wiki_list() "{{{
|
function! s:print_wiki_list()
|
||||||
let idx = 0
|
let idx = 0
|
||||||
while idx < vimwiki#vars#number_of_wikis()
|
while idx < vimwiki#vars#number_of_wikis()
|
||||||
if idx == vimwiki#vars#get_bufferlocal('wiki_nr')
|
if idx == vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
@ -823,10 +822,10 @@ function! s:print_wiki_list() "{{{
|
|||||||
let idx += 1
|
let idx += 1
|
||||||
endwhile
|
endwhile
|
||||||
echohl None
|
echohl None
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:update_wiki_link
|
|
||||||
function! s:update_wiki_link(fname, old, new) " {{{
|
function! s:update_wiki_link(fname, old, new)
|
||||||
echo "Updating links in ".a:fname
|
echo "Updating links in ".a:fname
|
||||||
let has_updates = 0
|
let has_updates = 0
|
||||||
let dest = []
|
let dest = []
|
||||||
@ -843,32 +842,33 @@ function! s:update_wiki_link(fname, old, new) " {{{
|
|||||||
call writefile(dest, a:fname)
|
call writefile(dest, a:fname)
|
||||||
call delete(a:fname.'#vimwiki_upd#')
|
call delete(a:fname.'#vimwiki_upd#')
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:update_wiki_links_dir
|
|
||||||
function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
function! s:update_wiki_links_dir(dir, old_fname, new_fname)
|
||||||
let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
|
let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
|
||||||
let new_fname = a:new_fname
|
let new_fname = a:new_fname
|
||||||
|
|
||||||
let old_fname_r = vimwiki#base#apply_template(
|
let old_fname_r = vimwiki#base#apply_template(
|
||||||
\ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate'), old_fname, '', '')
|
\ vimwiki#vars#get_syntaxlocal('WikiLinkMatchUrlTemplate'), old_fname, '', '')
|
||||||
|
|
||||||
let files = split(glob(vimwiki#vars#get_wikilocal('path').a:dir.'*'.vimwiki#vars#get_wikilocal('ext')), '\n')
|
let files = split(glob(vimwiki#vars#get_wikilocal('path').a:dir.'*'.
|
||||||
|
\ vimwiki#vars#get_wikilocal('ext')), '\n')
|
||||||
for fname in files
|
for fname in files
|
||||||
call s:update_wiki_link(fname, old_fname_r, new_fname)
|
call s:update_wiki_link(fname, old_fname_r, new_fname)
|
||||||
endfor
|
endfor
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:tail_name
|
|
||||||
function! s:tail_name(fname) "{{{
|
function! s:tail_name(fname)
|
||||||
let result = substitute(a:fname, ":", "__colon__", "g")
|
let result = substitute(a:fname, ":", "__colon__", "g")
|
||||||
let result = fnamemodify(result, ":t:r")
|
let result = fnamemodify(result, ":t:r")
|
||||||
let result = substitute(result, "__colon__", ":", "g")
|
let result = substitute(result, "__colon__", ":", "g")
|
||||||
return result
|
return result
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" s:update_wiki_links
|
|
||||||
function! s:update_wiki_links(old_fname, new_fname) " {{{
|
function! s:update_wiki_links(old_fname, new_fname)
|
||||||
let old_fname = a:old_fname
|
let old_fname = a:old_fname
|
||||||
let new_fname = a:new_fname
|
let new_fname = a:new_fname
|
||||||
|
|
||||||
@ -894,14 +894,13 @@ function! s:update_wiki_links(old_fname, new_fname) " {{{
|
|||||||
while idx < len(dirs_keys)
|
while idx < len(dirs_keys)
|
||||||
let dir = dirs_keys[idx]
|
let dir = dirs_keys[idx]
|
||||||
let new_dir = dirs_vals[idx]
|
let new_dir = dirs_vals[idx]
|
||||||
call s:update_wiki_links_dir(dir,
|
call s:update_wiki_links_dir(dir, new_dir.old_fname, new_dir.new_fname)
|
||||||
\ new_dir.old_fname, new_dir.new_fname)
|
|
||||||
let idx = idx + 1
|
let idx = idx + 1
|
||||||
endwhile
|
endwhile
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:get_wiki_buffers
|
|
||||||
function! s:get_wiki_buffers() "{{{
|
function! s:get_wiki_buffers()
|
||||||
let blist = []
|
let blist = []
|
||||||
let bcount = 1
|
let bcount = 1
|
||||||
while bcount<=bufnr("$")
|
while bcount<=bufnr("$")
|
||||||
@ -917,18 +916,18 @@ function! s:get_wiki_buffers() "{{{
|
|||||||
let bcount = bcount + 1
|
let bcount = bcount + 1
|
||||||
endwhile
|
endwhile
|
||||||
return blist
|
return blist
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:open_wiki_buffer
|
|
||||||
function! s:open_wiki_buffer(item) "{{{
|
function! s:open_wiki_buffer(item)
|
||||||
call vimwiki#base#edit_file(':e', a:item[0], '')
|
call vimwiki#base#edit_file(':e', a:item[0], '')
|
||||||
if !empty(a:item[1])
|
if !empty(a:item[1])
|
||||||
call vimwiki#vars#set_bufferlocal('prev_link', a:item[1], a:item[0])
|
call vimwiki#vars#set_bufferlocal('prev_link', a:item[1], a:item[0])
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#nested_syntax
|
|
||||||
function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort
|
||||||
" From http://vim.wikia.com/wiki/VimTip857
|
" From http://vim.wikia.com/wiki/VimTip857
|
||||||
let ft=toupper(a:filetype)
|
let ft=toupper(a:filetype)
|
||||||
let group='textGroup'.ft
|
let group='textGroup'.ft
|
||||||
@ -975,14 +974,15 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{
|
|||||||
" regular one.
|
" regular one.
|
||||||
" Perl syntax file has perlFunctionName which is usually has no effect due to
|
" Perl syntax file has perlFunctionName which is usually has no effect due to
|
||||||
" 'contained' flag. Now we have 'syntax include' that makes all the groups
|
" 'contained' flag. Now we have 'syntax include' that makes all the groups
|
||||||
" included as 'contained' into specific group.
|
" included as 'contained' into specific group.
|
||||||
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
|
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
|
||||||
" the rest syntax rules as now it has effect being really 'contained'.
|
" the rest syntax rules as now it has effect being really 'contained'.
|
||||||
" Clear it!
|
" Clear it!
|
||||||
if ft =~? 'perl'
|
if ft =~? 'perl'
|
||||||
syntax clear perlFunctionName
|
syntax clear perlFunctionName
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" creates or updates auto-generated listings in a wiki file, like TOC, diary
|
" creates or updates auto-generated listings in a wiki file, like TOC, diary
|
||||||
" links, tags list etc.
|
" links, tags list etc.
|
||||||
@ -993,7 +993,7 @@ endfunction "}}}
|
|||||||
" - if a:create is true, it will be created if it doesn't exist, otherwise it
|
" - if a:create is true, it will be created if it doesn't exist, otherwise it
|
||||||
" will only be updated if it already exists
|
" will only be updated if it already exists
|
||||||
function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||||
\ content_regex, default_lnum, create) "{{{
|
\ content_regex, default_lnum, create)
|
||||||
" apparently, Vim behaves strange when files change while in diff mode
|
" apparently, Vim behaves strange when files change while in diff mode
|
||||||
if &diff || &readonly
|
if &diff || &readonly
|
||||||
return
|
return
|
||||||
@ -1002,9 +1002,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
|||||||
" check if the listing is already there
|
" check if the listing is already there
|
||||||
let already_there = 0
|
let already_there = 0
|
||||||
|
|
||||||
let header_rx = '\m^\s*'.
|
let header_rx = '\m^\s*'.substitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'),
|
||||||
\ substitute(vimwiki#vars#get_syntaxlocal('rxH1_Template'), '__Header__', a:start_header, '')
|
\ '__Header__', a:start_header, '') .'\s*$'
|
||||||
\ .'\s*$'
|
|
||||||
|
|
||||||
let start_lnum = 1
|
let start_lnum = 1
|
||||||
while start_lnum <= line('$')
|
while start_lnum <= line('$')
|
||||||
@ -1080,27 +1079,26 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
|||||||
let winview_save.lnum += lines_diff
|
let winview_save.lnum += lines_diff
|
||||||
endif
|
endif
|
||||||
call winrestview(winview_save)
|
call winrestview(winview_save)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" WIKI link following functions {{{
|
|
||||||
" vimwiki#base#find_next_link
|
function! vimwiki#base#find_next_link()
|
||||||
function! vimwiki#base#find_next_link() "{{{
|
|
||||||
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), '')
|
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), '')
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" 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(vimwiki#vars#get_syntaxlocal('rxAnyLink'), 'b')
|
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), 'b')
|
||||||
endif
|
endif
|
||||||
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), 'b')
|
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), 'b')
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#base#follow_link
|
|
||||||
" This is an API function, that is, remappable by the user. Don't change the signature.
|
" This is an API function, that is, remappable by the user. Don't change the signature.
|
||||||
function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
|
function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
|
||||||
" Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
|
" Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
|
||||||
" default open_link handler
|
" default open_link handler
|
||||||
|
|
||||||
@ -1171,14 +1169,14 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
|
|||||||
else
|
else
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
execute "normal! ".a:1
|
execute "normal! ".a:1
|
||||||
else
|
else
|
||||||
call vimwiki#base#normalize_link(0)
|
call vimwiki#base#normalize_link(0)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#go_back_link
|
|
||||||
function! vimwiki#base#go_back_link() "{{{
|
function! vimwiki#base#go_back_link()
|
||||||
let prev_link = vimwiki#vars#get_bufferlocal('prev_link')
|
let prev_link = vimwiki#vars#get_bufferlocal('prev_link')
|
||||||
if !empty(prev_link)
|
if !empty(prev_link)
|
||||||
" go back to saved wiki link
|
" go back to saved wiki link
|
||||||
@ -1188,10 +1186,10 @@ function! vimwiki#base#go_back_link() "{{{
|
|||||||
" maybe we came here by jumping to a tag -> pop from the tag stack
|
" maybe we came here by jumping to a tag -> pop from the tag stack
|
||||||
silent! pop!
|
silent! pop!
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#goto_index
|
|
||||||
function! vimwiki#base#goto_index(wnum, ...) "{{{
|
function! vimwiki#base#goto_index(wnum, ...)
|
||||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in your Vimwiki settings!'
|
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in your Vimwiki settings!'
|
||||||
return
|
return
|
||||||
@ -1222,12 +1220,11 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
|
|||||||
\ vimwiki#vars#get_wikilocal('ext', idx)
|
\ vimwiki#vars#get_wikilocal('ext', idx)
|
||||||
|
|
||||||
call vimwiki#base#edit_file(cmd, index_file, '')
|
call vimwiki#base#edit_file(cmd, index_file, '')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#delete_link
|
|
||||||
function! vimwiki#base#delete_link() "{{{
|
function! vimwiki#base#delete_link()
|
||||||
"" file system funcs
|
" Delete wiki file you are in from filesystem
|
||||||
"" Delete wiki link you are in from filesystem
|
|
||||||
let val = input('Delete "'.expand('%').'" [y]es/[N]o? ')
|
let val = input('Delete "'.expand('%').'" [y]es/[N]o? ')
|
||||||
if val !~? '^y'
|
if val !~? '^y'
|
||||||
return
|
return
|
||||||
@ -1247,11 +1244,11 @@ function! vimwiki#base#delete_link() "{{{
|
|||||||
if expand('%:p') != ""
|
if expand('%:p') != ""
|
||||||
execute "e"
|
execute "e"
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#base#rename_link
|
|
||||||
" Rename current file, update all links to it
|
" Rename current file, update all links to it
|
||||||
function! vimwiki#base#rename_link() "{{{
|
function! vimwiki#base#rename_link()
|
||||||
let subdir = vimwiki#vars#get_bufferlocal('subdir')
|
let subdir = vimwiki#vars#get_bufferlocal('subdir')
|
||||||
let old_fname = subdir.expand('%:t')
|
let old_fname = subdir.expand('%:t')
|
||||||
|
|
||||||
@ -1285,15 +1282,14 @@ function! vimwiki#base#rename_link() "{{{
|
|||||||
if url != ''
|
if url != ''
|
||||||
let new_link = url
|
let new_link = url
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let new_link = subdir.new_link
|
let new_link = subdir.new_link
|
||||||
let new_fname = vimwiki#vars#get_wikilocal('path') . new_link . vimwiki#vars#get_wikilocal('ext')
|
let new_fname = vimwiki#vars#get_wikilocal('path') . new_link . vimwiki#vars#get_wikilocal('ext')
|
||||||
|
|
||||||
" do not rename if file with such name exists
|
" do not rename if file with such name exists
|
||||||
let fname = glob(new_fname)
|
let fname = glob(new_fname)
|
||||||
if fname != ''
|
if fname != ''
|
||||||
echomsg 'Vimwiki Error: Cannot rename to "'.new_fname.
|
echomsg 'Vimwiki Error: Cannot rename to "'.new_fname.'". File with that name exist!'
|
||||||
\ '". File with that name exist!'
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
" rename wiki link file
|
" rename wiki link file
|
||||||
@ -1310,8 +1306,7 @@ function! vimwiki#base#rename_link() "{{{
|
|||||||
|
|
||||||
let &buftype="nofile"
|
let &buftype="nofile"
|
||||||
|
|
||||||
let cur_buffer = [expand('%:p'),
|
let cur_buffer = [expand('%:p'), vimwiki#vars#get_bufferlocal('prev_link')]
|
||||||
\ vimwiki#vars#get_bufferlocal('prev_link')]
|
|
||||||
|
|
||||||
let blist = s:get_wiki_buffers()
|
let blist = s:get_wiki_buffers()
|
||||||
|
|
||||||
@ -1341,27 +1336,24 @@ function! vimwiki#base#rename_link() "{{{
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
call s:open_wiki_buffer([new_fname,
|
call s:open_wiki_buffer([new_fname, cur_buffer[1]])
|
||||||
\ cur_buffer[1]])
|
|
||||||
" execute 'bwipeout '.escape(cur_buffer[0], ' ')
|
" execute 'bwipeout '.escape(cur_buffer[0], ' ')
|
||||||
|
|
||||||
echomsg 'Vimwiki: '.old_fname.' is renamed to '.new_fname
|
echomsg 'Vimwiki: '.old_fname.' is renamed to '.new_fname
|
||||||
|
|
||||||
let &more = setting_more
|
let &more = setting_more
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#ui_select
|
|
||||||
function! vimwiki#base#ui_select() "{{{
|
function! vimwiki#base#ui_select()
|
||||||
call s:print_wiki_list()
|
call s:print_wiki_list()
|
||||||
let idx = input("Select Wiki (specify number): ")
|
let idx = input("Select Wiki (specify number): ")
|
||||||
if idx == ""
|
if idx == ""
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call vimwiki#base#goto_index(idx)
|
call vimwiki#base#goto_index(idx)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
" }}}
|
|
||||||
|
|
||||||
" TEXT OBJECTS functions {{{
|
|
||||||
|
|
||||||
function! vimwiki#base#TO_header(inner, including_subheaders, count)
|
function! vimwiki#base#TO_header(inner, including_subheaders, count)
|
||||||
let headers = s:collect_headers()
|
let headers = s:collect_headers()
|
||||||
@ -1416,8 +1408,7 @@ function! vimwiki#base#TO_header(inner, including_subheaders, count)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#base#TO_table_cell
|
function! vimwiki#base#TO_table_cell(inner, visual)
|
||||||
function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
|
||||||
if col('.') == col('$')-1
|
if col('.') == col('$')-1
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -1461,7 +1452,7 @@ function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
|||||||
|
|
||||||
" XXX: WORKAROUND.
|
" XXX: WORKAROUND.
|
||||||
" if blockwise selection is ended at | character then pressing j to extend
|
" if blockwise selection is ended at | character then pressing j to extend
|
||||||
" selection furhter fails. But if we shake the cursor left and right then
|
" selection further fails. But if we shake the cursor left and right then
|
||||||
" it works.
|
" it works.
|
||||||
normal! hl
|
normal! hl
|
||||||
else
|
else
|
||||||
@ -1479,10 +1470,10 @@ function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
|||||||
normal! 2h
|
normal! 2h
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#TO_table_col
|
|
||||||
function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
function! vimwiki#base#TO_table_col(inner, visual)
|
||||||
let t_rows = vimwiki#tbl#get_rows(line('.'))
|
let t_rows = vimwiki#tbl#get_rows(line('.'))
|
||||||
if empty(t_rows)
|
if empty(t_rows)
|
||||||
return
|
return
|
||||||
@ -1594,12 +1585,10 @@ function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
|||||||
" expand selection to the bottom line of the table
|
" expand selection to the bottom line of the table
|
||||||
call vimwiki#u#cursor(t_rows[-1][0], virtcol('.'))
|
call vimwiki#u#cursor(t_rows[-1][0], virtcol('.'))
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
" }}}
|
|
||||||
|
|
||||||
" HEADER functions {{{
|
|
||||||
" vimwiki#base#AddHeaderLevel
|
function! vimwiki#base#AddHeaderLevel()
|
||||||
function! vimwiki#base#AddHeaderLevel() "{{{
|
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
|
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
|
||||||
@ -1618,16 +1607,16 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
|||||||
call setline(lnum, line)
|
call setline(lnum, line)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let line = substitute(line, '^\s*', '&'.rxHdr.' ', '')
|
let line = substitute(line, '^\s*', '&'.rxHdr.' ', '')
|
||||||
if vimwiki#vars#get_syntaxlocal('symH')
|
if vimwiki#vars#get_syntaxlocal('symH')
|
||||||
let line = substitute(line, '\s*$', ' '.rxHdr.'&', '')
|
let line = substitute(line, '\s*$', ' '.rxHdr.'&', '')
|
||||||
endif
|
endif
|
||||||
call setline(lnum, line)
|
call setline(lnum, line)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#RemoveHeaderLevel
|
|
||||||
function! vimwiki#base#RemoveHeaderLevel() "{{{
|
function! vimwiki#base#RemoveHeaderLevel()
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
|
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
|
||||||
@ -1657,7 +1646,8 @@ function! vimwiki#base#RemoveHeaderLevel() "{{{
|
|||||||
|
|
||||||
call setline(lnum, line)
|
call setline(lnum, line)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" Returns all the headers in the current buffer as a list of the form
|
" Returns all the headers in the current buffer as a list of the form
|
||||||
@ -1687,7 +1677,8 @@ function! s:collect_headers()
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
let header_level = vimwiki#u#count_first_sym(line_content)
|
let header_level = vimwiki#u#count_first_sym(line_content)
|
||||||
let header_text = vimwiki#u#trim(matchstr(line_content, vimwiki#vars#get_syntaxlocal('rxHeader')))
|
let header_text =
|
||||||
|
\ vimwiki#u#trim(matchstr(line_content, vimwiki#vars#get_syntaxlocal('rxHeader')))
|
||||||
call add(headers, [lnum, header_level, header_text])
|
call add(headers, [lnum, header_level, header_text])
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@ -1774,7 +1765,8 @@ endfunction
|
|||||||
function! vimwiki#base#goto_sibling(direction)
|
function! vimwiki#base#goto_sibling(direction)
|
||||||
let headers = s:collect_headers()
|
let headers = s:collect_headers()
|
||||||
let current_header_index = s:current_header(headers, line('.'))
|
let current_header_index = s:current_header(headers, line('.'))
|
||||||
let next_potential_sibling = s:get_another_header(headers, current_header_index, a:direction, '<=')
|
let next_potential_sibling =
|
||||||
|
\ s:get_another_header(headers, current_header_index, a:direction, '<=')
|
||||||
if next_potential_sibling >= 0 && headers[next_potential_sibling][1] ==
|
if next_potential_sibling >= 0 && headers[next_potential_sibling][1] ==
|
||||||
\ headers[current_header_index][1]
|
\ headers[current_header_index][1]
|
||||||
call cursor(headers[next_potential_sibling][0], 1)
|
call cursor(headers[next_potential_sibling][0], 1)
|
||||||
@ -1832,19 +1824,17 @@ function! vimwiki#base#table_of_contents(create)
|
|||||||
|
|
||||||
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
let links_rx = '\m^\s*'.vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
||||||
|
|
||||||
call vimwiki#base#update_listing_in_buffer(lines, vimwiki#vars#get_global('toc_header'), links_rx,
|
call vimwiki#base#update_listing_in_buffer(lines,
|
||||||
\ 1, a:create)
|
\ vimwiki#vars#get_global('toc_header'), links_rx, 1, a:create)
|
||||||
endfunction
|
endfunction
|
||||||
"}}}
|
|
||||||
|
|
||||||
" LINK functions {{{
|
|
||||||
" vimwiki#base#apply_template
|
|
||||||
" Construct a regular expression matching from template (with special
|
" Construct a regular expression matching from template (with special
|
||||||
" characters properly escaped), by substituting rxUrl for __LinkUrl__, rxDesc
|
" characters properly escaped), by substituting rxUrl for __LinkUrl__, rxDesc
|
||||||
" for __LinkDescription__, and rxStyle for __LinkStyle__. The three
|
" for __LinkDescription__, and rxStyle for __LinkStyle__. The three
|
||||||
" arguments rxUrl, rxDesc, and rxStyle are copied verbatim, without any
|
" arguments rxUrl, rxDesc, and rxStyle are copied verbatim, without any
|
||||||
" special character escapes or substitutions.
|
" special character escapes or substitutions.
|
||||||
function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
|
function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle)
|
||||||
let lnk = a:template
|
let lnk = a:template
|
||||||
if a:rxUrl != ""
|
if a:rxUrl != ""
|
||||||
let lnk = s:safesubstitute(lnk, '__LinkUrl__', a:rxUrl, 'g')
|
let lnk = s:safesubstitute(lnk, '__LinkUrl__', a:rxUrl, 'g')
|
||||||
@ -1856,10 +1846,10 @@ function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
|
|||||||
let lnk = s:safesubstitute(lnk, '__LinkStyle__', a:rxStyle, 'g')
|
let lnk = s:safesubstitute(lnk, '__LinkStyle__', a:rxStyle, 'g')
|
||||||
endif
|
endif
|
||||||
return lnk
|
return lnk
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" 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"')
|
||||||
@ -1872,19 +1862,18 @@ function! s:clean_url(url) " {{{
|
|||||||
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
|
||||||
|
|
||||||
" s:is_diary_file
|
|
||||||
function! s:is_diary_file(filename) " {{{
|
function! s:is_diary_file(filename)
|
||||||
let file_path = vimwiki#path#path_norm(a:filename)
|
let file_path = vimwiki#path#path_norm(a:filename)
|
||||||
let rel_path = vimwiki#vars#get_wikilocal('diary_rel_path')
|
let rel_path = vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||||
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('path') . rel_path)
|
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('path') . rel_path)
|
||||||
return rel_path != ''
|
return rel_path != '' && file_path =~# '^'.vimwiki#u#escape(diary_path)
|
||||||
\ && file_path =~# '^'.vimwiki#u#escape(diary_path)
|
endfunction
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
" vimwiki#base#normalize_link_helper
|
|
||||||
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
|
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
|
||||||
let url = matchstr(a:str, a:rxUrl)
|
let url = matchstr(a:str, a:rxUrl)
|
||||||
let descr = matchstr(a:str, a:rxDesc)
|
let descr = matchstr(a:str, a:rxDesc)
|
||||||
if descr == ""
|
if descr == ""
|
||||||
@ -1893,18 +1882,18 @@ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
|
|||||||
let lnk = s:safesubstitute(a:template, '__LinkDescription__', descr, '')
|
let lnk = s:safesubstitute(a:template, '__LinkDescription__', descr, '')
|
||||||
let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '')
|
let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '')
|
||||||
return lnk
|
return lnk
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#normalize_imagelink_helper
|
|
||||||
function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template) "{{{
|
function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template)
|
||||||
let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template)
|
let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template)
|
||||||
let style = matchstr(a:str, a:rxStyle)
|
let style = matchstr(a:str, a:rxStyle)
|
||||||
let lnk = s:safesubstitute(lnk, '__LinkStyle__', style, '')
|
let lnk = s:safesubstitute(lnk, '__LinkStyle__', style, '')
|
||||||
return lnk
|
return lnk
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:normalize_link_in_diary
|
|
||||||
function! s:normalize_link_in_diary(lnk) " {{{
|
function! s:normalize_link_in_diary(lnk)
|
||||||
let link = a:lnk . vimwiki#vars#get_wikilocal('ext')
|
let link = a:lnk . vimwiki#vars#get_wikilocal('ext')
|
||||||
let link_wiki = vimwiki#vars#get_wikilocal('path') . '/' . link
|
let link_wiki = vimwiki#vars#get_wikilocal('path') . '/' . link
|
||||||
let link_diary = vimwiki#vars#get_wikilocal('path') . '/'
|
let link_diary = vimwiki#vars#get_wikilocal('path') . '/'
|
||||||
@ -1927,21 +1916,22 @@ function! s:normalize_link_in_diary(lnk) " {{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
return vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
|
return vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:normalize_link_syntax_n
|
|
||||||
function! s:normalize_link_syntax_n() " {{{
|
function! s:normalize_link_syntax_n()
|
||||||
|
|
||||||
" try WikiLink
|
" try WikiLink
|
||||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink'))
|
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink'))
|
||||||
if !empty(lnk)
|
if !empty(lnk)
|
||||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
||||||
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
||||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink'), sub)
|
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink'), sub)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" try WikiIncl
|
" try WikiIncl
|
||||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl'))
|
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl'))
|
||||||
if !empty(lnk)
|
if !empty(lnk)
|
||||||
@ -1974,10 +1964,10 @@ function! s:normalize_link_syntax_n() " {{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:normalize_link_syntax_v
|
|
||||||
function! s:normalize_link_syntax_v() " {{{
|
function! s:normalize_link_syntax_v()
|
||||||
let sel_save = &selection
|
let sel_save = &selection
|
||||||
let &selection = "old"
|
let &selection = "old"
|
||||||
let default_register_save = @"
|
let default_register_save = @"
|
||||||
@ -2002,10 +1992,10 @@ function! s:normalize_link_syntax_v() " {{{
|
|||||||
call setreg('"', default_register_save, registertype_save)
|
call setreg('"', default_register_save, registertype_save)
|
||||||
let &selection = sel_save
|
let &selection = sel_save
|
||||||
endtry
|
endtry
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#normalize_link
|
|
||||||
function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
function! vimwiki#base#normalize_link(is_visual_mode)
|
||||||
if exists('*vimwiki#'.vimwiki#vars#get_wikilocal('syntax').'_base#normalize_link')
|
if exists('*vimwiki#'.vimwiki#vars#get_wikilocal('syntax').'_base#normalize_link')
|
||||||
" Syntax-specific links
|
" Syntax-specific links
|
||||||
call vimwiki#{vimwiki#vars#get_wikilocal('syntax')}_base#normalize_link(a:is_visual_mode)
|
call vimwiki#{vimwiki#vars#get_wikilocal('syntax')}_base#normalize_link(a:is_visual_mode)
|
||||||
@ -2017,10 +2007,10 @@ function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
|||||||
call s:normalize_link_syntax_v()
|
call s:normalize_link_syntax_v()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#detect_nested_syntax
|
|
||||||
function! vimwiki#base#detect_nested_syntax() "{{{
|
function! vimwiki#base#detect_nested_syntax()
|
||||||
let last_word = '\v.*<(\w+)\s*$'
|
let last_word = '\v.*<(\w+)\s*$'
|
||||||
let lines = map(filter(getline(1, "$"), 'v:val =~ "\\%({{{\\|```\\)" && v:val =~ last_word'),
|
let lines = map(filter(getline(1, "$"), 'v:val =~ "\\%({{{\\|```\\)" && v:val =~ last_word'),
|
||||||
\ 'substitute(v:val, last_word, "\\=submatch(1)", "")')
|
\ 'substitute(v:val, last_word, "\\=submatch(1)", "")')
|
||||||
@ -2029,26 +2019,20 @@ function! vimwiki#base#detect_nested_syntax() "{{{
|
|||||||
let dict[elem] = elem
|
let dict[elem] = elem
|
||||||
endfor
|
endfor
|
||||||
return dict
|
return dict
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Command completion functions {{{
|
function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort
|
||||||
|
|
||||||
" vimwiki#base#complete_links_escaped
|
|
||||||
function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort " {{{
|
|
||||||
" We can safely ignore args if we use -custom=complete option, Vim engine
|
" We can safely ignore args if we use -custom=complete option, Vim engine
|
||||||
" will do the job of filtering.
|
" will do the job of filtering.
|
||||||
return vimwiki#base#get_globlinks_escaped()
|
return vimwiki#base#get_globlinks_escaped()
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" -------------------------------------------------------------------------
|
" -------------------------------------------------------------------------
|
||||||
" Load syntax-specific Wiki functionality
|
" Load syntax-specific Wiki functionality
|
||||||
for s:syn in s:vimwiki_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
|
||||||
" -------------------------------------------------------------------------
|
" -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,44 +1,49 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: Handle diary notes
|
" Description: Handle diary notes
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
" Load only once {{{
|
|
||||||
if exists("g:loaded_vimwiki_diary_auto") || &cp
|
if exists("g:loaded_vimwiki_diary_auto") || &cp
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_vimwiki_diary_auto = 1
|
let g:loaded_vimwiki_diary_auto = 1
|
||||||
"}}}
|
|
||||||
|
|
||||||
let s:vimwiki_max_scan_for_caption = 5
|
let s:vimwiki_max_scan_for_caption = 5
|
||||||
|
|
||||||
" Helpers {{{
|
|
||||||
function! s:prefix_zero(num) "{{{
|
function! s:prefix_zero(num)
|
||||||
if a:num < 10
|
if a:num < 10
|
||||||
return '0'.a:num
|
return '0'.a:num
|
||||||
endif
|
endif
|
||||||
return a:num
|
return a:num
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:diary_path(...) "{{{
|
|
||||||
|
function! s:diary_path(...)
|
||||||
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
|
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
|
||||||
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
|
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:diary_index(...) "{{{
|
|
||||||
|
function! s:diary_index(...)
|
||||||
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
|
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
|
||||||
return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx)
|
return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).
|
||||||
endfunction "}}}
|
\ vimwiki#vars#get_wikilocal('ext', idx)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#diary#diary_date_link(...) "{{{
|
|
||||||
|
function! vimwiki#diary#diary_date_link(...)
|
||||||
if a:0
|
if a:0
|
||||||
return strftime('%Y-%m-%d', a:1)
|
return strftime('%Y-%m-%d', a:1)
|
||||||
else
|
else
|
||||||
return strftime('%Y-%m-%d')
|
return strftime('%Y-%m-%d')
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
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'
|
||||||
@ -51,16 +56,15 @@ function! s:get_position_links(link) "{{{
|
|||||||
let idx = index(links, a:link)
|
let idx = index(links, a:link)
|
||||||
endif
|
endif
|
||||||
return [idx, links]
|
return [idx, links]
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
fun! s:get_month_name(month) "{{{
|
|
||||||
|
function! s:get_month_name(month)
|
||||||
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
|
return vimwiki#vars#get_global('diary_months')[str2nr(a:month)]
|
||||||
endfun "}}}
|
endfunction
|
||||||
|
|
||||||
" Helpers }}}
|
|
||||||
|
|
||||||
" Diary index stuff {{{
|
function! s:read_captions(files)
|
||||||
fun! s:read_captions(files) "{{{
|
|
||||||
let result = {}
|
let result = {}
|
||||||
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
|
let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader')
|
||||||
for fl in a:files
|
for fl in a:files
|
||||||
@ -81,11 +85,13 @@ fun! s:read_captions(files) "{{{
|
|||||||
|
|
||||||
endfor
|
endfor
|
||||||
return result
|
return result
|
||||||
endfun "}}}
|
endfunction
|
||||||
|
|
||||||
fun! s:get_diary_files() "{{{
|
|
||||||
|
function! s:get_diary_files()
|
||||||
let rx = '^\d\{4}-\d\d-\d\d'
|
let rx = '^\d\{4}-\d\d-\d\d'
|
||||||
let s_files = glob(vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
|
let s_files = glob(vimwiki#vars#get_wikilocal('path').
|
||||||
|
\ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
|
||||||
let files = split(s_files, '\n')
|
let files = split(s_files, '\n')
|
||||||
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
|
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
|
||||||
|
|
||||||
@ -93,9 +99,10 @@ fun! s:get_diary_files() "{{{
|
|||||||
call filter(files, 'v:val !~# ''.*\~$''')
|
call filter(files, 'v:val !~# ''.*\~$''')
|
||||||
|
|
||||||
return files
|
return files
|
||||||
endfun "}}}
|
endfunction
|
||||||
|
|
||||||
fun! s:group_links(links) "{{{
|
|
||||||
|
function! s:group_links(links)
|
||||||
let result = {}
|
let result = {}
|
||||||
let p_year = 0
|
let p_year = 0
|
||||||
let p_month = 0
|
let p_month = 0
|
||||||
@ -114,38 +121,43 @@ fun! s:group_links(links) "{{{
|
|||||||
let p_month = month
|
let p_month = month
|
||||||
endfor
|
endfor
|
||||||
return result
|
return result
|
||||||
endfun "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:sort(lst) "{{{
|
|
||||||
|
function! s:sort(lst)
|
||||||
if vimwiki#vars#get_wikilocal('diary_sort') ==? 'desc'
|
if vimwiki#vars#get_wikilocal('diary_sort') ==? 'desc'
|
||||||
return reverse(sort(a:lst))
|
return reverse(sort(a:lst))
|
||||||
else
|
else
|
||||||
return sort(a:lst)
|
return sort(a:lst)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:format_diary() "{{{
|
|
||||||
|
function! s:format_diary()
|
||||||
let result = []
|
let result = []
|
||||||
|
|
||||||
|
|
||||||
let links_with_captions = s:read_captions(s:get_diary_files())
|
let links_with_captions = s:read_captions(s:get_diary_files())
|
||||||
let g_files = s:group_links(links_with_captions)
|
let g_files = s:group_links(links_with_captions)
|
||||||
|
|
||||||
for year in s:sort(keys(g_files))
|
for year in s:sort(keys(g_files))
|
||||||
call add(result, '')
|
call add(result, '')
|
||||||
call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , ''))
|
call add(result,
|
||||||
|
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , ''))
|
||||||
|
|
||||||
for month in s:sort(keys(g_files[year]))
|
for month in s:sort(keys(g_files[year]))
|
||||||
call add(result, '')
|
call add(result, '')
|
||||||
call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'), '__Header__', s:get_month_name(month), ''))
|
call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'),
|
||||||
|
\ '__Header__', s:get_month_name(month), ''))
|
||||||
|
|
||||||
for [fl, cap] in s:sort(items(g_files[year][month]))
|
for [fl, cap] in s:sort(items(g_files[year][month]))
|
||||||
if empty(cap)
|
if empty(cap)
|
||||||
let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', fl, '')
|
let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
|
||||||
|
\ '__LinkUrl__', fl, '')
|
||||||
let entry = substitute(entry, '__LinkDescription__', cap, '')
|
let entry = substitute(entry, '__LinkDescription__', cap, '')
|
||||||
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry)
|
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry)
|
||||||
else
|
else
|
||||||
let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__', fl, '')
|
let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'),
|
||||||
|
\ '__LinkUrl__', fl, '')
|
||||||
let entry = substitute(entry, '__LinkDescription__', cap, '')
|
let entry = substitute(entry, '__LinkDescription__', cap, '')
|
||||||
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry)
|
call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry)
|
||||||
endif
|
endif
|
||||||
@ -155,11 +167,10 @@ function! s:format_diary() "{{{
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
return result
|
return result
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" Diary index stuff }}}
|
|
||||||
|
|
||||||
function! vimwiki#diary#make_note(wnum, ...) "{{{
|
function! vimwiki#diary#make_note(wnum, ...)
|
||||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||||
return
|
return
|
||||||
@ -172,7 +183,8 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
|||||||
let idx = 0
|
let idx = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx))
|
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', idx).
|
||||||
|
\ vimwiki#vars#get_wikilocal('diary_rel_path', idx))
|
||||||
|
|
||||||
let cmd = 'edit'
|
let cmd = 'edit'
|
||||||
if a:0
|
if a:0
|
||||||
@ -191,9 +203,10 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
|
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#diary#goto_diary_index(wnum) "{{{
|
|
||||||
|
function! vimwiki#diary#goto_diary_index(wnum)
|
||||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||||
return
|
return
|
||||||
@ -207,9 +220,10 @@ function! vimwiki#diary#goto_diary_index(wnum) "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
|
call vimwiki#base#edit_file('e', s:diary_index(idx), '')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#diary#goto_next_day() "{{{
|
|
||||||
|
function! vimwiki#diary#goto_next_day()
|
||||||
let link = ''
|
let link = ''
|
||||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||||
|
|
||||||
@ -227,9 +241,10 @@ function! vimwiki#diary#goto_next_day() "{{{
|
|||||||
if len(link)
|
if len(link)
|
||||||
call vimwiki#base#open_link(':e ', link)
|
call vimwiki#base#open_link(':e ', link)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#diary#goto_prev_day() "{{{
|
|
||||||
|
function! vimwiki#diary#goto_prev_day()
|
||||||
let link = ''
|
let link = ''
|
||||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||||
|
|
||||||
@ -247,9 +262,10 @@ function! vimwiki#diary#goto_prev_day() "{{{
|
|||||||
if len(link)
|
if len(link)
|
||||||
call vimwiki#base#open_link(':e ', link)
|
call vimwiki#base#open_link(':e ', link)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
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 vimwiki#path#is_equal(current_file, diary_file)
|
if vimwiki#path#is_equal(current_file, diary_file)
|
||||||
@ -259,11 +275,11 @@ function! vimwiki#diary#generate_diary_section() "{{{
|
|||||||
else
|
else
|
||||||
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
|
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" Calendar.vim {{{
|
|
||||||
" Callback function.
|
" Callback function for Calendar.vim
|
||||||
function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
function! vimwiki#diary#calendar_action(day, month, year, week, dir)
|
||||||
let day = s:prefix_zero(a:day)
|
let day = s:prefix_zero(a:day)
|
||||||
let month = s:prefix_zero(a:month)
|
let month = s:prefix_zero(a:month)
|
||||||
|
|
||||||
@ -283,16 +299,14 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
|||||||
|
|
||||||
" XXX: Well, +1 is for inconsistent index basing...
|
" XXX: Well, +1 is for inconsistent index basing...
|
||||||
call vimwiki#diary#make_note(vimwiki#vars#get_bufferlocal('wiki_nr')+1, 0, link)
|
call vimwiki#diary#make_note(vimwiki#vars#get_bufferlocal('wiki_nr')+1, 0, link)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" Sign function.
|
|
||||||
function vimwiki#diary#calendar_sign(day, month, year) "{{{
|
function vimwiki#diary#calendar_sign(day, month, year)
|
||||||
let day = s:prefix_zero(a:day)
|
let day = s:prefix_zero(a:day)
|
||||||
let month = s:prefix_zero(a:month)
|
let month = s:prefix_zero(a:month)
|
||||||
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
|
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
|
||||||
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
|
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
|
||||||
return filereadable(expand(sfile))
|
return filereadable(expand(sfile))
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" Calendar.vim }}}
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,20 +1,17 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: Link functions for markdown syntax
|
" Description: Link functions for markdown syntax
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
" MISC helper functions {{{
|
function! s:safesubstitute(text, search, replace, mode)
|
||||||
|
|
||||||
" s:safesubstitute
|
|
||||||
function! s:safesubstitute(text, search, replace, mode) "{{{
|
|
||||||
" Substitute regexp but do not interpret replace
|
" Substitute regexp but do not interpret replace
|
||||||
let escaped = escape(a:replace, '\&')
|
let escaped = escape(a:replace, '\&')
|
||||||
return substitute(a:text, a:search, escaped, a:mode)
|
return substitute(a:text, a:search, escaped, a:mode)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#markdown_base#scan_reflinks
|
|
||||||
function! vimwiki#markdown_base#scan_reflinks() " {{{
|
function! vimwiki#markdown_base#scan_reflinks()
|
||||||
let mkd_refs = {}
|
let mkd_refs = {}
|
||||||
" construct list of references using vimgrep
|
" construct list of references using vimgrep
|
||||||
try
|
try
|
||||||
@ -23,7 +20,7 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{
|
|||||||
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
||||||
"Ignore it, and move on to the next file
|
"Ignore it, and move on to the next file
|
||||||
endtry
|
endtry
|
||||||
"
|
|
||||||
for d in getqflist()
|
for d in getqflist()
|
||||||
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
|
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
|
||||||
let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr'))
|
let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr'))
|
||||||
@ -34,12 +31,11 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{
|
|||||||
endfor
|
endfor
|
||||||
call vimwiki#vars#set_bufferlocal('markdown_refs', mkd_refs)
|
call vimwiki#vars#set_bufferlocal('markdown_refs', mkd_refs)
|
||||||
return mkd_refs
|
return mkd_refs
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#markdown_base#open_reflink
|
|
||||||
" try markdown reference links
|
" try markdown reference links
|
||||||
function! vimwiki#markdown_base#open_reflink(link) " {{{
|
function! vimwiki#markdown_base#open_reflink(link)
|
||||||
" echom "vimwiki#markdown_base#open_reflink"
|
" echom "vimwiki#markdown_base#open_reflink"
|
||||||
let link = a:link
|
let link = a:link
|
||||||
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
|
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
|
||||||
@ -50,15 +46,10 @@ function! vimwiki#markdown_base#open_reflink(link) " {{{
|
|||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
" }}}
|
|
||||||
|
|
||||||
" WIKI link following functions {{{
|
|
||||||
|
|
||||||
" LINK functions {{{
|
function! s:normalize_link_syntax_n()
|
||||||
|
|
||||||
" s:normalize_link_syntax_n
|
|
||||||
function! s:normalize_link_syntax_n() " {{{
|
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
|
|
||||||
" try WikiIncl
|
" try WikiIncl
|
||||||
@ -72,27 +63,30 @@ function! s:normalize_link_syntax_n() " {{{
|
|||||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'))
|
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'))
|
||||||
if !empty(lnk)
|
if !empty(lnk)
|
||||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
||||||
\ vimwiki#vars#get_syntaxlocal('WikiLink1Template2'))
|
\ vimwiki#vars#get_syntaxlocal('WikiLink1Template2'))
|
||||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'), sub)
|
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'), sub)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" try WikiLink1: replace with WikiLink0
|
" try WikiLink1: replace with WikiLink0
|
||||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'))
|
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'))
|
||||||
if !empty(lnk)
|
if !empty(lnk)
|
||||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'),
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr'),
|
||||||
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
\ vimwiki#vars#get_global('WikiLinkTemplate2'))
|
||||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), sub)
|
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), sub)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" try Weblink
|
" try Weblink
|
||||||
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'))
|
let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'))
|
||||||
if !empty(lnk)
|
if !empty(lnk)
|
||||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'), vimwiki#vars#get_syntaxlocal('rxWeblinkMatchDescr'),
|
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'),
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchDescr'),
|
||||||
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
|
\ vimwiki#vars#get_syntaxlocal('Weblink1Template'))
|
||||||
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'), sub)
|
call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink'), sub)
|
||||||
return
|
return
|
||||||
@ -110,10 +104,10 @@ function! s:normalize_link_syntax_n() " {{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:normalize_link_syntax_v
|
|
||||||
function! s:normalize_link_syntax_v() " {{{
|
function! s:normalize_link_syntax_v()
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let sel_save = &selection
|
let sel_save = &selection
|
||||||
let &selection = "old"
|
let &selection = "old"
|
||||||
@ -138,10 +132,10 @@ function! s:normalize_link_syntax_v() " {{{
|
|||||||
let &selection = sel_save
|
let &selection = sel_save
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" vimwiki#base#normalize_link
|
|
||||||
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
|
function! vimwiki#markdown_base#normalize_link(is_visual_mode)
|
||||||
if 0
|
if 0
|
||||||
" Syntax-specific links
|
" Syntax-specific links
|
||||||
else
|
else
|
||||||
@ -152,11 +146,5 @@ function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
|
|||||||
call s:normalize_link_syntax_v()
|
call s:normalize_link_syntax_v()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" -------------------------------------------------------------------------
|
|
||||||
" Load syntax-specific Wiki functionality
|
|
||||||
" -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: Path manipulation functions
|
" Description: Path manipulation functions
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
function! vimwiki#path#chomp_slash(str) "{{{
|
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.
|
" Define path-compare function, either case-sensitive or not, depending on OS.
|
||||||
"{{{ " function! vimwiki#path#is_equal(p1, p2)
|
|
||||||
if vimwiki#u#is_windows()
|
if vimwiki#u#is_windows()
|
||||||
function! vimwiki#path#is_equal(p1, p2)
|
function! vimwiki#path#is_equal(p1, p2)
|
||||||
return a:p1 ==? a:p2
|
return a:p1 ==? a:p2
|
||||||
@ -18,10 +18,11 @@ else
|
|||||||
function! vimwiki#path#is_equal(p1, p2)
|
function! vimwiki#path#is_equal(p1, p2)
|
||||||
return a:p1 ==# a:p2
|
return a:p1 ==# a:p2
|
||||||
endfunction
|
endfunction
|
||||||
endif "}}}
|
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, '/[^/]\+/\.\.', '', '')
|
||||||
@ -31,9 +32,10 @@ function! vimwiki#path#normalize(path) "{{{
|
|||||||
let path = result
|
let path = result
|
||||||
endwhile
|
endwhile
|
||||||
return result
|
return result
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#path#path_norm(path) "{{{
|
|
||||||
|
function! vimwiki#path#path_norm(path)
|
||||||
" /-slashes
|
" /-slashes
|
||||||
if a:path !~# '^scp:'
|
if a:path !~# '^scp:'
|
||||||
let path = substitute(a:path, '\', '/', 'g')
|
let path = substitute(a:path, '\', '/', 'g')
|
||||||
@ -44,21 +46,24 @@ function! vimwiki#path#path_norm(path) "{{{
|
|||||||
else
|
else
|
||||||
return a:path
|
return a:path
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
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 /.
|
||||||
return a:link =~# '\m[/\\]$'
|
return a:link =~# '\m[/\\]$'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#path#abs_path_of_link(link) "{{{
|
|
||||||
|
function! vimwiki#path#abs_path_of_link(link)
|
||||||
return vimwiki#path#normalize(expand("%:p:h").'/'.a:link)
|
return vimwiki#path#normalize(expand("%:p:h").'/'.a:link)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" return longest common path prefix of 2 given paths.
|
" return longest common path prefix of 2 given paths.
|
||||||
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
|
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
|
||||||
function! vimwiki#path#path_common_pfx(path1, path2) "{{{
|
function! vimwiki#path#path_common_pfx(path1, path2)
|
||||||
let p1 = split(a:path1, '[/\\]', 1)
|
let p1 = split(a:path1, '[/\\]', 1)
|
||||||
let p2 = split(a:path2, '[/\\]', 1)
|
let p2 = split(a:path2, '[/\\]', 1)
|
||||||
|
|
||||||
@ -72,16 +77,17 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
|
|||||||
else
|
else
|
||||||
return join(p1[: idx-1], '/')
|
return join(p1[: idx-1], '/')
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#path#wikify_path(path) "{{{
|
|
||||||
|
function! vimwiki#path#wikify_path(path)
|
||||||
let result = resolve(fnamemodify(a:path, ':p'))
|
let result = resolve(fnamemodify(a:path, ':p'))
|
||||||
if vimwiki#u#is_windows()
|
if vimwiki#u#is_windows()
|
||||||
let result = substitute(result, '\\', '/', 'g')
|
let result = substitute(result, '\\', '/', 'g')
|
||||||
endif
|
endif
|
||||||
let result = vimwiki#path#chomp_slash(result)
|
let result = vimwiki#path#chomp_slash(result)
|
||||||
return result
|
return result
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! vimwiki#path#current_wiki_file()
|
function! vimwiki#path#current_wiki_file()
|
||||||
@ -90,7 +96,7 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
" Returns: the relative path from a:dir to a:file
|
" Returns: the relative path from a:dir to a:file
|
||||||
function! vimwiki#path#relpath(dir, file) "{{{
|
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, '/')
|
||||||
@ -112,12 +118,13 @@ function! vimwiki#path#relpath(dir, file) "{{{
|
|||||||
let result_path .= '/'
|
let result_path .= '/'
|
||||||
endif
|
endif
|
||||||
return result_path
|
return result_path
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" If the optional argument provided and nonzero,
|
" If the optional argument provided and nonzero,
|
||||||
" it will ask before creating a directory
|
" it will ask before creating a directory
|
||||||
" Returns: 1 iff directory exists or successfully created
|
" Returns: 1 iff directory exists or successfully created
|
||||||
function! vimwiki#path#mkdir(path, ...) "{{{
|
function! vimwiki#path#mkdir(path, ...)
|
||||||
let path = expand(a:path)
|
let path = expand(a:path)
|
||||||
|
|
||||||
if path =~# '^scp:'
|
if path =~# '^scp:'
|
||||||
@ -137,23 +144,23 @@ function! vimwiki#path#mkdir(path, ...) "{{{
|
|||||||
let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc'))
|
let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:0 && a:1 && input("Vimwiki: Make new directory: "
|
if a:0 && a:1 && input("Vimwiki: Make new directory: ".path."\n [y]es/[N]o? ") !~? '^y'
|
||||||
\ .path."\n [y]es/[N]o? ") !~? '^y'
|
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call mkdir(path, "p")
|
call mkdir(path, "p")
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#path#is_absolute(path) "{{{
|
|
||||||
|
function! vimwiki#path#is_absolute(path)
|
||||||
if vimwiki#u#is_windows()
|
if vimwiki#u#is_windows()
|
||||||
return a:path =~? '\m^\a:'
|
return a:path =~? '\m^\a:'
|
||||||
else
|
else
|
||||||
return a:path =~# '\m^/\|\~/'
|
return a:path =~# '\m^/\|\~/'
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Combine a directory and a file into one path, doesn't generate duplicate
|
" Combine a directory and a file into one path, doesn't generate duplicate
|
||||||
@ -173,3 +180,4 @@ else
|
|||||||
return directory . '/' . file
|
return directory . '/' . file
|
||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
|
|
||||||
|
|
||||||
let s:TAGS_METADATA_FILE_NAME = '.tags'
|
let s:TAGS_METADATA_FILE_NAME = '.tags'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" Tags metadata in-memory format:
|
" Tags metadata in-memory format:
|
||||||
" metadata := { 'pagename': [entries, ...] }
|
" metadata := { 'pagename': [entries, ...] }
|
||||||
" entry := { 'tagname':..., 'lineno':..., 'link':... }
|
" entry := { 'tagname':..., 'lineno':..., 'link':... }
|
||||||
@ -19,12 +21,13 @@ let s:TAGS_METADATA_FILE_NAME = '.tags'
|
|||||||
" an optional field, "vimwiki:". In this field, we encode tab-separated values
|
" an optional field, "vimwiki:". In this field, we encode tab-separated values
|
||||||
" of missing parameters -- "pagename" and "link".
|
" of missing parameters -- "pagename" and "link".
|
||||||
|
|
||||||
" vimwiki#tags#update_tags
|
|
||||||
|
|
||||||
" Update tags metadata.
|
" Update tags metadata.
|
||||||
" a:full_rebuild == 1: re-scan entire wiki
|
" a:full_rebuild == 1: re-scan entire wiki
|
||||||
" a:full_rebuild == 0: only re-scan current page
|
" a:full_rebuild == 0: only re-scan current page
|
||||||
" a:all_files == '': only if the file is newer than .tags
|
" a:all_files == '': only if the file is newer than .tags
|
||||||
function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
|
function! vimwiki#tags#update_tags(full_rebuild, all_files)
|
||||||
let all_files = a:all_files != ''
|
let all_files = a:all_files != ''
|
||||||
if !a:full_rebuild
|
if !a:full_rebuild
|
||||||
" Updating for one page (current)
|
" Updating for one page (current)
|
||||||
@ -42,8 +45,7 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
|
|||||||
else " full rebuild
|
else " full rebuild
|
||||||
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
|
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
|
||||||
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
|
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
|
||||||
let tags_file_last_modification =
|
let tags_file_last_modification = getftime(vimwiki#tags#metadata_file_path())
|
||||||
\ getftime(vimwiki#tags#metadata_file_path())
|
|
||||||
let metadata = s:load_tags_metadata()
|
let metadata = s:load_tags_metadata()
|
||||||
for file in files
|
for file in files
|
||||||
if all_files || getftime(file) >= tags_file_last_modification
|
if all_files || getftime(file) >= tags_file_last_modification
|
||||||
@ -56,12 +58,11 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{
|
|||||||
endfor
|
endfor
|
||||||
call s:write_tags_metadata(metadata)
|
call s:write_tags_metadata(metadata)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
" s:scan_tags
|
|
||||||
" Scans the list of text lines (argument) and produces tags metadata as a
|
" Scans the list of text lines (argument) and produces tags metadata as a list of tag entries.
|
||||||
" list of tag entries.
|
function! s:scan_tags(lines, page_name)
|
||||||
function! s:scan_tags(lines, page_name) "{{{
|
|
||||||
|
|
||||||
let entries = []
|
let entries = []
|
||||||
|
|
||||||
@ -136,17 +137,18 @@ function! s:scan_tags(lines, page_name) "{{{
|
|||||||
|
|
||||||
endfor " loop over lines
|
endfor " loop over lines
|
||||||
return entries
|
return entries
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#tags#metadata_file_path
|
|
||||||
" Returns tags metadata file path
|
" Returns tags metadata file path
|
||||||
function! vimwiki#tags#metadata_file_path() abort "{{{
|
function! vimwiki#tags#metadata_file_path() abort
|
||||||
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'), s:TAGS_METADATA_FILE_NAME), ':p')
|
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'),
|
||||||
endfunction " }}}
|
\ s:TAGS_METADATA_FILE_NAME), ':p')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" s:load_tags_metadata
|
|
||||||
" Loads tags metadata from file, returns a dictionary
|
" Loads tags metadata from file, returns a dictionary
|
||||||
function! s:load_tags_metadata() abort "{{{
|
function! s:load_tags_metadata() abort
|
||||||
let metadata_path = vimwiki#tags#metadata_file_path()
|
let metadata_path = vimwiki#tags#metadata_file_path()
|
||||||
if !filereadable(metadata_path)
|
if !filereadable(metadata_path)
|
||||||
return {}
|
return {}
|
||||||
@ -193,29 +195,29 @@ function! s:load_tags_metadata() abort "{{{
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return metadata
|
return metadata
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" s:remove_page_from_tags
|
|
||||||
" Removes all entries for given page from metadata in-place. Returns updated
|
" Removes all entries for given page from metadata in-place. Returns updated
|
||||||
" metadata (just in case).
|
" metadata (just in case).
|
||||||
function! s:remove_page_from_tags(metadata, page_name) "{{{
|
function! s:remove_page_from_tags(metadata, page_name)
|
||||||
if has_key(a:metadata, a:page_name)
|
if has_key(a:metadata, a:page_name)
|
||||||
call remove(a:metadata, a:page_name)
|
call remove(a:metadata, a:page_name)
|
||||||
return a:metadata
|
return a:metadata
|
||||||
else
|
else
|
||||||
return a:metadata
|
return a:metadata
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" s:merge_tags
|
|
||||||
" Merges metadata of one file into a:metadata
|
" Merges metadata of one file into a:metadata
|
||||||
function! s:merge_tags(metadata, pagename, file_metadata) "{{{
|
function! s:merge_tags(metadata, pagename, file_metadata)
|
||||||
let metadata = a:metadata
|
let metadata = a:metadata
|
||||||
let metadata[a:pagename] = a:file_metadata
|
let metadata[a:pagename] = a:file_metadata
|
||||||
return metadata
|
return metadata
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" s:tags_entry_cmp
|
|
||||||
" Compares two actual lines from tags file. Return value is in strcmp style.
|
" Compares two actual lines from tags file. Return value is in strcmp style.
|
||||||
" See help on sort() -- that's what this function is going to be used for.
|
" See help on sort() -- that's what this function is going to be used for.
|
||||||
" See also s:write_tags_metadata below -- that's where we compose these tags
|
" See also s:write_tags_metadata below -- that's where we compose these tags
|
||||||
@ -225,7 +227,7 @@ endfunction " }}}
|
|||||||
" numbers as strings, not integers, and so, for example, tag at line 14
|
" numbers as strings, not integers, and so, for example, tag at line 14
|
||||||
" preceeds the same tag on the same page at line 9. (Because string "14" is
|
" preceeds the same tag on the same page at line 9. (Because string "14" is
|
||||||
" alphabetically 'less than' string "9".)
|
" alphabetically 'less than' string "9".)
|
||||||
function! s:tags_entry_cmp(i1, i2) "{{{
|
function! s:tags_entry_cmp(i1, i2)
|
||||||
let items = []
|
let items = []
|
||||||
for orig_item in [a:i1, a:i2]
|
for orig_item in [a:i1, a:i2]
|
||||||
let fields = split(orig_item, "\t")
|
let fields = split(orig_item, "\t")
|
||||||
@ -245,11 +247,11 @@ function! s:tags_entry_cmp(i1, i2) "{{{
|
|||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" s:write_tags_metadata
|
|
||||||
" Saves metadata object into a file. Throws exceptions in case of problems.
|
" Saves metadata object into a file. Throws exceptions in case of problems.
|
||||||
function! s:write_tags_metadata(metadata) "{{{
|
function! s:write_tags_metadata(metadata)
|
||||||
let metadata_path = vimwiki#tags#metadata_file_path()
|
let metadata_path = vimwiki#tags#metadata_file_path()
|
||||||
let tags = []
|
let tags = []
|
||||||
for pagename in keys(a:metadata)
|
for pagename in keys(a:metadata)
|
||||||
@ -271,11 +273,11 @@ function! s:write_tags_metadata(metadata) "{{{
|
|||||||
call sort(tags, "s:tags_entry_cmp")
|
call sort(tags, "s:tags_entry_cmp")
|
||||||
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
|
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
|
||||||
call writefile(tags, metadata_path)
|
call writefile(tags, metadata_path)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#tags#get_tags
|
|
||||||
" Returns list of unique tags found in the .tags file
|
" Returns list of unique tags found in the .tags file
|
||||||
function! vimwiki#tags#get_tags() "{{{
|
function! vimwiki#tags#get_tags()
|
||||||
let metadata = s:load_tags_metadata()
|
let metadata = s:load_tags_metadata()
|
||||||
let tags = {}
|
let tags = {}
|
||||||
for entries in values(metadata)
|
for entries in values(metadata)
|
||||||
@ -284,13 +286,13 @@ function! vimwiki#tags#get_tags() "{{{
|
|||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
return keys(tags)
|
return keys(tags)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" vimwiki#tags#generate_tags
|
|
||||||
" Similar to vimwiki#base#generate_links. In the current buffer, appends
|
" Similar to vimwiki#base#generate_links. In the current buffer, appends
|
||||||
" tags and references to all their instances. If no arguments (tags) are
|
" tags and references to all their instances. If no arguments (tags) are
|
||||||
" specified, outputs all tags.
|
" specified, outputs all tags.
|
||||||
function! vimwiki#tags#generate_tags(...) abort "{{{
|
function! vimwiki#tags#generate_tags(...) abort
|
||||||
let need_all_tags = (a:0 == 0)
|
let need_all_tags = (a:0 == 0)
|
||||||
let specific_tags = a:000
|
let specific_tags = a:000
|
||||||
|
|
||||||
@ -309,8 +311,7 @@ function! vimwiki#tags#generate_tags(...) abort "{{{
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
let lines = []
|
let lines = []
|
||||||
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
|
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).vimwiki#lst#default_symbol().' '
|
||||||
\ vimwiki#lst#default_symbol().' '
|
|
||||||
for tagname in sort(keys(tags_entries))
|
for tagname in sort(keys(tags_entries))
|
||||||
if need_all_tags || index(specific_tags, tagname) != -1
|
if need_all_tags || index(specific_tags, tagname) != -1
|
||||||
call extend(lines, [
|
call extend(lines, [
|
||||||
@ -318,8 +319,8 @@ function! vimwiki#tags#generate_tags(...) abort "{{{
|
|||||||
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''),
|
\ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''),
|
||||||
\ '' ])
|
\ '' ])
|
||||||
for taglink in sort(tags_entries[tagname])
|
for taglink in sort(tags_entries[tagname])
|
||||||
call add(lines, bullet .
|
call add(lines, bullet . substitute(vimwiki#vars#get_global('WikiLinkTemplate1'),
|
||||||
\ substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', taglink, ''))
|
\ '__LinkUrl__', taglink, ''))
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -328,15 +329,14 @@ function! vimwiki#tags#generate_tags(...) abort "{{{
|
|||||||
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
\ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' '
|
||||||
\ .vimwiki#vars#get_syntaxlocal('rxWikiLink').'$\)'
|
\ .vimwiki#vars#get_syntaxlocal('rxWikiLink').'$\)'
|
||||||
|
|
||||||
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx,
|
call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx, line('$')+1, 1)
|
||||||
\ line('$')+1, 1)
|
endfunction
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
" vimwiki#tags#complete_tags
|
|
||||||
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort " {{{
|
function! vimwiki#tags#complete_tags(ArgLead, CmdLine, CursorPos) abort
|
||||||
" We can safely ignore args if we use -custom=complete option, Vim engine
|
" We can safely ignore args if we use -custom=complete option, Vim engine
|
||||||
" will do the job of filtering.
|
" will do the job of filtering.
|
||||||
let taglist = vimwiki#tags#get_tags()
|
let taglist = vimwiki#tags#get_tags()
|
||||||
return join(taglist, "\n")
|
return join(taglist, "\n")
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
@ -1,28 +1,29 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: Tables
|
" Description: Tables
|
||||||
" | Easily | manageable | text | tables | ! |
|
" | Easily | manageable | text | tables | ! |
|
||||||
" |--------|------------|-------|--------|---------|
|
" |--------|------------|-------|--------|---------|
|
||||||
" | Have | fun! | Drink | tea | Period. |
|
" | Have | fun! | Drink | tea | Period. |
|
||||||
"
|
"
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
" Load only once {{{
|
|
||||||
|
|
||||||
if exists("g:loaded_vimwiki_tbl_auto") || &cp
|
if exists("g:loaded_vimwiki_tbl_auto") || &cp
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_vimwiki_tbl_auto = 1
|
let g:loaded_vimwiki_tbl_auto = 1
|
||||||
"}}}
|
|
||||||
|
|
||||||
let s:textwidth = &tw
|
let s:textwidth = &tw
|
||||||
|
|
||||||
|
|
||||||
" Misc functions {{{
|
function! s:rxSep()
|
||||||
function! s:rxSep() "{{{
|
|
||||||
return vimwiki#vars#get_syntaxlocal('rxTableSep')
|
return vimwiki#vars#get_syntaxlocal('rxTableSep')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:wide_len(str) "{{{
|
|
||||||
|
function! s:wide_len(str)
|
||||||
" vim73 has new function that gives correct string width.
|
" vim73 has new function that gives correct string width.
|
||||||
if exists("*strdisplaywidth")
|
if exists("*strdisplaywidth")
|
||||||
return strdisplaywidth(a:str)
|
return strdisplaywidth(a:str)
|
||||||
@ -42,42 +43,49 @@ function! s:wide_len(str) "{{{
|
|||||||
let &modified = savemodified
|
let &modified = savemodified
|
||||||
endif
|
endif
|
||||||
return ret
|
return ret
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:cell_splitter() "{{{
|
|
||||||
|
function! s:cell_splitter()
|
||||||
return '\s*'.s:rxSep().'\s*'
|
return '\s*'.s:rxSep().'\s*'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:sep_splitter() "{{{
|
|
||||||
|
function! s:sep_splitter()
|
||||||
return '-'.s:rxSep().'-'
|
return '-'.s:rxSep().'-'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:is_table(line) "{{{
|
|
||||||
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) "{{{
|
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*$')
|
||||||
|
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 "}}}
|
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*$')
|
|
||||||
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())
|
return line =~# '^\s*$' ||
|
||||||
return line =~# '^\s*$' || (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
|
\ (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep())
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:count_separators_up(lnum) "{{{
|
|
||||||
|
function! s:count_separators_up(lnum)
|
||||||
let lnum = a:lnum - 1
|
let lnum = a:lnum - 1
|
||||||
while lnum > 1
|
while lnum > 1
|
||||||
if !s:is_separator(getline(lnum))
|
if !s:is_separator(getline(lnum))
|
||||||
@ -87,9 +95,10 @@ function! s:count_separators_up(lnum) "{{{
|
|||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
return (a:lnum-lnum)
|
return (a:lnum-lnum)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:count_separators_down(lnum) "{{{
|
|
||||||
|
function! s:count_separators_down(lnum)
|
||||||
let lnum = a:lnum + 1
|
let lnum = a:lnum + 1
|
||||||
while lnum < line('$')
|
while lnum < line('$')
|
||||||
if !s:is_separator(getline(lnum))
|
if !s:is_separator(getline(lnum))
|
||||||
@ -99,9 +108,10 @@ function! s:count_separators_down(lnum) "{{{
|
|||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
return (lnum-a:lnum)
|
return (lnum-a:lnum)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:create_empty_row(cols) "{{{
|
|
||||||
|
function! s:create_empty_row(cols)
|
||||||
let row = s:rxSep()
|
let row = s:rxSep()
|
||||||
let cell = " ".s:rxSep()
|
let cell = " ".s:rxSep()
|
||||||
|
|
||||||
@ -110,9 +120,10 @@ function! s:create_empty_row(cols) "{{{
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
return row
|
return row
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:create_row_sep(cols) "{{{
|
|
||||||
|
function! s:create_row_sep(cols)
|
||||||
let row = s:rxSep()
|
let row = s:rxSep()
|
||||||
let cell = "---".s:rxSep()
|
let cell = "---".s:rxSep()
|
||||||
|
|
||||||
@ -121,9 +132,10 @@ function! s:create_row_sep(cols) "{{{
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
return row
|
return row
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#get_cells(line) "{{{
|
|
||||||
|
function! vimwiki#tbl#get_cells(line)
|
||||||
let result = []
|
let result = []
|
||||||
let cell = ''
|
let cell = ''
|
||||||
let quote = ''
|
let quote = ''
|
||||||
@ -174,13 +186,15 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
|||||||
call add(result, vimwiki#u#trim(cell.quote, '|'))
|
call add(result, vimwiki#u#trim(cell.quote, '|'))
|
||||||
endif
|
endif
|
||||||
return result
|
return result
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:col_count(lnum) "{{{
|
|
||||||
|
function! s:col_count(lnum)
|
||||||
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
|
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:get_indent(lnum) "{{{
|
|
||||||
|
function! s:get_indent(lnum)
|
||||||
if !s:is_table(getline(a:lnum))
|
if !s:is_table(getline(a:lnum))
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -198,9 +212,10 @@ function! s:get_indent(lnum) "{{{
|
|||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
return indent
|
return indent
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
function! s:get_rows(lnum) "{{{
|
|
||||||
|
function! s:get_rows(lnum)
|
||||||
if !s:is_table(getline(a:lnum))
|
if !s:is_table(getline(a:lnum))
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -232,9 +247,10 @@ function! s:get_rows(lnum) "{{{
|
|||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
return upper_rows + lower_rows
|
return upper_rows + lower_rows
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:get_cell_max_lens(lnum, ...) "{{{
|
|
||||||
|
function! s:get_cell_max_lens(lnum, ...)
|
||||||
let max_lens = {}
|
let max_lens = {}
|
||||||
for [lnum, row] in s:get_rows(a:lnum)
|
for [lnum, row] in s:get_rows(a:lnum)
|
||||||
if s:is_separator(row)
|
if s:is_separator(row)
|
||||||
@ -251,9 +267,10 @@ function! s:get_cell_max_lens(lnum, ...) "{{{
|
|||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
return max_lens
|
return max_lens
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:get_aligned_rows(lnum, col1, col2) "{{{
|
|
||||||
|
function! s:get_aligned_rows(lnum, col1, col2)
|
||||||
let rows = s:get_rows(a:lnum)
|
let rows = s:get_rows(a:lnum)
|
||||||
let startlnum = rows[0][0]
|
let startlnum = rows[0][0]
|
||||||
let cells = []
|
let cells = []
|
||||||
@ -271,10 +288,11 @@ function! s:get_aligned_rows(lnum, col1, col2) "{{{
|
|||||||
call add(result, [lnum, new_row])
|
call add(result, [lnum, new_row])
|
||||||
endfor
|
endfor
|
||||||
return result
|
return result
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Number of the current column. Starts from 0.
|
" Number of the current column. Starts from 0.
|
||||||
function! s:cur_column() "{{{
|
function! s:cur_column()
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
if !s:is_table(line)
|
if !s:is_table(line)
|
||||||
return -1
|
return -1
|
||||||
@ -291,12 +309,10 @@ function! s:cur_column() "{{{
|
|||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
return col
|
return col
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Format functions {{{
|
function! s:fmt_cell(cell, max_len)
|
||||||
function! s:fmt_cell(cell, max_len) "{{{
|
|
||||||
let cell = ' '.a:cell.' '
|
let cell = ' '.a:cell.' '
|
||||||
|
|
||||||
let diff = a:max_len - s:wide_len(a:cell)
|
let diff = a:max_len - s:wide_len(a:cell)
|
||||||
@ -306,9 +322,10 @@ function! s:fmt_cell(cell, max_len) "{{{
|
|||||||
|
|
||||||
let cell .= repeat(' ', diff)
|
let cell .= repeat(' ', diff)
|
||||||
return cell
|
return cell
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:fmt_row(cells, max_lens, col1, col2) "{{{
|
|
||||||
|
function! s:fmt_row(cells, max_lens, col1, col2)
|
||||||
let new_line = s:rxSep()
|
let new_line = s:rxSep()
|
||||||
for idx in range(len(a:cells))
|
for idx in range(len(a:cells))
|
||||||
if idx == a:col1
|
if idx == a:col1
|
||||||
@ -326,17 +343,19 @@ function! s:fmt_row(cells, max_lens, col1, col2) "{{{
|
|||||||
let idx += 1
|
let idx += 1
|
||||||
endwhile
|
endwhile
|
||||||
return new_line
|
return new_line
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:fmt_cell_sep(max_len) "{{{
|
|
||||||
|
function! s:fmt_cell_sep(max_len)
|
||||||
if a:max_len == 0
|
if a:max_len == 0
|
||||||
return repeat('-', 3)
|
return repeat('-', 3)
|
||||||
else
|
else
|
||||||
return repeat('-', a:max_len+2)
|
return repeat('-', a:max_len+2)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:fmt_sep(max_lens, col1, col2) "{{{
|
|
||||||
|
function! s:fmt_sep(max_lens, col1, col2)
|
||||||
let new_line = s:rxSep()
|
let new_line = s:rxSep()
|
||||||
for idx in range(len(a:max_lens))
|
for idx in range(len(a:max_lens))
|
||||||
if idx == a:col1
|
if idx == a:col1
|
||||||
@ -347,11 +366,10 @@ function! s:fmt_sep(max_lens, col1, col2) "{{{
|
|||||||
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
|
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
|
||||||
endfor
|
endfor
|
||||||
return new_line
|
return new_line
|
||||||
endfunction "}}}
|
endfunction
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Keyboard functions "{{{
|
|
||||||
function! s:kbd_create_new_row(cols, goto_first) "{{{
|
function! s:kbd_create_new_row(cols, goto_first)
|
||||||
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
|
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
|
||||||
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
|
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
|
||||||
let cmd .= "\<ESC>0"
|
let cmd .= "\<ESC>0"
|
||||||
@ -364,26 +382,29 @@ function! s:kbd_create_new_row(cols, goto_first) "{{{
|
|||||||
let cmd .= "a"
|
let cmd .= "a"
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:kbd_goto_next_row() "{{{
|
|
||||||
|
function! s:kbd_goto_next_row()
|
||||||
let cmd = "\<ESC>j"
|
let cmd = "\<ESC>j"
|
||||||
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
|
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
|
||||||
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
|
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
|
||||||
let cmd .= "a"
|
let cmd .= "a"
|
||||||
return cmd
|
return cmd
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:kbd_goto_prev_row() "{{{
|
|
||||||
|
function! s:kbd_goto_prev_row()
|
||||||
let cmd = "\<ESC>k"
|
let cmd = "\<ESC>k"
|
||||||
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
|
let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
|
||||||
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
|
let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
|
||||||
let cmd .= "a"
|
let cmd .= "a"
|
||||||
return cmd
|
return cmd
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Used in s:kbd_goto_next_col
|
" Used in s:kbd_goto_next_col
|
||||||
function! vimwiki#tbl#goto_next_col() "{{{
|
function! vimwiki#tbl#goto_next_col()
|
||||||
let curcol = virtcol('.')
|
let curcol = virtcol('.')
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let newcol = s:get_indent(lnum)
|
let newcol = s:get_indent(lnum)
|
||||||
@ -396,9 +417,10 @@ function! vimwiki#tbl#goto_next_col() "{{{
|
|||||||
endfor
|
endfor
|
||||||
let newcol += 2 " +2 == 1 separator + 1 space |<space
|
let newcol += 2 " +2 == 1 separator + 1 space |<space
|
||||||
call vimwiki#u#cursor(lnum, newcol)
|
call vimwiki#u#cursor(lnum, newcol)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:kbd_goto_next_col(jumpdown) "{{{
|
|
||||||
|
function! s:kbd_goto_next_col(jumpdown)
|
||||||
let cmd = "\<ESC>"
|
let cmd = "\<ESC>"
|
||||||
if a:jumpdown
|
if a:jumpdown
|
||||||
let seps = s:count_separators_down(line('.'))
|
let seps = s:count_separators_down(line('.'))
|
||||||
@ -406,10 +428,11 @@ function! s:kbd_goto_next_col(jumpdown) "{{{
|
|||||||
endif
|
endif
|
||||||
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
|
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
|
||||||
return cmd
|
return cmd
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Used in s:kbd_goto_prev_col
|
" Used in s:kbd_goto_prev_col
|
||||||
function! vimwiki#tbl#goto_prev_col() "{{{
|
function! vimwiki#tbl#goto_prev_col()
|
||||||
let curcol = virtcol('.')
|
let curcol = virtcol('.')
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let newcol = s:get_indent(lnum)
|
let newcol = s:get_indent(lnum)
|
||||||
@ -428,9 +451,10 @@ function! vimwiki#tbl#goto_prev_col() "{{{
|
|||||||
endfor
|
endfor
|
||||||
let newcol += 2 " +2 == 1 separator + 1 space |<space
|
let newcol += 2 " +2 == 1 separator + 1 space |<space
|
||||||
call vimwiki#u#cursor(lnum, newcol)
|
call vimwiki#u#cursor(lnum, newcol)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:kbd_goto_prev_col(jumpup) "{{{
|
|
||||||
|
function! s:kbd_goto_prev_col(jumpup)
|
||||||
let cmd = "\<ESC>"
|
let cmd = "\<ESC>"
|
||||||
if a:jumpup
|
if a:jumpup
|
||||||
let seps = s:count_separators_up(line('.'))
|
let seps = s:count_separators_up(line('.'))
|
||||||
@ -442,12 +466,10 @@ function! s:kbd_goto_prev_col(jumpup) "{{{
|
|||||||
" let cmd .= "a"
|
" let cmd .= "a"
|
||||||
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
|
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
|
||||||
return cmd
|
return cmd
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Global functions {{{
|
function! vimwiki#tbl#kbd_cr()
|
||||||
function! vimwiki#tbl#kbd_cr() "{{{
|
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
if !s:is_table(getline(lnum))
|
if !s:is_table(getline(lnum))
|
||||||
return ""
|
return ""
|
||||||
@ -459,9 +481,10 @@ function! vimwiki#tbl#kbd_cr() "{{{
|
|||||||
else
|
else
|
||||||
return s:kbd_goto_next_row()
|
return s:kbd_goto_next_row()
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#kbd_tab() "{{{
|
|
||||||
|
function! vimwiki#tbl#kbd_tab()
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
if !s:is_table(getline(lnum))
|
if !s:is_table(getline(lnum))
|
||||||
return "\<Tab>"
|
return "\<Tab>"
|
||||||
@ -475,9 +498,10 @@ function! vimwiki#tbl#kbd_tab() "{{{
|
|||||||
return s:kbd_create_new_row(cols, 1)
|
return s:kbd_create_new_row(cols, 1)
|
||||||
endif
|
endif
|
||||||
return s:kbd_goto_next_col(is_sep || last)
|
return s:kbd_goto_next_col(is_sep || last)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#kbd_shift_tab() "{{{
|
|
||||||
|
function! vimwiki#tbl#kbd_shift_tab()
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
if !s:is_table(getline(lnum))
|
if !s:is_table(getline(lnum))
|
||||||
return "\<S-Tab>"
|
return "\<S-Tab>"
|
||||||
@ -490,9 +514,10 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
|
|||||||
return ""
|
return ""
|
||||||
endif
|
endif
|
||||||
return s:kbd_goto_prev_col(is_sep || first)
|
return s:kbd_goto_prev_col(is_sep || first)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
|
||||||
|
function! vimwiki#tbl#format(lnum, ...)
|
||||||
if !(&filetype ==? 'vimwiki')
|
if !(&filetype ==? 'vimwiki')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -520,11 +545,12 @@ function! vimwiki#tbl#format(lnum, ...) "{{{
|
|||||||
let row = indentstring.row
|
let row = indentstring.row
|
||||||
call setline(lnum, row)
|
call setline(lnum, row)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let &tw = s:textwidth
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! vimwiki#tbl#create(...) "{{{
|
let &tw = s:textwidth
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! vimwiki#tbl#create(...)
|
||||||
if a:0 > 1
|
if a:0 > 1
|
||||||
let cols = a:1
|
let cols = a:1
|
||||||
let rows = a:2
|
let rows = a:2
|
||||||
@ -555,19 +581,21 @@ function! vimwiki#tbl#create(...) "{{{
|
|||||||
for r in range(rows - 1)
|
for r in range(rows - 1)
|
||||||
call add(lines, row)
|
call add(lines, row)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
call append(line('.'), lines)
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
call append(line('.'), lines)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! vimwiki#tbl#align_or_cmd(cmd)
|
||||||
if s:is_table(getline('.'))
|
if s:is_table(getline('.'))
|
||||||
call vimwiki#tbl#format(line('.'))
|
call vimwiki#tbl#format(line('.'))
|
||||||
else
|
else
|
||||||
exe 'normal! '.a:cmd
|
exe 'normal! '.a:cmd
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
|
||||||
|
function! vimwiki#tbl#reset_tw(lnum)
|
||||||
if !(&filetype ==? 'vimwiki')
|
if !(&filetype ==? 'vimwiki')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -575,14 +603,14 @@ function! vimwiki#tbl#reset_tw(lnum) "{{{
|
|||||||
if !s:is_table(line)
|
if !s:is_table(line)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:textwidth = &tw
|
let s:textwidth = &tw
|
||||||
let &tw = 0
|
let &tw = 0
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" TODO: move_column_left and move_column_right are good candidates to be
|
|
||||||
" refactored.
|
" TODO: move_column_left and move_column_right are good candidates to be refactored.
|
||||||
function! vimwiki#tbl#move_column_left() "{{{
|
function! vimwiki#tbl#move_column_left()
|
||||||
|
|
||||||
"echomsg "DEBUG move_column_left: "
|
"echomsg "DEBUG move_column_left: "
|
||||||
|
|
||||||
@ -598,7 +626,7 @@ function! vimwiki#tbl#move_column_left() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if cur_col > 0
|
if cur_col > 0
|
||||||
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
|
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
|
||||||
call cursor(line('.'), 1)
|
call cursor(line('.'), 1)
|
||||||
|
|
||||||
let sep = '\('.s:rxSep().'\).\zs'
|
let sep = '\('.s:rxSep().'\).\zs'
|
||||||
@ -608,16 +636,16 @@ function! vimwiki#tbl#move_column_left() "{{{
|
|||||||
let mpos = match(line, sep, mpos+1)
|
let mpos = match(line, sep, mpos+1)
|
||||||
if mpos != -1
|
if mpos != -1
|
||||||
let col += 1
|
let col += 1
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! vimwiki#tbl#move_column_right() "{{{
|
function! vimwiki#tbl#move_column_right()
|
||||||
|
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
|
|
||||||
@ -631,7 +659,7 @@ function! vimwiki#tbl#move_column_right() "{{{
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if cur_col < s:col_count(line('.'))-1
|
if cur_col < s:col_count(line('.'))-1
|
||||||
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
|
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
|
||||||
call cursor(line('.'), 1)
|
call cursor(line('.'), 1)
|
||||||
|
|
||||||
let sep = '\('.s:rxSep().'\).\zs'
|
let sep = '\('.s:rxSep().'\).\zs'
|
||||||
@ -641,33 +669,35 @@ function! vimwiki#tbl#move_column_right() "{{{
|
|||||||
let mpos = match(line, sep, mpos+1)
|
let mpos = match(line, sep, mpos+1)
|
||||||
if mpos != -1
|
if mpos != -1
|
||||||
let col += 1
|
let col += 1
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! vimwiki#tbl#get_rows(lnum) "{{{
|
function! vimwiki#tbl#get_rows(lnum)
|
||||||
return s:get_rows(a:lnum)
|
return s:get_rows(a:lnum)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#is_table(line) "{{{
|
|
||||||
|
function! vimwiki#tbl#is_table(line)
|
||||||
return s:is_table(a:line)
|
return s:is_table(a:line)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#is_separator(line) "{{{
|
|
||||||
|
function! vimwiki#tbl#is_separator(line)
|
||||||
return s:is_separator(a:line)
|
return s:is_separator(a:line)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#cell_splitter() "{{{
|
|
||||||
|
function! vimwiki#tbl#cell_splitter()
|
||||||
return s:cell_splitter()
|
return s:cell_splitter()
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#tbl#sep_splitter() "{{{
|
|
||||||
|
function! vimwiki#tbl#sep_splitter()
|
||||||
return s:sep_splitter()
|
return s:sep_splitter()
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Desc: Utility functions
|
" Description: Utility functions
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
function! vimwiki#u#trim(string, ...) "{{{
|
function! vimwiki#u#trim(string, ...)
|
||||||
let chars = ''
|
let chars = ''
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
let chars = a:1
|
let chars = a:1
|
||||||
@ -11,17 +11,20 @@ function! vimwiki#u#trim(string, ...) "{{{
|
|||||||
let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
|
let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
|
||||||
let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
|
let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
|
||||||
return res
|
return res
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Builtin cursor doesn't work right with unicode characters.
|
" Builtin cursor doesn't work right with unicode characters.
|
||||||
function! vimwiki#u#cursor(lnum, cnum) "{{{
|
function! vimwiki#u#cursor(lnum, cnum)
|
||||||
exe a:lnum
|
exe a:lnum
|
||||||
exe 'normal! 0'.a:cnum.'|'
|
exe 'normal! 0'.a:cnum.'|'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#u#is_windows() "{{{
|
|
||||||
|
function! vimwiki#u#is_windows()
|
||||||
return has("win32") || has("win64") || has("win95") || has("win16")
|
return has("win32") || has("win64") || has("win95") || has("win16")
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! vimwiki#u#is_macos()
|
function! vimwiki#u#is_macos()
|
||||||
if has("mac") || has("macunix") || has("gui_mac")
|
if has("mac") || has("macunix") || has("gui_mac")
|
||||||
@ -32,27 +35,32 @@ function! vimwiki#u#is_macos()
|
|||||||
return os == 'Darwin' || os == 'Mac'
|
return os == 'Darwin' || os == 'Mac'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#u#count_first_sym(line) "{{{
|
|
||||||
|
function! vimwiki#u#count_first_sym(line)
|
||||||
let first_sym = matchstr(a:line, '\S')
|
let first_sym = matchstr(a:line, '\S')
|
||||||
return len(matchstr(a:line, first_sym.'\+'))
|
return len(matchstr(a:line, first_sym.'\+'))
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! vimwiki#u#escape(string) "{{{
|
|
||||||
|
function! vimwiki#u#escape(string)
|
||||||
return escape(a:string, '~.*[]\^$')
|
return escape(a:string, '~.*[]\^$')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Load concrete Wiki syntax: sets regexes and templates for headers and links
|
" Load concrete Wiki syntax: sets regexes and templates for headers and links
|
||||||
function vimwiki#u#reload_regexes() "{{{
|
function vimwiki#u#reload_regexes()
|
||||||
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'.vim'
|
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'.vim'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Load syntax-specific functionality
|
" Load syntax-specific functionality
|
||||||
function vimwiki#u#reload_regexes_custom() "{{{
|
function vimwiki#u#reload_regexes_custom()
|
||||||
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'_custom.vim'
|
execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'_custom.vim'
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Backward compatible version of the built-in function shiftwidth()
|
" Backward compatible version of the built-in function shiftwidth()
|
||||||
if exists('*shiftwidth') "{{{
|
if exists('*shiftwidth')
|
||||||
func vimwiki#u#sw()
|
func vimwiki#u#sw()
|
||||||
return shiftwidth()
|
return shiftwidth()
|
||||||
endfunc
|
endfunc
|
||||||
@ -60,4 +68,5 @@ else
|
|||||||
func vimwiki#u#sw()
|
func vimwiki#u#sw()
|
||||||
return &sw
|
return &sw
|
||||||
endfunc
|
endfunc
|
||||||
endif "}}}
|
endif
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
" Vimwiki autoload plugin file
|
" Vimwiki autoload plugin file
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" ------------------------------------------------------------------------------------------------
|
" ------------------------------------------------------------------------------------------------
|
||||||
" This file provides functions to manage the various state variables which are needed during a
|
" This file provides functions to manage the various state variables which are needed during a
|
||||||
" Vimwiki session.
|
" Vimwiki session.
|
||||||
@ -268,7 +270,7 @@ function! s:validate_settings()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:normalize_path(path) "{{{
|
function! s:normalize_path(path)
|
||||||
" trim trailing / and \ because otherwise resolve() doesn't work quite right
|
" trim trailing / and \ because otherwise resolve() doesn't work quite right
|
||||||
let path = substitute(a:path, '[/\\]\+$', '', '')
|
let path = substitute(a:path, '[/\\]\+$', '', '')
|
||||||
if path !~# '^scp:'
|
if path !~# '^scp:'
|
||||||
@ -276,7 +278,7 @@ function! s:normalize_path(path) "{{{
|
|||||||
else
|
else
|
||||||
return path.'/'
|
return path.'/'
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! vimwiki#vars#populate_syntax_vars(syntax)
|
function! vimwiki#vars#populate_syntax_vars(syntax)
|
||||||
@ -703,7 +705,9 @@ function! vimwiki#vars#add_temporary_wiki(settings)
|
|||||||
call s:validate_settings()
|
call s:validate_settings()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" number of registered wikis + temporary
|
" number of registered wikis + temporary
|
||||||
function! vimwiki#vars#number_of_wikis()
|
function! vimwiki#vars#number_of_wikis()
|
||||||
return len(g:vimwiki_wikilocal_vars) - 1
|
return len(g:vimwiki_wikilocal_vars) - 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki filetype plugin file
|
" Vimwiki filetype plugin file
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
@ -8,7 +8,6 @@ endif
|
|||||||
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
|
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
|
||||||
|
|
||||||
|
|
||||||
" MISC STUFF {{{
|
|
||||||
|
|
||||||
setlocal commentstring=%%%s
|
setlocal commentstring=%%%s
|
||||||
|
|
||||||
@ -16,16 +15,14 @@ if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
|||||||
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
|
let &l:conceallevel = vimwiki#vars#get_global('conceallevel')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" GOTO FILE: gf {{{
|
" This is for GOTO FILE: gf
|
||||||
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
|
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
|
||||||
setlocal isfname-=[,]
|
setlocal isfname-=[,]
|
||||||
" gf}}}
|
|
||||||
|
|
||||||
exe "setlocal tags+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"')
|
exe "setlocal tags+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"')
|
||||||
|
|
||||||
" MISC }}}
|
|
||||||
|
|
||||||
" COMPLETION {{{
|
|
||||||
function! Complete_wikifiles(findstart, base)
|
function! Complete_wikifiles(findstart, base)
|
||||||
if a:findstart == 1
|
if a:findstart == 1
|
||||||
let column = col('.')-2
|
let column = col('.')-2
|
||||||
@ -116,9 +113,9 @@ function! Complete_wikifiles(findstart, base)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
setlocal omnifunc=Complete_wikifiles
|
setlocal omnifunc=Complete_wikifiles
|
||||||
" COMPLETION }}}
|
|
||||||
|
|
||||||
" LIST STUFF {{{
|
|
||||||
|
|
||||||
" settings necessary for the automatic formatting of lists
|
" settings necessary for the automatic formatting of lists
|
||||||
setlocal autoindent
|
setlocal autoindent
|
||||||
setlocal nosmartindent
|
setlocal nosmartindent
|
||||||
@ -130,7 +127,6 @@ setlocal formatoptions-=o
|
|||||||
setlocal formatoptions-=2
|
setlocal formatoptions-=2
|
||||||
setlocal formatoptions+=n
|
setlocal formatoptions+=n
|
||||||
|
|
||||||
"Create 'formatlistpat'
|
|
||||||
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
|
let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem')
|
||||||
|
|
||||||
if !empty(&langmap)
|
if !empty(&langmap)
|
||||||
@ -146,17 +142,18 @@ if !empty(&langmap)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" LIST STUFF }}}
|
|
||||||
|
|
||||||
" FOLDING {{{
|
|
||||||
" Folding list items {{{
|
" ------------------------------------------------
|
||||||
function! VimwikiFoldListLevel(lnum) "{{{
|
" Folding stuff
|
||||||
|
" ------------------------------------------------
|
||||||
|
|
||||||
|
function! VimwikiFoldListLevel(lnum)
|
||||||
return vimwiki#lst#fold_level(a:lnum)
|
return vimwiki#lst#fold_level(a:lnum)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
" Folding list items }}}
|
|
||||||
|
|
||||||
" Folding sections and code blocks {{{
|
|
||||||
function! VimwikiFoldLevel(lnum) "{{{
|
function! VimwikiFoldLevel(lnum)
|
||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
|
|
||||||
" Header/section folding...
|
" Header/section folding...
|
||||||
@ -170,26 +167,29 @@ function! VimwikiFoldLevel(lnum) "{{{
|
|||||||
else
|
else
|
||||||
return "="
|
return "="
|
||||||
endif
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
" Constants used by VimwikiFoldText {{{
|
" Constants used by VimwikiFoldText
|
||||||
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
|
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
|
||||||
let s:ellipsis = (&enc ==? 'utf-8') ? "\u2026" : "..."
|
let s:ellipsis = (&enc ==? 'utf-8') ? "\u2026" : "..."
|
||||||
let s:ell_len = strlen(s:ellipsis)
|
let s:ell_len = strlen(s:ellipsis)
|
||||||
let s:newline = (&enc ==? 'utf-8') ? "\u21b2 " : " "
|
let s:newline = (&enc ==? 'utf-8') ? "\u21b2 " : " "
|
||||||
let s:tolerance = 5
|
let s:tolerance = 5
|
||||||
" }}}
|
|
||||||
|
|
||||||
function! s:shorten_text_simple(text, len) "{{{ unused
|
|
||||||
|
" unused
|
||||||
|
function! s:shorten_text_simple(text, len)
|
||||||
let spare_len = a:len - len(a:text)
|
let spare_len = a:len - len(a:text)
|
||||||
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
|
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
|
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
|
||||||
" for long enough "text", the string's length is within s:tolerance of "len"
|
" for long enough "text", the string's length is within s:tolerance of "len"
|
||||||
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
|
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
|
||||||
function! s:shorten_text(text, len) "{{{ returns [string, spare]
|
function! s:shorten_text(text, len)
|
||||||
|
" returns [string, spare]
|
||||||
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
|
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
|
||||||
" trick here -- replace all non-spaces with dot, calculate lengths and
|
" trick here -- replace all non-spaces with dot, calculate lengths and
|
||||||
" indexes on it, then use original string to break at selected index.
|
" indexes on it, then use original string to break at selected index.
|
||||||
@ -202,11 +202,11 @@ function! s:shorten_text(text, len) "{{{ returns [string, spare]
|
|||||||
let newlen = a:len - s:ell_len
|
let newlen = a:len - s:ell_len
|
||||||
let idx = strridx(text_pattern, ' ', newlen + s:tolerance)
|
let idx = strridx(text_pattern, ' ', newlen + s:tolerance)
|
||||||
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
|
let break_idx = (idx + s:tolerance >= newlen) ? idx : newlen
|
||||||
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis,
|
return [matchstr(a:text, '\m^.\{'.break_idx.'\}').s:ellipsis, newlen - break_idx]
|
||||||
\ newlen - break_idx]
|
endfunction
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! VimwikiFoldText() "{{{
|
|
||||||
|
function! VimwikiFoldText()
|
||||||
let line = getline(v:foldstart)
|
let line = getline(v:foldstart)
|
||||||
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
|
||||||
@ -226,12 +226,14 @@ function! VimwikiFoldText() "{{{
|
|||||||
endif
|
endif
|
||||||
return main_text.len_text.content_text
|
return main_text.len_text.content_text
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
" Folding sections and code blocks }}}
|
|
||||||
" FOLDING }}}
|
|
||||||
|
|
||||||
" COMMANDS {{{
|
|
||||||
|
" ------------------------------------------------
|
||||||
|
" Commands
|
||||||
|
" ------------------------------------------------
|
||||||
|
|
||||||
command! -buffer Vimwiki2HTML
|
command! -buffer Vimwiki2HTML
|
||||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||||
\ <bar>
|
\ <bar>
|
||||||
@ -289,7 +291,8 @@ command! -buffer -range -nargs=1 VimwikiListChangeSymbolI
|
|||||||
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo
|
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo
|
||||||
\ call vimwiki#lst#change_marker_in_list(<f-args>)
|
\ call vimwiki#lst#change_marker_in_list(<f-args>)
|
||||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
||||||
command! -buffer -range VimwikiToggleRejectedListItem call vimwiki#lst#toggle_rejected_cb(<line1>, <line2>)
|
command! -buffer -range VimwikiToggleRejectedListItem
|
||||||
|
\ call vimwiki#lst#toggle_rejected_cb(<line1>, <line2>)
|
||||||
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
|
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
|
||||||
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
|
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
|
||||||
command! -buffer -range -nargs=+ VimwikiListChangeLvl
|
command! -buffer -range -nargs=+ VimwikiListChangeLvl
|
||||||
@ -312,20 +315,25 @@ command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
|||||||
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
||||||
|
|
||||||
" tags commands
|
" tags commands
|
||||||
command! -buffer -bang
|
command! -buffer -bang VimwikiRebuildTags call vimwiki#tags#update_tags(1, '<bang>')
|
||||||
\ VimwikiRebuildTags call vimwiki#tags#update_tags(1, '<bang>')
|
|
||||||
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
||||||
\ VimwikiSearchTags VimwikiSearch /:<args>:/
|
\ VimwikiSearchTags VimwikiSearch /:<args>:/
|
||||||
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
|
||||||
\ VimwikiGenerateTags call vimwiki#tags#generate_tags(<f-args>)
|
\ VimwikiGenerateTags call vimwiki#tags#generate_tags(<f-args>)
|
||||||
|
|
||||||
" COMMANDS }}}
|
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
|
||||||
|
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
|
||||||
|
|
||||||
|
|
||||||
|
" ------------------------------------------------
|
||||||
|
" Keybindings
|
||||||
|
" ------------------------------------------------
|
||||||
|
|
||||||
" KEYBINDINGS {{{
|
|
||||||
if vimwiki#vars#get_global('use_mouse')
|
if vimwiki#vars#get_global('use_mouse')
|
||||||
nmap <buffer> <S-LeftMouse> <NOP>
|
nmap <buffer> <S-LeftMouse> <NOP>
|
||||||
nmap <buffer> <C-LeftMouse> <NOP>
|
nmap <buffer> <C-LeftMouse> <NOP>
|
||||||
nnoremap <silent><buffer> <2-LeftMouse> :call vimwiki#base#follow_link('nosplit', 0, 1, "\<lt>2-LeftMouse>")<CR>
|
nnoremap <silent><buffer> <2-LeftMouse>
|
||||||
|
\ :call vimwiki#base#follow_link('nosplit', 0, 1, "\<lt>2-LeftMouse>")<CR>
|
||||||
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
||||||
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
||||||
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
||||||
@ -335,44 +343,37 @@ endif
|
|||||||
if !hasmapto('<Plug>Vimwiki2HTML')
|
if !hasmapto('<Plug>Vimwiki2HTML')
|
||||||
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'h <Plug>Vimwiki2HTML'
|
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'h <Plug>Vimwiki2HTML'
|
||||||
endif
|
endif
|
||||||
nnoremap <script><buffer>
|
nnoremap <script><buffer> <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
||||||
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
|
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
|
||||||
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'hh <Plug>Vimwiki2HTMLBrowse'
|
exe 'nmap <buffer> '.vimwiki#vars#get_global('map_prefix').'hh <Plug>Vimwiki2HTMLBrowse'
|
||||||
endif
|
endif
|
||||||
nnoremap <script><buffer>
|
nnoremap <script><buffer> <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
||||||
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiFollowLink')
|
if !hasmapto('<Plug>VimwikiFollowLink')
|
||||||
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
|
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
|
||||||
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiSplitLink')
|
if !hasmapto('<Plug>VimwikiSplitLink')
|
||||||
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
|
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
|
||||||
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiVSplitLink')
|
if !hasmapto('<Plug>VimwikiVSplitLink')
|
||||||
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
|
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
|
||||||
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiNormalizeLink')
|
if !hasmapto('<Plug>VimwikiNormalizeLink')
|
||||||
nmap <silent><buffer> + <Plug>VimwikiNormalizeLink
|
nmap <silent><buffer> + <Plug>VimwikiNormalizeLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLink :VimwikiNormalizeLink 0<CR>
|
||||||
\ <Plug>VimwikiNormalizeLink :VimwikiNormalizeLink 0<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiNormalizeLinkVisual')
|
if !hasmapto('<Plug>VimwikiNormalizeLinkVisual')
|
||||||
vmap <silent><buffer> + <Plug>VimwikiNormalizeLinkVisual
|
vmap <silent><buffer> + <Plug>VimwikiNormalizeLinkVisual
|
||||||
endif
|
endif
|
||||||
vnoremap <silent><script><buffer>
|
vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisual :<C-U>VimwikiNormalizeLink 1<CR>
|
||||||
\ <Plug>VimwikiNormalizeLinkVisual :<C-U>VimwikiNormalizeLink 1<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiNormalizeLinkVisualCR')
|
if !hasmapto('<Plug>VimwikiNormalizeLinkVisualCR')
|
||||||
vmap <silent><buffer> <CR> <Plug>VimwikiNormalizeLinkVisualCR
|
vmap <silent><buffer> <CR> <Plug>VimwikiNormalizeLinkVisualCR
|
||||||
@ -384,50 +385,42 @@ if !hasmapto('<Plug>VimwikiTabnewLink')
|
|||||||
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
|
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
|
||||||
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
|
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
|
||||||
\ <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiGoBackLink')
|
if !hasmapto('<Plug>VimwikiGoBackLink')
|
||||||
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
|
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
|
||||||
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiNextLink')
|
if !hasmapto('<Plug>VimwikiNextLink')
|
||||||
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
|
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiNextLink :VimwikiNextLink<CR>
|
||||||
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiPrevLink')
|
if !hasmapto('<Plug>VimwikiPrevLink')
|
||||||
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
|
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
||||||
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDeleteLink')
|
if !hasmapto('<Plug>VimwikiDeleteLink')
|
||||||
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'d <Plug>VimwikiDeleteLink'
|
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'d <Plug>VimwikiDeleteLink'
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
||||||
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiRenameLink')
|
if !hasmapto('<Plug>VimwikiRenameLink')
|
||||||
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'r <Plug>VimwikiRenameLink'
|
exe 'nmap <silent><buffer> '.vimwiki#vars#get_global('map_prefix').'r <Plug>VimwikiRenameLink'
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
||||||
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
||||||
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
|
||||||
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
|
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
|
||||||
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
|
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
||||||
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
|
||||||
|
|
||||||
" List mappings
|
" List mappings
|
||||||
if !hasmapto('<Plug>VimwikiToggleListItem')
|
if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||||
@ -442,10 +435,8 @@ if !hasmapto('<Plug>VimwikiToggleRejectedListItem')
|
|||||||
nmap <silent><buffer> glx <Plug>VimwikiToggleRejectedListItem
|
nmap <silent><buffer> glx <Plug>VimwikiToggleRejectedListItem
|
||||||
vmap <silent><buffer> glx <Plug>VimwikiToggleRejectedListItem
|
vmap <silent><buffer> glx <Plug>VimwikiToggleRejectedListItem
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
vnoremap <silent><script><buffer> <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||||
vnoremap <silent><script><buffer>
|
|
||||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer>
|
||||||
\ <Plug>VimwikiToggleRejectedListItem :VimwikiToggleRejectedListItem<CR>
|
\ <Plug>VimwikiToggleRejectedListItem :VimwikiToggleRejectedListItem<CR>
|
||||||
vnoremap <silent><script><buffer>
|
vnoremap <silent><script><buffer>
|
||||||
@ -459,39 +450,31 @@ if !hasmapto('<Plug>VimwikiDecrementListItem')
|
|||||||
nmap <silent><buffer> glp <Plug>VimwikiDecrementListItem
|
nmap <silent><buffer> glp <Plug>VimwikiDecrementListItem
|
||||||
vmap <silent><buffer> glp <Plug>VimwikiDecrementListItem
|
vmap <silent><buffer> glp <Plug>VimwikiDecrementListItem
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
|
||||||
\ <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
|
vnoremap <silent><script><buffer> <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
|
||||||
vnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
|
||||||
\ <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
|
vnoremap <silent><script><buffer> <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
|
||||||
nnoremap <silent><script><buffer>
|
|
||||||
\ <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
|
|
||||||
vnoremap <silent><script><buffer>
|
|
||||||
\ <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem', 'i')
|
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem', 'i')
|
||||||
imap <silent><buffer> <C-D>
|
imap <silent><buffer> <C-D> <Plug>VimwikiDecreaseLvlSingleItem
|
||||||
\ <Plug>VimwikiDecreaseLvlSingleItem
|
|
||||||
endif
|
endif
|
||||||
inoremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
|
inoremap <silent><script><buffer> <Plug>VimwikiDecreaseLvlSingleItem
|
||||||
\ <C-O>:VimwikiListChangeLvl decrease 0<CR>
|
\ <C-O>:VimwikiListChangeLvl decrease 0<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiIncreaseLvlSingleItem', 'i')
|
if !hasmapto('<Plug>VimwikiIncreaseLvlSingleItem', 'i')
|
||||||
imap <silent><buffer> <C-T>
|
imap <silent><buffer> <C-T> <Plug>VimwikiIncreaseLvlSingleItem
|
||||||
\ <Plug>VimwikiIncreaseLvlSingleItem
|
|
||||||
endif
|
endif
|
||||||
inoremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
|
inoremap <silent><script><buffer> <Plug>VimwikiIncreaseLvlSingleItem
|
||||||
\ <C-O>:VimwikiListChangeLvl increase 0<CR>
|
\ <C-O>:VimwikiListChangeLvl increase 0<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiListNextSymbol', 'i')
|
if !hasmapto('<Plug>VimwikiListNextSymbol', 'i')
|
||||||
imap <silent><buffer> <C-L><C-J>
|
imap <silent><buffer> <C-L><C-J> <Plug>VimwikiListNextSymbol
|
||||||
\ <Plug>VimwikiListNextSymbol
|
|
||||||
endif
|
endif
|
||||||
inoremap <silent><script><buffer> <Plug>VimwikiListNextSymbol
|
inoremap <silent><script><buffer> <Plug>VimwikiListNextSymbol
|
||||||
\ <C-O>:VimwikiListChangeSymbolI next<CR>
|
\ <C-O>:VimwikiListChangeSymbolI next<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiListPrevSymbol', 'i')
|
if !hasmapto('<Plug>VimwikiListPrevSymbol', 'i')
|
||||||
imap <silent><buffer> <C-L><C-K>
|
imap <silent><buffer> <C-L><C-K> <Plug>VimwikiListPrevSymbol
|
||||||
\ <Plug>VimwikiListPrevSymbol
|
|
||||||
endif
|
endif
|
||||||
inoremap <silent><script><buffer> <Plug>VimwikiListPrevSymbol
|
inoremap <silent><script><buffer> <Plug>VimwikiListPrevSymbol
|
||||||
\ <C-O>:VimwikiListChangeSymbolI prev<CR>
|
\ <C-O>:VimwikiListChangeSymbolI prev<CR>
|
||||||
@ -507,15 +490,13 @@ nnoremap <silent> <buffer> O :<C-U>call vimwiki#lst#kbd_O()<CR>
|
|||||||
if !hasmapto('<Plug>VimwikiRenumberList')
|
if !hasmapto('<Plug>VimwikiRenumberList')
|
||||||
nmap <silent><buffer> glr <Plug>VimwikiRenumberList
|
nmap <silent><buffer> glr <Plug>VimwikiRenumberList
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiRenumberList :VimwikiRenumberList<CR>
|
||||||
\ <Plug>VimwikiRenumberList :VimwikiRenumberList<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiRenumberAllLists')
|
if !hasmapto('<Plug>VimwikiRenumberAllLists')
|
||||||
nmap <silent><buffer> gLr <Plug>VimwikiRenumberAllLists
|
nmap <silent><buffer> gLr <Plug>VimwikiRenumberAllLists
|
||||||
nmap <silent><buffer> gLR <Plug>VimwikiRenumberAllLists
|
nmap <silent><buffer> gLR <Plug>VimwikiRenumberAllLists
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiRenumberAllLists :VimwikiRenumberAllLists<CR>
|
||||||
\ <Plug>VimwikiRenumberAllLists :VimwikiRenumberAllLists<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem')
|
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem')
|
||||||
map <silent><buffer> glh <Plug>VimwikiDecreaseLvlSingleItem
|
map <silent><buffer> glh <Plug>VimwikiDecreaseLvlSingleItem
|
||||||
@ -546,14 +527,12 @@ noremap <silent><script><buffer>
|
|||||||
if !hasmapto('<Plug>VimwikiRemoveSingleCB')
|
if !hasmapto('<Plug>VimwikiRemoveSingleCB')
|
||||||
map <silent><buffer> gl<Space> <Plug>VimwikiRemoveSingleCB
|
map <silent><buffer> gl<Space> <Plug>VimwikiRemoveSingleCB
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
noremap <silent><script><buffer> <Plug>VimwikiRemoveSingleCB :VimwikiRemoveSingleCB<CR>
|
||||||
\ <Plug>VimwikiRemoveSingleCB :VimwikiRemoveSingleCB<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiRemoveCBInList')
|
if !hasmapto('<Plug>VimwikiRemoveCBInList')
|
||||||
map <silent><buffer> gL<Space> <Plug>VimwikiRemoveCBInList
|
map <silent><buffer> gL<Space> <Plug>VimwikiRemoveCBInList
|
||||||
endif
|
endif
|
||||||
noremap <silent><script><buffer>
|
noremap <silent><script><buffer> <Plug>VimwikiRemoveCBInList :VimwikiRemoveCBInList<CR>
|
||||||
\ <Plug>VimwikiRemoveCBInList :VimwikiRemoveCBInList<CR>
|
|
||||||
|
|
||||||
for s:char in vimwiki#vars#get_syntaxlocal('bullet_types')
|
for s:char in vimwiki#vars#get_syntaxlocal('bullet_types')
|
||||||
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
|
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')
|
||||||
@ -574,8 +553,7 @@ for s:typ in vimwiki#vars#get_syntaxlocal('number_types')
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|
||||||
|
function! s:CR(normal, just_mrkr)
|
||||||
function! s:CR(normal, just_mrkr) "{{{
|
|
||||||
if vimwiki#vars#get_global('table_mappings')
|
if vimwiki#vars#get_global('table_mappings')
|
||||||
let res = vimwiki#tbl#kbd_cr()
|
let res = vimwiki#tbl#kbd_cr()
|
||||||
if res != ""
|
if res != ""
|
||||||
@ -585,7 +563,7 @@ function! s:CR(normal, just_mrkr) "{{{
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr)
|
call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr)
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
if !hasmapto('VimwikiReturn', 'i')
|
if !hasmapto('VimwikiReturn', 'i')
|
||||||
if maparg('<CR>', 'i') !~? '<Esc>:VimwikiReturn'
|
if maparg('<CR>', 'i') !~? '<Esc>:VimwikiReturn'
|
||||||
@ -609,8 +587,7 @@ nnoremap <buffer> gww :VimwikiTableAlignW<CR>
|
|||||||
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
|
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
|
||||||
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
|
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><script><buffer>
|
nnoremap <silent><script><buffer> <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
|
||||||
\ <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
|
|
||||||
if !hasmapto('<Plug>VimwikiTableMoveColumnRight')
|
if !hasmapto('<Plug>VimwikiTableMoveColumnRight')
|
||||||
nmap <silent><buffer> <A-Right> <Plug>VimwikiTableMoveColumnRight
|
nmap <silent><buffer> <A-Right> <Plug>VimwikiTableMoveColumnRight
|
||||||
endif
|
endif
|
||||||
@ -619,7 +596,10 @@ nnoremap <silent><script><buffer>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
" Text objects {{{
|
" ------------------------------------------------
|
||||||
|
" Text objects
|
||||||
|
" ------------------------------------------------
|
||||||
|
|
||||||
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
|
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
|
||||||
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
|
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0, v:count1)<CR>
|
||||||
|
|
||||||
@ -653,8 +633,7 @@ vnoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
|
|||||||
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
|
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
|
||||||
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
|
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
|
||||||
endif
|
endif
|
||||||
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
|
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :<C-U>call vimwiki#base#AddHeaderLevel()<CR>
|
||||||
\<C-U>call vimwiki#base#AddHeaderLevel()<CR>
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
|
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
|
||||||
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
|
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
|
||||||
@ -693,11 +672,8 @@ endif
|
|||||||
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader :
|
nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader :
|
||||||
\<C-u>call vimwiki#base#goto_sibling(-1)<CR>
|
\<C-u>call vimwiki#base#goto_sibling(-1)<CR>
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" KEYBINDINGS }}}
|
|
||||||
|
|
||||||
" AUTOCOMMANDS {{{
|
|
||||||
if vimwiki#vars#get_wikilocal('auto_export')
|
if vimwiki#vars#get_wikilocal('auto_export')
|
||||||
" Automatically generate HTML on page write.
|
" Automatically generate HTML on page write.
|
||||||
augroup vimwiki
|
augroup vimwiki
|
||||||
@ -720,10 +696,4 @@ if vimwiki#vars#get_wikilocal('auto_tags')
|
|||||||
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
|
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
" AUTOCOMMANDS }}}
|
|
||||||
|
|
||||||
" PASTE, CAT URL {{{
|
|
||||||
" html commands
|
|
||||||
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
|
|
||||||
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
|
|
||||||
" }}}
|
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki plugin file
|
" Vimwiki plugin file
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
|
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
|
||||||
|
|
||||||
|
|
||||||
if exists("g:loaded_vimwiki") || &cp
|
if exists("g:loaded_vimwiki") || &cp
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_vimwiki = 1
|
let g:loaded_vimwiki = 1
|
||||||
|
|
||||||
|
|
||||||
let s:old_cpo = &cpo
|
let s:old_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
|
||||||
" this is called when the cursor leaves the buffer
|
" this is called when the cursor leaves the buffer
|
||||||
function! s:setup_buffer_leave() "{{{
|
function! s:setup_buffer_leave()
|
||||||
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
||||||
" a registered wiki and not a temporary wiki)
|
" a registered wiki and not a temporary wiki)
|
||||||
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
||||||
@ -25,7 +27,7 @@ function! s:setup_buffer_leave() "{{{
|
|||||||
if vimwiki#vars#get_global('menu') != ""
|
if vimwiki#vars#get_global('menu') != ""
|
||||||
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
|
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" create a new temporary wiki for the current buffer
|
" create a new temporary wiki for the current buffer
|
||||||
@ -52,7 +54,7 @@ endfunction
|
|||||||
" This function is called when Vim opens a new buffer with a known wiki
|
" This function is called when Vim opens a new buffer with a known wiki
|
||||||
" extension. Both when the buffer has never been opened in this session and
|
" extension. Both when the buffer has never been opened in this session and
|
||||||
" when it has.
|
" when it has.
|
||||||
function! s:setup_new_wiki_buffer() "{{{
|
function! s:setup_new_wiki_buffer()
|
||||||
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
if wiki_nr == -1 " it's not in a known wiki directory
|
if wiki_nr == -1 " it's not in a known wiki directory
|
||||||
if vimwiki#vars#get_global('global_ext')
|
if vimwiki#vars#get_global('global_ext')
|
||||||
@ -73,11 +75,11 @@ function! s:setup_new_wiki_buffer() "{{{
|
|||||||
" sourced
|
" sourced
|
||||||
setfiletype vimwiki
|
setfiletype vimwiki
|
||||||
|
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" this is called when the cursor enters the buffer
|
" this is called when the cursor enters the buffer
|
||||||
function! s:setup_buffer_enter() "{{{
|
function! s:setup_buffer_enter()
|
||||||
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
||||||
" a registered wiki and not a temporary wiki)
|
" a registered wiki and not a temporary wiki)
|
||||||
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
||||||
@ -91,10 +93,11 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
call s:set_global_options()
|
call s:set_global_options()
|
||||||
|
|
||||||
call s:set_windowlocal_options()
|
call s:set_windowlocal_options()
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
function! s:setup_cleared_syntax()
|
||||||
|
" highlight groups that get cleared
|
||||||
" on colorscheme change because they are not linked to Vim-predefined groups
|
" on colorscheme change because they are not linked to Vim-predefined groups
|
||||||
hi def VimwikiBold term=bold cterm=bold gui=bold
|
hi def VimwikiBold term=bold cterm=bold gui=bold
|
||||||
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
||||||
@ -108,10 +111,10 @@ function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
|
|||||||
\ .' term=bold cterm=bold'
|
\ .' term=bold cterm=bold'
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:vimwiki_get_known_extensions() " {{{
|
function! s:vimwiki_get_known_extensions()
|
||||||
" Getting all extensions that different wikis could have
|
" Getting all extensions that different wikis could have
|
||||||
let extensions = {}
|
let extensions = {}
|
||||||
for idx in range(vimwiki#vars#number_of_wikis())
|
for idx in range(vimwiki#vars#number_of_wikis())
|
||||||
@ -123,7 +126,7 @@ function! s:vimwiki_get_known_extensions() " {{{
|
|||||||
let extensions[ext] = 1
|
let extensions[ext] = 1
|
||||||
endfor
|
endfor
|
||||||
return keys(extensions)
|
return keys(extensions)
|
||||||
endfunction " }}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Set settings which are global for Vim, but should only be executed for
|
" Set settings which are global for Vim, but should only be executed for
|
||||||
@ -171,7 +174,7 @@ function! s:set_windowlocal_options()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
|
|
||||||
" Initialization of Vimwiki starts here. Make sure everything below does not
|
" Initialization of Vimwiki starts here. Make sure everything below does not
|
||||||
@ -179,30 +182,30 @@ endfunction
|
|||||||
|
|
||||||
call vimwiki#vars#init()
|
call vimwiki#vars#init()
|
||||||
|
|
||||||
" CALLBACK functions "{{{
|
|
||||||
" User can redefine it.
|
" Define callback functions which the user can redefine
|
||||||
if !exists("*VimwikiLinkHandler") "{{{
|
if !exists("*VimwikiLinkHandler")
|
||||||
function VimwikiLinkHandler(url)
|
function VimwikiLinkHandler(url)
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
endif "}}}
|
endif
|
||||||
|
|
||||||
if !exists("*VimwikiLinkConverter") "{{{
|
if !exists("*VimwikiLinkConverter")
|
||||||
function VimwikiLinkConverter(url, source, target)
|
function VimwikiLinkConverter(url, source, target)
|
||||||
" Return the empty string when unable to process link
|
" Return the empty string when unable to process link
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
endif "}}}
|
endif
|
||||||
|
|
||||||
if !exists("*VimwikiWikiIncludeHandler") "{{{
|
if !exists("*VimwikiWikiIncludeHandler")
|
||||||
function! VimwikiWikiIncludeHandler(value) "{{{
|
function! VimwikiWikiIncludeHandler(value)
|
||||||
return ''
|
return ''
|
||||||
endfunction "}}}
|
endfunction
|
||||||
endif "}}}
|
endif
|
||||||
" CALLBACK }}}
|
|
||||||
|
|
||||||
|
|
||||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
|
||||||
|
" Define autocommands for all known wiki extensions
|
||||||
|
|
||||||
let s:known_extensions = s:vimwiki_get_known_extensions()
|
let s:known_extensions = s:vimwiki_get_known_extensions()
|
||||||
|
|
||||||
@ -228,9 +231,9 @@ augroup vimwiki
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
augroup END
|
augroup END
|
||||||
"}}}
|
|
||||||
|
|
||||||
" COMMANDS {{{
|
|
||||||
|
|
||||||
command! VimwikiUISelect call vimwiki#base#ui_select()
|
command! VimwikiUISelect call vimwiki#base#ui_select()
|
||||||
" why not using <count> instead of v:count1?
|
" why not using <count> instead of v:count1?
|
||||||
" See https://github.com/vimwiki-backup/vimwiki/issues/324
|
" See https://github.com/vimwiki-backup/vimwiki/issues/324
|
||||||
@ -246,15 +249,17 @@ command! -count=1 VimwikiMakeDiaryNote
|
|||||||
command! -count=1 VimwikiTabMakeDiaryNote
|
command! -count=1 VimwikiTabMakeDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1, 1)
|
\ call vimwiki#diary#make_note(v:count1, 1)
|
||||||
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1, 0, vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
\ call vimwiki#diary#make_note(v:count1, 0,
|
||||||
|
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
||||||
command! -count=1 VimwikiMakeTomorrowDiaryNote
|
command! -count=1 VimwikiMakeTomorrowDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1, 0, vimwiki#diary#diary_date_link(localtime() + 60*60*24))
|
\ call vimwiki#diary#make_note(v:count1, 0,
|
||||||
|
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
|
||||||
|
|
||||||
command! VimwikiDiaryGenerateLinks
|
command! VimwikiDiaryGenerateLinks
|
||||||
\ call vimwiki#diary#generate_diary_section()
|
\ call vimwiki#diary#generate_diary_section()
|
||||||
"}}}
|
|
||||||
|
|
||||||
" MAPPINGS {{{
|
|
||||||
|
|
||||||
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
|
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
|
||||||
|
|
||||||
if !hasmapto('<Plug>VimwikiIndex')
|
if !hasmapto('<Plug>VimwikiIndex')
|
||||||
@ -305,9 +310,9 @@ endif
|
|||||||
nnoremap <unique><script> <Plug>VimwikiMakeTomorrowDiaryNote
|
nnoremap <unique><script> <Plug>VimwikiMakeTomorrowDiaryNote
|
||||||
\ :VimwikiMakeTomorrowDiaryNote<CR>
|
\ :VimwikiMakeTomorrowDiaryNote<CR>
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" MENU {{{
|
|
||||||
|
|
||||||
function! s:build_menu(topmenu)
|
function! s:build_menu(topmenu)
|
||||||
for idx in range(vimwiki#vars#number_of_wikis())
|
for idx in range(vimwiki#vars#number_of_wikis())
|
||||||
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
|
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
|
||||||
@ -324,7 +329,8 @@ function! s:build_table_menu(topmenu)
|
|||||||
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
|
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
|
||||||
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
|
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
|
||||||
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
|
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
|
||||||
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
|
exe 'nmenu '.a:topmenu.
|
||||||
|
\ '.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
|
||||||
exe 'nmenu disable '.a:topmenu.'.Table'
|
exe 'nmenu disable '.a:topmenu.'.Table'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -333,14 +339,13 @@ if !empty(vimwiki#vars#get_global('menu'))
|
|||||||
call s:build_menu(vimwiki#vars#get_global('menu'))
|
call s:build_menu(vimwiki#vars#get_global('menu'))
|
||||||
call s:build_table_menu(vimwiki#vars#get_global('menu'))
|
call s:build_table_menu(vimwiki#vars#get_global('menu'))
|
||||||
endif
|
endif
|
||||||
" }}}
|
|
||||||
|
|
||||||
" CALENDAR Hook "{{{
|
|
||||||
|
" Hook for calendar.vim
|
||||||
if vimwiki#vars#get_global('use_calendar')
|
if vimwiki#vars#get_global('use_calendar')
|
||||||
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
||||||
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
||||||
endif
|
endif
|
||||||
"}}}
|
|
||||||
|
|
||||||
|
|
||||||
let &cpo = s:old_cpo
|
let &cpo = s:old_cpo
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki syntax file
|
" Vimwiki syntax file
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
" Quit if syntax file is already loaded
|
" Quit if syntax file is already loaded
|
||||||
if v:version < 600
|
if v:version < 600
|
||||||
syntax clear
|
syntax clear
|
||||||
@ -12,35 +13,38 @@ endif
|
|||||||
|
|
||||||
let s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
|
let s:current_syntax = vimwiki#vars#get_wikilocal('syntax')
|
||||||
|
|
||||||
|
|
||||||
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
||||||
|
|
||||||
|
|
||||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
" LINKS: highlighting is complicated due to "nonexistent" links feature
|
||||||
function! s:add_target_syntax_ON(target, type) " {{{
|
function! s:add_target_syntax_ON(target, type)
|
||||||
let prefix0 = 'syntax match '.a:type.' `'
|
let prefix0 = 'syntax match '.a:type.' `'
|
||||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
||||||
let prefix1 = 'syntax match '.a:type.'T `'
|
let prefix1 = 'syntax match '.a:type.'T `'
|
||||||
let suffix1 = '` display contained'
|
let suffix1 = '` display contained'
|
||||||
execute prefix0. a:target. suffix0
|
execute prefix0. a:target. suffix0
|
||||||
execute prefix1. a:target. suffix1
|
execute prefix1. a:target. suffix1
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:add_target_syntax_OFF(target) " {{{
|
|
||||||
|
function! s:add_target_syntax_OFF(target)
|
||||||
let prefix0 = 'syntax match VimwikiNoExistsLink `'
|
let prefix0 = 'syntax match VimwikiNoExistsLink `'
|
||||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
|
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
|
||||||
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
|
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
|
||||||
let suffix1 = '` display contained'
|
let suffix1 = '` display contained'
|
||||||
execute prefix0. a:target. suffix0
|
execute prefix0. a:target. suffix0
|
||||||
execute prefix1. a:target. suffix1
|
execute prefix1. a:target. suffix1
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:highlight_existing_links() "{{{
|
|
||||||
|
function! s:highlight_existing_links()
|
||||||
" Wikilink
|
" Wikilink
|
||||||
" Conditional highlighting that depends on the existence of a wiki file or
|
" Conditional highlighting that depends on the existence of a wiki file or
|
||||||
" directory is only available for *schemeless* wiki links
|
" directory is only available for *schemeless* wiki links
|
||||||
" Links are set up upon BufEnter (see plugin/...)
|
" Links are set up upon BufEnter (see plugin/...)
|
||||||
let safe_links = '\%('.vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
|
let safe_links = '\%('.vimwiki#base#file_pattern(
|
||||||
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
\ vimwiki#vars#get_bufferlocal('existing_wikifiles')) . '\%(#[^|]*\)\?\|#[^|]*\)'
|
||||||
" Wikilink Dirs set up upon BufEnter (see plugin/...)
|
" Wikilink Dirs set up upon BufEnter (see plugin/...)
|
||||||
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
|
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
|
||||||
|
|
||||||
@ -75,7 +79,7 @@ function! s:highlight_existing_links() "{{{
|
|||||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
||||||
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
\ safe_dirs, vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||||
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
call s:add_target_syntax_ON(target, 'VimwikiLink')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" use max highlighting - could be quite slow if there are too many wikifiles
|
" use max highlighting - could be quite slow if there are too many wikifiles
|
||||||
@ -94,9 +98,11 @@ else
|
|||||||
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiIncl'), 'VimwikiLink')
|
call s:add_target_syntax_ON(vimwiki#vars#get_global('rxWikiIncl'), 'VimwikiLink')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
" Weblink
|
" Weblink
|
||||||
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiLink')
|
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiLink')
|
||||||
|
|
||||||
|
|
||||||
" WikiLink
|
" WikiLink
|
||||||
" All remaining schemes are highlighted automatically
|
" All remaining schemes are highlighted automatically
|
||||||
let s:rxSchemes = '\%('.
|
let s:rxSchemes = '\%('.
|
||||||
@ -107,64 +113,73 @@ let s:rxSchemes = '\%('.
|
|||||||
" a) match [[nonwiki-scheme-URL]]
|
" a) match [[nonwiki-scheme-URL]]
|
||||||
let s:target = vimwiki#base#apply_template(
|
let s:target = vimwiki#base#apply_template(
|
||||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
|
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
|
||||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'), vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
|
||||||
|
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||||
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
|
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
|
||||||
let s:target = vimwiki#base#apply_template(
|
let s:target = vimwiki#base#apply_template(
|
||||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate2')),
|
||||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'), vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiLinkUrl'),
|
||||||
|
\ vimwiki#vars#get_global('rxWikiLinkDescr'), '')
|
||||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||||
|
|
||||||
" a) match {{nonwiki-scheme-URL}}
|
" a) match {{nonwiki-scheme-URL}}
|
||||||
let s:target = vimwiki#base#apply_template(
|
let s:target = vimwiki#base#apply_template(
|
||||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
|
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate1')),
|
||||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'), vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
|
||||||
|
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
||||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||||
" b) match {{nonwiki-scheme-URL}[{...}]}
|
" b) match {{nonwiki-scheme-URL}[{...}]}
|
||||||
let s:target = vimwiki#base#apply_template(
|
let s:target = vimwiki#base#apply_template(
|
||||||
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
|
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiInclTemplate2')),
|
||||||
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'), vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
\ s:rxSchemes.vimwiki#vars#get_global('rxWikiInclUrl'),
|
||||||
|
\ vimwiki#vars#get_global('rxWikiInclArgs'), '')
|
||||||
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" generic headers "{{{
|
|
||||||
|
|
||||||
" Header levels, 1-6
|
" Header levels, 1-6
|
||||||
for s:i in range(1,6)
|
for s:i in range(1,6)
|
||||||
execute 'syntax match VimwikiHeader'.s:i
|
execute 'syntax match VimwikiHeader'.s:i
|
||||||
\ . ' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).'/'
|
\ . ' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).
|
||||||
\ . ' contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
|
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
|
||||||
execute 'syntax region VimwikiH'.s:i.'Folding'
|
\ 'VimwikiLink,@Spell'
|
||||||
\ . ' start=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).'/'
|
execute 'syntax region VimwikiH'.s:i.'Folding start=/'.
|
||||||
\ . ' end=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).'/me=s-1 transparent fold'
|
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).'/ end=/'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).
|
||||||
|
\ '/me=s-1 transparent fold'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
|
" possibly concealed chars
|
||||||
" possibly concealed chars " {{{
|
|
||||||
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
|
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
|
||||||
|
|
||||||
execute 'syn match VimwikiEqInChar contained /'.vimwiki#vars#get_syntaxlocal('char_eqin').'/'.s:conceal
|
execute 'syn match VimwikiEqInChar contained /'.
|
||||||
execute 'syn match VimwikiBoldChar contained /'.vimwiki#vars#get_syntaxlocal('char_bold').'/'.s:conceal
|
\ vimwiki#vars#get_syntaxlocal('char_eqin').'/'.s:conceal
|
||||||
execute 'syn match VimwikiItalicChar contained /'.vimwiki#vars#get_syntaxlocal('char_italic').'/'.s:conceal
|
execute 'syn match VimwikiBoldChar contained /'.
|
||||||
execute 'syn match VimwikiBoldItalicChar contained /'.vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'.s:conceal
|
\ vimwiki#vars#get_syntaxlocal('char_bold').'/'.s:conceal
|
||||||
execute 'syn match VimwikiItalicBoldChar contained /'.vimwiki#vars#get_syntaxlocal('char_italicbold').'/'.s:conceal
|
execute 'syn match VimwikiItalicChar contained /'.
|
||||||
execute 'syn match VimwikiCodeChar contained /'.vimwiki#vars#get_syntaxlocal('char_code').'/'.s:conceal
|
\ vimwiki#vars#get_syntaxlocal('char_italic').'/'.s:conceal
|
||||||
execute 'syn match VimwikiDelTextChar contained /'.vimwiki#vars#get_syntaxlocal('char_deltext').'/'.s:conceal
|
execute 'syn match VimwikiBoldItalicChar contained /'.
|
||||||
execute 'syn match VimwikiSuperScript contained /'.vimwiki#vars#get_syntaxlocal('char_superscript').'/'.s:conceal
|
\ vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'.s:conceal
|
||||||
execute 'syn match VimwikiSubScript contained /'.vimwiki#vars#get_syntaxlocal('char_subscript').'/'.s:conceal
|
execute 'syn match VimwikiItalicBoldChar contained /'.
|
||||||
" }}}
|
\ vimwiki#vars#get_syntaxlocal('char_italicbold').'/'.s:conceal
|
||||||
|
execute 'syn match VimwikiCodeChar contained /'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('char_code').'/'.s:conceal
|
||||||
|
execute 'syn match VimwikiDelTextChar contained /'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('char_deltext').'/'.s:conceal
|
||||||
|
execute 'syn match VimwikiSuperScript contained /'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('char_superscript').'/'.s:conceal
|
||||||
|
execute 'syn match VimwikiSubScript contained /'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('char_subscript').'/'.s:conceal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" concealed link parts " {{{
|
|
||||||
|
|
||||||
" define the conceal attribute for links only if Vim is new enough to handle it
|
|
||||||
" and the user has g:vimwiki_url_maxsave > 0
|
|
||||||
|
|
||||||
let s:options = ' contained transparent contains=NONE'
|
let s:options = ' contained transparent contains=NONE'
|
||||||
"
|
|
||||||
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
|
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
|
||||||
" VimwikiLinkRest group is left undefined if link shortening is not desired
|
" VimwikiLinkRest group is left undefined if link shortening is not desired
|
||||||
if exists("+conceallevel") && vimwiki#vars#get_global('url_maxsave') > 0
|
if exists("+conceallevel") && vimwiki#vars#get_global('url_maxsave') > 0
|
||||||
@ -187,27 +202,37 @@ execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix'
|
|||||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix').'/'.s:options
|
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix').'/'.s:options
|
||||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix1').'/'.s:options
|
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclPrefix1').'/'.s:options
|
||||||
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1').'/'.s:options
|
execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1').'/'.s:options
|
||||||
" }}}
|
|
||||||
|
|
||||||
" non concealed chars " {{{
|
|
||||||
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH').'\+\s*$\)/'
|
" non concealed chars
|
||||||
execute 'syn match VimwikiEqInCharT contained /'.vimwiki#vars#get_syntaxlocal('char_eqin').'/'
|
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.
|
||||||
execute 'syn match VimwikiBoldCharT contained /'.vimwiki#vars#get_syntaxlocal('char_bold').'/'
|
\ vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH').
|
||||||
execute 'syn match VimwikiItalicCharT contained /'.vimwiki#vars#get_syntaxlocal('char_italic').'/'
|
\ '\+\s*$\)/'
|
||||||
execute 'syn match VimwikiBoldItalicCharT contained /'.vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'
|
execute 'syn match VimwikiEqInCharT contained /'
|
||||||
execute 'syn match VimwikiItalicBoldCharT contained /'.vimwiki#vars#get_syntaxlocal('char_italicbold').'/'
|
\ .vimwiki#vars#get_syntaxlocal('char_eqin').'/'
|
||||||
execute 'syn match VimwikiCodeCharT contained /'.vimwiki#vars#get_syntaxlocal('char_code').'/'
|
execute 'syn match VimwikiBoldCharT contained /'
|
||||||
execute 'syn match VimwikiDelTextCharT contained /'.vimwiki#vars#get_syntaxlocal('char_deltext').'/'
|
\ .vimwiki#vars#get_syntaxlocal('char_bold').'/'
|
||||||
execute 'syn match VimwikiSuperScriptT contained /'.vimwiki#vars#get_syntaxlocal('char_superscript').'/'
|
execute 'syn match VimwikiItalicCharT contained /'
|
||||||
execute 'syn match VimwikiSubScriptT contained /'.vimwiki#vars#get_syntaxlocal('char_subscript').'/'
|
\ .vimwiki#vars#get_syntaxlocal('char_italic').'/'
|
||||||
|
execute 'syn match VimwikiBoldItalicCharT contained /'
|
||||||
|
\ .vimwiki#vars#get_syntaxlocal('char_bolditalic').'/'
|
||||||
|
execute 'syn match VimwikiItalicBoldCharT contained /'
|
||||||
|
\ .vimwiki#vars#get_syntaxlocal('char_italicbold').'/'
|
||||||
|
execute 'syn match VimwikiCodeCharT contained /'
|
||||||
|
\ .vimwiki#vars#get_syntaxlocal('char_code').'/'
|
||||||
|
execute 'syn match VimwikiDelTextCharT contained /'
|
||||||
|
\ .vimwiki#vars#get_syntaxlocal('char_deltext').'/'
|
||||||
|
execute 'syn match VimwikiSuperScriptT contained /'
|
||||||
|
\ .vimwiki#vars#get_syntaxlocal('char_superscript').'/'
|
||||||
|
execute 'syn match VimwikiSubScriptT contained /'
|
||||||
|
\ .vimwiki#vars#get_syntaxlocal('char_subscript').'/'
|
||||||
|
|
||||||
" Emoticons
|
" Emoticons
|
||||||
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
|
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
|
||||||
|
|
||||||
execute 'syntax match VimwikiTodo /'. vimwiki#vars#get_global('rxTodo') .'/'
|
execute 'syntax match VimwikiTodo /'. vimwiki#vars#get_global('rxTodo') .'/'
|
||||||
" }}}
|
|
||||||
|
|
||||||
" main syntax groups {{{
|
|
||||||
|
|
||||||
" Tables
|
" Tables
|
||||||
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
||||||
@ -229,6 +254,7 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
|||||||
syntax match VimwikiCellSeparator
|
syntax match VimwikiCellSeparator
|
||||||
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
||||||
|
|
||||||
|
|
||||||
" Lists
|
" Lists
|
||||||
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
|
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'/'
|
||||||
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
|
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
|
||||||
@ -246,32 +272,51 @@ elseif vimwiki#vars#get_global('hl_cb_checked') == 2
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
execute 'syntax match VimwikiEqIn /'.vimwiki#vars#get_syntaxlocal('rxEqIn').'/ contains=VimwikiEqInChar'
|
execute 'syntax match VimwikiEqIn /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
|
||||||
execute 'syntax match VimwikiEqInT /'.vimwiki#vars#get_syntaxlocal('rxEqIn').'/ contained contains=VimwikiEqInCharT'
|
\ '/ contains=VimwikiEqInChar'
|
||||||
|
execute 'syntax match VimwikiEqInT /'.vimwiki#vars#get_syntaxlocal('rxEqIn').
|
||||||
|
\ '/ contained contains=VimwikiEqInCharT'
|
||||||
|
|
||||||
execute 'syntax match VimwikiBold /'.vimwiki#vars#get_syntaxlocal('rxBold').'/ contains=VimwikiBoldChar,@Spell'
|
execute 'syntax match VimwikiBold /'.vimwiki#vars#get_syntaxlocal('rxBold').
|
||||||
execute 'syntax match VimwikiBoldT /'.vimwiki#vars#get_syntaxlocal('rxBold').'/ contained contains=VimwikiBoldCharT,@Spell'
|
\ '/ contains=VimwikiBoldChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiBoldT /'.vimwiki#vars#get_syntaxlocal('rxBold').
|
||||||
|
\ '/ contained contains=VimwikiBoldCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiItalic /'.vimwiki#vars#get_syntaxlocal('rxItalic').'/ contains=VimwikiItalicChar,@Spell'
|
execute 'syntax match VimwikiItalic /'.vimwiki#vars#get_syntaxlocal('rxItalic').
|
||||||
execute 'syntax match VimwikiItalicT /'.vimwiki#vars#get_syntaxlocal('rxItalic').'/ contained contains=VimwikiItalicCharT,@Spell'
|
\ '/ contains=VimwikiItalicChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiItalicT /'.vimwiki#vars#get_syntaxlocal('rxItalic').
|
||||||
|
\ '/ contained contains=VimwikiItalicCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiBoldItalic /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
execute 'syntax match VimwikiBoldItalic /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
|
||||||
execute 'syntax match VimwikiBoldItalicT /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiBoldItalicT /'.vimwiki#vars#get_syntaxlocal('rxBoldItalic').
|
||||||
|
\ '/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiItalicBold /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
execute 'syntax match VimwikiItalicBold /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
|
||||||
execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
|
\ '/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItalicBold').
|
||||||
|
\ '/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').'/ contains=VimwikiDelTextChar,@Spell'
|
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').
|
||||||
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').'/ contained contains=VimwikiDelTextChar,@Spell'
|
\ '/ contains=VimwikiDelTextChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').
|
||||||
|
\ '/ contained contains=VimwikiDelTextChar,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').'/ contains=VimwikiSuperScriptChar,@Spell'
|
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
|
||||||
execute 'syntax match VimwikiSuperScriptT /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').'/ contained contains=VimwikiSuperScriptCharT,@Spell'
|
\ '/ contains=VimwikiSuperScriptChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiSuperScriptT /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
|
||||||
|
\ '/ contained contains=VimwikiSuperScriptCharT,@Spell'
|
||||||
|
|
||||||
execute 'syntax match VimwikiSubScript /'.vimwiki#vars#get_syntaxlocal('rxSubScript').'/ contains=VimwikiSubScriptChar,@Spell'
|
execute 'syntax match VimwikiSubScript /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
|
||||||
execute 'syntax match VimwikiSubScriptT /'.vimwiki#vars#get_syntaxlocal('rxSubScript').'/ contained contains=VimwikiSubScriptCharT,@Spell'
|
\ '/ contains=VimwikiSubScriptChar,@Spell'
|
||||||
|
execute 'syntax match VimwikiSubScriptT /'.vimwiki#vars#get_syntaxlocal('rxSubScript').
|
||||||
|
\ '/ contained contains=VimwikiSubScriptCharT,@Spell'
|
||||||
|
|
||||||
|
execute 'syntax match VimwikiCode /'.vimwiki#vars#get_syntaxlocal('rxCode').
|
||||||
|
\ '/ contains=VimwikiCodeChar'
|
||||||
|
execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').
|
||||||
|
\ '/ contained contains=VimwikiCodeCharT'
|
||||||
|
|
||||||
execute 'syntax match VimwikiCode /'.vimwiki#vars#get_syntaxlocal('rxCode').'/ contains=VimwikiCodeChar'
|
|
||||||
execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode').'/ contained contains=VimwikiCodeCharT'
|
|
||||||
|
|
||||||
" <hr> horizontal rule
|
" <hr> horizontal rule
|
||||||
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
|
execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/'
|
||||||
@ -285,11 +330,15 @@ execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMath
|
|||||||
|
|
||||||
" placeholders
|
" placeholders
|
||||||
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
|
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
|
||||||
syntax match VimwikiPlaceholder /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
|
syntax match VimwikiPlaceholder
|
||||||
syntax match VimwikiPlaceholder /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
|
\ /^\s*%title\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
|
||||||
syntax match VimwikiPlaceholder /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
|
syntax match VimwikiPlaceholder
|
||||||
|
\ /^\s*%date\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
|
||||||
|
syntax match VimwikiPlaceholder
|
||||||
|
\ /^\s*%template\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
|
||||||
syntax match VimwikiPlaceholderParam /.*/ contained
|
syntax match VimwikiPlaceholderParam /.*/ contained
|
||||||
|
|
||||||
|
|
||||||
" html tags
|
" html tags
|
||||||
if vimwiki#vars#get_global('valid_html_tags') != ''
|
if vimwiki#vars#get_global('valid_html_tags') != ''
|
||||||
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
|
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
|
||||||
@ -298,16 +347,16 @@ if vimwiki#vars#get_global('valid_html_tags') != ''
|
|||||||
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
||||||
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
||||||
|
|
||||||
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').'/ contains=@Spell,VimwikiTodo'
|
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').
|
||||||
|
\ '/ contains=@Spell,VimwikiTodo'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" tags
|
" tags
|
||||||
execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
|
execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" header groups highlighting "{{{
|
|
||||||
|
|
||||||
|
" header groups highlighting
|
||||||
if vimwiki#vars#get_global('hl_headers') == 0
|
if vimwiki#vars#get_global('hl_headers') == 0
|
||||||
" Strangely in default colorscheme Title group is not set to bold for cterm...
|
" Strangely in default colorscheme Title group is not set to bold for cterm...
|
||||||
if !exists("g:colors_name")
|
if !exists("g:colors_name")
|
||||||
@ -323,9 +372,8 @@ else
|
|||||||
\ .vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold'
|
\ .vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold'
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
"}}}
|
|
||||||
|
|
||||||
" syntax group highlighting "{{{
|
|
||||||
|
|
||||||
hi def link VimwikiMarkers Normal
|
hi def link VimwikiMarkers Normal
|
||||||
|
|
||||||
@ -407,15 +455,17 @@ hi def link VimwikiCodeCharT VimwikiMarkers
|
|||||||
hi def link VimwikiHeaderCharT VimwikiMarkers
|
hi def link VimwikiHeaderCharT VimwikiMarkers
|
||||||
hi def link VimwikiLinkCharT VimwikiLinkT
|
hi def link VimwikiLinkCharT VimwikiLinkT
|
||||||
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
|
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Load syntax-specific functionality
|
" Load syntax-specific functionality
|
||||||
call vimwiki#u#reload_regexes_custom()
|
call vimwiki#u#reload_regexes_custom()
|
||||||
|
|
||||||
|
|
||||||
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
|
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
|
||||||
let b:current_syntax="vimwiki"
|
let b:current_syntax="vimwiki"
|
||||||
|
|
||||||
" EMBEDDED syntax setup "{{{
|
|
||||||
|
" EMBEDDED syntax setup
|
||||||
let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes')
|
let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes')
|
||||||
if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes')
|
if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes')
|
||||||
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), "keep")
|
let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), "keep")
|
||||||
@ -428,12 +478,14 @@ if !empty(s:nested)
|
|||||||
\ vimwiki#vars#get_syntaxlocal('rxPreEnd'), 'VimwikiPre')
|
\ vimwiki#vars#get_syntaxlocal('rxPreEnd'), 'VimwikiPre')
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
" LaTeX
|
" LaTeX
|
||||||
call vimwiki#base#nested_syntax('tex',
|
call vimwiki#base#nested_syntax('tex',
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
|
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||||
\ '\%([[:blank:][:punct:]].*\)\?',
|
\ '\%([[:blank:][:punct:]].*\)\?',
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
|
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
|
||||||
"}}}
|
|
||||||
|
|
||||||
|
|
||||||
syntax spell toplevel
|
syntax spell toplevel
|
||||||
|
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki syntax file
|
" Vimwiki syntax file
|
||||||
" Desc: Defines default syntax
|
" Description: Defines default syntax
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
" s:default_syntax is kind of a reference to the dict in
|
" s:default_syntax is kind of a reference to the dict in
|
||||||
" g:vimwiki_syntax_variables['default']. It is used here simply as an
|
" g:vimwiki_syntax_variables['default']. It is used here simply as an
|
||||||
" abbreviation for the latter.
|
" abbreviation for the latter.
|
||||||
let s:default_syntax = g:vimwiki_syntax_variables['default']
|
let s:default_syntax = g:vimwiki_syntax_variables['default']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" text: $ equation_inline $
|
" text: $ equation_inline $
|
||||||
let s:default_syntax.rxEqIn = '\$[^$`]\+\$'
|
let s:default_syntax.rxEqIn = '\$[^$`]\+\$'
|
||||||
let s:default_syntax.char_eqin = '\$'
|
let s:default_syntax.char_eqin = '\$'
|
||||||
@ -97,8 +100,11 @@ let s:default_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:''[:space:]]\+:\)\+\%(\s\|$\
|
|||||||
|
|
||||||
let s:default_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
let s:default_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
|
||||||
let s:default_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
let s:default_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
|
||||||
let s:default_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
let s:default_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*'.
|
||||||
let s:default_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
\ '[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||||
|
let s:default_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
|
||||||
|
\ '\%([[:punct:]]\|\s\|$\)\@='
|
||||||
let s:default_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
let s:default_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||||
let s:default_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
let s:default_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||||
let s:default_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
|
let s:default_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
|
||||||
|
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki syntax file
|
" Vimwiki syntax file
|
||||||
" Desc: Defines markdown syntax
|
" Description: Defines markdown syntax
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
" see the comments in vimwiki_default.vim for some info about this file
|
" see the comments in vimwiki_default.vim for some info about this file
|
||||||
|
|
||||||
|
|
||||||
let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
|
let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
|
||||||
|
|
||||||
" text: $ equation_inline $
|
" text: $ equation_inline $
|
||||||
@ -92,8 +94,11 @@ let s:markdown_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)
|
|||||||
|
|
||||||
let s:markdown_syntax.header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
|
let s:markdown_syntax.header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
|
||||||
let s:markdown_syntax.header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
|
let s:markdown_syntax.header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
|
||||||
let s:markdown_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
let s:markdown_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs'.
|
||||||
let s:markdown_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
|
\ '\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
|
||||||
let s:markdown_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]' "XXX plus markdown-style links
|
let s:markdown_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
|
||||||
|
\ '\%([[:punct:]]\|\s\|$\)\@='
|
||||||
|
let s:markdown_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||||
let s:markdown_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
let s:markdown_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||||
let s:markdown_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
|
let s:markdown_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
|
||||||
|
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||||
|
@ -4,41 +4,44 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function! s:add_target_syntax_ON(target, type)
|
||||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
|
||||||
function! s:add_target_syntax_ON(target, type) " {{{
|
|
||||||
let prefix0 = 'syntax match '.a:type.' `'
|
let prefix0 = 'syntax match '.a:type.' `'
|
||||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
||||||
let prefix1 = 'syntax match '.a:type.'T `'
|
let prefix1 = 'syntax match '.a:type.'T `'
|
||||||
let suffix1 = '` display contained'
|
let suffix1 = '` display contained'
|
||||||
execute prefix0. a:target. suffix0
|
execute prefix0. a:target. suffix0
|
||||||
execute prefix1. a:target. suffix1
|
execute prefix1. a:target. suffix1
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:add_target_syntax_OFF(target, type) " {{{
|
|
||||||
|
function! s:add_target_syntax_OFF(target, type)
|
||||||
let prefix0 = 'syntax match VimwikiNoExistsLink `'
|
let prefix0 = 'syntax match VimwikiNoExistsLink `'
|
||||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
||||||
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
|
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
|
||||||
let suffix1 = '` display contained'
|
let suffix1 = '` display contained'
|
||||||
execute prefix0. a:target. suffix0
|
execute prefix0. a:target. suffix0
|
||||||
execute prefix1. a:target. suffix1
|
execute prefix1. a:target. suffix1
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:wrap_wikilink1_rx(target) "{{{
|
|
||||||
|
function! s:wrap_wikilink1_rx(target)
|
||||||
return vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidPrefix') . a:target.
|
return vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidPrefix') . a:target.
|
||||||
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidSuffix')
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidSuffix')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:existing_mkd_refs() "{{{
|
|
||||||
|
function! s:existing_mkd_refs()
|
||||||
return keys(vimwiki#markdown_base#scan_reflinks())
|
return keys(vimwiki#markdown_base#scan_reflinks())
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
function! s:highlight_existing_links() "{{{
|
|
||||||
|
function! s:highlight_existing_links()
|
||||||
" Wikilink1
|
" Wikilink1
|
||||||
" Conditional highlighting that depends on the existence of a wiki file or
|
" Conditional highlighting that depends on the existence of a wiki file or
|
||||||
" directory is only available for *schemeless* wiki links
|
" directory is only available for *schemeless* wiki links
|
||||||
" Links are set up upon BufEnter (see plugin/...)
|
" Links are set up upon BufEnter (see plugin/...)
|
||||||
let safe_links = '\%('.vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
|
let safe_links = '\%('.
|
||||||
|
\ vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikifiles')) .
|
||||||
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
\ '\%(#[^|]*\)\?\|#[^|]*\)'
|
||||||
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
|
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
|
||||||
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
|
let safe_dirs = vimwiki#base#file_pattern(vimwiki#vars#get_bufferlocal('existing_wikidirs'))
|
||||||
@ -78,7 +81,7 @@ function! s:highlight_existing_links() "{{{
|
|||||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
||||||
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
\ safe_reflinks, vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||||
endfunction "}}}
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" use max highlighting - could be quite slow if there are too many wikifiles
|
" use max highlighting - could be quite slow if there are too many wikifiles
|
||||||
@ -93,9 +96,11 @@ else
|
|||||||
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
|
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), 'VimwikiWikiLink1')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
" Weblink
|
" Weblink
|
||||||
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink1'), 'VimwikiWeblink1')
|
call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink1'), 'VimwikiWeblink1')
|
||||||
|
|
||||||
|
|
||||||
" WikiLink
|
" WikiLink
|
||||||
" All remaining schemes are highlighted automatically
|
" All remaining schemes are highlighted automatically
|
||||||
let s:rxSchemes = '\%('.
|
let s:rxSchemes = '\%('.
|
||||||
@ -106,26 +111,28 @@ let s:rxSchemes = '\%('.
|
|||||||
" a) match [nonwiki-scheme-URL]
|
" a) match [nonwiki-scheme-URL]
|
||||||
let s:target = vimwiki#base#apply_template(
|
let s:target = vimwiki#base#apply_template(
|
||||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
|
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template1')),
|
||||||
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'), vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'),
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||||
" b) match [DESCRIPTION][nonwiki-scheme-URL]
|
" b) match [DESCRIPTION][nonwiki-scheme-URL]
|
||||||
let s:target = vimwiki#base#apply_template(
|
let s:target = vimwiki#base#apply_template(
|
||||||
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
\ vimwiki#u#escape(vimwiki#vars#get_syntaxlocal('WikiLink1Template2')),
|
||||||
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'), vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
\ s:rxSchemes . vimwiki#vars#get_syntaxlocal('rxWikiLink1Url'),
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Descr'), '')
|
||||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
|
||||||
" }}}
|
|
||||||
|
|
||||||
|
|
||||||
" generic headers "{{{
|
|
||||||
|
|
||||||
" Header levels, 1-6
|
" Header levels, 1-6
|
||||||
for s:i in range(1,6)
|
for s:i in range(1,6)
|
||||||
execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i).'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i).
|
||||||
|
\ '/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,'.
|
||||||
|
\ 'VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" concealed chars " {{{
|
|
||||||
|
" concealed chars
|
||||||
if exists("+conceallevel")
|
if exists("+conceallevel")
|
||||||
syntax conceal on
|
syntax conceal on
|
||||||
endif
|
endif
|
||||||
@ -136,24 +143,26 @@ syntax spell toplevel
|
|||||||
" is present) and may be concealed
|
" is present) and may be concealed
|
||||||
let s:options = ' contained transparent contains=NONE'
|
let s:options = ' contained transparent contains=NONE'
|
||||||
" conceal wikilink1
|
" conceal wikilink1
|
||||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rx_wikilink_md_prefix').'/'.s:options
|
execute 'syn match VimwikiWikiLink1Char /'.
|
||||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rx_wikilink_md_suffix').'/'.s:options
|
\ vimwiki#vars#get_syntaxlocal('rx_wikilink_md_prefix').'/'.s:options
|
||||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rxWikiLink1Prefix1').'/'.s:options
|
execute 'syn match VimwikiWikiLink1Char /'.
|
||||||
execute 'syn match VimwikiWikiLink1Char /'.vimwiki#vars#get_syntaxlocal('rxWikiLink1Suffix1').'/'.s:options
|
\ vimwiki#vars#get_syntaxlocal('rx_wikilink_md_suffix').'/'.s:options
|
||||||
|
execute 'syn match VimwikiWikiLink1Char /'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Prefix1').'/'.s:options
|
||||||
|
execute 'syn match VimwikiWikiLink1Char /'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWikiLink1Suffix1').'/'.s:options
|
||||||
|
|
||||||
" conceal weblink1
|
" conceal weblink1
|
||||||
execute 'syn match VimwikiWeblink1Char "'.vimwiki#vars#get_syntaxlocal('rxWeblink1Prefix1').'"'.s:options
|
execute 'syn match VimwikiWeblink1Char "'.
|
||||||
execute 'syn match VimwikiWeblink1Char "'.vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options
|
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Prefix1').'"'.s:options
|
||||||
|
execute 'syn match VimwikiWeblink1Char "'.
|
||||||
|
\ vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options
|
||||||
|
|
||||||
if exists("+conceallevel")
|
if exists("+conceallevel")
|
||||||
syntax conceal off
|
syntax conceal off
|
||||||
endif
|
endif
|
||||||
" }}}
|
|
||||||
|
|
||||||
" non concealed chars " {{{
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" main syntax groups {{{
|
|
||||||
|
|
||||||
" Tables
|
" Tables
|
||||||
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
||||||
@ -175,22 +184,12 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
|||||||
\ VimwikiEqInT,
|
\ VimwikiEqInT,
|
||||||
\ @Spell
|
\ @Spell
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" header groups highlighting "{{{
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
|
|
||||||
" syntax group highlighting "{{{
|
" syntax group highlighting
|
||||||
hi def link VimwikiWeblink1 VimwikiLink
|
hi def link VimwikiWeblink1 VimwikiLink
|
||||||
hi def link VimwikiWeblink1T VimwikiLink
|
hi def link VimwikiWeblink1T VimwikiLink
|
||||||
|
|
||||||
hi def link VimwikiWikiLink1 VimwikiLink
|
hi def link VimwikiWikiLink1 VimwikiLink
|
||||||
hi def link VimwikiWikiLink1T VimwikiLink
|
hi def link VimwikiWikiLink1T VimwikiLink
|
||||||
"}}}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" EMBEDDED syntax setup "{{{
|
|
||||||
"}}}
|
|
||||||
"
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=99
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||||
" Vimwiki syntax file
|
" Vimwiki syntax file
|
||||||
" Desc: Defines mediaWiki syntax
|
" Description: Defines mediaWiki syntax
|
||||||
" Home: https://github.com/vimwiki/vimwiki/
|
" Home: https://github.com/vimwiki/vimwiki/
|
||||||
|
|
||||||
|
|
||||||
" see the comments in vimwiki_default.vim for some info about this file
|
" see the comments in vimwiki_default.vim for some info about this file
|
||||||
|
|
||||||
|
|
||||||
let s:media_syntax = g:vimwiki_syntax_variables['media']
|
let s:media_syntax = g:vimwiki_syntax_variables['media']
|
||||||
|
|
||||||
" text: $ equation_inline $
|
" text: $ equation_inline $
|
||||||
@ -78,5 +80,6 @@ let s:media_syntax.bold_match = '''''''__Text__'''''''
|
|||||||
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
|
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
|
||||||
" want to call escape() on this string, we must keep it in single quotes
|
" want to call escape() on this string, we must keep it in single quotes
|
||||||
let s:media_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
let s:media_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
|
||||||
let s:media_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)' " XXX rework to mediawiki categories format?
|
let s:media_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)'
|
||||||
let s:media_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)' " XXX rework to mediawiki categories format?
|
let s:media_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:'.
|
||||||
|
\ '\([^:[:space:]]\+:\)*\(\s\|$\)'
|
||||||
|
Loading…
Reference in New Issue
Block a user