From 458c4539e5e2138bcddd4e38dc2142d27c1e62ef Mon Sep 17 00:00:00 2001 From: Maxim Kim Date: Tue, 24 Aug 2010 00:00:00 +0000 Subject: [PATCH] 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: on a todo list item with [ ] doesn't create new todo list item. * FIX: Issue 106: With MediaWiki syntax on a child todo list item produce errors. * FIX: Issue 107: With MediaWiki syntax 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. --- autoload/vimwiki.vim | 290 +++++++++++++++++++++++++++---------- autoload/vimwiki_diary.vim | 65 ++++++++- autoload/vimwiki_html.vim | 120 ++++++++------- autoload/vimwiki_lst.vim | 21 ++- autoload/vimwiki_tbl.vim | 6 + doc/vimwiki.txt | 239 +++++++++++++++++++++--------- ftplugin/vimwiki.vim | 124 +++++++++------- plugin/vimwiki.vim | 78 ++++------ syntax/vimwiki.vim | 187 +++++++++++++++++------- syntax/vimwiki_default.vim | 13 +- syntax/vimwiki_media.vim | 9 ++ 11 files changed, 784 insertions(+), 368 deletions(-) diff --git a/autoload/vimwiki.vim b/autoload/vimwiki.vim index 61c2972..c023ce2 100644 --- a/autoload/vimwiki.vim +++ b/autoload/vimwiki.vim @@ -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 =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link) + execute 'syntax match VimwikiLink /!\@/ 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 "}}} diff --git a/autoload/vimwiki_diary.vim b/autoload/vimwiki_diary.vim index 37b7eed..9803cc1 100644 --- a/autoload/vimwiki_diary.vim +++ b/autoload/vimwiki_diary.vim @@ -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 "}}} diff --git a/autoload/vimwiki_html.vim b/autoload/vimwiki_html.vim index 3c88ecc..1efa539 100644 --- a/autoload/vimwiki_html.vim +++ b/autoload/vimwiki_html.vim @@ -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, '') call add(lines, '') - call add(lines, ''.title.'') + call add(lines, ''.a:title.'') call add(lines, '') call add(lines, '') @@ -171,11 +161,13 @@ function! s:safe_html(line) "{{{ let line = substitute(a:line, '&', '\&', 'g') - " let line = substitute(line, '<', '\<', 'g') - " let line = substitute(line, '>', '\>', 'g') - " XXX: I believe there should be a much nicer way to do it. - let line = substitute(line, '<\(br\|hr\)\@!', '\<', 'g') - let line = substitute(line, '\(\(br\|hr\)\s*/\?\)\@', '\>', 'g') + let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|') + let line = substitute(line,'<\%(/\?\%(' + \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!', + \'\<', 'g') + let line = substitute(line,'\%(', + \'\>', '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, '

'.param.'

') + call insert(toc, '

'.param.'

') 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 = ''. \ '' - elseif s:is_non_wiki_link(a:src) + elseif vimwiki#is_non_wiki_link(a:src) let link = ''.a:caption.'' elseif s:is_img_link(a:src) let link = ''.a:caption.'' @@ -592,8 +597,8 @@ endfunction " }}} " BLOCK TAGS {{{ function! s:close_tag_pre(pre, ldest) "{{{ - if a:pre - call insert(a:ldest, "") + if a:pre[0] + call insert(a:ldest, "") 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, "
")
     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, "
") 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, "
") @@ -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, "
") 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) diff --git a/autoload/vimwiki_lst.vim b/autoload/vimwiki_lst.vim index 497bff3..fcdfe36 100644 --- a/autoload/vimwiki_lst.vim +++ b/autoload/vimwiki_lst.vim @@ -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 = "\" 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 diff --git a/autoload/vimwiki_tbl.vim b/autoload/vimwiki_tbl.vim index f61ce67..251c0ae 100644 --- a/autoload/vimwiki_tbl.vim +++ b/autoload/vimwiki_tbl.vim @@ -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 diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 6050c58..8cae209 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -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]ww or VimwikiGoHome +[count]ww or VimwikiIndex Open index file of the [count]'s wiki. ww opens first wiki from |g:vimwiki_list|. @@ -106,12 +106,12 @@ There are global and local mappings in vimwiki. 3ww opens third wiki from |g:vimwiki_list|. etc. To remap: > - :map w VimwikiGoHome + :map w VimwikiIndex < -See also|:VimwikiGoHome| +See also |:VimwikiIndex| -[count]wt or VimwikiTabGoHome +[count]wt or VimwikiTabIndex Open index file of the [count]'s wiki in a new tab. wt tabopens first wiki from |g:vimwiki_list|. @@ -120,9 +120,9 @@ See also|:VimwikiGoHome| 3wt tabopens third wiki from |g:vimwiki_list|. etc. To remap: > - :map t VimwikiTabGoHome + :map t VimwikiTabIndex < -See also|:VimwikiTabGoHome| +See also |:VimwikiTabIndex| ws or VimwikiUISelect @@ -174,56 +174,56 @@ See also|:VimwikiTabMakeDiaryNote| NORMAL MODE *vimwiki-local-mappings* *vimwiki_* - Follow/Create WikiWord. - Maps to|:VimwikiFollowWord|. + Follow/Create wiki link. + Maps to |:VimwikiFollowLink|. To remap: > - :map wf VimwikiFollowWord + :map wf VimwikiFollowLink < *vimwiki_* - Split and follow/create WikiWord - Maps to|:VimwikiSplitWord|. + Split and follow/create wiki link. + Maps to |:VimwikiSplitLink|. To remap: > - :map we VimwikiSplitWord + :map we VimwikiSplitLink < *vimwiki_* - Vertical split and follow/create WikiWord - Maps to|:VimwikiVSplitWord|. + Vertical split and follow/create wiki link. + Maps to |:VimwikiVSplitLink|. To remap: > - :map wq VimwikiVSplitWord + :map wq VimwikiVSplitLink < *vimwiki_* - Go back to previous WikiWord - Maps to|:VimwikiGoBackWord|. + Go back to previous wiki link + Maps to |:VimwikiGoBackLink|. To remap: > - :map wb VimwikiGoBackWord + :map wb VimwikiGoBackLink < *vimwiki_* - Find next WikiWord - Maps to|:VimwikiNextWord|. + Find next wiki link. + Maps to |:VimwikiNextLink|. To remap: > - :map wn VimwikiNextWord + :map wn VimwikiNextLink < *vimwiki_* - Find previous WikiWord - Maps to|:VimwikiPrevWord|. + Find previous wiki link. + Maps to |:VimwikiPrevLink|. To remap: > - :map wp VimwikiPrevWord + :map wp VimwikiPrevLink < *vimwiki_wd* -wd Delete WikiWord you are in. - Maps to|:VimwikiDeleteWord|. +wd Delete wiki link you are in. + Maps to |:VimwikiDeleteLink|. To remap: > - :map dd VimwikiDeleteWord + :map dd VimwikiDeleteLink < *vimwiki_wr* -wr Rename WikiWord you are in. - Maps to|:VimwikiRenameWord|. +wr Rename wiki link you are in. + Maps to |:VimwikiRenameLink|. To remap: > - :map rr VimwikiRenameWord + :map rr VimwikiRenameLink < *vimwiki_* Toggle list item on/off (checked/unchecked) - Maps to|:VimwikiToggleListItem|. + Maps to |:VimwikiToggleListItem|. To remap: > :map tt VimwikiToggleListItem < See |vimwiki-todo-lists|. @@ -250,16 +250,23 @@ gww reformat it. Move current table column to the right. See |:VimwikiTableMoveColumnRight| + *vimwiki_* + Open previous day diary link if available. + See |:VimwikiDiaryPrevDay| + + *vimwiki_* + 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. - Split and follow/create WikiWord + Split and follow/create wiki link. - Vertical split and follow/create WikiWord + Vertical split and follow/create wiki link. - Go back to previous WikiWord + 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 . + +*:VimwikiDiaryPrevDay* + Open previous day diary link if available. + Mapped to . ============================================================================== @@ -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: >
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 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 my script. +Otherwise it would be my script (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: on a todo list item with [ ] doesn't create new + todo list item. + * FIX: Issue 106: With MediaWiki syntax on a child todo list + item produce errors. + * FIX: Issue 107: With MediaWiki syntax 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|. diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 807d1f5..be97b29 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -21,6 +21,11 @@ let b:undo_ftplugin = "setlocal ". setlocal autowriteall setlocal commentstring= + +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 vimwiki_lst#insertCR() -nnoremap o :call vimwiki_lst#insertOo('o')a -nnoremap O :call vimwiki_lst#insertOo('O')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 '.l_o.' :call vimwiki_lst#insertOo("o")a' + exe 'nnoremap '.l_o.' :call vimwiki_lst#kbd_oO("o")a' endif let l_O = matchstr(&langmap, '\C,\zs.\zeO,') if l_O - exe 'nnoremap '.l_O.' :call vimwiki_lst#insertOo("O")a' + exe 'nnoremap '.l_O.' :call vimwiki_lst#kbd_oO("O")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(, ) @@ -227,6 +222,8 @@ exe 'command! -buffer -nargs=* VimwikiSearch vimgrep '. exe 'command! -buffer -nargs=* VWS vimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') +command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("") + " table commands command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create() 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 nmap - noremap <2-LeftMouse> :VimwikiFollowWord - noremap :VimwikiSplitWord - noremap :VimwikiVSplitWord - noremap :VimwikiGoBackWord + noremap <2-LeftMouse> :VimwikiFollowLink + noremap :VimwikiSplitLink + noremap :VimwikiVSplitLink + noremap :VimwikiGoBackLink endif -if !hasmapto('VimwikiFollowWord') - nmap VimwikiFollowWord +if !hasmapto('VimwikiFollowLink') + nmap VimwikiFollowLink endif noremap