Version 1.1

* NEW: Issue 57: Make it possible to have pre block inside list item.
* NEW: Issue 82: Add quick goto command. See |:VimwikiGoto|.
* NEW: Issue 83: Quick switch in diary. See |:VimwikiDiaryNextDay| and
  |:VimwikiDiaryPrevDay| commands.
* FIX: Issue 84: Vimwiki rename removed the WikiWord display name.
* FIX: Issue 85: Errors if you have '~' subdirectory in a wiki directory.
* FIX: Issue 86: Existed links '[[WikiLink1|Alias1]] | [[WikiLink2]]' are
  highlighted as a single link.
* FIX: Issue 88: Underline text. See |g:vimwiki_valid_html_tags|.
* FIX: Issue 92: Wikies in a subdir could be renamed to an empty file.
* FIX: Issue 93: Use alias name in html title. See |vimwiki-title|.
* FIX: Issue 94: Relative links to PHP files are broken. See
  |g:vimwiki_file_exts| for details.
* FIX: Issue 96: Closing bracket at the end of weblink shouldn't be a part
  of that link.
* FIX: Issue 97: Error opening weblink in a browser if it has # inside.
* FIX: Issue 99: Vim is not responing while opening arbitrary wiki file.
* FIX: Issue 100: Additional content on diary index page could be
  corrupted.
* NEW: Issue 101: Customized HTML tags. See |g:vimwiki_valid_html_tags|
* NEW: Issue 102: Conceal feature usage. See |g:vimwiki_conceallevel|.
* FIX: Issue 103: Always highlight links to non-wiki files as existed.
* FIX: Issue 104: vimwiki#nested_syntax needs 'keepend' to avoid contained
  language syntax eat needed '}}}'.
* FIX: Issue 105: <i_CR> on a todo list item with [ ] doesn't create new
  todo list item.
* FIX: Issue 106: With MediaWiki syntax <C-Space> on a child todo list
  item produce errors.
* FIX: Issue 107: With MediaWiki syntax <C-Space> on a list item creates
  todo list item without space between * and [ ].
* FIX: Issue 110: Syntax highlighting doesn't work for indented codeblock.
* FIX: Issue 115: Nested Perl syntax highlighting differs from regular
  one.
* MISC: Many vimwiki commands were renamed from Vimwiki.*Word to
  Vimwiki.*Link. VimwikiGoHome is renamed to VimwikiIndex,
  VimwikiTabGoHome to VimwikiTabIndex.
* MISC: vimwiki-option-gohome is removed.
This commit is contained in:
Maxim Kim 2010-08-24 00:00:00 +00:00 committed by Able Scraper
parent 8e53e53ffe
commit 458c4539e5
11 changed files with 784 additions and 368 deletions

View File

@ -65,7 +65,7 @@ function! vimwiki#current_subdir()"{{{
endfunction"}}}
function! vimwiki#open_link(cmd, link, ...) "{{{
if s:is_link_to_non_wiki_file(a:link)
if vimwiki#is_non_wiki_link(a:link)
call s:edit_file(a:cmd, a:link)
else
if a:0
@ -127,6 +127,13 @@ function! vimwiki#generate_links()"{{{
endfor
endfunction " }}}
function! vimwiki#goto(key) "{{{
call s:edit_file(':e',
\ VimwikiGet('path').
\ a:key.
\ VimwikiGet('ext'))
endfunction "}}}
function! s:is_windows() "{{{
return has("win32") || has("win64") || has("win95") || has("win16")
endfunction "}}}
@ -134,15 +141,21 @@ endfunction "}}}
function! s:get_links(pat) "{{{
" search all wiki files in 'path' and its subdirs.
let subdir = vimwiki#current_subdir()
let globlinks = glob(VimwikiGet('path').subdir.'**/'.a:pat)
" remove .wiki extensions
let globlinks = substitute(globlinks, '\'.VimwikiGet('ext'), "", "g")
" if current wiki is temporary -- was added by an arbitrary wiki file then do
" not search wiki files in subdirectories. Or it would hang the system if
" wiki file was created in $HOME or C:/ dirs.
if VimwikiGet('temp')
let search_dirs = ''
else
let search_dirs = '**/'
endif
let globlinks = glob(VimwikiGet('path').subdir.search_dirs.a:pat)
" remove extensions (and backup extensions too: .wiki~)
let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\~\?', "", "g")
let links = split(globlinks, '\n')
" remove backup files (.wiki~)
call filter(links, 'v:val !~ ''.*\~$''')
" remove paths
let rem_path = escape(expand(VimwikiGet('path')).subdir, '\')
call map(links, 'substitute(v:val, rem_path, "", "g")')
@ -235,15 +248,15 @@ function! s:strip_word(word) "{{{
endfunction
" }}}
function! s:is_link_to_non_wiki_file(link) "{{{
" Check if link is to a non-wiki file.
" The easiest way is to check if it has extension like .txt or .html
if a:link =~ '\.\w\{1,4}$'
function! vimwiki#is_non_wiki_link(lnk) "{{{
let exts = '.\+\.\%('.
\ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
\ '\)$'
if a:lnk =~ exts
return 1
endif
return 0
endfunction
" }}}
endfunction "}}}
function! vimwiki#is_link_to_dir(link) "{{{
" Check if link is to a directory.
@ -252,8 +265,7 @@ function! vimwiki#is_link_to_dir(link) "{{{
return 1
endif
return 0
endfunction
" }}}
endfunction " }}}
function! s:print_wiki_list() "{{{
let idx = 0
@ -294,19 +306,23 @@ endfunction
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
let old_fname_r = old_fname
let new_fname_r = new_fname
if !s:is_wiki_word(new_fname)
let new_fname = '[['.new_fname.']]'
if !s:is_wiki_word(new_fname) && s:is_wiki_word(old_fname)
let new_fname_r = '[['.new_fname.']]'
endif
if !s:is_wiki_word(old_fname)
let old_fname = '\[\['.vimwiki#unsafe_link(old_fname).
\ '\%(|.*\)\?\%(\]\[.*\)\?\]\]'
let old_fname_r = '\[\[\zs'.vimwiki#unsafe_link(old_fname).
\ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]'
else
let old_fname = '\<'.old_fname.'\>'
let old_fname_r = '\<'.old_fname.'\>'
endif
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
for fname in files
call s:update_wiki_link(fname, old_fname, new_fname)
call s:update_wiki_link(fname, old_fname_r, new_fname_r)
endfor
endfunction
" }}}
@ -348,8 +364,7 @@ function! s:update_wiki_links(old_fname, new_fname) " {{{
\ new_dir.old_fname, new_dir.new_fname)
let idx = idx + 1
endwhile
endfunction
" }}}
endfunction " }}}
function! s:get_wiki_buffers() "{{{
let blist = []
@ -365,21 +380,58 @@ function! s:get_wiki_buffers() "{{{
let bcount = bcount + 1
endwhile
return blist
endfunction
" }}}
endfunction " }}}
function! s:open_wiki_buffer(item) "{{{
call s:edit_file('e', a:item[0])
if !empty(a:item[1])
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
endif
endfunction
" }}}
endfunction " }}}
" }}}
" SYNTAX highlight {{{
function! vimwiki#WikiHighlightLinks() "{{{
function! vimwiki#highlight_links() "{{{
try
syntax clear VimwikiNoExistsLink
syntax clear VimwikiNoExistsLinkT
syntax clear VimwikiLink
syntax clear VimwikiLinkT
catch
endtry
"" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
" Every WikiWord is nonexistent
if g:vimwiki_camel_case
execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiWord.'/ display'
execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiWord.'/ display contained'
endif
execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink1.'/ display contains=VimwikiNoLinkChar'
execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink2.'/ display contains=VimwikiNoLinkChar'
execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiLink1.'/ display contained'
execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiLink2.'/ display contained'
" till we find them in vimwiki's path
call s:highlight_existed_links()
else
" A WikiWord (unqualifiedWikiName)
execute 'syntax match VimwikiLink /\<'.g:vimwiki_rxWikiWord.'\>/'
" A [[bracketed wiki word]]
execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink1.'/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink2.'/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLinkT /\<'.g:vimwiki_rxWikiWord.'\>/ display contained'
execute 'syntax match VimwikiLinkT /'.g:vimwiki_rxWikiLink1.'/ display contained'
execute 'syntax match VimwikiLinkT /'.g:vimwiki_rxWikiLink2.'/ display contained'
endif
execute 'syntax match VimwikiLink `'.g:vimwiki_rxWeblink.'` display contains=@NoSpell'
endfunction "}}}
function! s:highlight_existed_links() "{{{
let links = s:get_links('*'.VimwikiGet('ext'))
" Links with subdirs should be highlighted for linux and windows separators
@ -390,31 +442,116 @@ function! vimwiki#WikiHighlightLinks() "{{{
for link in links
if g:vimwiki_camel_case &&
\ link =~ g:vimwiki_rxWikiWord && !s:is_link_to_non_wiki_file(link)
execute 'syntax match VimwikiLink /!\@<!\<'.link.'\>/'
\ link =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link)
execute 'syntax match VimwikiLink /!\@<!\<'.link.'\>/ display'
endif
execute 'syntax match VimwikiLink /\[\[\<'.
\ vimwiki#unsafe_link(link).
\ '\>\%(|\+.*\)*\]\]/'
execute 'syntax match VimwikiLink /\[\[\<'.
\ vimwiki#unsafe_link(link).
\ '\>\]\[.\+\]\]/'
execute 'syntax match VimwikiLink /\[\['.
\ escape(vimwiki#unsafe_link(link), '~&$.*').
\ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLink /\[\['.
\ escape(vimwiki#unsafe_link(link), '~&$.*').
\ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLinkT /\[\['.
\ escape(vimwiki#unsafe_link(link), '~&$.*').
\ '\%(|\+.\{-}\)\{-}\]\]/ display contained'
execute 'syntax match VimwikiLinkT /\[\['.
\ escape(vimwiki#unsafe_link(link), '~&$.*').
\ '\]\[.\{-1,}\]\]/ display contained'
endfor
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/'
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/'
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLinkT /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contained'
execute 'syntax match VimwikiLinkT /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/ display contained'
" Issue 103: Always highlight links to non-wiki files as existed.
execute 'syntax match VimwikiLink /\[\[.\+\.\%('.
\join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
\'\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLink /\[\[.\+\.\%('.
\join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
\'\)\]\[.\+\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLinkT /\[\[.\+\.\%('.
\join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
\'\)\%(|\+.*\)*\]\]/ display contained'
execute 'syntax match VimwikiLinkT /\[\[.\+\.\%('.
\join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
\'\)\]\[.\+\]\]/ display contained'
" highlight dirs
let dirs = s:get_links('*/')
call map(dirs, 'substitute(v:val, os_p, os_p2, "g")')
for dir in dirs
execute 'syntax match VimwikiLink /\[\[\<'.
\ vimwiki#unsafe_link(dir).
\ '\>[/\\]*\%(|\+.*\)*\]\]/'
endfor
endfunction
" }}}
execute 'syntax match VimwikiLink /\[\['.
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
\ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
execute 'syntax match VimwikiLink /\[\['.
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar'
function! vimwiki#hl_exists(hl)"{{{
execute 'syntax match VimwikiLinkT /\[\['.
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
\ '[/\\]*\%(|\+.*\)*\]\]/ display contained'
execute 'syntax match VimwikiLinkT /\[\['.
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contained'
endfor
endfunction "}}}
function! vimwiki#setup_colors() "{{{
function! s:set_visible_ignore_color() "{{{
if !exists("g:colors_name") || g:colors_name == 'default'
if &background == 'light'
hi VimwikiIgnore guifg=#d0d0d0
else
hi VimwikiIgnore guifg=#505050
endif
else
hi link VimwikiIgnore Normal
endif
endfunction "}}}
let hlfg_ignore = vimwiki#get_hl_param('Ignore', 'guifg')
let hlbg_normal = vimwiki#get_hl_param('Normal', 'guibg')
if hlfg_ignore == 'bg' || hlfg_ignore == hlbg_normal
call s:set_visible_ignore_color()
else
hi link VimwikiIgnore Ignore
endif
if g:vimwiki_hl_headers == 0
hi def link VimwikiHeader Title
return
endif
if &background == 'light'
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed
hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black
hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black
hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black
else
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White
endif
endfunction "}}}
function vimwiki#get_hl_param(hgroup, hparam) "{{{
redir => hlstatus
exe "silent hi ".a:hgroup
redir END
return matchstr(hlstatus, a:hparam.'\s*=\s*\zs\S\+')
endfunction "}}}
function! vimwiki#hl_exists(hl) "{{{
if !hlexists(a:hl)
return 0
endif
@ -454,26 +591,38 @@ function! vimwiki#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
else
unlet b:current_syntax
endif
execute 'syntax region textSnip'.ft.'
\ matchgroup='.a:textSnipHl.'
\ start="'.a:start.'" end="'.a:end.'"
\ contains=@'.group
execute 'syntax region textSnip'.ft.
\ ' matchgroup='.a:textSnipHl.
\ ' start="'.a:start.'" end="'.a:end.'"'.
\ ' contains=@'.group.' keepend'
" A workaround to Issue 115: Nested Perl syntax highlighting differs from
" regular one.
" Perl syntax file has perlFunctionName which is usually has no effect due to
" 'contained' flag. Now we have 'syntax include' that makes all the groups
" included as 'contained' into specific group.
" Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
" the rest syntax rules as now it has effect being really 'contained'.
" Clear it!
if ft =~ 'perl'
syntax clear perlFunctionName
endif
endfunction "}}}
"}}}
" WIKI functions {{{
function! vimwiki#WikiNextWord() "{{{
function! vimwiki#find_next_link() "{{{
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '')
endfunction
" }}}
function! vimwiki#WikiPrevWord() "{{{
function! vimwiki#find_prev_link() "{{{
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b')
endfunction
" }}}
function! vimwiki#WikiFollowWord(split) "{{{
function! vimwiki#follow_link(split) "{{{
if a:split == "split"
let cmd = ":split "
elseif a:split == "vsplit"
@ -486,7 +635,7 @@ function! vimwiki#WikiFollowWord(split) "{{{
if link == ""
let weblink = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWeblink))
if weblink != ""
call VimwikiWeblinkHandler(weblink)
call VimwikiWeblinkHandler(escape(weblink, '#'))
else
execute "normal! \n"
endif
@ -496,20 +645,18 @@ function! vimwiki#WikiFollowWord(split) "{{{
let subdir = vimwiki#current_subdir()
call vimwiki#open_link(cmd, subdir.link)
endfunction
" }}}
endfunction " }}}
function! vimwiki#WikiGoBackWord() "{{{
function! vimwiki#go_back_link() "{{{
if exists("b:vimwiki_prev_link")
" go back to saved WikiWord
let prev_word = b:vimwiki_prev_link
execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g')
call setpos('.', prev_word[1])
endif
endfunction
" }}}
endfunction " }}}
function! vimwiki#WikiGoHome(index) "{{{
function! vimwiki#goto_index(index) "{{{
call vimwiki#select(a:index)
call vimwiki#mkdir(VimwikiGet('path'))
@ -517,17 +664,15 @@ function! vimwiki#WikiGoHome(index) "{{{
execute ':e '.fnameescape(
\ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext'))
catch /E37/ " catch 'No write since last change' error
" this is really unsecure!!!
execute ':'.VimwikiGet('gohome').' '.
execute ':split '.
\ VimwikiGet('path').
\ VimwikiGet('index').
\ VimwikiGet('ext')
catch /E325/ " catch 'ATTENTION' error (:h E325)
endtry
endfunction
"}}}
endfunction "}}}
function! vimwiki#WikiDeleteWord() "{{{
function! vimwiki#delete_link() "{{{
"" file system funcs
"" Delete WikiWord you are in from filesystem
let val = input('Delete ['.expand('%').'] (y/n)? ', "")
@ -547,10 +692,9 @@ function! vimwiki#WikiDeleteWord() "{{{
if expand('%:p') != ""
execute "e"
endif
endfunction
"}}}
endfunction "}}}
function! vimwiki#WikiRenameWord() "{{{
function! vimwiki#rename_link() "{{{
"" Rename WikiWord, update all links to renamed WikiWord
let subdir = vimwiki#current_subdir()
let old_fname = subdir.expand('%:t')
@ -575,18 +719,17 @@ function! vimwiki#WikiRenameWord() "{{{
return
endif
let new_link = subdir.new_link
" check new_fname - it should be 'good', not empty
if substitute(new_link, '\s', '', 'g') == ''
echomsg 'vimwiki: Cannot rename to an empty filename!'
return
endif
if s:is_link_to_non_wiki_file(new_link)
if vimwiki#is_non_wiki_link(new_link)
echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!'
return
endif
let new_link = subdir.new_link
let new_link = s:strip_word(new_link)
let new_fname = VimwikiGet('path').s:filename(new_link).VimwikiGet('ext')
@ -649,16 +792,15 @@ function! vimwiki#WikiRenameWord() "{{{
echomsg old_fname." is renamed to ".new_fname
let &more = setting_more
endfunction
" }}}
endfunction " }}}
function! vimwiki#WikiUISelect()"{{{
function! vimwiki#ui_select()"{{{
call s:print_wiki_list()
let idx = input("Select Wiki (specify number): ")
if idx == ""
return
endif
call vimwiki#WikiGoHome(idx)
call vimwiki#goto_index(idx)
endfunction
"}}}

View File

@ -62,7 +62,7 @@ function! s:get_diary_range(lines, header) "{{{
let idx += 1
endfor
let ln_end = idx - 1
let ln_end = idx
return [ln_start, ln_end]
endfunction "}}}
@ -99,10 +99,24 @@ function! s:get_links() "{{{
call map(links, 'fnamemodify(v:val, ":t")')
call filter(links, 'v:val =~ "'.escape(rx, '\').'"')
call map(links, '"[[".v:val."]]"')
return links
endfunction "}}}
function! s:get_position_links(link) "{{{
let idx = -1
let links = []
if a:link =~ '\d\{4}-\d\d-\d\d'
let links = s:get_links()
" include 'today' into links
if index(links, s:diary_date_link()) == -1
call add(links, s:diary_date_link())
endif
call sort(links)
let idx = index(links, a:link)
endif
return [idx, links]
endfunction "}}}
function! s:format_links(links) "{{{
let lines = []
let line = '| '
@ -137,6 +151,7 @@ function! s:add_link(page, header, link) "{{{
if ln_start == -1
call insert(lines, '= '.a:header.' =')
let ln_start = 1
let ln_end = 1
endif
" removing 'old' links
@ -148,6 +163,7 @@ function! s:add_link(page, header, link) "{{{
" get all diary links from filesystem
let links = s:get_links()
call map(links, '"[[".v:val."]]"')
" add current link
if index(links, link) == -1
@ -192,7 +208,7 @@ function! vimwiki_diary#make_note(index, ...) "{{{
call vimwiki#open_link(':e ', link, s:diary_index())
endfunction "}}}
" Calendar.vim callback and sign functions.
" Calendar.vim callback function.
function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
@ -213,8 +229,9 @@ function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{
" Create diary note for a selected date in default wiki.
call vimwiki_diary#make_note(1, link)
endfunction
endfunction "}}}
" Calendar.vim sign function.
function vimwiki_diary#calendar_sign(day, month, year) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
@ -222,3 +239,43 @@ function vimwiki_diary#calendar_sign(day, month, year) "{{{
\ a:year.'-'.month.'-'.day.VimwikiGet('ext')
return filereadable(expand(sfile))
endfunction "}}}
function! vimwiki_diary#goto_next_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == (len(links) - 1)
return
endif
if idx != -1 && idx < len(links) - 1
let link = VimwikiGet('diary_rel_path').links[idx+1]
else
" goto today
let link = VimwikiGet('diary_rel_path').s:diary_date_link()
endif
if len(link)
call vimwiki#open_link(':e ', link)
endif
endfunction "}}}
function! vimwiki_diary#goto_prev_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == 0
return
endif
if idx > 0
let link = VimwikiGet('diary_rel_path').links[idx-1]
else
" goto today
let link = VimwikiGet('diary_rel_path').s:diary_date_link()
endif
if len(link)
call vimwiki#open_link(':e ', link)
endif
endfunction "}}}

View File

@ -48,14 +48,6 @@ function! s:is_img_link(lnk) "{{{
return 0
endfunction "}}}
function! s:is_non_wiki_link(lnk) "{{{
" TODO: Add more file extensions here
if a:lnk =~ '.\+\.\%(pdf\|txt\|doc\|rtf\|xls\)$'
return 1
endif
return 0
endfunction "}}}
function! s:has_abs_path(fname) "{{{
if a:fname =~ '\(^.:\)\|\(^/\)'
return 1
@ -102,15 +94,13 @@ function! s:create_default_CSS(path) " {{{
endif
endfunction "}}}
function! s:get_html_header(wikifile, subdir, charset) "{{{
function! s:get_html_header(title, subdir, charset) "{{{
let lines=[]
let title = fnamemodify(a:wikifile, ":t:r")
if VimwikiGet('html_header') != "" && !s:warn_html_header
try
let lines = readfile(expand(VimwikiGet('html_header')))
call map(lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")')
call map(lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(a:subdir) .'", "g")')
return lines
@ -134,7 +124,7 @@ function! s:get_html_header(wikifile, subdir, charset) "{{{
call add(lines, '<head>')
call add(lines, '<link rel="Stylesheet" type="text/css" href="'.
\ css_name.'" />')
call add(lines, '<title>'.title.'</title>')
call add(lines, '<title>'.a:title.'</title>')
call add(lines, '<meta http-equiv="Content-Type" content="text/html;'.
\ ' charset='.a:charset.'" />')
call add(lines, '</head>')
@ -171,11 +161,13 @@ function! s:safe_html(line) "{{{
let line = substitute(a:line, '&', '\&amp;', 'g')
" let line = substitute(line, '<', '\&lt;', 'g')
" let line = substitute(line, '>', '\&gt;', 'g')
" XXX: I believe there should be a much nicer way to do it.
let line = substitute(line, '<\(br\|hr\)\@!', '\&lt;', 'g')
let line = substitute(line, '\(\(br\|hr\)\s*/\?\)\@<!>', '\&gt;', 'g')
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
let line = substitute(line,'<\%(/\?\%('
\.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!',
\'\&lt;', 'g')
let line = substitute(line,'\%(</\?\%('
\.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>',
\'\&gt;', 'g')
return line
endfunction "}}}
@ -299,23 +291,36 @@ function! s:get_html_toc(toc_list) "{{{
return toc
endfunction "}}}
" insert placeholder's contents into dest.
function! s:process_placeholders(dest, placeholders, type, ins_content) "{{{
" insert toc into dest.
function! s:process_toc(dest, placeholders, toc) "{{{
if !empty(a:placeholders)
for [placeholder, row, idx] in a:placeholders
let [type, param] = placeholder
if type == a:type
let ins_content = a:ins_content[:]
if type == 'toc'
let toc = a:toc[:]
if !empty(param)
call insert(ins_content, '<h1>'.param.'</h1>')
call insert(toc, '<h1>'.param.'</h1>')
endif
let shift = idx * len(ins_content)
call extend(a:dest, ins_content, row + shift)
let shift = idx * len(toc)
call extend(a:dest, toc, row + shift)
endif
endfor
endif
endfunction "}}}
" get title.
function! s:process_title(placeholders, default_title) "{{{
if !empty(a:placeholders)
for [placeholder, row, idx] in a:placeholders
let [type, param] = placeholder
if type == 'title' && !empty(param)
return param
endif
endfor
endif
return a:default_title
endfunction "}}}
"}}}
" INLINE TAGS "{{{
@ -371,7 +376,7 @@ function! s:tag_internal_link(value) "{{{
if s:is_img_link(a:caption)
let link = '<a href="'.a:src.'"><img src="'.a:caption.'"'.style_str.' />'.
\ '</a>'
elseif s:is_non_wiki_link(a:src)
elseif vimwiki#is_non_wiki_link(a:src)
let link = '<a href="'.a:src.'">'.a:caption.'</a>'
elseif s:is_img_link(a:src)
let link = '<img src="'.a:src.'" alt="'.a:caption.'"'. style_str.' />'
@ -592,8 +597,8 @@ endfunction " }}}
" BLOCK TAGS {{{
function! s:close_tag_pre(pre, ldest) "{{{
if a:pre
call insert(a:ldest, "</pre></code>")
if a:pre[0]
call insert(a:ldest, "</pre>")
return 0
endif
return a:pre
@ -671,8 +676,8 @@ endfunction "}}}
function! s:close_tag_list(lists, ldest) "{{{
while len(a:lists)
let item = remove(a:lists, -1)
call add(a:ldest, item[0])
let item = remove(a:lists, 0)
call insert(a:ldest, item[0])
endwhile
endfunction! "}}}
@ -685,10 +690,11 @@ function! s:close_tag_def_list(deflist, ldest) "{{{
endfunction! "}}}
function! s:process_tag_pre(line, pre) "{{{
" pre is the list of [is_in_pre, indent_of_pre]
let lines = []
let pre = a:pre
let processed = 0
if !pre && a:line =~ '{{{[^\(}}}\)]*\s*$'
if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
let class = matchstr(a:line, '{{{\zs.*$')
let class = substitute(class, '\s\+$', '', 'g')
if class != ""
@ -696,15 +702,15 @@ function! s:process_tag_pre(line, pre) "{{{
else
call add(lines, "<pre>")
endif
let pre = 1
let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
let processed = 1
elseif pre && a:line =~ '^}}}\s*$'
let pre = 0
elseif pre[0] && a:line =~ '^\s*}}}\s*$'
let pre = [0, 0]
call add(lines, "</pre>")
let processed = 1
elseif pre
elseif pre[0]
let processed = 1
call add(lines, a:line)
call add(lines, substitute(a:line, '^\s\{'.pre[1].'}', '', ''))
endif
return [processed, lines, pre]
endfunction "}}}
@ -713,7 +719,6 @@ function! s:process_tag_quote(line, quote) "{{{
let lines = []
let quote = a:quote
let processed = 0
" if a:line =~ '^\s\{4,}[^[:blank:]*#]'
if a:line =~ '^\s\{4,}\S'
if !quote
call add(lines, "<blockquote>")
@ -721,9 +726,6 @@ function! s:process_tag_quote(line, quote) "{{{
endif
let processed = 1
call add(lines, substitute(a:line, '^\s*', '', ''))
elseif quote && a:line =~ '^\s*$'
let processed = 1
call add(lines, a:line)
elseif quote
call add(lines, "</blockquote>")
let quote = 0
@ -987,12 +989,14 @@ endfunction "}}}
"}}}
" }}}
" WIKI2HTML "{{{
function! s:parse_line(line, state) " {{{
let state = {}
let state.para = a:state.para
let state.quote = a:state.quote
let state.pre = a:state.pre
let state.pre = a:state.pre[:]
let state.table = a:state.table[:]
let state.lists = a:state.lists[:]
let state.deflist = a:state.deflist
@ -1014,6 +1018,15 @@ function! s:parse_line(line, state) " {{{
endif
endif
" title -- placeholder
if !processed
if line =~ '^\s*%title'
let processed = 1
let param = matchstr(line, '^\s*%title\s\zs.*')
let state.placeholder = ['title', param]
endif
endif
" toc -- placeholder "{{{
if !processed
if line =~ '^\s*%toc'
@ -1027,9 +1040,10 @@ function! s:parse_line(line, state) " {{{
" pres "{{{
if !processed
let [processed, lines, state.pre] = s:process_tag_pre(line, state.pre)
if processed && len(state.lists)
call s:close_tag_list(state.lists, lines)
endif
" pre is just fine to be in the list -- do not close list item here.
" if processed && len(state.lists)
" call s:close_tag_list(state.lists, lines)
" endif
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
@ -1052,7 +1066,7 @@ function! s:parse_line(line, state) " {{{
if processed && state.quote
let state.quote = s:close_tag_quote(state.quote, lines)
endif
if processed && state.pre
if processed && state.pre[0]
let state.pre = s:close_tag_pre(state.pre, lines)
endif
if processed && len(state.table)
@ -1109,7 +1123,7 @@ function! s:parse_line(line, state) " {{{
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
if processed && state.pre
if processed && state.pre[0]
let state.pre = s:close_tag_pre(state.pre, lines)
endif
if processed && state.para
@ -1153,7 +1167,7 @@ function! s:parse_line(line, state) " {{{
if processed && state.quote
let state.quote = s:close_tag_quote(state.quote, res_lines)
endif
if processed && state.pre
if processed && state.pre[0]
let state.pre = s:close_tag_pre(state.pre, res_lines)
endif
if processed && len(state.table)
@ -1186,7 +1200,7 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
let subdir = vimwiki#subdir(VimwikiGet('path'), wikifile)
let lsource = s:remove_comments(readfile(wikifile))
let ldest = s:get_html_header(wikifile, subdir, &fileencoding)
let ldest = []
let path = expand(a:path).subdir
call vimwiki#mkdir(path)
@ -1201,7 +1215,7 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
let state = {}
let state.para = 0
let state.quote = 0
let state.pre = 0
let state.pre = [0, 0] " [in_pre, indent_pre]
let state.table = []
let state.deflist = 0
let state.lists = []
@ -1236,8 +1250,7 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
if !nohtml
let toc = s:get_html_toc(state.toc)
call s:process_placeholders(ldest, placeholders, 'toc', toc)
call s:process_toc(ldest, placeholders, toc)
call s:remove_blank_lines(ldest)
"" process end of file
@ -1251,6 +1264,8 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
call s:close_tag_table(state.table, lines)
call extend(ldest, lines)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
call extend(ldest, s:get_html_header(title, subdir, &fileencoding), 0)
call extend(ldest, s:get_html_footer())
"" make html file.
@ -1266,9 +1281,12 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
endif
echomsg 'Saving vimwiki files...'
let save_eventignore = &eventignore
let &eventignore = "all"
let cur_buf = bufname('%')
bufdo call s:save_vimwiki_buffer()
exe 'buffer '.cur_buf
let &eventignore = save_eventignore
let path = expand(a:path)
call vimwiki#mkdir(path)

View File

@ -40,7 +40,6 @@ endfunction "}}}
" Get regexp of the list item with checkbox.
function! s:rx_cb_list_item() "{{{
" return s:rx_list_item().'\s*\zs\[.\?\]'
return s:rx_list_item().'\s*\zs\[.\?\]'
endfunction "}}}
@ -182,9 +181,7 @@ function! s:get_sibling_items(lnum) "{{{
let lnum = a:lnum
let ind = s:get_level(lnum)
while s:get_level(lnum) >= ind &&
\ lnum != 0
while lnum != 0 && s:get_level(lnum) >= ind
if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
call add(result, lnum)
endif
@ -192,9 +189,7 @@ function! s:get_sibling_items(lnum) "{{{
endwhile
let lnum = s:prev_list_item(a:lnum)
while s:get_level(lnum) >= ind &&
\ lnum != 0
while lnum != 0 && s:get_level(lnum) >= ind
if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
call add(result, lnum)
endif
@ -227,7 +222,7 @@ function! s:create_cb_list_item(lnum) "{{{
let m = matchstr(line, s:rx_list_item())
if m != ''
let li_content = substitute(strpart(line, len(m)), '^\s*', '', '')
let line = m.'[ ] '.li_content
let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content
call setline(a:lnum, line)
endif
endfunction "}}}
@ -321,7 +316,7 @@ function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
endfunction "}}}
function! vimwiki_lst#insertCR() "{{{
function! vimwiki_lst#kbd_cr() "{{{
" This function is heavily relies on proper 'set comments' option.
let cr = "\<CR>"
if getline('.') =~ s:rx_cb_list_item()
@ -330,7 +325,7 @@ function! vimwiki_lst#insertCR() "{{{
return cr
endfunction "}}}
function! vimwiki_lst#insertOo(cmd) "{{{
function! vimwiki_lst#kbd_oO(cmd) "{{{
" cmd should be 'o' or 'O'
let beg_lnum = foldclosed('.')
@ -343,11 +338,13 @@ function! vimwiki_lst#insertOo(cmd) "{{{
let lnum = line('.')
endif
" let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content
let m = matchstr(line, s:rx_list_item())
let res = ''
if line =~ s:rx_cb_list_item()
let res = matchstr(line, s:rx_list_item()).'[ ] '
let res = substitute(m, '\s*$', ' ', '').'[ ] '
elseif line =~ s:rx_list_item()
let res = matchstr(line, s:rx_list_item())
let res = substitute(m, '\s*$', ' ', '')
elseif &autoindent || &smartindent
let res = matchstr(line, '^\s*')
endif

View File

@ -19,6 +19,12 @@ let s:textwidth = &tw
" Misc functions {{{
function! s:wide_len(str) "{{{
" vim73 has new function that gives correct string width.
if exists("*strdisplaywidth")
return strdisplaywidth(a:str)
endif
" get str display width in vim ver < 7.2
if !g:vimwiki_CJK_length
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
else

View File

@ -9,7 +9,7 @@
|___| |___| |_| |_||__| |__||___| |___| |_||___| ~
Version: 1.0
Version: 1.1
==============================================================================
CONTENTS *vimwiki-contents*
@ -97,7 +97,7 @@ There are global and local mappings in vimwiki.
------------------------------------------------------------------------------
3.1. Global mappings *vimwiki-global-mappings*
[count]<Leader>ww or <Plug>VimwikiGoHome
[count]<Leader>ww or <Plug>VimwikiIndex
Open index file of the [count]'s wiki.
<Leader>ww opens first wiki from |g:vimwiki_list|.
@ -106,12 +106,12 @@ There are global and local mappings in vimwiki.
3<Leader>ww opens third wiki from |g:vimwiki_list|.
etc.
To remap: >
:map <Leader>w <Plug>VimwikiGoHome
:map <Leader>w <Plug>VimwikiIndex
<
See also|:VimwikiGoHome|
See also |:VimwikiIndex|
[count]<Leader>wt or <Plug>VimwikiTabGoHome
[count]<Leader>wt or <Plug>VimwikiTabIndex
Open index file of the [count]'s wiki in a new tab.
<Leader>wt tabopens first wiki from |g:vimwiki_list|.
@ -120,9 +120,9 @@ See also|:VimwikiGoHome|
3<Leader>wt tabopens third wiki from |g:vimwiki_list|.
etc.
To remap: >
:map <Leader>t <Plug>VimwikiTabGoHome
:map <Leader>t <Plug>VimwikiTabIndex
<
See also|:VimwikiTabGoHome|
See also |:VimwikiTabIndex|
<Leader>ws or <Plug>VimwikiUISelect
@ -174,56 +174,56 @@ See also|:VimwikiTabMakeDiaryNote|
NORMAL MODE *vimwiki-local-mappings*
*vimwiki_<CR>*
<CR> Follow/Create WikiWord.
Maps to|:VimwikiFollowWord|.
<CR> Follow/Create wiki link.
Maps to |:VimwikiFollowLink|.
To remap: >
:map <Leader>wf <Plug>VimwikiFollowWord
:map <Leader>wf <Plug>VimwikiFollowLink
<
*vimwiki_<S-CR>*
<S-CR> Split and follow/create WikiWord
Maps to|:VimwikiSplitWord|.
<S-CR> Split and follow/create wiki link.
Maps to |:VimwikiSplitLink|.
To remap: >
:map <Leader>we <Plug>VimwikiSplitWord
:map <Leader>we <Plug>VimwikiSplitLink
<
*vimwiki_<C-CR>*
<C-CR> Vertical split and follow/create WikiWord
Maps to|:VimwikiVSplitWord|.
<C-CR> Vertical split and follow/create wiki link.
Maps to |:VimwikiVSplitLink|.
To remap: >
:map <Leader>wq <Plug>VimwikiVSplitWord
:map <Leader>wq <Plug>VimwikiVSplitLink
<
*vimwiki_<Backspace>*
<Backspace> Go back to previous WikiWord
Maps to|:VimwikiGoBackWord|.
<Backspace> Go back to previous wiki link
Maps to |:VimwikiGoBackLink|.
To remap: >
:map <Leader>wb <Plug>VimwikiGoBackWord
:map <Leader>wb <Plug>VimwikiGoBackLink
<
*vimwiki_<Tab>*
<Tab> Find next WikiWord
Maps to|:VimwikiNextWord|.
<Tab> Find next wiki link.
Maps to |:VimwikiNextLink|.
To remap: >
:map <Leader>wn <Plug>VimwikiNextWord
:map <Leader>wn <Plug>VimwikiNextLink
<
*vimwiki_<S-Tab>*
<S-Tab> Find previous WikiWord
Maps to|:VimwikiPrevWord|.
<S-Tab> Find previous wiki link.
Maps to |:VimwikiPrevLink|.
To remap: >
:map <Leader>wp <Plug>VimwikiPrevWord
:map <Leader>wp <Plug>VimwikiPrevLink
<
*vimwiki_<Leader>wd*
<Leader>wd Delete WikiWord you are in.
Maps to|:VimwikiDeleteWord|.
<Leader>wd Delete wiki link you are in.
Maps to |:VimwikiDeleteLink|.
To remap: >
:map <Leader>dd <Plug>VimwikiDeleteWord
:map <Leader>dd <Plug>VimwikiDeleteLink
<
*vimwiki_<Leader>wr*
<Leader>wr Rename WikiWord you are in.
Maps to|:VimwikiRenameWord|.
<Leader>wr Rename wiki link you are in.
Maps to |:VimwikiRenameLink|.
To remap: >
:map <Leader>rr <Plug>VimwikiRenameWord
:map <Leader>rr <Plug>VimwikiRenameLink
<
*vimwiki_<C-Space>*
<C-Space> Toggle list item on/off (checked/unchecked)
Maps to|:VimwikiToggleListItem|.
Maps to |:VimwikiToggleListItem|.
To remap: >
:map <leader>tt <Plug>VimwikiToggleListItem
< See |vimwiki-todo-lists|.
@ -250,16 +250,23 @@ gww reformat it.
<A-Right> Move current table column to the right.
See |:VimwikiTableMoveColumnRight|
*vimwiki_<C-Up>*
<C-Up> Open previous day diary link if available.
See |:VimwikiDiaryPrevDay|
*vimwiki_<C-Down>*
<C-Down> Open next day diary link if available.
See |:VimwikiDiaryNextDay|
Works only if |g:vimwiki_use_mouse| is set to 1.
<2-LeftMouse> Follow/Create WikiWord
<2-LeftMouse> Follow/Create wiki link.
<S-2-LeftMouse> Split and follow/create WikiWord
<S-2-LeftMouse> Split and follow/create wiki link.
<C-2-LeftMouse> Vertical split and follow/create WikiWord
<C-2-LeftMouse> Vertical split and follow/create wiki link.
<RightMouse><LeftMouse> Go back to previous WikiWord
<RightMouse><LeftMouse> Go back to previous wiki link.
Note: <2-LeftMouse> is just left double click.
@ -298,10 +305,10 @@ ic Inner column in a table.
------------------------------------------------------------------------------
4.1. Global Commands *vimwiki-global-commands*
*:VimwikiGoHome*
*:VimwikiIndex*
Open index file of the current wiki.
*:VimwikiTabGoHome*
*:VimwikiTabIndex*
Open index file of the current wiki in a new tab.
*:VimwikiUISelect*
@ -316,36 +323,40 @@ ic Inner column in a table.
------------------------------------------------------------------------------
4.2. Local commands *vimwiki-local-commands*
*:VimwikiFollowWord*
Follow/create WikiWord.
*:VimwikiFollowLink*
Follow/create wiki link..
*:VimwikiGoBackWord*
Go back to previous WikiWord you come from.
*:VimwikiGoBackLink*
Go back to previous wiki link. you come from.
*:VimwikiSplitWord*
Split and follow/create WikiWord.
*:VimwikiSplitLink*
Split and follow/create wiki link..
*:VimwikiVSplitWord*
Vertical split and follow/create WikiWord.
*:VimwikiVSplitLink*
Vertical split and follow/create wiki link..
*:VimwikiNextWord*
Find next WikiWord.
*:VimwikiNextLink*
Find next wiki link..
*:VimwikiPrevWord*
Find previous WikiWord.
*:VimwikiPrevLink*
Find previous wiki link..
*:VimwikiGoto*
Goto link provided by an argument. For example: >
:VimwikiGoto HelloWorld
< opens opens/creates HelloWorld wiki page.
*:VimwikiDeleteLink*
Delete wiki link. you are in.
*:VimwikiDeleteWord*
Delete WikiWord you are in.
*:VimwikiRenameWord*
Rename WikiWord you are in.
*:VimwikiRenameLink*
Rename wiki link. you are in.
*:Vimwiki2HTML*
@ -405,6 +416,13 @@ ic Inner column in a table.
*:VimwikiGenerateLinks*
Insert all available links into current buffer.
*:VimwikiDiaryNextDay*
Open next day diary link if available.
Mapped to <C-Down>.
*:VimwikiDiaryPrevDay*
Open previous day diary link if available.
Mapped to <C-Up>.
==============================================================================
@ -768,6 +786,18 @@ or >
%toc Whatever
------------------------------------------------------------------------------
%title Title of the page *vimwiki-title*
When you htmlize your wiki page you have default title which is the filename
of the page.
Place >
%title My books
into your wiki page if you want another title.
------------------------------------------------------------------------------
%nohtml *vimwiki-nohtml*
@ -1063,7 +1093,7 @@ This header.tpl could look like: >
<div class="contents">
where
%title% is replaced by a wiki page name
%title% is replaced by a wiki page name or by a |vimwiki-title|
%root_path% is replaced by a count of ../ for pages buried in subdirs:
if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
%root_path% is replaced by '../../../'.
@ -1100,19 +1130,6 @@ or even >
\ 'css_name': 'css/main.css'}]
<
*vimwiki-option-gohome*
------------------------------------------------------------------------------
Key Default value Values~
gohome split split, vsplit, tabe
Description~
This option controls the way |:VimwikiGoHome| command works.
For instance you have 'No write since last change' buffer. After <Leader>ww
(or :VimwikiGoHome) vimwiki index file will be splitted with it. Or vertically
splitted. Or opened in a new tab.
Ex: >
let g:vimwiki_list = [{'path': '~/my_site/', 'gohome': 'vsplit'}]
<
*vimwiki-option-maxhi*
------------------------------------------------------------------------------
@ -1120,11 +1137,11 @@ Key Default value Values~
maxhi 1 0, 1
Description~
Non-existent WikiWord highlighting could be quite slow and if you don't want
Non-existent wiki links highlighting could be quite slow and if you don't want
it set maxhi to 0: >
let g:vimwiki_list = [{'path': '~/my_site/', 'maxhi': 0}]
This disables filesystem checks for WikiWords.
This disables filesystem checks for wiki links.
*vimwiki-option-nested_syntaxes*
@ -1478,6 +1495,9 @@ Value Description~
Default: 0
Note: Vim73 has new function |strdisplaywidth|, so for Vim73 users this option
is obsolete.
------------------------------------------------------------------------------
*g:vimwiki_dir_link*
@ -1558,6 +1578,42 @@ headers would look like: >
Default: '' (empty)
------------------------------------------------------------------------------
*g:vimwiki_file_exts*
Comma separated list of file extensions.
Consider you have the following link: [[my_script.php][my script]].
If there is 'php' extension in g:vimwiki_file_exts this link would be htmlized
to <a href="my_script.php">my script</a>.
Otherwise it would be <a href="my_script.php.html">my script</a> (note .html)
Default: 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz'
------------------------------------------------------------------------------
*g:vimwiki_valid_html_tags*
Comma separated list of html tags that can be used in vimwiki.
Default: 'b,i,s,u,sub,sup,kbd,br,hr'
------------------------------------------------------------------------------
*g:vimwiki_conceallevel*
In vim73 |conceallevel| is local to window, thus if you open viwmiki buffer in
a new tab or window, it would be set to default value.
Vimwiki sets |conceallevel| to g:vimwiki_conceallevel everytime vimwiki buffer
is entered.
Default: 3
==============================================================================
12. Help *vimwiki-help*
@ -1592,6 +1648,45 @@ Maxim Kim.
==============================================================================
14. Changelog *vimwiki-changelog*
1.1~
* NEW: Issue 57: Make it possible to have pre block inside list item.
* NEW: Issue 82: Add quick goto command. See |:VimwikiGoto|.
* NEW: Issue 83: Quick switch in diary. See |:VimwikiDiaryNextDay| and
|:VimwikiDiaryPrevDay| commands.
* FIX: Issue 84: Vimwiki rename removed the WikiWord display name.
* FIX: Issue 85: Errors if you have '~' subdirectory in a wiki directory.
* FIX: Issue 86: Existed links '[[WikiLink1|Alias1]] | [[WikiLink2]]' are
highlighted as a single link.
* FIX: Issue 88: Underline text. See |g:vimwiki_valid_html_tags|.
* FIX: Issue 92: Wikies in a subdir could be renamed to an empty file.
* FIX: Issue 93: Use alias name in html title. See |vimwiki-title|.
* FIX: Issue 94: Relative links to PHP files are broken. See
|g:vimwiki_file_exts| for details.
* FIX: Issue 96: Closing bracket at the end of weblink shouldn't be a part
of that link.
* FIX: Issue 97: Error opening weblink in a browser if it has # inside.
* FIX: Issue 99: Vim is not responing while opening arbitrary wiki file.
* FIX: Issue 100: Additional content on diary index page could be
corrupted.
* NEW: Issue 101: Customized HTML tags. See |g:vimwiki_valid_html_tags|
* NEW: Issue 102: Conceal feature usage. See |g:vimwiki_conceallevel|.
* FIX: Issue 103: Always highlight links to non-wiki files as existed.
* FIX: Issue 104: vimwiki#nested_syntax needs 'keepend' to avoid contained
language syntax eat needed '}}}'.
* FIX: Issue 105: <i_CR> on a todo list item with [ ] doesn't create new
todo list item.
* FIX: Issue 106: With MediaWiki syntax <C-Space> on a child todo list
item produce errors.
* FIX: Issue 107: With MediaWiki syntax <C-Space> on a list item creates
todo list item without space between * and [ ].
* FIX: Issue 110: Syntax highlighting doesn't work for indented codeblock.
* FIX: Issue 115: Nested Perl syntax highlighting differs from regular
one.
* MISC: Many vimwiki commands were renamed from Vimwiki.*Word to
Vimwiki.*Link. VimwikiGoHome is renamed to VimwikiIndex,
VimwikiTabGoHome to VimwikiTabIndex.
* MISC: vimwiki-option-gohome is removed.
1.0~
* NEW: Issue 41: Table cell and column text objects. See
|vimwiki-text-objects|.

View File

@ -21,6 +21,11 @@ let b:undo_ftplugin = "setlocal ".
setlocal autowriteall
setlocal commentstring=<!--%s-->
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
endif
" MISC }}}
" GOTO FILE: gf {{{
@ -38,32 +43,22 @@ else
endif
setlocal formatoptions=tnro
inoremap <buffer> <expr> <CR> vimwiki_lst#insertCR()
nnoremap <buffer> o :call vimwiki_lst#insertOo('o')<CR>a
nnoremap <buffer> O :call vimwiki_lst#insertOo('O')<CR>a
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
let l_o = matchstr(&langmap, '\C,\zs.\zeo,')
if l_o
exe 'nnoremap <buffer> '.l_o.' :call vimwiki_lst#insertOo("o")<CR>a'
exe 'nnoremap <buffer> '.l_o.' :call vimwiki_lst#kbd_oO("o")<CR>a'
endif
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
if l_O
exe 'nnoremap <buffer> '.l_O.' :call vimwiki_lst#insertOo("O")<CR>a'
exe 'nnoremap <buffer> '.l_O.' :call vimwiki_lst#kbd_oO("O")<CR>a'
endif
endif
" COMMENTS }}}
" FOLDING for headers and list items using expr fold method. {{{
if g:vimwiki_folding == 1
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
endif
function! VimwikiFoldLevel(lnum) "{{{
let line = getline(a:lnum)
@ -208,14 +203,14 @@ command! -buffer Vimwiki2HTML
command! -buffer VimwikiAll2HTML
\ call vimwiki_html#WikiAll2HTML(expand(VimwikiGet('path_html')))
command! -buffer VimwikiNextWord call vimwiki#WikiNextWord()
command! -buffer VimwikiPrevWord call vimwiki#WikiPrevWord()
command! -buffer VimwikiDeleteWord call vimwiki#WikiDeleteWord()
command! -buffer VimwikiRenameWord call vimwiki#WikiRenameWord()
command! -buffer VimwikiFollowWord call vimwiki#WikiFollowWord('nosplit')
command! -buffer VimwikiGoBackWord call vimwiki#WikiGoBackWord()
command! -buffer VimwikiSplitWord call vimwiki#WikiFollowWord('split')
command! -buffer VimwikiVSplitWord call vimwiki#WikiFollowWord('vsplit')
command! -buffer VimwikiNextLink call vimwiki#find_next_link()
command! -buffer VimwikiPrevLink call vimwiki#find_prev_link()
command! -buffer VimwikiDeleteLink call vimwiki#delete_link()
command! -buffer VimwikiRenameLink call vimwiki#rename_link()
command! -buffer VimwikiFollowLink call vimwiki#follow_link('nosplit')
command! -buffer VimwikiGoBackLink call vimwiki#go_back_link()
command! -buffer VimwikiSplitLink call vimwiki#follow_link('split')
command! -buffer VimwikiVSplitLink call vimwiki#follow_link('vsplit')
command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(<line1>, <line2>)
@ -227,6 +222,8 @@ exe 'command! -buffer -nargs=* VimwikiSearch vimgrep <args> '.
exe 'command! -buffer -nargs=* VWS vimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("<args>")
" table commands
command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create(<f-args>)
command! -buffer VimwikiTableAlignQ call vimwiki_tbl#align_or_cmd('gqq')
@ -234,65 +231,69 @@ command! -buffer VimwikiTableAlignW call vimwiki_tbl#align_or_cmd('gww')
command! -buffer VimwikiTableMoveColumnLeft call vimwiki_tbl#move_column_left()
command! -buffer VimwikiTableMoveColumnRight call vimwiki_tbl#move_column_right()
" diary commands
command! -buffer VimwikiDiaryNextDay call vimwiki_diary#goto_next_day()
command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day()
" COMMANDS }}}
" KEYBINDINGS {{{
if g:vimwiki_use_mouse
nmap <buffer> <S-LeftMouse> <NOP>
nmap <buffer> <C-LeftMouse> <NOP>
noremap <silent><buffer> <2-LeftMouse> :VimwikiFollowWord<CR>
noremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitWord<CR>
noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitWord<CR>
noremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackWord<CR>
noremap <silent><buffer> <2-LeftMouse> :VimwikiFollowLink<CR>
noremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
noremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
endif
if !hasmapto('<Plug>VimwikiFollowWord')
nmap <silent><buffer> <CR> <Plug>VimwikiFollowWord
if !hasmapto('<Plug>VimwikiFollowLink')
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiFollowWord :VimwikiFollowWord<CR>
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
if !hasmapto('<Plug>VimwikiSplitWord')
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitWord
if !hasmapto('<Plug>VimwikiSplitLink')
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiSplitWord :VimwikiSplitWord<CR>
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
if !hasmapto('<Plug>VimwikiVSplitWord')
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitWord
if !hasmapto('<Plug>VimwikiVSplitLink')
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiVSplitWord :VimwikiVSplitWord<CR>
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
if !hasmapto('<Plug>VimwikiGoBackWord')
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackWord
if !hasmapto('<Plug>VimwikiGoBackLink')
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiGoBackWord :VimwikiGoBackWord<CR>
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
if !hasmapto('<Plug>VimwikiNextWord')
nmap <silent><buffer> <TAB> <Plug>VimwikiNextWord
if !hasmapto('<Plug>VimwikiNextLink')
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiNextWord :VimwikiNextWord<CR>
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
if !hasmapto('<Plug>VimwikiPrevWord')
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevWord
if !hasmapto('<Plug>VimwikiPrevLink')
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiPrevWord :VimwikiPrevWord<CR>
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
if !hasmapto('<Plug>VimwikiDeleteWord')
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteWord
if !hasmapto('<Plug>VimwikiDeleteLink')
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiDeleteWord :VimwikiDeleteWord<CR>
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
if !hasmapto('<Plug>VimwikiRenameWord')
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameWord
if !hasmapto('<Plug>VimwikiRenameLink')
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiRenameWord :VimwikiRenameWord<CR>
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
if !hasmapto('<Plug>VimwikiToggleListItem')
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
@ -304,10 +305,35 @@ endif
noremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
if !hasmapto('<Plug>VimwikiDiaryNextDay')
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
endif
noremap <silent><script><buffer>
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
function! s:CR() "{{{
let res = vimwiki_lst#kbd_cr()
if res == "\<CR>" && g:vimwiki_table_auto_fmt
let res = vimwiki_tbl#kbd_cr()
endif
return res
endfunction "}}}
" List and Table <CR> mapping
inoremap <buffer> <expr> <CR> <SID>CR()
" List mappings
nnoremap <buffer> o :call vimwiki_lst#kbd_oO('o')<CR>a
nnoremap <buffer> O :call vimwiki_lst#kbd_oO('O')<CR>a
" Table mappings
if g:vimwiki_table_auto_fmt
inoremap <expr> <buffer> <CR> vimwiki_tbl#kbd_cr()
inoremap <expr> <buffer> <Tab> vimwiki_tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> vimwiki_tbl#kbd_shift_tab()
endif

View File

@ -72,7 +72,7 @@ function! s:setup_buffer_enter() "{{{
endif
if idx == -1
call add(g:vimwiki_list, {'path': path, 'ext': ext})
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'temp': 1})
let g:vimwiki_current_idx = len(g:vimwiki_list) - 1
else
let g:vimwiki_current_idx = idx
@ -81,52 +81,29 @@ function! s:setup_buffer_enter() "{{{
let b:vimwiki_idx = g:vimwiki_current_idx
endif
call s:setup_colors()
if &filetype != 'vimwiki'
setlocal ft=vimwiki
else
setlocal syntax=vimwiki
endif
" Update existed/non-existed links highlighting.
call vimwiki#highlight_links()
" 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.
" TODO: remove the same from ftplugin.
if g:vimwiki_folding == 1 && &fdm != 'expr'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
endif
" And conceal level too.
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
endif
endfunction "}}}
function! s:setup_colors()"{{{
if g:vimwiki_hl_headers == 0
return
endif
if &background == 'light'
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed
hi def VimwikiHeader2 guibg=bg guifg=#309010 gui=bold ctermfg=DarkGreen
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black
hi def VimwikiHeader5 guibg=bg guifg=#001020 gui=bold ctermfg=Black
hi def VimwikiHeader6 guibg=bg guifg=#000000 gui=bold ctermfg=Black
else
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White
endif
endfunction"}}}
" OPTION get/set functions {{{
" return value of option for current wiki or if second parameter exists for
" wiki with a given index.
@ -201,11 +178,13 @@ let s:vimwiki_defaults.index = 'index'
let s:vimwiki_defaults.ext = '.wiki'
let s:vimwiki_defaults.maxhi = 1
let s:vimwiki_defaults.syntax = 'default'
let s:vimwiki_defaults.gohome = 'split'
let s:vimwiki_defaults.html_header = ''
let s:vimwiki_defaults.html_footer = ''
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
" file.
let s:vimwiki_defaults.temp = 0
" diary
let s:vimwiki_defaults.diary_rel_path = 'diary/'
@ -265,9 +244,12 @@ call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('CJK_length', 0)
call s:default('dir_link', '')
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr')
call s:default('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 3)
call s:default('current_idx', 0)
@ -292,7 +274,8 @@ else
endif
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'.
\'[().,?]\@<!'
"}}}
" AUTOCOMMANDS for all known wiki extensions {{{
@ -316,12 +299,13 @@ augroup vimwiki
for ext in keys(extensions)
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
exe 'autocmd BufNewFile,BufRead, *'.ext.' setf vimwiki'
" ColorScheme could have or could have not a
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
" syntax after colorscheme change.
exe 'autocmd ColorScheme *'.ext.' call s:setup_colors()'.
\ ' | set syntax=vimwiki'
exe 'autocmd ColorScheme *'.ext.' call vimwiki#setup_colors()'.
\ ' | call vimwiki#highlight_links()'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
@ -334,11 +318,11 @@ augroup END
"}}}
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#WikiUISelect()
command! -count VimwikiGoHome
\ call vimwiki#WikiGoHome(v:count1)
command! -count VimwikiTabGoHome tabedit <bar>
\ call vimwiki#WikiGoHome(v:count1)
command! VimwikiUISelect call vimwiki#ui_select()
command! -count VimwikiIndex
\ call vimwiki#goto_index(v:count1)
command! -count VimwikiTabIndex tabedit <bar>
\ call vimwiki#goto_index(v:count1)
command! -count VimwikiMakeDiaryNote
\ call vimwiki_diary#make_note(v:count1)
@ -347,15 +331,15 @@ command! -count VimwikiTabMakeDiaryNote tabedit <bar>
"}}}
" MAPPINGS {{{
if !hasmapto('<Plug>VimwikiGoHome')
map <silent><unique> <Leader>ww <Plug>VimwikiGoHome
if !hasmapto('<Plug>VimwikiIndex')
map <silent><unique> <Leader>ww <Plug>VimwikiIndex
endif
noremap <unique><script> <Plug>VimwikiGoHome :VimwikiGoHome<CR>
noremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabGoHome')
map <silent><unique> <Leader>wt <Plug>VimwikiTabGoHome
if !hasmapto('<Plug>VimwikiTabIndex')
map <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
endif
noremap <unique><script> <Plug>VimwikiTabGoHome :VimwikiTabGoHome<CR>
noremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect')
map <silent><unique> <Leader>ws <Plug>VimwikiUISelect
@ -382,7 +366,7 @@ function! s:build_menu(topmenu)
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ ')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#WikiGoHome('.(idx + 1).')<CR>'
\ ' :call vimwiki#goto_index('.(idx + 1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
\ ' :call vimwiki_diary#make_note('.(idx + 1).')<CR>'
let idx += 1

View File

@ -10,25 +10,49 @@ elseif exists("b:current_syntax")
finish
endif
"" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
" Every WikiWord is nonexistent
if g:vimwiki_camel_case
execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiWord.'/'
endif
execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink1.'/'
execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink2.'/'
" till we find them in vimwiki's path
call vimwiki#WikiHighlightLinks()
else
" A WikiWord (unqualifiedWikiName)
execute 'syntax match VimwikiLink /\<'.g:vimwiki_rxWikiWord.'\>/'
" A [[bracketed wiki word]]
execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink1.'/'
execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink2.'/'
" Links highlighting is controlled by vimwiki#highlight_links() function.
" It is called from setup_buffer_enter() function in the BufEnter autocommand.
" Load concrete Wiki syntax
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" Concealed chars
if exists("+conceallevel")
syntax conceal on
endif
syn match VimwikiLinkChar contained /\[\[/
syn match VimwikiLinkChar contained /\]\]/
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.\{-}]]/
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}]\[\ze.\{-}]]/
syn match VimwikiNoLinkChar contained /\[\[/
syn match VimwikiNoLinkChar contained /\]\]/
syn match VimwikiNoLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.*]]/
syn match VimwikiNoLinkChar contained /\[\[[^\[\]\|]\{-}]\[\ze.*]]/
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'
if exists("+conceallevel")
syntax conceal off
endif
execute 'syntax match VimwikiLink `'.g:vimwiki_rxWeblink.'`'
" Non concealed chars
syn match VimwikiHeaderChar contained /\%(^\s*=\+\)\|\%(=\+\s*$\)/
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldCharT contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeCharT contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
" Emoticons
syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
@ -36,16 +60,14 @@ syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" Load concrete Wiki syntax
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" Tables
" execute 'syntax match VimwikiTable /'.g:vimwiki_rxTable.'/'
syntax match VimwikiTableRow /\s*|.\+|\s*/
\ transparent contains=VimwikiCellSeparator,VimwikiLink,
\ VimwikiNoExistsLink,VimwikiEmoticons,VimwikiTodo,
\ VimwikiBold,VimwikiItalic,VimwikiBoldItalic,VimwikiItalicBold,
\ VimwikiDelText,VimwikiSuperScript,VimwikiSubScript,VimwikiCode
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,VimwikiLinkT,
\ VimwikiNoExistsLinkT,VimwikiEmoticons,VimwikiTodo,
\ VimwikiBoldT,VimwikiItalicT,VimwikiBoldItalicT,VimwikiItalicBoldT,
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
@ -54,21 +76,29 @@ execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/'
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar'
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT'
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/'
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar'
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT'
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/'
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar'
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT'
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/'
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar'
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT'
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/'
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar'
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar'
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/'
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar'
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT'
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/'
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar'
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT'
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/'
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
@ -88,62 +118,107 @@ if g:vimwiki_hl_cb_checked
endif
" placeholders
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholderParam /\s.*/ contained
" html tags
syntax match VimwikiHTMLtag '<br\s*/\?>'
syntax match VimwikiHTMLtag '<hr\s*/\?>'
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
syntax region VimwikiComment start='<!--' end='-->'
if !vimwiki#hl_exists("VimwikiHeader1")
execute 'syntax match VimwikiHeader /'.g:vimwiki_rxHeader.'/ contains=VimwikiTodo'
if g:vimwiki_hl_headers == 0
execute 'syntax match VimwikiHeader /'.g:vimwiki_rxHeader.'/ contains=VimwikiTodo,VimwikiHeaderChar'
else
" Header levels, 1-6
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo,VimwikiHeaderChar'
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo,VimwikiHeaderChar'
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo,VimwikiHeaderChar'
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo,VimwikiHeaderChar'
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo,VimwikiHeaderChar'
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo,VimwikiHeaderChar'
endif
" group names "{{{
if !vimwiki#hl_exists("VimwikiHeader1")
hi def link VimwikiHeader Title
else
hi def link VimwikiHeader1 Title
hi def link VimwikiHeader2 Title
hi def link VimwikiHeader3 Title
hi def link VimwikiHeader4 Title
hi def link VimwikiHeader5 Title
hi def link VimwikiHeader6 Title
endif
call vimwiki#setup_colors()
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def link VimwikiBoldT VimwikiBold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def link VimwikiItalicT VimwikiItalic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def link VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic
hi def VimwikiUnderline gui=underline
hi def link VimwikiCode PreProc
hi def link VimwikiCodeT VimwikiCode
hi def link VimwikiNoExistsLink Error
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
hi def link VimwikiPre PreProc
hi def link VimwikiPreT VimwikiPre
hi def link VimwikiLink Underlined
hi def link VimwikiLinkT Underlined
hi def link VimwikiList Function
hi def link VimwikiCheckBox VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiEmoticons Character
hi def link VimwikiDelText Constant
hi def link VimwikiDelTextT VimwikiDelText
hi def link VimwikiSuperScript Number
hi def link VimwikiSuperScriptT VimwikiSuperScript
hi def link VimwikiSubScript Number
hi def link VimwikiSubScriptT VimwikiSubScript
hi def link VimwikiTodo Todo
hi def link VimwikiComment Comment
hi def link VimwikiCellSeparator SpecialKey
hi def link VimwikiCellSeparator PreProc
hi def link VimwikiPlaceholder SpecialKey
hi def link VimwikiPlaceholderParam String
hi def link VimwikiHTMLtag SpecialKey
hi def link VimwikiBoldChar VimwikiIgnore
hi def link VimwikiItalicChar VimwikiIgnore
hi def link VimwikiBoldItalicChar VimwikiIgnore
hi def link VimwikiItalicBoldChar VimwikiIgnore
hi def link VimwikiDelTextChar VimwikiIgnore
hi def link VimwikiSuperScriptChar VimwikiIgnore
hi def link VimwikiSubScriptChar VimwikiIgnore
hi def link VimwikiCodeChar VimwikiIgnore
hi def link VimwikiHeaderChar VimwikiIgnore
hi def link VimwikiLinkChar VimwikiLink
hi def link VimwikiNoLinkChar VimwikiNoExistsLink
hi def link VimwikiBoldCharT VimwikiIgnore
hi def link VimwikiItalicCharT VimwikiIgnore
hi def link VimwikiBoldItalicCharT VimwikiIgnore
hi def link VimwikiItalicBoldCharT VimwikiIgnore
hi def link VimwikiDelTextCharT VimwikiIgnore
hi def link VimwikiSuperScriptCharT VimwikiIgnore
hi def link VimwikiSubScriptCharT VimwikiIgnore
hi def link VimwikiCodeCharT VimwikiIgnore
hi def link VimwikiHeaderCharT VimwikiIgnore
hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoLinkCharT VimwikiNoExistsLinkT
"}}}
let b:current_syntax="vimwiki"
@ -153,9 +228,9 @@ let nested = VimwikiGet('nested_syntaxes')
if !empty(nested)
for [hl_syntax, vim_syntax] in items(nested)
call vimwiki#nested_syntax(vim_syntax,
\ '^{{{\%(.*[[:blank:][:punct:]]\)\?'.
\ '^\s*{{{\%(.*[[:blank:][:punct:]]\)\?'.
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ '^}}}', 'VimwikiPre')
\ '^\s*}}}', 'VimwikiPre')
endfor
endif
"}}}

View File

@ -11,6 +11,7 @@ let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bold = '*'
" text: _emphasis_
" let g:vimwiki_rxItalic = '_[^_]\+_'
@ -19,6 +20,7 @@ let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
@ -26,24 +28,30 @@ let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bolditalic = '\*_'
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italicbold = '_\*'
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
let g:vimwiki_char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
" Header levels, 1-6
let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$'
@ -59,12 +67,11 @@ let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'.
\ '\%('.g:vimwiki_rxH5.'\)\|'.
\ '\%('.g:vimwiki_rxH6.'\)'
let g:vimwiki_char_header = '\%(^\s*=\+\)\|\%(=\+\s*$\)'
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^----.*$'
" Tables. Each line starts and ends with '||'; each cell is separated by '||'
let g:vimwiki_rxTable = '||'
" List items start with optional whitespace(s) then '* ' or '# '
let g:vimwiki_rxListBullet = '^\s*\%(\*\|-\)\s'
let g:vimwiki_rxListNumber = '^\s*#\s'

View File

@ -6,25 +6,33 @@
" text: '''strong'''
let g:vimwiki_rxBold = "'''[^']\\+'''"
let g:vimwiki_char_bold = "'''"
" text: ''emphasis''
let g:vimwiki_rxItalic = "''[^']\\+''"
let g:vimwiki_char_italic = "''"
" text: '''''strong italic'''''
let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''"
let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic
let g:vimwiki_char_bolditalic = "'''''"
let g:vimwiki_char_italicbold = g:vimwiki_char_bolditalic
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^]\+\^'
let g:vimwiki_char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,]\+,,'
let g:vimwiki_char_subscript = ',,'
" Header levels, 1-6
let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$'
@ -39,6 +47,7 @@ let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'.
\ '\%('.g:vimwiki_rxH4.'\)\|'.
\ '\%('.g:vimwiki_rxH5.'\)\|'.
\ '\%('.g:vimwiki_rxH6.'\)'
let g:vimwiki_char_header = '\%(^\s*=\+\)\|\%(=\+\s*$\)'
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^----.*$'