Version 2.0.1.stu
* Follow (i.e. open target of) markdown reference-style links. * Bug fixes.
This commit is contained in:
parent
d5a6d097da
commit
d19cc85a71
@ -8,19 +8,16 @@ if exists("g:loaded_vimwiki_auto") || &cp
|
||||
endif
|
||||
let g:loaded_vimwiki_auto = 1
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
execute 'runtime! autoload/vimwiki/'.VimwikiGet('syntax').'_base.vim'
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
" MISC helper functions {{{
|
||||
|
||||
" s:normalize_path
|
||||
function! s:normalize_path(path) "{{{
|
||||
let g:VimwikiLog.normalize_path += 1 "XXX
|
||||
" resolve doesn't work quite right with symlinks ended with / or \
|
||||
return resolve(expand(substitute(a:path, '[/\\]\+$', '', ''))).'/'
|
||||
endfunction "}}}
|
||||
|
||||
" s:path_html
|
||||
function! s:path_html(idx) "{{{
|
||||
let path_html = VimwikiGet('path_html', a:idx)
|
||||
if !empty(path_html)
|
||||
@ -32,8 +29,41 @@ function! s:path_html(idx) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#base#get_known_extensions() " {{{
|
||||
" Getting all extensions that different wikis could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for ext in keys(g:vimwiki_ext2syntax)
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
return keys(extensions)
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#base#get_known_syntaxes() " {{{
|
||||
" Getting all syntaxes that different wikis could have
|
||||
let syntaxes = {}
|
||||
let syntaxes['default'] = 1
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'syntax')
|
||||
let syntaxes[wiki.syntax] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for syn in values(g:vimwiki_ext2syntax)
|
||||
let syntaxes[syn] = 1
|
||||
endfor
|
||||
return keys(syntaxes)
|
||||
endfunction " }}}
|
||||
" }}}
|
||||
|
||||
" vimwiki#base#apply_wiki_options
|
||||
function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
||||
" wiki using the options dictionary
|
||||
for kk in keys(a:options)
|
||||
@ -43,6 +73,7 @@ function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
||||
call vimwiki#base#setup_buffer_state(g:vimwiki_current_idx)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#read_wiki_options
|
||||
function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" options from the current page's directory, or its ancesters. If a file
|
||||
" named vimwiki.vimrc is found, which declares a wiki-options dictionary
|
||||
@ -55,7 +86,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" overwrite !! (not to mention all the other globals ...)
|
||||
let l:vimwiki_list = deepcopy(g:vimwiki_list, 1)
|
||||
"
|
||||
if a:check
|
||||
if a:check > 1
|
||||
call vimwiki#base#print_wiki_state()
|
||||
echo " \n"
|
||||
endif
|
||||
@ -67,7 +98,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" other names are possible, but most vimrc files will cause grief!
|
||||
for nm in ['vimwiki.vimrc']
|
||||
" TODO: use an alternate strategy, instead of source, to read options
|
||||
if done |
|
||||
if done
|
||||
continue
|
||||
endif
|
||||
"
|
||||
@ -78,7 +109,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
"
|
||||
echo "\nFound file : ".local_wiki_options_filename
|
||||
let query = "Vimwiki: Check for options in this file [Y]es/[n]o? "
|
||||
if a:check && (tolower(input(query)) !~ "y")
|
||||
if a:check > 0 && (tolower(input(query)) !~ "y")
|
||||
continue
|
||||
endif
|
||||
"
|
||||
@ -90,7 +121,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
continue
|
||||
endif
|
||||
"
|
||||
if a:check
|
||||
if a:check > 0
|
||||
echo "\n\nFound wiki options\n g:local_wiki = ".string(g:local_wiki)
|
||||
let query = "Vimwiki: Apply these options [Y]es/[n]o? "
|
||||
if tolower(input(query)) !~ "y"
|
||||
@ -114,7 +145,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
let g:vimwiki_list = deepcopy(l:vimwiki_list, 1)
|
||||
"
|
||||
endif
|
||||
if a:check
|
||||
if a:check > 1
|
||||
echo " \n "
|
||||
if done
|
||||
call vimwiki#base#print_wiki_state()
|
||||
@ -124,6 +155,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#validate_wiki_options
|
||||
function! vimwiki#base#validate_wiki_options(idx) " {{{ Validate wiki options
|
||||
" Only call this function *before* opening a wiki page.
|
||||
"
|
||||
@ -144,6 +176,7 @@ function! vimwiki#base#validate_wiki_options(idx) " {{{ Validate wiki options
|
||||
"" call vimwiki#base#cache_buffer_state()
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#setup_buffer_state
|
||||
function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variables
|
||||
" Only call this function *after* opening a wiki page.
|
||||
if a:idx < 0
|
||||
@ -162,6 +195,7 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#cache_buffer_state
|
||||
function! vimwiki#base#cache_buffer_state() "{{{
|
||||
if !exists('g:vimwiki_current_idx') && g:vimwiki_debug
|
||||
echo "[Vimwiki Internal Error]: Missing global state variable: 'g:vimwiki_current_idx'"
|
||||
@ -169,6 +203,7 @@ function! vimwiki#base#cache_buffer_state() "{{{
|
||||
let b:vimwiki_idx = g:vimwiki_current_idx
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#recall_buffer_state
|
||||
function! vimwiki#base#recall_buffer_state() "{{{
|
||||
if !exists('b:vimwiki_idx')
|
||||
if g:vimwiki_debug
|
||||
@ -181,6 +216,7 @@ function! vimwiki#base#recall_buffer_state() "{{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#print_wiki_state
|
||||
function! vimwiki#base#print_wiki_state() "{{{ print wiki options
|
||||
" and buffer state variables
|
||||
let g_width = 18
|
||||
@ -198,6 +234,7 @@ function! vimwiki#base#print_wiki_state() "{{{ print wiki options
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#mkdir
|
||||
" If the optional argument 'confirm' == 1 is provided,
|
||||
" vimwiki#base#mkdir will ask before creating a directory
|
||||
function! vimwiki#base#mkdir(path, ...) "{{{
|
||||
@ -213,9 +250,9 @@ function! vimwiki#base#mkdir(path, ...) "{{{
|
||||
call mkdir(path, "p")
|
||||
endif
|
||||
return 1
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#file_pattern
|
||||
function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
|
||||
" string. Aim to support *all* special characters, forcing the user to choose
|
||||
" names that are compatible with any external restrictions that they
|
||||
@ -231,18 +268,18 @@ function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
|
||||
"
|
||||
let pattern = vimwiki#base#branched_pattern(a:files,"\n")
|
||||
return '\V'.pattern.'\m'
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#branched_pattern
|
||||
function! vimwiki#base#branched_pattern(string,separator) "{{{ get search regex
|
||||
" from a string-list; separators assumed at start and end as well
|
||||
let pattern = substitute(a:string, a:separator, '\\|','g')
|
||||
let pattern = substitute(pattern, '\%^\\|', '\\%(','')
|
||||
let pattern = substitute(pattern,'\\|\%$', '\\)','')
|
||||
return pattern
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#subdir
|
||||
"FIXME TODO slow and faulty
|
||||
function! vimwiki#base#subdir(path, filename)"{{{
|
||||
let g:VimwikiLog.subdir += 1 "XXX
|
||||
@ -264,17 +301,18 @@ function! vimwiki#base#subdir(path, filename)"{{{
|
||||
return res
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#current_subdir
|
||||
function! vimwiki#base#current_subdir(idx)"{{{
|
||||
return vimwiki#base#subdir(VimwikiGet('path', a:idx), expand('%:p'))
|
||||
endfunction"}}}
|
||||
|
||||
" vimwiki#base#invsubdir
|
||||
function! vimwiki#base#invsubdir(subdir) " {{{
|
||||
return substitute(a:subdir, '[^/\.]\+/', '../', 'g')
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#resolve_scheme
|
||||
function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
" - Only return non-negative index when valid wiki link found
|
||||
"
|
||||
" if link is schemeless add wikiN: scheme
|
||||
let lnk = a:lnk
|
||||
let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl
|
||||
@ -392,6 +430,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
return [idx, scheme, path, subdir, lnk, ext, url]
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#system_open_link
|
||||
function! vimwiki#base#system_open_link(url) "{{{
|
||||
" handlers
|
||||
function! s:win32_handler(url)
|
||||
@ -420,6 +459,7 @@ function! vimwiki#base#system_open_link(url) "{{{
|
||||
echomsg 'Default Vimwiki link handler was unable to open the HTML file!'
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#open_link
|
||||
function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
let [idx, scheme, path, subdir, lnk, ext, url] =
|
||||
\ vimwiki#base#resolve_scheme(a:link, 0)
|
||||
@ -467,9 +507,9 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#generate_links
|
||||
function! vimwiki#base#generate_links() "{{{only get links from the current dir
|
||||
" change to the directory of the current file
|
||||
let orig_pwd = getcwd()
|
||||
@ -497,6 +537,7 @@ function! vimwiki#base#generate_links() "{{{only get links from the current dir
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#goto
|
||||
function! vimwiki#base#goto(key) "{{{
|
||||
call vimwiki#base#edit_file(':e',
|
||||
\ VimwikiGet('path').
|
||||
@ -504,6 +545,7 @@ function! vimwiki#base#goto(key) "{{{
|
||||
\ VimwikiGet('ext'))
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#backlinks
|
||||
function! vimwiki#base#backlinks() "{{{
|
||||
execute 'lvimgrep "\%(^\|[[:blank:][:punct:]]\)'.
|
||||
\ expand("%:t:r").
|
||||
@ -511,11 +553,12 @@ function! vimwiki#base#backlinks() "{{{
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#get_links
|
||||
function! vimwiki#base#get_links(pat) "{{{ return string-list for files
|
||||
" in the current wiki matching the pattern "pat"
|
||||
" search all wiki files (or directories) in wiki 'path' and its subdirs.
|
||||
|
||||
let time1 = reltime() " start the clock XXX
|
||||
let time1 = reltime() " start the clock
|
||||
|
||||
" XXX:
|
||||
" if maxhi = 1 and <leader>w<leader>w before loading any vimwiki file
|
||||
@ -586,6 +629,7 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
|
||||
return globlinks
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#edit_file
|
||||
function! vimwiki#base#edit_file(command, filename, ...) "{{{
|
||||
" XXX: Should we allow * in filenames!?
|
||||
" Maxim: It is allowed, escaping here is for vim to be able to open files
|
||||
@ -610,17 +654,17 @@ function! vimwiki#base#edit_file(command, filename, ...) "{{{
|
||||
if a:0 && a:2 && len(a:1) > 0
|
||||
let b:vimwiki_prev_link = a:1
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#search_word
|
||||
function! vimwiki#base#search_word(wikiRx, cmd) "{{{
|
||||
let match_line = search(a:wikiRx, 's'.a:cmd)
|
||||
if match_line == 0
|
||||
echomsg 'vimwiki: Wiki link not found.'
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#matchstr_at_cursor
|
||||
" Returns part of the line that matches wikiRX at cursor
|
||||
function! vimwiki#base#matchstr_at_cursor(wikiRX) "{{{
|
||||
let col = col('.') - 1
|
||||
@ -644,6 +688,7 @@ function! vimwiki#base#matchstr_at_cursor(wikiRX) "{{{
|
||||
endif
|
||||
endf "}}}
|
||||
|
||||
" vimwiki#base#replacestr_at_cursor
|
||||
function! vimwiki#base#replacestr_at_cursor(wikiRX, sub) "{{{
|
||||
let col = col('.') - 1
|
||||
let line = getline('.')
|
||||
@ -666,6 +711,7 @@ function! vimwiki#base#replacestr_at_cursor(wikiRX, sub) "{{{
|
||||
endif
|
||||
endf "}}}
|
||||
|
||||
" s:print_wiki_list
|
||||
function! s:print_wiki_list() "{{{
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
@ -680,9 +726,9 @@ function! s:print_wiki_list() "{{{
|
||||
let idx += 1
|
||||
endwhile
|
||||
echohl None
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:update_wiki_link
|
||||
function! s:update_wiki_link(fname, old, new) " {{{
|
||||
echo "Updating links in ".a:fname
|
||||
let has_updates = 0
|
||||
@ -700,9 +746,9 @@ function! s:update_wiki_link(fname, old, new) " {{{
|
||||
call writefile(dest, a:fname)
|
||||
call delete(a:fname.'#vimwiki_upd#')
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:update_wiki_links_dir
|
||||
function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
|
||||
let new_fname = a:new_fname
|
||||
@ -718,9 +764,9 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
for fname in files
|
||||
call s:update_wiki_link(fname, old_fname_r, new_fname_r)
|
||||
endfor
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:tail_name
|
||||
function! s:tail_name(fname) "{{{
|
||||
let result = substitute(a:fname, ":", "__colon__", "g")
|
||||
let result = fnamemodify(result, ":t:r")
|
||||
@ -728,6 +774,7 @@ function! s:tail_name(fname) "{{{
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" s:update_wiki_links
|
||||
function! s:update_wiki_links(old_fname, new_fname) " {{{
|
||||
let old_fname = s:tail_name(a:old_fname)
|
||||
let new_fname = s:tail_name(a:new_fname)
|
||||
@ -760,6 +807,7 @@ function! s:update_wiki_links(old_fname, new_fname) " {{{
|
||||
endwhile
|
||||
endfunction " }}}
|
||||
|
||||
" s:get_wiki_buffers
|
||||
function! s:get_wiki_buffers() "{{{
|
||||
let blist = []
|
||||
let bcount = 1
|
||||
@ -776,6 +824,7 @@ function! s:get_wiki_buffers() "{{{
|
||||
return blist
|
||||
endfunction " }}}
|
||||
|
||||
" s:open_wiki_buffer
|
||||
function! s:open_wiki_buffer(item) "{{{
|
||||
call vimwiki#base#edit_file(':e', a:item[0])
|
||||
if !empty(a:item[1])
|
||||
@ -783,6 +832,7 @@ function! s:open_wiki_buffer(item) "{{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#nested_syntax
|
||||
function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
||||
" From http://vim.wikia.com/wiki/VimTip857
|
||||
let ft=toupper(a:filetype)
|
||||
@ -799,8 +849,9 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{
|
||||
" let b:skip_set_iskeyword = 1
|
||||
let is_keyword = &iskeyword
|
||||
|
||||
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
|
||||
try
|
||||
" keep going even if syntax file is not found
|
||||
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
|
||||
execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
|
||||
catch
|
||||
endtry
|
||||
@ -833,28 +884,28 @@ endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
" vimwiki#base#find_next_link
|
||||
function! vimwiki#base#find_next_link() "{{{
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, '')
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#find_prev_link
|
||||
function! vimwiki#base#find_prev_link() "{{{
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" follow_link
|
||||
" vimwiki#base#follow_link
|
||||
function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pass
|
||||
" to VimwikiLinkHandler, or failing that, the default open_link handler
|
||||
if exists('*vimwiki#base_'.VimwikiGet('syntax').'#follow_link')
|
||||
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#follow_link')
|
||||
" Syntax-specific links
|
||||
" XXX: @Stuart: do we still need it?
|
||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
if a:0
|
||||
call vimwiki#base_{VimwikiGet('syntax')}#follow_link(a:split, a:1)
|
||||
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split, a:1)
|
||||
else
|
||||
call vimwiki#base_{VimwikiGet('syntax')}#follow_link(a:split)
|
||||
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split)
|
||||
endif
|
||||
else
|
||||
if a:split == "split"
|
||||
@ -897,6 +948,7 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#go_back_link
|
||||
function! vimwiki#base#go_back_link() "{{{
|
||||
if exists("b:vimwiki_prev_link")
|
||||
" go back to saved wiki link
|
||||
@ -906,6 +958,7 @@ function! vimwiki#base#go_back_link() "{{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#goto_index
|
||||
function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
if a:wnum > len(g:vimwiki_list)
|
||||
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
|
||||
@ -937,6 +990,7 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#delete_link
|
||||
function! vimwiki#base#delete_link() "{{{
|
||||
"" file system funcs
|
||||
"" Delete wiki link you are in from filesystem
|
||||
@ -961,6 +1015,7 @@ function! vimwiki#base#delete_link() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#rename_link
|
||||
function! vimwiki#base#rename_link() "{{{
|
||||
"" Rename wiki link, update all links to renamed WikiWord
|
||||
let subdir = VimwikiGet('subdir')
|
||||
@ -1061,6 +1116,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
let &more = setting_more
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#ui_select
|
||||
function! vimwiki#base#ui_select() "{{{
|
||||
call s:print_wiki_list()
|
||||
let idx = input("Select Wiki (specify number): ")
|
||||
@ -1068,12 +1124,12 @@ function! vimwiki#base#ui_select() "{{{
|
||||
return
|
||||
endif
|
||||
call vimwiki#base#goto_index(idx)
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" TEXT OBJECTS functions {{{
|
||||
|
||||
" vimwiki#base#TO_header
|
||||
function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||
if !search('^\(=\+\).\+\1\s*$', 'bcW')
|
||||
return
|
||||
@ -1114,9 +1170,9 @@ function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||
let lnum = prevnonblank(line('.') - 1)
|
||||
call cursor(lnum, 0)
|
||||
endif
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#TO_table_cell
|
||||
function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
||||
if col('.') == col('$')-1
|
||||
return
|
||||
@ -1181,6 +1237,7 @@ function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#TO_table_col
|
||||
function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||
let t_rows = vimwiki#tbl#get_rows(line('.'))
|
||||
if empty(t_rows)
|
||||
@ -1297,6 +1354,7 @@ endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" HEADER functions {{{
|
||||
" vimwiki#base#AddHeaderLevel
|
||||
function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
@ -1322,9 +1380,9 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
endif
|
||||
call setline(lnum, line)
|
||||
endif
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#RemoveHeaderLevel
|
||||
function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
@ -1355,12 +1413,12 @@ function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
|
||||
call setline(lnum, line)
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
"}}}
|
||||
|
||||
" LINK functions {{{
|
||||
" Construct a regular expression matching from template (with special
|
||||
" vimwiki#base#apply_template
|
||||
" Construct a regular expression matching from template (with special
|
||||
" characters properly escaped), by substituting rxUrl for __LinkUrl__, rxDesc
|
||||
" for __LinkDescription__, and rxStyle for __LinkStyle__. The three
|
||||
" arguments rxUrl, rxDesc, and rxStyle are copied verbatim, without any
|
||||
@ -1378,9 +1436,9 @@ function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
|
||||
let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", '')
|
||||
endif
|
||||
return lnk
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:clean_url
|
||||
function! s:clean_url(url) " {{{
|
||||
let url = split(a:url, '/\|=\|-\|&\|?\|\.')
|
||||
let url = filter(url, 'v:val != ""')
|
||||
@ -1396,6 +1454,7 @@ function! s:clean_url(url) " {{{
|
||||
return join(url, " ")
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#normalize_link_helper
|
||||
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
|
||||
let str = a:str
|
||||
let url = matchstr(str, a:rxUrl)
|
||||
@ -1409,6 +1468,7 @@ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
|
||||
return lnk
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#normalize_imagelink_helper
|
||||
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 style = matchstr(str, a:rxStyle)
|
||||
@ -1416,6 +1476,7 @@ function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, t
|
||||
return lnk
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_link_syntax_n
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
let lnum = line('.')
|
||||
|
||||
@ -1459,6 +1520,7 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_link_syntax_v
|
||||
function! s:normalize_link_syntax_v() " {{{
|
||||
let lnum = line('.')
|
||||
let sel_save = &selection
|
||||
@ -1484,7 +1546,7 @@ function! s:normalize_link_syntax_v() " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" normalize_link
|
||||
" vimwiki#base#normalize_link
|
||||
function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
||||
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#normalize_link')
|
||||
" Syntax-specific links
|
||||
@ -1500,3 +1562,12 @@ function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
" }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
for syn in vimwiki#base#get_known_syntaxes()
|
||||
execute 'runtime! autoload/vimwiki/'.syn.'_base.vim'
|
||||
endfor
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -237,12 +237,12 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
call vimwiki#base#validate_wiki_options(idx)
|
||||
call vimwiki#base#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
|
||||
|
||||
if a:0
|
||||
if a:0 && a:1 == 1
|
||||
let cmd = 'tabedit'
|
||||
else
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
if len(a:0)>1
|
||||
if a:0>1
|
||||
let link = 'diary:'.a:2
|
||||
else
|
||||
let link = 'diary:'.s:diary_date_link(idx)
|
||||
|
@ -422,6 +422,13 @@ function! s:tag_wikiincl(value) "{{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '{{idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.'}}'
|
||||
endif
|
||||
|
||||
" Issue 343: Image transclusions: schemeless links have .html appended.
|
||||
" If link is schemeless pass it as it is
|
||||
if scheme == ''
|
||||
let url = lnk
|
||||
endif
|
||||
|
||||
let url = escape(url, '#')
|
||||
let line = vimwiki#html#linkify_image(url, descr, verbatim_str)
|
||||
return line
|
||||
|
@ -1,10 +1,190 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Desc: Link functions for markdown syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Author: Stuart Andrews <stu.andrews@gmail.com> (.. i.e. don't blame Maxim!)
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
|
||||
" MISC helper functions {{{
|
||||
|
||||
" vimwiki#markdown_base#reset_mkd_refs
|
||||
function! vimwiki#markdown_base#reset_mkd_refs() "{{{
|
||||
call VimwikiClear('markdown_refs')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#markdown_base#scan_reflinks
|
||||
function! vimwiki#markdown_base#scan_reflinks() " {{{
|
||||
let mkd_refs = {}
|
||||
" construct list of references using vimgrep
|
||||
try
|
||||
execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
|
||||
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
||||
"Ignore it, and move on to the next file
|
||||
endtry
|
||||
"
|
||||
for d in getqflist()
|
||||
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
|
||||
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
|
||||
let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl)
|
||||
if descr != '' && url != ''
|
||||
let mkd_refs[descr] = url
|
||||
endif
|
||||
endfor
|
||||
call VimwikiSet('markdown_refs', mkd_refs)
|
||||
return mkd_refs
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" vimwiki#markdown_base#get_reflinks
|
||||
function! vimwiki#markdown_base#get_reflinks() " {{{
|
||||
let done = 1
|
||||
try
|
||||
let mkd_refs = VimwikiGet('markdown_refs')
|
||||
catch
|
||||
" work-around hack
|
||||
let done = 0
|
||||
" ... the following command does not work inside catch block !?
|
||||
" > let mkd_refs = vimwiki#markdown_base#scan_reflinks()
|
||||
endtry
|
||||
if !done
|
||||
let mkd_refs = vimwiki#markdown_base#scan_reflinks()
|
||||
endif
|
||||
return mkd_refs
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#markdown_base#open_reflink
|
||||
" try markdown reference links
|
||||
function! vimwiki#markdown_base#open_reflink(link) " {{{
|
||||
" echom "vimwiki#markdown_base#open_reflink"
|
||||
let link = a:link
|
||||
let mkd_refs = vimwiki#markdown_base#get_reflinks()
|
||||
if has_key(mkd_refs, link)
|
||||
let url = mkd_refs[link]
|
||||
call vimwiki#base#system_open_link(url)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_path
|
||||
" s:path_html
|
||||
" vimwiki#base#apply_wiki_options
|
||||
" vimwiki#base#read_wiki_options
|
||||
" vimwiki#base#validate_wiki_options
|
||||
" vimwiki#base#setup_buffer_state
|
||||
" vimwiki#base#cache_buffer_state
|
||||
" vimwiki#base#recall_buffer_state
|
||||
" vimwiki#base#print_wiki_state
|
||||
" vimwiki#base#mkdir
|
||||
" vimwiki#base#file_pattern
|
||||
" vimwiki#base#branched_pattern
|
||||
" vimwiki#base#subdir
|
||||
" vimwiki#base#current_subdir
|
||||
" vimwiki#base#invsubdir
|
||||
" vimwiki#base#resolve_scheme
|
||||
" vimwiki#base#system_open_link
|
||||
" vimwiki#base#open_link
|
||||
" vimwiki#base#generate_links
|
||||
" vimwiki#base#goto
|
||||
" vimwiki#base#backlinks
|
||||
" vimwiki#base#get_links
|
||||
" vimwiki#base#edit_file
|
||||
" vimwiki#base#search_word
|
||||
" vimwiki#base#matchstr_at_cursor
|
||||
" vimwiki#base#replacestr_at_cursor
|
||||
" s:print_wiki_list
|
||||
" s:update_wiki_link
|
||||
" s:update_wiki_links_dir
|
||||
" s:tail_name
|
||||
" s:update_wiki_links
|
||||
" s:get_wiki_buffers
|
||||
" s:open_wiki_buffer
|
||||
" vimwiki#base#nested_syntax
|
||||
" }}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
" vimwiki#base#find_next_link
|
||||
" vimwiki#base#find_prev_link
|
||||
|
||||
" vimwiki#base#follow_link
|
||||
function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
|
||||
" to VimwikiLinkHandler, or failing that, the default open_link handler
|
||||
" echom "markdown_base#follow_link"
|
||||
|
||||
if 0
|
||||
" Syntax-specific links
|
||||
" XXX: @Stuart: do we still need it?
|
||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
else
|
||||
if a:split == "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
endif
|
||||
|
||||
" try WikiLink
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl)
|
||||
" try WikiIncl
|
||||
if lnk == ""
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
|
||||
\ g:vimwiki_rxWikiInclMatchUrl)
|
||||
endif
|
||||
" try Weblink
|
||||
if lnk == ""
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
|
||||
\ g:vimwiki_rxWeblinkMatchUrl)
|
||||
endif
|
||||
|
||||
if lnk != ""
|
||||
if !VimwikiLinkHandler(lnk)
|
||||
if !vimwiki#markdown_base#open_reflink(lnk)
|
||||
call vimwiki#base#open_link(cmd, lnk)
|
||||
endif
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
if a:0 > 0
|
||||
execute "normal! ".a:1
|
||||
else
|
||||
call vimwiki#base#normalize_link(0)
|
||||
endif
|
||||
endif
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#go_back_link
|
||||
" vimwiki#base#goto_index
|
||||
" vimwiki#base#delete_link
|
||||
" vimwiki#base#rename_link
|
||||
" vimwiki#base#ui_select
|
||||
|
||||
" TEXT OBJECTS functions {{{
|
||||
" vimwiki#base#TO_header
|
||||
" vimwiki#base#TO_table_cell
|
||||
" vimwiki#base#TO_table_col
|
||||
" }}}
|
||||
|
||||
" HEADER functions {{{
|
||||
" vimwiki#base#AddHeaderLevel
|
||||
" vimwiki#base#RemoveHeaderLevel
|
||||
"}}}
|
||||
|
||||
" LINK functions {{{
|
||||
" vimwiki#base#apply_template
|
||||
|
||||
" s:clean_url
|
||||
" vimwiki#base#normalize_link_helper
|
||||
" vimwiki#base#normalize_imagelink_helper
|
||||
|
||||
" s:normalize_link_syntax_n
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
let lnum = line('.')
|
||||
|
||||
@ -74,6 +254,7 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_link_syntax_v
|
||||
function! s:normalize_link_syntax_v() " {{{
|
||||
let lnum = line('.')
|
||||
let sel_save = &selection
|
||||
@ -99,13 +280,23 @@ function! s:normalize_link_syntax_v() " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" normalize_link
|
||||
" vimwiki#base#normalize_link
|
||||
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
|
||||
if !a:is_visual_mode
|
||||
call s:normalize_link_syntax_n()
|
||||
elseif visualmode() ==# 'v' && line("'<") == line("'>")
|
||||
" action undefined for 'line-wise' or 'multi-line' visual mode selections
|
||||
call s:normalize_link_syntax_v()
|
||||
if 0
|
||||
" Syntax-specific links
|
||||
else
|
||||
if !a:is_visual_mode
|
||||
call s:normalize_link_syntax_n()
|
||||
elseif visualmode() ==# 'v' && line("'<") == line("'>")
|
||||
" action undefined for 'line-wise' or 'multi-line' visual mode selections
|
||||
call s:normalize_link_syntax_v()
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|___| |___| |_| |_||__| |__||___| |___| |_||___| ~
|
||||
|
||||
|
||||
Version: 2.0 'stu'
|
||||
Version: 2.0.1 'stu'
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *vimwiki-contents*
|
||||
@ -610,10 +610,10 @@ Markdown Links~
|
||||
These links are only available for Markdown syntax. See
|
||||
http://daringfireball.net/projects/markdown/syntax#link.
|
||||
|
||||
Inline links: >
|
||||
Inline link: >
|
||||
[Looks like this](URL)
|
||||
|
||||
Image links: >
|
||||
Image link: >
|
||||
![Looks like this](URL)
|
||||
|
||||
The URL can be anything recognized by vimwiki as a raw URL.
|
||||
@ -623,10 +623,26 @@ Reference-style links: >
|
||||
a) [Link Name][Id]
|
||||
b) [Id][], using the "implicit link name" shortcut
|
||||
|
||||
Vimwiki treats reference style links just like default "Wikilinks". In the
|
||||
current implementation: the Id field must be a valid wiki page name,
|
||||
reference style links must always include *two* consecutive pairs of
|
||||
[-brackets, and entries can not use "[" or "]".
|
||||
Reference style links must always include *two* consecutive pairs of
|
||||
[-brackets, and field entries can not use "[" or "]".
|
||||
|
||||
|
||||
NOTE: (in Vimwiki's current implementation) Reference-style links are a hybrid
|
||||
of Vimwiki's default "Wikilink" and the tradition reference-style link.
|
||||
|
||||
If the Id is defined elsewhere in the source, as per the Markdown standard: >
|
||||
[Id]: URL
|
||||
|
||||
then the URL is opened with the system default handler. Otherwise, Vimwiki
|
||||
treats the reference-sytle link as a Wikilink, interpreting the Id field as a
|
||||
wiki page name.
|
||||
|
||||
Highlighting of existing links when |vimwiki-option-maxhi| is activated
|
||||
identifies links whose Id field is not defined, either as a reference-link or
|
||||
as a wiki page.
|
||||
|
||||
To scan the page for new or changed definitions for reference-links, simply
|
||||
re-open the page ":e<CR>".
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@ -1193,21 +1209,21 @@ Use the :VimwikiTable command to create a default table with 5 columns and 2
|
||||
rows: >
|
||||
|
||||
| | | | | |
|
||||
|---+---+---+---+---|
|
||||
|---|---|---|---|---|
|
||||
| | | | | |
|
||||
<
|
||||
|
||||
Tables are auto-formattable. Let's add some text into first cell: >
|
||||
|
||||
| First Name | | | | |
|
||||
|---+---+---+---+---|
|
||||
|---|---|---|---|---|
|
||||
| | | | | |
|
||||
<
|
||||
|
||||
Whenever you press <TAB>, <CR> or leave Insert mode, the table is formatted: >
|
||||
|
||||
| First Name | | | | |
|
||||
|------------+---+---+---+---|
|
||||
|------------|---|---|---|---|
|
||||
| | | | | |
|
||||
<
|
||||
|
||||
@ -1215,7 +1231,7 @@ You can easily create nice-looking text tables, just press <TAB> and enter new
|
||||
values: >
|
||||
|
||||
| First Name | Last Name | Age | City | e-mail |
|
||||
|------------+------------+-----+----------+----------------------|
|
||||
|------------|------------|-----|----------|----------------------|
|
||||
| Vladislav | Pokrishkin | 31 | Moscow | vlad_pok@smail.com |
|
||||
| James | Esfandiary | 27 | Istanbul | esfandiary@tmail.com |
|
||||
<
|
||||
@ -2170,10 +2186,16 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
|
||||
==============================================================================
|
||||
14. Changelog *vimwiki-changelog*
|
||||
|
||||
2.0.1 'stu'~
|
||||
|
||||
* Follow (i.e. open target of) markdown reference-style links.
|
||||
* Bug fixes.
|
||||
|
||||
|
||||
2.0 'stu'~
|
||||
|
||||
This release is partly incompatible with previous.
|
||||
|
||||
*
|
||||
Summary ~
|
||||
|
||||
* Quick page-link creation.
|
||||
|
@ -195,7 +195,10 @@ function! s:setup_buffer_enter() "{{{
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding == 1 && &fdm != 'expr'
|
||||
if g:vimwiki_folding == 2 && &fdm != 'expr'
|
||||
" User-defined fold-expression, and fold-text
|
||||
endif
|
||||
if g:vimwiki_folding == 1
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
@ -295,6 +298,19 @@ function! VimwikiSet(option, value, ...) "{{{
|
||||
let b:vimwiki_list[a:option] = a:value
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
" Clear option for current wiki or if third parameter exists for
|
||||
" wiki with a given index.
|
||||
" Currently, only works if option was previously saved in the buffer local
|
||||
" dictionary, that acts as a cache.
|
||||
function! VimwikiClear(option, ...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
|
||||
if exists('b:vimwiki_list') && has_key(b:vimwiki_list, a:option)
|
||||
call remove(b:vimwiki_list, a:option)
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
@ -415,19 +431,7 @@ call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
|
||||
"}}}
|
||||
|
||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||
" Getting all extensions that different wikis could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for ext in keys(g:vimwiki_ext2syntax)
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
let extensions = vimwiki#base#get_known_extensions()
|
||||
|
||||
augroup filetypedetect
|
||||
" clear FlexWiki's stuff
|
||||
@ -436,7 +440,7 @@ augroup end
|
||||
|
||||
augroup vimwiki
|
||||
autocmd!
|
||||
for ext in keys(extensions)
|
||||
for ext in extensions
|
||||
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_reenter()'
|
||||
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
||||
|
@ -300,8 +300,10 @@ endfor
|
||||
" }}}
|
||||
|
||||
" concealed chars " {{{
|
||||
let cchar = ''
|
||||
if exists("+conceallevel")
|
||||
syntax conceal on
|
||||
let cchar = ' cchar=~ '
|
||||
endif
|
||||
|
||||
syntax spell toplevel
|
||||
@ -329,9 +331,9 @@ execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
|
||||
|
||||
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
|
||||
execute 'syn match VimwikiLinkRest contained `\%(///\=[^/ \t]\+/\)\zs\S\{'
|
||||
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\{'
|
||||
\.g:vimwiki_url_mingain.',}\ze\%([/#?]\w\|\S\{'
|
||||
\.g:vimwiki_url_maxsave.'}\)` cchar=~ '.options
|
||||
\.g:vimwiki_url_maxsave.'}\)`'.cchar.options
|
||||
|
||||
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'
|
||||
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
|
||||
@ -586,12 +588,13 @@ if !empty(nested)
|
||||
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
|
||||
" call vimwiki#base#nested_syntax(vim_syntax,
|
||||
" \ '^\s*{{\$\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
" \ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
" \ '^\s*}}\$', 'VimwikiMath')
|
||||
endfor
|
||||
endif
|
||||
" LaTeX
|
||||
call vimwiki#base#nested_syntax('tex',
|
||||
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ '\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
|
||||
"}}}
|
||||
|
||||
let timeend = vimwiki#u#time(starttime) "XXX
|
||||
|
@ -83,7 +83,7 @@ let g:vimwiki_rxPreStart = '```'
|
||||
let g:vimwiki_rxPreEnd = '```'
|
||||
|
||||
" Math block
|
||||
let g:vimwiki_rxMathStart = '{{\$'
|
||||
let g:vimwiki_rxMathEnd = '}}\$'
|
||||
let g:vimwiki_rxMathStart = '\$\$'
|
||||
let g:vimwiki_rxMathEnd = '\$\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
|
@ -101,7 +101,6 @@ let g:vimwiki_rxWikiLinkMatchDescr = ''.
|
||||
\ g:vimwiki_rxWikiLink1MatchDescr
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: setup of wikiincl regexps {{{
|
||||
" }}}
|
||||
|
||||
@ -182,6 +181,15 @@ let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: setup wikilink1 reference link definitions {{{
|
||||
let g:vimwiki_rxMkdRef = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
let g:vimwiki_rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
|
||||
\ g:vimwiki_rxWeblink0.'\ze'
|
||||
" }}}
|
||||
|
||||
" }}} end of Links
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
||||
@ -214,6 +222,11 @@ function! s:wrap_wikilink1_rx(target) "{{{
|
||||
\ g:vimwiki_rxWikiLink1InvalidSuffix
|
||||
endfunction "}}}
|
||||
|
||||
function! s:existing_mkd_refs() "{{{
|
||||
call vimwiki#markdown_base#reset_mkd_refs()
|
||||
return "\n".join(keys(vimwiki#markdown_base#get_reflinks()), "\n")."\n"
|
||||
endfunction "}}}
|
||||
|
||||
function! s:highlight_existing_links() "{{{
|
||||
" Wikilink1
|
||||
" Conditional highlighting that depends on the existence of a wiki file or
|
||||
@ -222,8 +235,11 @@ function! s:highlight_existing_links() "{{{
|
||||
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
|
||||
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
|
||||
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
|
||||
" Ref links are cached
|
||||
let safe_reflinks = vimwiki#base#file_pattern(s:existing_mkd_refs())
|
||||
|
||||
" match [URL]
|
||||
|
||||
" match [URL][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
@ -232,7 +248,7 @@ function! s:highlight_existing_links() "{{{
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [DIRURL]
|
||||
" match [DIRURL][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
@ -240,6 +256,15 @@ function! s:highlight_existing_links() "{{{
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [MKDREF][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][MKDREF]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user