From 84297c90516c40df5c6e224930c3bd92a8046efd Mon Sep 17 00:00:00 2001 From: Maxim Kim Date: Sat, 11 Jun 2011 00:00:00 +0000 Subject: [PATCH] Version 1.2 = Note = Remove previous version of vimwiki before install - files in autoload dir is moved/renamed to autoload/vimwiki dir. = Changelog = * Issue 70: Table spanning cell support. * Issue 72: Do not convert again for unchanged file. |:VimwikiAll2HTML| converts only changed wiki files. * Issue 117: |VimwikiDiaryIndex| command that opens diary index wiki page. * Issue 120: Links in headers are not highlighted in vimwiki but are highlighted in HTML. * Issue 138: Added possibility to remap table-column move bindings. See |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight| commands. For remap instructions see |vimwiki_| and |vimwiki_|. * Issue 125: Problem with 'o' command given while at the of the file. * Issue 131: FileType is not set up when GUIEnter autocommand is used in vimrc. Use 'nested' in 'au GUIEnter * nested VimwikiIndex' * Issue 132: Link to perl (or any non-wiki) file in vimwiki subdirectory doesn't work as intended. * Issue 135: %title and %toc used together cause TOC to appear in an unexpected place in HTML. * Issue 139: |:VimwikiTabnewLink| command is added. * Fix of g:vimwiki_stripsym = '' (i.e. an empty string) -- it removes bad symbols from filenames. * Issue 145: With modeline 'set ft=vimwiki' links are not correctly highlighted when open wiki files. * Issue 146: Filetype difficulty with ".txt" as a vimwiki extension. * Issue 148: There are no mailto links. * Issue 151: Use location list instead of quickfix list for :VimwikiSearch command result. Use :lopen instead of :copen, :lnext instead of :cnext etc. * Issue 152: Add the list of HTML files that would not be deleted after |:VimwikiAll2HTML|. * Issue 153: Delete HTML files that has no corresponding wiki ones with |:VimwikiAll2HTML|. * Issue 156: Add multiple HTML templates. See |vimwiki-option-template_path|. Options html_header and html_footer are no longer exist. * Issue 173: When virtualedit=all option is enabled the 'o' command behave strange. * Issue 178: Problem with alike wikie's paths. * Issue 182: Browser command does not quote url. * Issue 183: Spelling error highlighting is not possible with nested syntaxes. * Issue 184: Wrong foldlevel in some cases. * Issue 195: Page renaming issue. * Issue 196: vim: modeline bug -- syn=vim doesn't work. * Issue 199: Generated HTML for sublists is invalid. * Issue 200: Generated HTML for todo lists does not show completion status the fix relies on CSS, thus your old stylesheets need to be updated!; may not work in obsolete browsers or font-deficient systems. * Issue 205: Block code: highlighting differs from processing. Inline code block {{{ ... }}} is removed. Use `...` instead. * Issue 208: Default highlight colors are problematic in many colorschemes. Headers are highlighted as |hl-Title| by default, use |g:vimwiki_hl_headers| to restore previous default Red, Green, Blue or custom header colors. Some other changes in highlighting. * Issue 209: Wild comments slow down html generation. Comments are changed, use %% to comment out entire line. * Issue 210: HTML: para enclose header. * Issue 214: External links containing Chinese characters get trimmed. * Issue 218: Command to generate HTML file and open it in webbrowser. See |:Vimwiki2HTMLBrowse|(bind to whh) * NEW: Added wh mapping to call |:Vimwiki2HTML| --- README | 7 +- autoload/{vimwiki.vim => vimwiki/base.vim} | 238 +++--- autoload/vimwiki/default.tpl | 11 + .../{vimwiki_diary.vim => vimwiki/diary.vim} | 27 +- .../{vimwiki_html.vim => vimwiki/html.vim} | 514 ++++++++----- autoload/{vimwiki_lst.vim => vimwiki/lst.vim} | 70 +- autoload/vimwiki/style.css | 39 + autoload/{vimwiki_tbl.vim => vimwiki/tbl.vim} | 28 +- doc/vimwiki.txt | 694 +++++++++++------- ftplugin/vimwiki.vim | 180 +++-- plugin/vimwiki.vim | 133 ++-- syntax/vimwiki.vim | 143 ++-- syntax/vimwiki_default.vim | 2 + syntax/vimwiki_media.vim | 2 + 14 files changed, 1276 insertions(+), 812 deletions(-) rename autoload/{vimwiki.vim => vimwiki/base.vim} (82%) create mode 100644 autoload/vimwiki/default.tpl rename autoload/{vimwiki_diary.vim => vimwiki/diary.vim} (89%) rename autoload/{vimwiki_html.vim => vimwiki/html.vim} (75%) rename autoload/{vimwiki_lst.vim => vimwiki/lst.vim} (87%) create mode 100644 autoload/vimwiki/style.css rename autoload/{vimwiki_tbl.vim => vimwiki/tbl.vim} (94%) diff --git a/README b/README index eafb185..d0556ae 100644 --- a/README +++ b/README @@ -5,8 +5,7 @@ A Personal Wiki For Vim Plugin Screenshots are available on http://code.google.com/p/vimwiki/ There are also zipped vimwiki files there in case you do not like vimball archives. -Vimwiki quick reference card http://habamax.ru/myvim/data/vimwikiqrc.pdf by J.A.J. Pater. -Thx Gager Jacob for the update. +Vimwiki quick reference card http://vimwiki.googlecode.com/hg/misc/Vimwiki1.1.1QR.pdf. Prerequisites @@ -42,8 +41,8 @@ Feed it with the following example: * ScratchPad -- various temporary stuff. -Notice that ProjectGutenberg, MyUrgentTasks and ScratchPad highlighted as -errors. These are links in CamelCase form that do not exists yet. (CamelCase +Notice that !ProjectGutenberg, !MyUrgentTasks and !ScratchPad curly underlined. +These are links in CamelCase form that do not exists yet. (CamelCase form -- capitalized word connected with other capitalized words) Place cursor on ProjectGutenberg and press . Now you are in diff --git a/autoload/vimwiki.vim b/autoload/vimwiki/base.vim similarity index 82% rename from autoload/vimwiki.vim rename to autoload/vimwiki/base.vim index db98cc1..b56eff6 100644 --- a/autoload/vimwiki.vim +++ b/autoload/vimwiki/base.vim @@ -18,14 +18,18 @@ let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]' " MISC helper functions {{{ -function! vimwiki#chomp_slash(str) "{{{ +function! vimwiki#base#chomp_slash(str) "{{{ return substitute(a:str, '[/\\]\+$', '', '') endfunction "}}} -function! vimwiki#mkdir(path) "{{{ +function! vimwiki#base#path_norm(path) "{{{ + return substitute(a:path, '\', '/', 'g') +endfunction "}}} + +function! vimwiki#base#mkdir(path) "{{{ let path = expand(a:path) if !isdirectory(path) && exists("*mkdir") - let path = vimwiki#chomp_slash(path) + let path = vimwiki#base#chomp_slash(path) if s:is_windows() && !empty(g:vimwiki_w32_dir_enc) let path = iconv(path, &enc, g:vimwiki_w32_dir_enc) endif @@ -34,17 +38,30 @@ function! vimwiki#mkdir(path) "{{{ endfunction " }}} -function! vimwiki#safe_link(string) "{{{ - return substitute(a:string, s:badsymbols, g:vimwiki_stripsym, 'g') +function! vimwiki#base#safe_link(link) "{{{ + " handling Windows absolute paths + if a:link =~ '^[[:alpha:]]:[/\\].*' + let link_start = a:link[0 : 2] + let link = a:link[3 : ] + else + let link_start = '' + let link = a:link + endif + let link = substitute(link, s:badsymbols, g:vimwiki_stripsym, 'g') + return link_start.link endfunction "}}} -function! vimwiki#unsafe_link(string) "{{{ - return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g') +function! vimwiki#base#unsafe_link(string) "{{{ + if len(g:vimwiki_stripsym) > 0 + return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g') + else + return a:string + endif endfunction "}}} -function! vimwiki#subdir(path, filename)"{{{ +function! vimwiki#base#subdir(path, filename)"{{{ let path = expand(a:path) let filename = expand(a:filename) let idx = 0 @@ -60,13 +77,17 @@ function! vimwiki#subdir(path, filename)"{{{ return res endfunction"}}} -function! vimwiki#current_subdir()"{{{ - return vimwiki#subdir(VimwikiGet('path'), expand('%:p')) +function! vimwiki#base#current_subdir()"{{{ + return vimwiki#base#subdir(VimwikiGet('path'), expand('%:p')) endfunction"}}} -function! vimwiki#open_link(cmd, link, ...) "{{{ - if vimwiki#is_non_wiki_link(a:link) - call s:edit_file(a:cmd, a:link) +function! vimwiki#base#open_link(cmd, link, ...) "{{{ + if vimwiki#base#is_non_wiki_link(a:link) + if s:is_path_absolute(a:link) + call vimwiki#base#edit_file(a:cmd, a:link) + else + call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link) + endif else if a:0 let vimwiki_prev_link = [a:1, []] @@ -74,17 +95,17 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ let vimwiki_prev_link = [expand('%:p'), getpos('.')] endif - if vimwiki#is_link_to_dir(a:link) + if vimwiki#base#is_link_to_dir(a:link) if g:vimwiki_dir_link == '' - call s:edit_file(a:cmd, VimwikiGet('path').a:link) + call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link) else - call s:edit_file(a:cmd, + call vimwiki#base#edit_file(a:cmd, \ VimwikiGet('path').a:link. \ g:vimwiki_dir_link. \ VimwikiGet('ext')) endif else - call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext')) + call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext')) endif if exists('vimwiki_prev_link') @@ -94,7 +115,7 @@ function! vimwiki#open_link(cmd, link, ...) "{{{ endfunction " }}} -function! vimwiki#select(wnum)"{{{ +function! vimwiki#base#select(wnum)"{{{ if a:wnum < 1 || a:wnum > len(g:vimwiki_list) return endif @@ -105,7 +126,7 @@ function! vimwiki#select(wnum)"{{{ endfunction " }}} -function! vimwiki#generate_links()"{{{ +function! vimwiki#base#generate_links()"{{{ let links = s:get_links('*'.VimwikiGet('ext')) " We don't want link to itself. @@ -127,8 +148,8 @@ function! vimwiki#generate_links()"{{{ endfor endfunction " }}} -function! vimwiki#goto(key) "{{{ - call s:edit_file(':e', +function! vimwiki#base#goto(key) "{{{ + call vimwiki#base#edit_file(':e', \ VimwikiGet('path'). \ a:key. \ VimwikiGet('ext')) @@ -138,9 +159,13 @@ function! s:is_windows() "{{{ return has("win32") || has("win64") || has("win95") || has("win16") endfunction "}}} +function! s:is_path_absolute(path) "{{{ + return a:path =~ '^/.*' || a:path =~ '^[[:alpha:]]:[/\\].*' +endfunction "}}} + function! s:get_links(pat) "{{{ " search all wiki files in 'path' and its subdirs. - let subdir = vimwiki#current_subdir() + let subdir = vimwiki#base#current_subdir() " 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 @@ -173,11 +198,11 @@ function! s:cursor(lnum, cnum) "{{{ endfunction "}}} function! s:filename(link) "{{{ - let result = vimwiki#safe_link(a:link) + let result = vimwiki#base#safe_link(a:link) if a:link =~ '|' - let result = vimwiki#safe_link(split(a:link, '|')[0]) + let result = vimwiki#base#safe_link(split(a:link, '|')[0]) elseif a:link =~ '][' - let result = vimwiki#safe_link(split(a:link, '][')[0]) + let result = vimwiki#base#safe_link(split(a:link, '][')[0]) endif return result endfunction @@ -191,10 +216,15 @@ function! s:is_wiki_word(str) "{{{ endfunction " }}} -function! s:edit_file(command, filename) "{{{ +function! vimwiki#base#edit_file(command, filename) "{{{ let fname = escape(a:filename, '% ') - call vimwiki#mkdir(fnamemodify(a:filename, ":p:h")) - execute a:command.' '.fname + call vimwiki#base#mkdir(fnamemodify(a:filename, ":p:h")) + try + execute a:command.' '.fname + catch /E37/ " catch 'No write since last change' error + execute ':split '.fname + catch /E325/ " catch 'ATTENTION' error (:h E325) + endtry endfunction " }}} @@ -242,13 +272,13 @@ function! s:strip_word(word) "{{{ let w = split(w, "][")[0] endif - let result = vimwiki#safe_link(w) + let result = vimwiki#base#safe_link(w) endif return result endfunction " }}} -function! vimwiki#is_non_wiki_link(lnk) "{{{ +function! vimwiki#base#is_non_wiki_link(lnk) "{{{ let exts = '.\+\.\%('. \ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|'). \ '\)$' @@ -258,7 +288,7 @@ function! vimwiki#is_non_wiki_link(lnk) "{{{ return 0 endfunction "}}} -function! vimwiki#is_link_to_dir(link) "{{{ +function! vimwiki#base#is_link_to_dir(link) "{{{ " Check if link is to a directory. " It should be ended with \ or /. if a:link =~ '.\+[/\\]$' @@ -314,10 +344,10 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{ endif if !s:is_wiki_word(old_fname) - let old_fname_r = '\[\[\zs'.vimwiki#unsafe_link(old_fname). + let old_fname_r = '\[\[\zs'.vimwiki#base#unsafe_link(old_fname). \ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]' else - let old_fname_r = '\<'.old_fname.'\>' + let old_fname_r = '!\@' endif let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n') @@ -383,7 +413,7 @@ function! s:get_wiki_buffers() "{{{ endfunction " }}} function! s:open_wiki_buffer(item) "{{{ - call s:edit_file('e', a:item[0]) + call vimwiki#base#edit_file(':e', a:item[0]) if !empty(a:item[1]) call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1]) endif @@ -392,7 +422,7 @@ endfunction " }}} " }}} " SYNTAX highlight {{{ -function! vimwiki#highlight_links() "{{{ +function! vimwiki#base#highlight_links() "{{{ try syntax clear VimwikiNoExistsLink syntax clear VimwikiNoExistsLinkT @@ -442,21 +472,21 @@ function! s:highlight_existed_links() "{{{ for link in links if g:vimwiki_camel_case && - \ link =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link) + \ link =~ g:vimwiki_rxWikiWord && !vimwiki#base#is_non_wiki_link(link) execute 'syntax match VimwikiLink /!\@/ display' endif execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\%(|\+.\{-}\)\{-}\]\]/ display contained' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(link), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(link), '~&$.*'). \ '\]\[.\{-1,}\]\]/ display contained' endfor execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar' @@ -485,76 +515,22 @@ function! s:highlight_existed_links() "{{{ call map(dirs, 'substitute(v:val, os_p, os_p2, "g")') for dir in dirs execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLink /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#unsafe_link(dir), '~&$.*'). \ '[/\\]*\%(|\+.*\)*\]\]/ display contained' execute 'syntax match VimwikiLinkT /\[\['. - \ escape(vimwiki#unsafe_link(dir), '~&$.*'). + \ escape(vimwiki#base#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 - try - exe "silent hi ".a:hgroup - catch /E411/ - endtry - redir END - return matchstr(hlstatus, a:hparam.'\s*=\s*\zs\S\+') -endfunction "}}} - -function! vimwiki#hl_exists(hl) "{{{ +function! vimwiki#base#hl_exists(hl) "{{{ if !hlexists(a:hl) return 0 endif @@ -565,7 +541,7 @@ function! vimwiki#hl_exists(hl) "{{{ endfunction "}}} -function! vimwiki#nested_syntax(filetype, start, end, textSnipHl) abort "{{{ +function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{{ " From http://vim.wikia.com/wiki/VimTip857 let ft=toupper(a:filetype) let group='textGroup'.ft @@ -615,21 +591,23 @@ endfunction "}}} "}}} " WIKI functions {{{ -function! vimwiki#find_next_link() "{{{ +function! vimwiki#base#find_next_link() "{{{ call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '') endfunction " }}} -function! vimwiki#find_prev_link() "{{{ +function! vimwiki#base#find_prev_link() "{{{ call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b') endfunction " }}} -function! vimwiki#follow_link(split) "{{{ +function! vimwiki#base#follow_link(split) "{{{ if a:split == "split" let cmd = ":split " elseif a:split == "vsplit" let cmd = ":vsplit " + elseif a:split == "tabnew" + let cmd = ":tabnew " else let cmd = ":e " endif @@ -645,12 +623,12 @@ function! vimwiki#follow_link(split) "{{{ return endif - let subdir = vimwiki#current_subdir() - call vimwiki#open_link(cmd, subdir.link) + let subdir = vimwiki#base#current_subdir() + call vimwiki#base#open_link(cmd, subdir.link) endfunction " }}} -function! vimwiki#go_back_link() "{{{ +function! vimwiki#base#go_back_link() "{{{ if exists("b:vimwiki_prev_link") " go back to saved WikiWord let prev_word = b:vimwiki_prev_link @@ -659,23 +637,13 @@ function! vimwiki#go_back_link() "{{{ endif endfunction " }}} -function! vimwiki#goto_index(index) "{{{ - call vimwiki#select(a:index) - call vimwiki#mkdir(VimwikiGet('path')) - - try - execute ':e '.fnameescape( - \ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext')) - catch /E37/ " catch 'No write since last change' error - execute ':split '. - \ VimwikiGet('path'). - \ VimwikiGet('index'). - \ VimwikiGet('ext') - catch /E325/ " catch 'ATTENTION' error (:h E325) - endtry +function! vimwiki#base#goto_index(index) "{{{ + call vimwiki#base#select(a:index) + call vimwiki#base#edit_file('e', + \ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext')) endfunction "}}} -function! vimwiki#delete_link() "{{{ +function! vimwiki#base#delete_link() "{{{ "" file system funcs "" Delete WikiWord you are in from filesystem let val = input('Delete ['.expand('%').'] (y/n)? ', "") @@ -697,9 +665,9 @@ function! vimwiki#delete_link() "{{{ endif endfunction "}}} -function! vimwiki#rename_link() "{{{ +function! vimwiki#base#rename_link() "{{{ "" Rename WikiWord, update all links to renamed WikiWord - let subdir = vimwiki#current_subdir() + let subdir = vimwiki#base#current_subdir() let old_fname = subdir.expand('%:t') " there is no file (new one maybe) @@ -727,7 +695,7 @@ function! vimwiki#rename_link() "{{{ echomsg 'vimwiki: Cannot rename to an empty filename!' return endif - if vimwiki#is_non_wiki_link(new_link) + if vimwiki#base#is_non_wiki_link(new_link) echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!' return endif @@ -797,13 +765,13 @@ function! vimwiki#rename_link() "{{{ let &more = setting_more endfunction " }}} -function! vimwiki#ui_select()"{{{ +function! vimwiki#base#ui_select()"{{{ call s:print_wiki_list() let idx = input("Select Wiki (specify number): ") if idx == "" return endif - call vimwiki#goto_index(idx) + call vimwiki#base#goto_index(idx) endfunction "}}} @@ -811,7 +779,7 @@ endfunction " TEXT OBJECTS functions {{{ -function! vimwiki#TO_header(inner, visual) "{{{ +function! vimwiki#base#TO_header(inner, visual) "{{{ if !search('^\(=\+\).\+\1\s*$', 'bcW') return endif @@ -821,7 +789,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ let block_start = line(".") let advance = 0 - let level = vimwiki#count_first_sym(getline('.')) + let level = vimwiki#base#count_first_sym(getline('.')) let is_header_selected = sel_start == block_start \ && sel_start != sel_end @@ -854,7 +822,7 @@ function! vimwiki#TO_header(inner, visual) "{{{ endfunction "}}} -function! vimwiki#TO_table_cell(inner, visual) "{{{ +function! vimwiki#base#TO_table_cell(inner, visual) "{{{ if col('.') == col('$')-1 return endif @@ -918,7 +886,7 @@ function! vimwiki#TO_table_cell(inner, visual) "{{{ endif endfunction "}}} -function! vimwiki#TO_table_col(inner, visual) "{{{ +function! vimwiki#base#TO_table_col(inner, visual) "{{{ let t_rows = vimwiki_tbl#get_rows(line('.')) if empty(t_rows) return @@ -1032,12 +1000,12 @@ function! vimwiki#TO_table_col(inner, visual) "{{{ endif endfunction "}}} -function! vimwiki#count_first_sym(line) "{{{ +function! vimwiki#base#count_first_sym(line) "{{{ let first_sym = matchstr(a:line, '\S') return len(matchstr(a:line, first_sym.'\+')) endfunction "}}} -function! vimwiki#AddHeaderLevel() "{{{ +function! vimwiki#base#AddHeaderLevel() "{{{ let lnum = line('.') let line = getline(lnum) @@ -1046,7 +1014,7 @@ function! vimwiki#AddHeaderLevel() "{{{ endif if line =~ '^\s*\(=\+\).\+\1\s*$' - let level = vimwiki#count_first_sym(line) + let level = vimwiki#base#count_first_sym(line) if level < 6 let line = substitute(line, '\(=\+\).\+\1', '=&=', '') call setline(lnum, line) @@ -1059,7 +1027,7 @@ function! vimwiki#AddHeaderLevel() "{{{ endfunction "}}} -function! vimwiki#RemoveHeaderLevel() "{{{ +function! vimwiki#base#RemoveHeaderLevel() "{{{ let lnum = line('.') let line = getline(lnum) @@ -1068,7 +1036,7 @@ function! vimwiki#RemoveHeaderLevel() "{{{ endif if line =~ '^\s*\(=\+\).\+\1\s*$' - let level = vimwiki#count_first_sym(line) + let level = vimwiki#base#count_first_sym(line) let old = repeat('=', level) let new = repeat('=', level - 1) diff --git a/autoload/vimwiki/default.tpl b/autoload/vimwiki/default.tpl new file mode 100644 index 0000000..3e31d99 --- /dev/null +++ b/autoload/vimwiki/default.tpl @@ -0,0 +1,11 @@ + + + + +%title% + + + +%content% + + diff --git a/autoload/vimwiki_diary.vim b/autoload/vimwiki/diary.vim similarity index 89% rename from autoload/vimwiki_diary.vim rename to autoload/vimwiki/diary.vim index 9803cc1..7c7f51e 100644 --- a/autoload/vimwiki_diary.vim +++ b/autoload/vimwiki/diary.vim @@ -197,19 +197,24 @@ function! s:make_date_link(...) "{{{ return VimwikiGet('diary_rel_path').link endfunction "}}} -function! vimwiki_diary#make_note(index, ...) "{{{ - call vimwiki#select(a:index) - call vimwiki#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path')) +function! vimwiki#diary#make_note(index, ...) "{{{ + call vimwiki#base#select(a:index) + call vimwiki#base#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path')) if a:0 let link = s:make_date_link(a:1) else let link = s:make_date_link() endif - call vimwiki#open_link(':e ', link, s:diary_index()) + call vimwiki#base#open_link(':e ', link, s:diary_index()) +endfunction "}}} + +function! vimwiki#diary#goto_index(index) "{{{ + call vimwiki#base#select(a:index) + call vimwiki#base#edit_file(':e', s:diary_index()) endfunction "}}} " Calendar.vim callback function. -function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ +function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{ let day = s:prefix_zero(a:day) let month = s:prefix_zero(a:month) @@ -228,11 +233,11 @@ function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{ endif " Create diary note for a selected date in default wiki. - call vimwiki_diary#make_note(1, link) + call vimwiki#diary#make_note(1, link) endfunction "}}} " Calendar.vim sign function. -function vimwiki_diary#calendar_sign(day, month, year) "{{{ +function vimwiki#diary#calendar_sign(day, month, year) "{{{ let day = s:prefix_zero(a:day) let month = s:prefix_zero(a:month) let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path'). @@ -240,7 +245,7 @@ function vimwiki_diary#calendar_sign(day, month, year) "{{{ return filereadable(expand(sfile)) endfunction "}}} -function! vimwiki_diary#goto_next_day() "{{{ +function! vimwiki#diary#goto_next_day() "{{{ let link = '' let [idx, links] = s:get_position_links(expand('%:t:r')) @@ -256,11 +261,11 @@ function! vimwiki_diary#goto_next_day() "{{{ endif if len(link) - call vimwiki#open_link(':e ', link) + call vimwiki#base#open_link(':e ', link) endif endfunction "}}} -function! vimwiki_diary#goto_prev_day() "{{{ +function! vimwiki#diary#goto_prev_day() "{{{ let link = '' let [idx, links] = s:get_position_links(expand('%:t:r')) @@ -276,6 +281,6 @@ function! vimwiki_diary#goto_prev_day() "{{{ endif if len(link) - call vimwiki#open_link(':e ', link) + call vimwiki#base#open_link(':e ', link) endif endfunction "}}} diff --git a/autoload/vimwiki_html.vim b/autoload/vimwiki/html.vim similarity index 75% rename from autoload/vimwiki_html.vim rename to autoload/vimwiki/html.vim index 1efa539..3d685d6 100644 --- a/autoload/vimwiki_html.vim +++ b/autoload/vimwiki/html.vim @@ -13,12 +13,6 @@ endif let g:loaded_vimwiki_html_auto = 1 "}}} -" SCRIPT VARS "{{{ -" Warn if html header or html footer do not exist only once. -let s:warn_html_header = 0 -let s:warn_html_footer = 0 -"}}} - " UTILITY "{{{ function! s:root_path(subdir) "{{{ return repeat('../', len(split(a:subdir, '[/\\]'))) @@ -35,7 +29,7 @@ function! s:remove_blank_lines(lines) " {{{ endfunction "}}} function! s:is_web_link(lnk) "{{{ - if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\)' + if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\|mailto:\)' return 1 endif return 0 @@ -55,104 +49,69 @@ function! s:has_abs_path(fname) "{{{ return 0 endfunction "}}} +function! s:find_autoload_file(name) " {{{ + for path in split(&runtimepath, ',') + let fname = path.'/autoload/vimwiki/'.a:name + if glob(fname) != '' + return fname + endif + endfor + return '' +endfunction " }}} + function! s:create_default_CSS(path) " {{{ let path = expand(a:path) let css_full_name = path.VimwikiGet('css_name') if glob(css_full_name) == "" - call vimwiki#mkdir(fnamemodify(css_full_name, ':p:h')) - let lines = [] - - call add(lines, 'body {font-family: Tahoma, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}') - call add(lines, 'h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, serif; margin-top: 1.5em; margin-bottom: 0.5em;}') - call add(lines, 'h1 {font-size: 2.0em; color: #a77070;}') - call add(lines, 'h2 {font-size: 1.6em; color: #779977;}') - call add(lines, 'h3 {font-size: 1.3em; color: #555577;}') - call add(lines, 'h4 {font-size: 1.2em; color: #222244;}') - call add(lines, 'h5 {font-size: 1.1em; color: #222244;}') - call add(lines, 'h6 {font-size: 1.0em; color: #222244;}') - call add(lines, 'p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}') - call add(lines, 'ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}') - call add(lines, 'li {margin: 0.3em auto;}') - call add(lines, 'ul {margin-left: 2em; padding-left: 0.5em;}') - call add(lines, 'dt {font-weight: bold;}') - call add(lines, 'img {border: none;}') - call add(lines, 'pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}') - call add(lines, 'blockquote {padding: 0.4em; background-color: #f6f5eb;}') - call add(lines, 'th, td {border: 1px solid #ccc; padding: 0.3em;}') - call add(lines, 'th {background-color: #f0f0f0;}') - call add(lines, 'hr {border: none; border-top: 1px solid #ccc; width: 100%;}') - call add(lines, 'del {text-decoration: line-through; color: #777777;}') - call add(lines, '.toc li {list-style-type: none;}') - call add(lines, '.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}') - call add(lines, '.justleft {text-align: left;}') - call add(lines, '.justright {text-align: right;}') - call add(lines, '.justcenter {text-align: center;}') - call add(lines, '.center {margin-left: auto; margin-right: auto;}') - - call writefile(lines, css_full_name) - echomsg "Default style.css is created." + call vimwiki#base#mkdir(fnamemodify(css_full_name, ':p:h')) + let default_css = s:find_autoload_file('style.css') + if default_css != '' + let lines = readfile(default_css) + call writefile(lines, css_full_name) + echomsg "Default style.css has been created." + endif endif endfunction "}}} -function! s:get_html_header(title, subdir, charset) "{{{ +function! s:template_full_name(name) "{{{ + if a:name == '' + let name = VimwikiGet('template_default') + else + let name = a:name + endif + + let fname = expand(VimwikiGet('template_path'). + \name. + \VimwikiGet('template_ext')) + + if filereadable(fname) + return fname + else + return '' + endif +endfunction "}}} + +function! s:get_html_template(wikifile, template) "{{{ + " TODO: refactor it!!! let lines=[] - if VimwikiGet('html_header') != "" && !s:warn_html_header + let template_name = s:template_full_name(a:template) + if template_name != '' try - let lines = readfile(expand(VimwikiGet('html_header'))) - call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")') - call map(lines, 'substitute(v:val, "%root_path%", "'. - \ s:root_path(a:subdir) .'", "g")') + let lines = readfile(template_name) return lines catch /E484/ - let s:warn_html_header = 1 - echomsg 'vimwiki: Header template '.VimwikiGet('html_header'). + echomsg 'vimwiki: html template '.template_name. \ ' does not exist!' endtry endif - let css_name = expand(VimwikiGet('css_name')) - let css_name = substitute(css_name, '\', '/', 'g') - if !s:has_abs_path(css_name) - " Relative css file for deep links: [[dir1/dir2/dir3/filename]] - let css_name = s:root_path(a:subdir).css_name + " if no VimwikiGet('html_template') set up or error while reading template + " file -- use default one. + let default_tpl = s:find_autoload_file('default.tpl') + if default_tpl != '' + let lines = readfile(default_tpl) endif - - " if no VimwikiGet('html_header') set up or error while reading template - " file -- use default header. - call add(lines, '') - call add(lines, '') - call add(lines, '') - call add(lines, ''.a:title.'') - call add(lines, '') - call add(lines, '') - call add(lines, '') - - return lines -endfunction "}}} - -function! s:get_html_footer() "{{{ - let lines=[] - - if VimwikiGet('html_footer') != "" && !s:warn_html_footer - try - let lines = readfile(expand(VimwikiGet('html_footer'))) - return lines - catch /E484/ - let s:warn_html_footer = 1 - echomsg 'vimwiki: Footer template '.VimwikiGet('html_footer'). - \ ' does not exist!' - endtry - endif - - " if no VimwikiGet('html_footer') set up or error while reading template - " file -- use default footer. - call add(lines, "") - call add(lines, '') - call add(lines, '') - return lines endfunction "}}} @@ -174,6 +133,19 @@ endfunction "}}} function! s:delete_html_files(path) "{{{ let htmlfiles = split(glob(a:path.'**/*.html'), '\n') for fname in htmlfiles + " ignore user html files, e.g. search.html,404.html + if stridx(g:vimwiki_user_htmls, fnamemodify(fname, ":t")) >= 0 + continue + endif + + " delete if there is no corresponding wiki file + let subdir = vimwiki#base#subdir(VimwikiGet('path_html'), fname) + let wikifile = VimwikiGet("path").subdir. + \fnamemodify(fname, ":t:r").VimwikiGet("ext") + if filereadable(wikifile) + continue + endif + try call delete(fname) catch @@ -182,45 +154,6 @@ function! s:delete_html_files(path) "{{{ endfor endfunction "}}} -function! s:remove_comments(lines) "{{{ - let res = [] - let multiline_comment = 0 - - let idx = 0 - while idx < len(a:lines) - let line = a:lines[idx] - let idx += 1 - - if multiline_comment - let col = matchend(line, '-->',) - if col != -1 - let multiline_comment = 0 - let line = strpart(line, col) - else - continue - endif - endif - - if !multiline_comment && line =~ '' - let line = substitute(line, '', '', 'g') - if line =~ '^\s*$' - continue - endif - endif - - if !multiline_comment - let col = match(line, ' is a comment. -Ex: > - +Text line started with %% is a comment. +E.g.: > + %% this text would not be in HTML < + +------------------------------------------------------------------------------ +5.10. Horizontal line *vimwiki-syntax-hr* + +4 or more dashes at the start of the line is a 'horizontal line' (
): > + ---- +< + + ============================================================================== 6. Folding/Outline *vimwiki-folding* @@ -761,25 +832,26 @@ Hit |zr| one more time: * [ ] Do stuff 2~ * [ ] Do stuff 3~ -NOTE: Whether you use default syntax, folding on list items should work +NOTE:If you use default vimwiki syntax, folding on list items will work properly only if all of them are indented using current |shiftwidth|. -For MediaWiki * or # should be in the first column. +For MediaWiki, * or # should be in the first column. To turn folding on/off check |g:vimwiki_folding|. + ============================================================================== 7. Placeholders *vimwiki-placeholders* ------------------------------------------------------------------------------ %toc Table of Contents *vimwiki-toc* *vimwiki-table-of-contents* -You can add 'table of contents' to your html page generated from wiki one. +You can add 'table of contents' to your HTML page generated from wiki one. Just place > %toc into your wiki page. -You can also add caption to your 'toc': > +You can also add a caption to your 'toc': > %toc Table of Contents @@ -791,9 +863,8 @@ or > ------------------------------------------------------------------------------ %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 > +When you htmlize your wiki page, the default title is the filename of the +page. Place > %title My books @@ -803,13 +874,25 @@ into your wiki page if you want another title. ------------------------------------------------------------------------------ %nohtml *vimwiki-nohtml* -If you do not want a wiki page to be converted to html, place: +If you do not want a wiki page to be converted to HTML, place: %nohtml into it. +------------------------------------------------------------------------------ +%template *vimwiki-template* + +To apply a concrete HTML template to a wiki page, place: + +%template name + +into it. + +See |vimwiki-option-template_path| for details. + + ============================================================================== 8. Todo lists *vimwiki-todo-lists* @@ -826,33 +909,33 @@ Consider the following example: * [X] Add highlighting to list item boxes * [X] Add [ ] to the next created with o, O and list item. - -Pressing on the first list item will toggle it and all of it's child +Pressing on the first list item will toggle it and all of its child items: = Toggleable list of todo items = * [ ] Toggle list item on/off. * [ ] Simple toggling between [ ] and [X]. - * [ ] All list's subitems should be toggled on/off appropriately. - * [ ] Toggle child subitems only if current line is list item - * [ ] Parent list item should be toggled depending on it's child items. - * [X] Make numbered list items toggleable too - * [X] Add highlighting to list item boxes - * [X] Add [ ] to the next created with o, O and list item. + * [ ] All of a list's subitems should be toggled on/off appropriately. + * [ ] Toggle child subitems only if the current line is a list item. + * [ ] Parent list item should be toggled depending on their child items. + * [X] Make numbered list items toggleable too. + * [X] Add highlighting to list item boxes. + * [X] Add [ ] to the next list item created using o, O or . -Pressing on the third list item will toggle it and all of it's +Pressing on the third list item will toggle it and adjust all of its parent items: = Toggleable list of todo items = * [.] Toggle list item on/off. * [ ] Simple toggling between [ ] and [X]. - * [X] All list's subitems should be toggled on/off appropriately. - * [ ] Toggle child subitems only if current line is list item + * [X] All of a list's subitems should be toggled on/off appropriately. + * [ ] Toggle child subitems only if current line is list item. * [ ] Parent list item should be toggled depending on it's child items. - * [ ] Make numbered list items toggleable too - * [ ] Add highlighting to list item boxes - * [ ] Add [ ] to the next created with o, O and list item. + * [ ] Make numbered list items toggleable too. + * [ ] Add highlighting to list item boxes. + * [ ] Add [ ] to the next list item created using o, O or . -Parent items could be toggled by its child items. Symbol inside [ ] depends on -percentage of toggled child items(see also |g:vimwiki_listsyms|): > +Parent items could be changed when their child items change. The symbol +between [ ] depends on the percentage of toggled child items (see also +|g:vimwiki_listsyms|): > [ ] -- 0% [.] -- 1-33% [o] -- 34-66% @@ -865,7 +948,8 @@ It is possible to toggle several list items using visual mode. ============================================================================== 9. Tables *vimwiki-tables* -Use :VimwikiTable command to create default table with 5 columns and 2 rows: > +Use the :VimwikiTable command to create a default table with 5 columns and 2 +rows: > | | | | | | |---+---+---+---+---| @@ -879,14 +963,14 @@ Tables are auto-formattable. Let's add some text into first cell: > | | | | | | < -Whenever you press , or leave Insert mode table is formatted: > +Whenever you press , or leave Insert mode, the table is formatted: > | First Name | | | | | |------------+---+---+---+---| | | | | | | < -You can easily create nice looking text tables, just press and enter new +You can easily create nice-looking text tables, just press and enter new values: > | First Name | Last Name | Age | City | e-mail | @@ -898,11 +982,10 @@ values: > To indent table indent the first row. Then format it with 'gqq'. - ============================================================================== 10. Diary *vimwiki-diary* -Diary helps you make daily notes. You can really easy add information into +The diary helps you make daily notes. You can easily add information into vimwiki that should be sorted out later. Just hit ww to create new daily note with name based on current date. The link to this newly created file is added to a diary wiki file. @@ -937,30 +1020,29 @@ By default there are 4 links on the line. All links are sorted by their dates. Calendar integration *vimwiki-calendar* ------------------------------------------------------------------------------ If you have Calendar.vim installed you can use it to create diary notes. -Just open calendar with :Calendar and tap on the date. Wiki file would -be created in default wiki's diary. +Just open calendar with :Calendar and tap on the date. A wiki file +will be created in the default wiki's diary. Get it from http://www.vim.org/scripts/script.php?script_id=52 See |g:vimwiki_use_calendar| option to turn it off/on. - ============================================================================== 11. Options *vimwiki-options* -There are global and per wiki(local) options available to tune vimwiki. -All global options are set using the following template: > +There are global and per-wiki (local) options available to tune vimwiki. +All global options are set using the following pattern: > let g:option_name=option_value -All per wiki options are |Dictionary|'s pairs in a list of wikies -(dictionaries). See |g:vimwiki_list| option for more details. +All per-wiki options are dictionaries (see |Dictionary|) in a list of wikies. +See |g:vimwiki_list| option for more details. ------------------------------------------------------------------------------ *g:vimwiki_list* *vimwiki-multiple-wikies* Each item in g:vimwiki_list is a |Dictionary| that holds all customization -available for a wiki represented by that item. It is in form of > +available for a wiki represented by that item. It is in the form: > {'option1': 'value1', 'option2: 'value2', ...} Consider the following example: > @@ -972,20 +1054,20 @@ It gives us one wiki located at ~/my_site/ that could be htmlized to The next example: > let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}, \ {'path': '~/my_docs/', 'ext': '.mdox'}] -gives us 2 wikies, first wiki as in previous example, second one is located in -~/my_docs/ and its files have .mdox extension. +gives us 2 wikies, the first wiki as in the previous example, and the second +one located in ~/my_docs/, with files that have the .mdox extension. -Empty |Dictionary| in the g:vimwiki_list is the wiki with default options: > +An empty |Dictionary| in g:vimwiki_list is the wiki with default options: > let g:vimwiki_list = [{}, \ {'path': '~/my_docs/', 'ext': '.mdox'}] < -You can also create wikis as a separate |Dictionary|s. > +You can also create wikis as separate |Dictionary|s. > let wiki_1 = {} let wiki_1.path = '~/my_docs/' - let wiki_1.html_header = '~/public_html/header.tpl' + let wiki_1.html_template = '~/public_html/template.tpl' let wiki_1.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} let wiki_2 = {} @@ -999,7 +1081,6 @@ You can also create wikis as a separate |Dictionary|s. > PER WIKI OPTIONS *viwmiki-local-options* - *vimwiki-option-path* ------------------------------------------------------------------------------ Key Default value~ @@ -1016,14 +1097,15 @@ Key Default value~ path_html ~/vimwiki_html/ Description~ -HTML files converted from wiki files location: > +Location of HTML files converted from wiki files: > let g:vimwiki_list = [{'path': '~/my_site/', \ 'path_html': '~/my_site_html/'}] -If you omit this option path_html would be path - '/' + '_html/': > +If you omit this option, the value of path_html would be set to the value of +path with the trailing slash ('/') removed and '_html' added; i.e. for: > let g:vimwiki_list = [{'path': '~/okidoki/'}] -ie, path_html = '~/okidoki_html/' +path_html will be set to '~/okidoki_html/'. *vimwiki-option-auto_export* ------------------------------------------------------------------------------ @@ -1031,11 +1113,11 @@ Key Default value Values~ auto_export 0 0, 1 Description~ -Set this option to 1 to automatically generate HTML file when corresponding -wiki page is saved: > +Set this option to 1 to automatically generate the HTML file when the +corresponding wiki page is saved: > let g:vimwiki_list = [{'path': '~/my_site/', 'auto_export': 1}] -This will keep you HTML files up to date. +This will keep your HTML files up to date. *vimwiki-option-index* ------------------------------------------------------------------------------ @@ -1046,7 +1128,7 @@ Description~ Name of wiki index file: > let g:vimwiki_list = [{'path': '~/my_site/', 'index': 'main'}] -NOTE: Do not add extension. +NOTE: Do not include the extension. *vimwiki-option-ext* @@ -1068,23 +1150,32 @@ syntax default default, media Description~ Wiki syntax. You can use different markup languages (currently default vimwiki and -MediaWiki) but only vimwiki's default markup could be converted to HTML at the +MediaWiki), but only vimwiki's default markup will be converted to HTML at the moment. To use MediaWiki's wiki markup: > let g:vimwiki_list = [{'path': '~/my_site/', 'syntax': 'media'}] < -*vimwiki-option-html_header* +*vimwiki-option-template_path* ------------------------------------------------------------------------------ -Key Default value~ -html_header +Key Default value~ +template_path ~/vimwiki/templates/ Description~ -Set up file name for html header template: > +Setup path for HTML templates: > let g:vimwiki_list = [{'path': '~/my_site/', - \ 'html_header': '~/public_html/header.tpl'}] + \ 'template_path': '~/public_html/templates/', + \ 'template_default': 'def_template', + \ 'template_ext': '.html'}] -This header.tpl could look like: > +There could be a bunch of templates: > + def_template.html + index.html + bio.html + person.html +etc. + +Each template could look like: > @@ -1092,7 +1183,11 @@ This header.tpl could look like: > -
+
+ %content% +
+ + where %title% is replaced by a wiki page name or by a |vimwiki-title| @@ -1100,22 +1195,37 @@ where if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then %root_path% is replaced by '../../../'. + %content% is replaced by a wiki file content. -*vimwiki-option-html_footer* + +The default template will be applied to all wiki pages unless a page specifies +a template. Consider you have wiki page named 'Maxim.wiki' and you want apply +'person.html' template to it. Just add: > + %template person +to that page. + + +*vimwiki-option-template_default* ------------------------------------------------------------------------------ -Key Default value~ -html_footer +Key Default value~ +template_default default Description~ -Set up file name for html footer template: > - let g:vimwiki_list = [{'path': '~/my_site/', - \ 'html_footer': '~/public_html/footer.tpl'}] +Setup default template name (without extension). + +See |vimwiki-option-template_path| for details. + + +*vimwiki-option-template_ext* +------------------------------------------------------------------------------ +Key Default value~ +template_ext .html + +Description~ +Setup template filename extension. + +See |vimwiki-option-template_path| for details. -This footer.tpl could look like: > -
- - -< *vimwiki-option-css_name* ------------------------------------------------------------------------------ @@ -1123,7 +1233,7 @@ Key Default value~ css_name style.css Description~ -Set up css file name: > +Setup CSS file name: > let g:vimwiki_list = [{'path': '~/my_pages/', \ 'css_name': 'main.css'}] < @@ -1139,8 +1249,8 @@ Key Default value Values~ maxhi 1 0, 1 Description~ -Non-existent wiki links highlighting could be quite slow and if you don't want -it set maxhi to 0: > +Non-existent wiki links highlighting can be quite slow. If you don't want it, +set maxhi to 0: > let g:vimwiki_list = [{'path': '~/my_site/', 'maxhi': 0}] This disables filesystem checks for wiki links. @@ -1152,7 +1262,7 @@ Key Default value Values~ nested_syntaxes {} pairs of highlight keyword and vim filetype Description~ -You can make preformatted text to be highlighted with a different syntaxes +You can configure preformatted text to be highlighted with any syntax available for vim. For example the following setup in your vimrc: > let wiki = {} @@ -1160,7 +1270,7 @@ For example the following setup in your vimrc: > let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} let g:vimwiki_list = [wiki] -would give you python and c++ highlighting in: > +would give you Python and C++ highlighting in: > {{{class="brush: python" for i in range(1, 5): print(i) @@ -1189,7 +1299,6 @@ or in: > }}} - *vimwiki-option-diary_rel_path* ------------------------------------------------------------------------------ Key Default value~ @@ -1239,25 +1348,24 @@ Use: > let g:option_name=option_value to set them. ------------------------------------------------------------------------------- +----------------------------------------------------------------------------- *g:vimwiki_hl_headers* Highlight headers with =Reddish=, ==Greenish==, ===Blueish=== colors. Value Description~ -1 Use predefined colors to highlight different header levels. -0 Use |hl-Title| or VimwikiHeader1-VimwikiHeader6 (if defined - in a colorscheme) - -Default: 1 +1 Use VimwikiHeader1-VimwikiHeader6 group colors to highlight + different header levels. +0 Use |hl-Title| color for headers. +Default: 0 ------------------------------------------------------------------------------ *g:vimwiki_hl_cb_checked* -Checked list items could be highlighted with a color: +Checked list items can be highlighted with a color: - * [X] the whole line could be highlighted with the option set to 1. + * [X] the whole line can be highlighted with the option set to 1. * [ ] I wish vim could use strikethru. Value Description~ @@ -1270,12 +1378,20 @@ Default: 0 ------------------------------------------------------------------------------ *g:vimwiki_global_ext* *vimwiki-temporary-wiki* -If a file with a registered wiki extension is opened in a dir that is not -listed in |g:vimwiki_list| then: +If a file with a registered wiki extension is opened in a directory that is +not listed in |g:vimwiki_list| then: Value Description~ 1 make a temporary wiki in that dir. -0 don't make temporary wiki it that dir. +0 don't make temporary wiki in that dir. + +A temporary wiki is created to scan the filesystem for available links to +highlight. + +Consider your wiki extension is .txt then you can > + let g:vimwiki_global_ext = 0 +to make it local to vimwiki paths listed in g:vimwiki_list. So other text +files wouldn't be treated as wiki pages. Default: 1 @@ -1293,7 +1409,7 @@ You can set up your own: > ------------------------------------------------------------------------------ *g:vimwiki_auto_checkbox* -if on, creates checkbox while toggling list item. +If on, creates checkbox while toggling list item. Value Description~ 0 Do not create checkbox. @@ -1301,11 +1417,11 @@ Value Description~ Default: 1 -Ex: +E.g.: Press (|:VimwikiToggleListItem|) on a list item without checkbox to create it: > * List item -result: > +Result: > * [ ] List item @@ -1322,21 +1438,23 @@ etc. Default: 'Vimwiki' + ------------------------------------------------------------------------------ *g:vimwiki_stripsym* -Change strip symbol -- in Windows you cannot use /*?<>:" in file names so -vimwiki replaces them with neutral symbol (_ is default): > +Change strip symbol -- in Windows you cannot use /*?<>:" in filenames, so +vimwiki replaces them with a neutral symbol (_ is default): > let g:vimwiki_stripsym = '_' You can change it to a for example: > let g:vimwiki_stripsym = ' ' + ------------------------------------------------------------------------------ *g:vimwiki_badsyms* -Consider you do not like spaces in filenames (as some vimwiki users do). -In that case you can set up bad symbols that would be converted to +If you do not like spaces in filenames (as some vimwiki users do), you can set +up bad symbols to include spaces, so that they are also converted: |g:vimwiki_stripsym|: > let g:vimwiki_badsyms = ' ' @@ -1345,6 +1463,7 @@ Now files for all [[links with spaces]] would be created like This option is a complement one to |g:vimwiki_stripsym|. + ------------------------------------------------------------------------------ *g:vimwiki_listsyms* @@ -1354,6 +1473,7 @@ Default value is ' .oOX'. g:vimwiki_listsyms[0] is for 0% done items. g:vimwiki_listsyms[4] is for 100% done items. + ------------------------------------------------------------------------------ *g:vimwiki_use_mouse* @@ -1365,11 +1485,12 @@ Value Description~ Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_folding* -Enable/disable vimwiki's folding/outline. Folding in vimwiki is using 'expr' -foldmethod which is very flexible but really slow. +Enable/disable vimwiki's folding/outline functionality. Folding in vimwiki +uses the 'expr' foldmethod which is very flexible but really slow. Value Description~ 0 Disable folding. @@ -1377,6 +1498,7 @@ Value Description~ Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_fold_lists* @@ -1388,21 +1510,23 @@ Value Description~ Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_fold_trailing_empty_lines* Fold or do not fold empty lines between folded headers. Value Description~ -0 Fold only one empty line. The rest empty lines are unfolded. +0 Fold only one empty line. Leave the rest of the empty lines. 1 Fold in all empty lines. Default: 0 + ------------------------------------------------------------------------------ *g:vimwiki_camel_case* -If you do not want WikiWord to be a link this setting is just for you. +If you do not want WikiWord to be a link, this setting is just for you. Value Description~ 0 Do not make links from CamelCased words. @@ -1410,18 +1534,20 @@ Value Description~ Default: 1 + ------------------------------------------------------------------------------ *g:vimwiki_list_ignore_newline* This is HTML related. -Convert newlines to
s in multiline list items. +Convert newlines to
s in multiline list items. Value Description~ -0 Newlines in a list item are converted to
s. +0 Newlines in a list item are converted to
s. 1 Ignore newlines. Default: 1 + ------------------------------------------------------------------------------ *g:vimwiki_use_calendar* @@ -1444,9 +1570,9 @@ You can open external weblinks in a webbrowser. Webbrowsers are listed in For win32 it is: chrome, opera, firefox and explorer. For other OSes it is: opera, firefox and konqueror. -The first available browser from the list is used to open weblink. -If you have opera and firefox and want weblinks to be opened in the latter -just: > +The first available browser from the list is used to open the weblink. +If you have opera and firefox and want weblinks to be opened in the latter, +just specify: > let g:vimwiki_browsers=['C:\Program Files\Firefox\firefox.exe'] or redefine VimwikiWeblinkHandler function: > @@ -1488,8 +1614,8 @@ Default: '' ------------------------------------------------------------------------------ *g:vimwiki_CJK_length* -Use special method to calculate correct length of the strings with double wide -characters. (To align table cells properly) +Use special method to calculate correct length of the strings with double-wide +characters (to align table cells properly). Value Description~ 0 Do not use it. @@ -1497,8 +1623,8 @@ Value Description~ Default: 0 -Note: Vim73 has new function |strdisplaywidth|, so for Vim73 users this option -is obsolete. +Note: Vim73 has a new function |strdisplaywidth|, so for Vim73 users this +option is obsolete. ------------------------------------------------------------------------------ @@ -1519,9 +1645,9 @@ Default: '' (empty string) ------------------------------------------------------------------------------ *g:vimwiki_html_header_numbering* -Set this option if you want headers to be auto numbered in html. +Set this option if you want headers to be auto-numbered in HTML. -ex: > +E.g.: > 1 Header1 1.1 Header2 1.2 Header2 @@ -1560,8 +1686,8 @@ Default: 0 Ending symbol for |g:vimwiki_html_header_numbering|. Value Description~ -'.' Dot would be added to the end of header's number. -')' Closing bracket would be added to the end of header's number. +'.' Dot will be added after a header's number. +')' Closing bracket will be added after a header's number. etc. With @@ -1583,11 +1709,11 @@ Default: '' (empty) ------------------------------------------------------------------------------ *g:vimwiki_file_exts* -Comma separated list of file extensions. +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. +If there is a 'php' extension in g:vimwiki_file_exts, this link would be +htmlized to my script. Otherwise it would be my script (note .html) @@ -1597,11 +1723,26 @@ 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. +Comma-separated list of HTML tags that can be used in vimwiki. Default: 'b,i,s,u,sub,sup,kbd,br,hr' +------------------------------------------------------------------------------ +*g:vimwiki_user_htmls* + +Comma-separated list of HTML files that have no corresponding wiki files and +should not be deleted after |:VimwikiAll2HTML|. + +Default: '' + +Example: +Consider you have 404.html and search.html in your vimwiki 'path_html'. +With: > + let g:vimwiki_user_htmls = '404.html,search.html' +they would not be deleted after |:VimwikiAll2HTML|. + + ------------------------------------------------------------------------------ *g:vimwiki_conceallevel* @@ -1614,42 +1755,93 @@ is entered. Default: 3 - - ============================================================================== 12. Help *vimwiki-help* Your help in making vimwiki better is really appreciated! -Any help. Would it be spell correction or code snippet to patch -- everything -is welcomed. +Any help, whether it is a spelling correction or a code snippet to patch -- +everything is welcomed. -Issues could be filled in at http://code.google.com/p/vimwiki/issues . +Issues can be filed at http://code.google.com/p/vimwiki/issues . ============================================================================== 13. Developers *vimwiki-developers* - - Maxim Kim - Original author. - - Mikhail Trishchenkov - Joined in at Dec 2009. + - Maxim Kim as original author. + - See the http://code.google.com/p/vimwiki/people/list for the others. -Vimwiki's website: http://code.google.com/p/vimwiki/ -Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226 - -... afterword - -Many thanks to all of you for voting vimwiki up on www.vim.org. I do vimwiki -in my spare time I could use to dance argentine tango with beautiful women. -Your votes are kind of a good replacement. ;) - -Sincerely yours, -Maxim Kim. +Web: http://code.google.com/p/vimwiki/ +Mail-List: https://groups.google.com/forum/#!forum/vimwiki +Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226 ============================================================================== 14. Changelog *vimwiki-changelog* +1.2~ + * Issue 70: Table spanning cell support. + * Issue 72: Do not convert again for unchanged file. |:VimwikiAll2HTML| + converts only changed wiki files. + * Issue 117: |VimwikiDiaryIndex| command that opens diary index wiki page. + * Issue 120: Links in headers are not highlighted in vimwiki but are + highlighted in HTML. + * Issue 138: Added possibility to remap table-column move bindings. See + |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight| + commands. For remap instructions see |vimwiki_| + and |vimwiki_|. + * Issue 125: Problem with 'o' command given while at the of the file. + * Issue 131: FileType is not set up when GUIEnter autocommand is used in + vimrc. Use 'nested' in 'au GUIEnter * nested VimwikiIndex' + * Issue 132: Link to perl (or any non-wiki) file in vimwiki subdirectory + doesn't work as intended. + * Issue 135: %title and %toc used together cause TOC to appear in an + unexpected place in HTML. + * Issue 139: |:VimwikiTabnewLink| command is added. + * Fix of g:vimwiki_stripsym = '' (i.e. an empty string) -- it removes bad + symbols from filenames. + * Issue 145: With modeline 'set ft=vimwiki' links are not correctly + highlighted when open wiki files. + * Issue 146: Filetype difficulty with ".txt" as a vimwiki extension. + * Issue 148: There are no mailto links. + * Issue 151: Use location list instead of quickfix list for :VimwikiSearch + command result. Use :lopen instead of :copen, :lnext instead of :cnext + etc. + * Issue 152: Add the list of HTML files that would not be deleted after + |:VimwikiAll2HTML|. + * Issue 153: Delete HTML files that has no corresponding wiki ones with + |:VimwikiAll2HTML|. + * Issue 156: Add multiple HTML templates. See + |vimwiki-option-template_path|. Options html_header and html_footer are + no longer exist. + * Issue 173: When virtualedit=all option is enabled the 'o' command behave + strange. + * Issue 178: Problem with alike wikie's paths. + * Issue 182: Browser command does not quote url. + * Issue 183: Spelling error highlighting is not possible with nested + syntaxes. + * Issue 184: Wrong foldlevel in some cases. + * Issue 195: Page renaming issue. + * Issue 196: vim: modeline bug -- syn=vim doesn't work. + * Issue 199: Generated HTML for sublists is invalid. + * Issue 200: Generated HTML for todo lists does not show completion status + the fix relies on CSS, thus your old stylesheets need to be updated!; + may not work in obsolete browsers or font-deficient systems. + * Issue 205: Block code: highlighting differs from processing. Inline code + block {{{ ... }}} is removed. Use `...` instead. + * Issue 208: Default highlight colors are problematic in many + colorschemes. Headers are highlighted as |hl-Title| by default, use + |g:vimwiki_hl_headers| to restore previous default Red, Green, Blue or + custom header colors. Some other changes in highlighting. + * Issue 209: Wild comments slow down html generation. Comments are + changed, use %% to comment out entire line. + * Issue 210: HTML: para enclose header. + * Issue 214: External links containing Chinese characters get trimmed. + * Issue 218: Command to generate HTML file and open it in webbrowser. See + |:Vimwiki2HTMLBrowse|(bind to whh) + * NEW: Added wh mapping to call |:Vimwiki2HTML| + + 1.1.1~ * FIX: Issue 122: Dot character in vimwiki's directory path isn't escaped. * FIX: Issue 123: Where is Vimwiki2HTML and other commands? Sometimes @@ -1667,7 +1859,7 @@ Maxim Kim. 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 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 @@ -1702,7 +1894,7 @@ Maxim Kim. |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight|. * NEW: Issue 44: should move cursor to the previous table cell. * NEW: Issue 45: It should be possible to indent tables. Indented tables - are centered in html. + are centered in HTML. * NEW: Issue 46: Do not htmlize some wiki pages (blacklist). New placeholder is added: %nohtml. See |vimwiki-nohtml|. * FIX: Issue 47: Lists aren't HTMLized properly. @@ -1725,11 +1917,11 @@ Maxim Kim. * NEW: Issue 60: Links inside completed gtd-items. * NEW: Issue 61: Headers numbering. See |g:vimwiki_html_header_numbering| and |g:vimwiki_html_header_numbering_sym| options. - * FIX: Issue 63: Table cannot have leading empty cells in html. + * FIX: Issue 63: Table cannot have leading empty cells in HTML. * FIX: Issue 65: Table separator is not htmlized right if on top of the table. - * FIX: Issue 66: Table empty cells are very small in html. - * FIX: Issue 67: Wrong html conversion of multilined list item with bold + * FIX: Issue 66: Table empty cells are very small in HTML. + * FIX: Issue 67: Wrong HTML conversion of multilined list item with bold text on the start of next line. * FIX: Issue 68: auto-indent problem with langmap. * FIX: Issue 73: Link navigation by Tab. "Escaped" wiki-word should be @@ -1741,7 +1933,7 @@ Maxim Kim. date if it has corresponding diary page. * FIX: Issue 80: Debian Lenny GUI Vim 7.2 has problems with toggling inner todo list items. - * FIX: Issue 81: Don't convert WikiWord as a link in html when + * FIX: Issue 81: Don't convert WikiWord as a link in HTML when `let g:vimwiki_camel_case = 0` 0.9.9~ @@ -1754,7 +1946,7 @@ Maxim Kim. * NEW: Keyword STARTED: is added. * NEW: Words TODO:, DONE:, STARTED:, XXX:, FIXME:, FIXED: are highlighed inside headers. - * FIX: Export to html external links with 'file://' protocol. Ex: + * FIX: Export to HTML external links with 'file://' protocol. Ex: [file:///home/user1/book.pdf my book]. * FIX: Menu is corrupted if wiki's path contains spaces. * FIX: Settings |wrap| and |linebreak| are removed from ftplugin. Add them @@ -1780,10 +1972,10 @@ Maxim Kim. * NEW: Speed up vimwiki's folding a bit. Should lag a bit less in a long todo lists. * NEW: Centered headers. Start header with at least one space to make it - html centered. - * NEW: Change in default css: header's colors. + HTML centered. + * NEW: Change in default CSS: header's colors. * NEW: Vimwiki is aware of |GetLatestVimScripts| now. - * FIX: Use tag instead of custom in html. + * FIX: Use tag instead of custom in HTML. * FIX: There are no text styling in htmlized quoted text. * FIX: set default value of g:vimwiki_fold_lists to 0 as written in this help. @@ -1813,8 +2005,8 @@ Maxim Kim. (in VISUAL and in VISUAL LINE modes) * NEW: Issue 26: Highlight code snippets in vimwiki's pre. See |vimwiki-option-nested_syntaxes|. Thanks kriomant. - * NEW: Issue 27: Automatic garbage deletion from html directory. - * NEW: Save all open vimwiki buffers before export to html. + * NEW: Issue 27: Automatic garbage deletion from HTML directory. + * NEW: Save all open vimwiki buffers before export to HTML. * NEW: Issue 29: Custom :Search command. * NEW: Header text objects are now expandable in VISUAL mode. Tap 'vah' to select a header. Tap again 'ah' to expand selection further. Thanks Andy @@ -1822,12 +2014,12 @@ Maxim Kim. * FIX: Folding settings are reset to vim defaults in a new tab (think of \wt) so you cannot hide things in folds. * FIX: https links in form of [https://hello.world.com] are not exported - into html. Thanks Saurabh Sarpal for the patch. + into HTML. Thanks Saurabh Sarpal for the patch. 0.9.6~ * NEW: You can have multiline list items. See |vimwiki-syntax-lists|. * NEW: You can ignore newlines in multiline list items when do export to - html. See |g:vimwiki_list_ignore_newline| option. + HTML. See |g:vimwiki_list_ignore_newline| option. * NEW: Different checkbox symbols [.], [:], [o] are added. See |vimwiki-todo-lists|. * NEW: Now there is no longer syntax of preformatted text that is started @@ -1843,7 +2035,7 @@ Maxim Kim. wikies opened at the same time with different syntaxes. * FIX: Command |:VimwikiToggleListItem| do not switch parent checkboxes if there are non-checkbox list items available. - * FIX: Issue 24: Link error in html when write [[one.two.three]]. + * FIX: Issue 24: Link error in HTML when write [[one.two.three]]. * FIX: Rename WikiWord to something with a colon (:) does nasty things. * FIX: Command |:VimwikiToggleListItem| do not switch right if there are list items without checkboxes in the list. @@ -1864,9 +2056,9 @@ Maxim Kim. * FIX: indent/vimwiki.vim is obsolete. If you upgrade from previous versions remove it. It causes wrong list indentation if noexpandtab is set. - * FIX: If tabs and spaces are used to indent list items html export gives + * FIX: If tabs and spaces are used to indent list items HTML export gives error. Thanks Klaus Ethgen for report. - * FIX: Some html export fixes. + * FIX: Some HTML export fixes. 0.9.4~ * NEW: Links with directories: [[dir1/dir2/Link|Text]]. Thanks Jie Wu. @@ -1874,12 +2066,12 @@ Maxim Kim. path_html. See |vimwiki-option-html_header|. * FIX: Indent is incorrect for vim without "float" compile option. Thanks Julian Kooij. - * FIX: Convert to html doesn't work right with links like [[foo::bar]]. + * FIX: Convert to HTML doesn't work right with links like [[foo::bar]]. * FIX: Rename wikiword doesn't work right when rename WikiWord to [[WikiWord blablabla]]. * FIX: Renaming of links with description doesn't work. * FIX: Weblinks with commas are not highlighted. - * MISC: Some changes in default css file. + * MISC: Some changes in default CSS file. 0.9.3~ * NEW: g:vimwiki_menu option is a string which is menu path. So one can @@ -1899,7 +2091,7 @@ Maxim Kim. * FIX: Clear out FlexWiki ftplugin's setup. Now you don't have to hack filetype.vim to get rid of unexpected ':setlocal bomb' from FlexWiki's ftplugin. - * FIX: When write done: it will show another done: in html file. + * FIX: When write done: it will show another done: in HTML file. 0.9.2a~ * FIX: Installation on Linux doesn't work. (Dos line endings in @@ -1910,7 +2102,7 @@ Maxim Kim. * NEW: Header text object. See |vimwiki-text-objects|. * NEW: Add/remove Header levels with '=' and '-'. See |vimwiki_=|. * NEW: Vimwiki GUI menu to select available wikies. See |g:vimwiki_menu|. - * NEW: You can specify the name of your css file now. See + * NEW: You can specify the name of your CSS file now. See |vimwiki-option-css_name| * NEW: You can add styles to image links, see |vimwiki-syntax-links|. * FIX: History doesn't work after |VimwikiRenameWord|. @@ -1963,7 +2155,7 @@ Maxim Kim. * DEL: Removed setlocal textwidth = 0 from ftplugin. * FIX: New regexps for bold, italic, bolditalic. * FIX: The last item in List sometimes fold-in incorrectly. - * FIX: Minor tweaks on default css. + * FIX: Minor tweaks on default CSS. 0.8.1~ * NEW: Vimwiki's foldmethod changed from syntax to expr. Foldtext is diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index be97b29..5d31b37 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -20,7 +20,7 @@ let b:undo_ftplugin = "setlocal ". " MISC STUFF {{{ setlocal autowriteall -setlocal commentstring= +setlocal commentstring=%%%s if g:vimwiki_conceallevel && exists("+conceallevel") let &conceallevel = g:vimwiki_conceallevel @@ -47,12 +47,12 @@ 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#kbd_oO("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#kbd_oO("O")a' + exe 'nnoremap '.l_O.' :call vimwiki#lst#kbd_oO("O")a' endif endif @@ -64,18 +64,18 @@ function! VimwikiFoldLevel(lnum) "{{{ " Header folding... if line =~ g:vimwiki_rxHeader - let n = vimwiki#count_first_sym(line) + let n = vimwiki#base#count_first_sym(line) return '>'.n endif - if g:vimwiki_fold_trailing_empty_lines == 0 - if line =~ '^\s*$' - let nnline = getline(nextnonblank(a:lnum + 1)) - if nnline =~ g:vimwiki_rxHeader - let n = vimwiki#count_first_sym(nnline) - return '<'.n - endif - endif + if g:vimwiki_fold_trailing_empty_lines == 0 && line =~ '^\s*$' + let nnline = getline(nextnonblank(a:lnum + 1)) + else + let nnline = getline(a:lnum + 1) + endif + if nnline =~ g:vimwiki_rxHeader + let n = vimwiki#base#count_first_sym(nnline) + return '<'.n endif " List item folding... @@ -129,7 +129,7 @@ function! s:get_base_level(lnum) "{{{ let lnum = a:lnum - 1 while lnum > 0 if getline(lnum) =~ g:vimwiki_rxHeader - return vimwiki#count_first_sym(getline(lnum)) + return vimwiki#base#count_first_sym(getline(lnum)) endif let lnum -= 1 endwhile @@ -169,7 +169,7 @@ endfunction "}}} function! s:get_li_level(lnum) "{{{ if VimwikiGet('syntax') == 'media' - let level = vimwiki#count_first_sym(getline(a:lnum)) + let level = vimwiki#base#count_first_sym(getline(a:lnum)) else let level = (indent(a:lnum) / &sw) endif @@ -198,42 +198,48 @@ endfunction "}}} " COMMANDS {{{ command! -buffer Vimwiki2HTML - \ call vimwiki_html#Wiki2HTML(expand(VimwikiGet('path_html')), + \ w call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')), \ expand('%')) +command! -buffer Vimwiki2HTMLBrowse + \ w call VimwikiWeblinkHandler( + \ vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')), + \ expand('%'))) command! -buffer VimwikiAll2HTML - \ call vimwiki_html#WikiAll2HTML(expand(VimwikiGet('path_html'))) + \ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html'))) -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 VimwikiNextLink call vimwiki#base#find_next_link() +command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link() +command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link() +command! -buffer VimwikiRenameLink call vimwiki#base#rename_link() +command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit') +command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link() +command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split') +command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit') -command! -buffer -range VimwikiToggleListItem call vimwiki_lst#ToggleListItem(, ) +command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew') -command! -buffer VimwikiGenerateLinks call vimwiki#generate_links() +command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(, ) -exe 'command! -buffer -nargs=* VimwikiSearch vimgrep '. +command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links() + +exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') -exe 'command! -buffer -nargs=* VWS vimgrep '. +exe 'command! -buffer -nargs=* VWS lvimgrep '. \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') -command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("") +command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("") " table commands -command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create() -command! -buffer VimwikiTableAlignQ call vimwiki_tbl#align_or_cmd('gqq') -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() +command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create() +command! -buffer VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq') +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() +command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day() +command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day() " COMMANDS }}} @@ -241,58 +247,78 @@ command! -buffer VimwikiDiaryPrevDay call vimwiki_diary#goto_prev_day() if g:vimwiki_use_mouse nmap nmap - noremap <2-LeftMouse> :VimwikiFollowLink - noremap :VimwikiSplitLink - noremap :VimwikiVSplitLink - noremap :VimwikiGoBackLink + nnoremap <2-LeftMouse> :VimwikiFollowLink + nnoremap :VimwikiSplitLink + nnoremap :VimwikiVSplitLink + nnoremap :VimwikiGoBackLink endif + +if !hasmapto('Vimwiki2HTML') + nmap wh Vimwiki2HTML +endif +nnoremap