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_<A-Left>| and |vimwiki_<A-Right>|. * 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 <leader>whh) * NEW: Added <Leader>wh mapping to call |:Vimwiki2HTML|
This commit is contained in:
parent
78ee71394a
commit
84297c9051
7
README
7
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 <Enter>. Now you are in
|
||||
|
@ -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) "{{{
|
||||
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"))
|
||||
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 = '!\@<!\<'.old_fname.'\>'
|
||||
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 /!\@<!\<'.link.'\>/ 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(
|
||||
function! vimwiki#base#goto_index(index) "{{{
|
||||
call vimwiki#base#select(a:index)
|
||||
call vimwiki#base#edit_file('e',
|
||||
\ 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
|
||||
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)
|
||||
|
11
autoload/vimwiki/default.tpl
Normal file
11
autoload/vimwiki/default.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
|
||||
<title>%title%</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
|
||||
</head>
|
||||
<body>
|
||||
%content%
|
||||
</body>
|
||||
</html>
|
@ -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 "}}}
|
@ -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 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 is created."
|
||||
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, '<html>')
|
||||
call add(lines, '<head>')
|
||||
call add(lines, '<link rel="Stylesheet" type="text/css" href="'.
|
||||
\ css_name.'" />')
|
||||
call add(lines, '<title>'.a:title.'</title>')
|
||||
call add(lines, '<meta http-equiv="Content-Type" content="text/html;'.
|
||||
\ ' charset='.a:charset.'" />')
|
||||
call add(lines, '</head>')
|
||||
call add(lines, '<body>')
|
||||
|
||||
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, '</body>')
|
||||
call add(lines, '</html>')
|
||||
|
||||
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, '<!--',)
|
||||
if col != -1
|
||||
let multiline_comment = 1
|
||||
let line = strpart(line, 1, col - 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
call add(res, line)
|
||||
endwhile
|
||||
return res
|
||||
endfunction "}}}
|
||||
|
||||
function! s:mid(value, cnt) "{{{
|
||||
return strpart(a:value, a:cnt, len(a:value) - 2 * a:cnt)
|
||||
endfunction "}}}
|
||||
@ -283,7 +216,7 @@ function! s:get_html_toc(toc_list) "{{{
|
||||
|
||||
let toc_text = s:process_tags_remove_links(text)
|
||||
let toc_text = s:process_tags_typefaces(toc_text)
|
||||
call add(toc, '<li><a href="#'.id.'">'.toc_text.'</a></li>')
|
||||
call add(toc, '<li><a href="#'.id.'">'.toc_text.'</a>')
|
||||
let plevel = level
|
||||
endfor
|
||||
call s:close_list(toc, level, 0)
|
||||
@ -293,6 +226,7 @@ endfunction "}}}
|
||||
|
||||
" insert toc into dest.
|
||||
function! s:process_toc(dest, placeholders, toc) "{{{
|
||||
let toc_idx = 0
|
||||
if !empty(a:placeholders)
|
||||
for [placeholder, row, idx] in a:placeholders
|
||||
let [type, param] = placeholder
|
||||
@ -301,8 +235,9 @@ function! s:process_toc(dest, placeholders, toc) "{{{
|
||||
if !empty(param)
|
||||
call insert(toc, '<h1>'.param.'</h1>')
|
||||
endif
|
||||
let shift = idx * len(toc)
|
||||
let shift = toc_idx * len(toc)
|
||||
call extend(a:dest, toc, row + shift)
|
||||
let toc_idx += 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
@ -321,6 +256,46 @@ function! s:process_title(placeholders, default_title) "{{{
|
||||
return a:default_title
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_html_uptodate(wikifile) "{{{
|
||||
let tpl_time = -1
|
||||
|
||||
let tpl_file = s:template_full_name('')
|
||||
if tpl_file != ''
|
||||
let tpl_time = getftime(tpl_file)
|
||||
endif
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||
let htmlfile = expand(VimwikiGet('path_html').subdir.
|
||||
\fnamemodify(wikifile, ":t:r").".html")
|
||||
|
||||
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:html_insert_contents(html_lines, content) "{{{
|
||||
let lines = []
|
||||
for line in a:html_lines
|
||||
if line =~ '%content%'
|
||||
let parts = split(line, '%content%', 1)
|
||||
if empty(parts)
|
||||
call extend(lines, a:content)
|
||||
else
|
||||
for idx in range(len(parts))
|
||||
call add(lines, parts[idx])
|
||||
if idx < len(parts) - 1
|
||||
call extend(lines, a:content)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
else
|
||||
call add(lines, line)
|
||||
endif
|
||||
endfor
|
||||
return lines
|
||||
endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" INLINE TAGS "{{{
|
||||
@ -376,19 +351,19 @@ function! s:tag_internal_link(value) "{{{
|
||||
if s:is_img_link(a:caption)
|
||||
let link = '<a href="'.a:src.'"><img src="'.a:caption.'"'.style_str.' />'.
|
||||
\ '</a>'
|
||||
elseif vimwiki#is_non_wiki_link(a:src)
|
||||
elseif vimwiki#base#is_non_wiki_link(a:src)
|
||||
let link = '<a href="'.a:src.'">'.a:caption.'</a>'
|
||||
elseif s:is_img_link(a:src)
|
||||
let link = '<img src="'.a:src.'" alt="'.a:caption.'"'. style_str.' />'
|
||||
elseif vimwiki#is_link_to_dir(a:src)
|
||||
elseif vimwiki#base#is_link_to_dir(a:src)
|
||||
if g:vimwiki_dir_link == ''
|
||||
let link = '<a href="'.vimwiki#safe_link(a:src).'">'.a:caption.'</a>'
|
||||
let link = '<a href="'.vimwiki#base#safe_link(a:src).'">'.a:caption.'</a>'
|
||||
else
|
||||
let link = '<a href="'.vimwiki#safe_link(a:src).
|
||||
let link = '<a href="'.vimwiki#base#safe_link(a:src).
|
||||
\ g:vimwiki_dir_link.'.html">'.a:caption.'</a>'
|
||||
endif
|
||||
else
|
||||
let link = '<a href="'.vimwiki#safe_link(a:src).
|
||||
let link = '<a href="'.vimwiki#base#safe_link(a:src).
|
||||
\ '.html">'.a:caption.'</a>'
|
||||
endif
|
||||
|
||||
@ -574,8 +549,6 @@ function! s:process_tags_typefaces(line) "{{{
|
||||
let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super')
|
||||
let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
|
||||
let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
|
||||
let line = s:make_tag(line, g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd,
|
||||
\ 's:tag_pre')
|
||||
return line
|
||||
endfunction " }}}
|
||||
|
||||
@ -624,13 +597,100 @@ function! s:close_tag_table(table, ldest) "{{{
|
||||
" The first element of table list is a string which tells us if table should be centered.
|
||||
" The rest elements are rows which are lists of columns:
|
||||
" ['center',
|
||||
" ['col1', 'col2', 'col3'],
|
||||
" ['col1', 'col2', 'col3'],
|
||||
" ['col1', 'col2', 'col3']
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" ]
|
||||
" And CELLx is: { 'body': 'col_x', 'rowspan': r, 'colspan': c }
|
||||
|
||||
function! s:sum_rowspan(table) "{{{
|
||||
let table = a:table
|
||||
|
||||
" Get max cells
|
||||
let max_cells = 0
|
||||
for row in table[1:]
|
||||
let n_cells = len(row)
|
||||
if n_cells > max_cells
|
||||
let max_cells = n_cells
|
||||
end
|
||||
endfor
|
||||
|
||||
" Sum rowspan
|
||||
for cell_idx in range(max_cells)
|
||||
let rows = 1
|
||||
|
||||
for row_idx in range(len(table)-1, 1, -1)
|
||||
if cell_idx >= len(table[row_idx])
|
||||
let rows = 1
|
||||
continue
|
||||
endif
|
||||
|
||||
if table[row_idx][cell_idx].rowspan == 0
|
||||
let rows += 1
|
||||
else " table[row_idx][cell_idx].rowspan == 1
|
||||
let table[row_idx][cell_idx].rowspan = rows
|
||||
let rows = 1
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:sum_colspan(table) "{{{
|
||||
for row in a:table[1:]
|
||||
let cols = 1
|
||||
|
||||
for cell_idx in range(len(row)-1, 0, -1)
|
||||
if row[cell_idx].colspan == 0
|
||||
let cols += 1
|
||||
else "row[cell_idx].colspan == 1
|
||||
let row[cell_idx].colspan = cols
|
||||
let cols = 1
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:close_tag_row(row, header, ldest) "{{{
|
||||
call add(a:ldest, '<tr>')
|
||||
|
||||
" Set tag element of columns
|
||||
if a:header
|
||||
let tag_name = 'th'
|
||||
else
|
||||
let tag_name = 'td'
|
||||
end
|
||||
|
||||
" Close tag of columns
|
||||
for cell in a:row
|
||||
if cell.rowspan == 0 || cell.colspan == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
if cell.rowspan > 1
|
||||
let rowspan_attr = ' rowspan="' . cell.rowspan . '"'
|
||||
else "cell.rowspan == 1
|
||||
let rowspan_attr = ''
|
||||
endif
|
||||
if cell.colspan > 1
|
||||
let colspan_attr = ' colspan="' . cell.colspan . '"'
|
||||
else "cell.colspan == 1
|
||||
let colspan_attr = ''
|
||||
endif
|
||||
|
||||
call add(a:ldest, '<' . tag_name . rowspan_attr . colspan_attr .'>')
|
||||
call add(a:ldest, s:process_inline_tags(cell.body))
|
||||
call add(a:ldest, '</'. tag_name . '>')
|
||||
endfor
|
||||
|
||||
call add(a:ldest, '</tr>')
|
||||
endfunction "}}}
|
||||
|
||||
let table = a:table
|
||||
let ldest = a:ldest
|
||||
if len(table)
|
||||
call s:sum_rowspan(table)
|
||||
call s:sum_colspan(table)
|
||||
|
||||
if table[0] == 'center'
|
||||
call add(ldest, "<table class='center'>")
|
||||
else
|
||||
@ -651,21 +711,15 @@ function! s:close_tag_table(table, ldest) "{{{
|
||||
if head > 0
|
||||
for row in table[1 : head-1]
|
||||
if !empty(filter(row, '!empty(v:val)'))
|
||||
call add(ldest, '<tr>')
|
||||
call extend(ldest, map(row, '"<th>".s:process_inline_tags(v:val)."</th>"'))
|
||||
call add(ldest, '</tr>')
|
||||
call s:close_tag_row(row, 1, ldest)
|
||||
endif
|
||||
endfor
|
||||
for row in table[head+1 :]
|
||||
call add(ldest, '<tr>')
|
||||
call extend(ldest, map(row, '"<td>".s:process_inline_tags(v:val)."</td>"'))
|
||||
call add(ldest, '</tr>')
|
||||
call s:close_tag_row(row, 0, ldest)
|
||||
endfor
|
||||
else
|
||||
for row in table[1 :]
|
||||
call add(ldest, '<tr>')
|
||||
call extend(ldest, map(row, '"<td>".s:process_inline_tags(v:val)."</td>"'))
|
||||
call add(ldest, '</tr>')
|
||||
call s:close_tag_row(row, 0, ldest)
|
||||
endfor
|
||||
endif
|
||||
call add(ldest, "</table>")
|
||||
@ -741,11 +795,15 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
|
||||
let chk = matchlist(a:line, a:rx_list)
|
||||
if len(chk) > 0
|
||||
if chk[1] == g:vimwiki_listsyms[4]
|
||||
let st_tag .= '<del><input type="checkbox" checked />'
|
||||
let en_tag = '</del>'.a:en_tag
|
||||
else
|
||||
let st_tag .= '<input type="checkbox" />'
|
||||
if len(chk[1])>0
|
||||
"wildcard characters are difficult to match correctly
|
||||
if chk[1] =~ '[.*\\^$~]'
|
||||
let chk[1] ='\'.chk[1]
|
||||
endif
|
||||
let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
|
||||
if completion >= 0 && completion <=4
|
||||
let st_tag = '<li class="done'.completion.'">'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return [st_tag, en_tag]
|
||||
@ -790,7 +848,7 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
|
||||
let checkbox = '\s*\[\(.\?\)\]\s*'
|
||||
let [st_tag, en_tag] = s:add_checkbox(line,
|
||||
\ lstRegExp.checkbox, '<li>', '</li>')
|
||||
\ lstRegExp.checkbox, '<li>', '')
|
||||
|
||||
if !in_list
|
||||
call add(a:lists, [lstTagClose, indent])
|
||||
@ -948,10 +1006,27 @@ endfunction "}}}
|
||||
|
||||
function! s:process_tag_table(line, table) "{{{
|
||||
function! s:table_empty_cell(value) "{{{
|
||||
if a:value =~ '^\s*$'
|
||||
return ' '
|
||||
let cell = {}
|
||||
|
||||
if a:value =~ '^\s*\\/\s*$'
|
||||
let cell.body = ''
|
||||
let cell.rowspan = 0
|
||||
let cell.colspan = 1
|
||||
elseif a:value =~ '^\s*>\s*$'
|
||||
let cell.body = ''
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 0
|
||||
elseif a:value =~ '^\s*$'
|
||||
let cell.body = ' '
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 1
|
||||
else
|
||||
let cell.body = a:value
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 1
|
||||
endif
|
||||
return a:value
|
||||
|
||||
return cell
|
||||
endfunction "}}}
|
||||
|
||||
function! s:table_add_row(table, line) "{{{
|
||||
@ -1010,6 +1085,12 @@ function! s:parse_line(line, state) " {{{
|
||||
|
||||
let processed = 0
|
||||
|
||||
if !processed
|
||||
if line =~ g:vimwiki_rxComment
|
||||
let processed = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
" nohtml -- placeholder
|
||||
if !processed
|
||||
if line =~ '^\s*%nohtml'
|
||||
@ -1027,6 +1108,16 @@ function! s:parse_line(line, state) " {{{
|
||||
endif
|
||||
endif
|
||||
|
||||
" html template -- placeholder "{{{
|
||||
if !processed
|
||||
if line =~ '^\s*%template'
|
||||
let processed = 1
|
||||
let param = matchstr(line, '^\s*%template\s\zs.*')
|
||||
let state.placeholder = ['template', param]
|
||||
endif
|
||||
endif
|
||||
"}}}
|
||||
|
||||
" toc -- placeholder "{{{
|
||||
if !processed
|
||||
if line =~ '^\s*%toc'
|
||||
@ -1093,6 +1184,7 @@ function! s:parse_line(line, state) " {{{
|
||||
let state.table = s:close_tag_table(state.table, res_lines)
|
||||
let state.pre = s:close_tag_pre(state.pre, res_lines)
|
||||
let state.quote = s:close_tag_quote(state.quote, res_lines)
|
||||
let state.para = s:close_tag_para(state.para, res_lines)
|
||||
|
||||
let line = s:process_inline_tags(line)
|
||||
|
||||
@ -1189,25 +1281,32 @@ function! s:parse_line(line, state) " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
||||
function! vimwiki#html#Wiki2HTML(path, wikifile) "{{{
|
||||
|
||||
let starttime = reltime() " start the clock
|
||||
echo 'Generating HTML ... '
|
||||
if !s:syntax_supported()
|
||||
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
||||
return
|
||||
endif
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
let subdir = vimwiki#subdir(VimwikiGet('path'), wikifile)
|
||||
|
||||
let lsource = s:remove_comments(readfile(wikifile))
|
||||
let ldest = []
|
||||
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||
|
||||
let path = expand(a:path).subdir
|
||||
call vimwiki#mkdir(path)
|
||||
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
|
||||
|
||||
let lsource = readfile(wikifile)
|
||||
let ldest = []
|
||||
|
||||
call vimwiki#base#mkdir(path)
|
||||
|
||||
" nohtml placeholder -- to skip html generation.
|
||||
let nohtml = 0
|
||||
|
||||
" template placeholder
|
||||
let template_name = ''
|
||||
|
||||
" for table of contents placeholders.
|
||||
let placeholders = []
|
||||
|
||||
@ -1238,17 +1337,23 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
||||
if state.placeholder[0] == 'nohtml'
|
||||
let nohtml = 1
|
||||
break
|
||||
elseif state.placeholder[0] == 'template'
|
||||
let template_name = state.placeholder[1]
|
||||
else
|
||||
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
|
||||
let state.placeholder = []
|
||||
endif
|
||||
let state.placeholder = []
|
||||
endif
|
||||
|
||||
call extend(ldest, lines)
|
||||
endfor
|
||||
|
||||
|
||||
if !nohtml
|
||||
if nohtml
|
||||
echon "\r"."%nohtml placeholder found"
|
||||
return
|
||||
endif
|
||||
|
||||
let toc = s:get_html_toc(state.toc)
|
||||
call s:process_toc(ldest, placeholders, toc)
|
||||
call s:remove_blank_lines(ldest)
|
||||
@ -1265,16 +1370,37 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
||||
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())
|
||||
|
||||
let html_lines = s:get_html_template(a:wikifile, template_name)
|
||||
|
||||
" processing template variables (refactor to a function)
|
||||
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
|
||||
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
|
||||
\ s:root_path(subdir) .'", "g")')
|
||||
|
||||
let css_name = expand(VimwikiGet('css_name'))
|
||||
let css_name = substitute(css_name, '\', '/', 'g')
|
||||
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
|
||||
|
||||
let enc = &fileencoding
|
||||
if enc == ''
|
||||
let enc = &encoding
|
||||
endif
|
||||
call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
|
||||
|
||||
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
|
||||
|
||||
"" make html file.
|
||||
let wwFileNameOnly = fnamemodify(wikifile, ":t:r")
|
||||
call writefile(ldest, path.wwFileNameOnly.'.html')
|
||||
endif
|
||||
call writefile(html_lines, path.htmlfile)
|
||||
|
||||
" measure the elapsed time and cut away miliseconds and smaller
|
||||
let elapsedtimestr = matchstr(reltimestr(reltime(starttime)),'\d\+\(\.\d\d\)\=')
|
||||
echon "\r".htmlfile.' written (time: '.elapsedtimestr.'s)'
|
||||
return path.htmlfile
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_html#WikiAll2HTML(path) "{{{
|
||||
|
||||
function! vimwiki#html#WikiAll2HTML(path) "{{{
|
||||
if !s:syntax_supported()
|
||||
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
||||
return
|
||||
@ -1289,9 +1415,9 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
|
||||
let &eventignore = save_eventignore
|
||||
|
||||
let path = expand(a:path)
|
||||
call vimwiki#mkdir(path)
|
||||
call vimwiki#base#mkdir(path)
|
||||
|
||||
echomsg 'Deleting old html files...'
|
||||
echomsg 'Deleting non-wiki html files...'
|
||||
call s:delete_html_files(path)
|
||||
|
||||
echomsg 'Converting wiki to html files...'
|
||||
@ -1300,8 +1426,12 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
|
||||
|
||||
let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
|
||||
for wikifile in wikifiles
|
||||
if !s:is_html_uptodate(wikifile)
|
||||
echomsg 'Processing '.wikifile
|
||||
call vimwiki_html#Wiki2HTML(path, wikifile)
|
||||
call vimwiki#html#Wiki2HTML(path, wikifile)
|
||||
else
|
||||
echomsg 'Skipping '.wikifile
|
||||
endif
|
||||
endfor
|
||||
call s:create_default_CSS(path)
|
||||
echomsg 'Done!'
|
@ -46,7 +46,7 @@ endfunction "}}}
|
||||
" Get level of the list item.
|
||||
function! s:get_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)
|
||||
endif
|
||||
@ -287,7 +287,7 @@ endfunction "}}}
|
||||
" Script functions }}}
|
||||
|
||||
" Toggle list item between [ ] and [X]
|
||||
function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
|
||||
function! vimwiki#lst#ToggleListItem(line1, line2) "{{{
|
||||
let line1 = a:line1
|
||||
let line2 = a:line2
|
||||
|
||||
@ -316,7 +316,7 @@ function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_lst#kbd_cr() "{{{
|
||||
function! vimwiki#lst#kbd_cr() "{{{
|
||||
" This function is heavily relies on proper 'set comments' option.
|
||||
let cr = "\<CR>"
|
||||
if getline('.') =~ s:rx_cb_list_item()
|
||||
@ -325,9 +325,12 @@ function! vimwiki_lst#kbd_cr() "{{{
|
||||
return cr
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_lst#kbd_oO(cmd) "{{{
|
||||
function! vimwiki#lst#kbd_oO(cmd) "{{{
|
||||
" cmd should be 'o' or 'O'
|
||||
|
||||
let l:count = v:count1
|
||||
while l:count > 0
|
||||
|
||||
let beg_lnum = foldclosed('.')
|
||||
let end_lnum = foldclosedend('.')
|
||||
if end_lnum != -1 && a:cmd ==# 'o'
|
||||
@ -348,6 +351,7 @@ function! vimwiki_lst#kbd_oO(cmd) "{{{
|
||||
elseif &autoindent || &smartindent
|
||||
let res = matchstr(line, '^\s*')
|
||||
endif
|
||||
|
||||
if a:cmd ==# 'o'
|
||||
call append(lnum, res)
|
||||
call cursor(lnum + 1, col('$'))
|
||||
@ -355,5 +359,11 @@ function! vimwiki_lst#kbd_oO(cmd) "{{{
|
||||
call append(lnum - 1, res)
|
||||
call cursor(lnum, col('$'))
|
||||
endif
|
||||
|
||||
let l:count -= 1
|
||||
endwhile
|
||||
|
||||
startinsert!
|
||||
|
||||
endfunction "}}}
|
||||
|
39
autoload/vimwiki/style.css
Normal file
39
autoload/vimwiki/style.css
Normal file
@ -0,0 +1,39 @@
|
||||
body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}
|
||||
h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;}
|
||||
h1 {font-size: 2.6em; color: #000000;}
|
||||
h2 {font-size: 2.2em; color: #404040;}
|
||||
h3 {font-size: 1.8em; color: #707070;}
|
||||
h4 {font-size: 1.4em; color: #909090;}
|
||||
h5 {font-size: 1.3em; color: #989898;}
|
||||
h6 {font-size: 1.2em; color: #9c9c9c;}
|
||||
p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}
|
||||
ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}
|
||||
li {margin: 0.3em auto;}
|
||||
ul {margin-left: 2em; padding-left: 0.5em;}
|
||||
dt {font-weight: bold;}
|
||||
img {border: none;}
|
||||
pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}
|
||||
blockquote {padding: 0.4em; background-color: #f6f5eb;}
|
||||
th, td {border: 1px solid #ccc; padding: 0.3em;}
|
||||
th {background-color: #f0f0f0;}
|
||||
hr {border: none; border-top: 1px solid #ccc; width: 100%;}
|
||||
del {text-decoration: line-through; color: #777777;}
|
||||
.toc li {list-style-type: none;}
|
||||
.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}
|
||||
.justleft {text-align: left;}
|
||||
.justright {text-align: right;}
|
||||
.justcenter {text-align: center;}
|
||||
.center {margin-left: auto; margin-right: auto;}
|
||||
/* classes for items of todo lists */
|
||||
.done0:before {content: "\2592\2592\2592\2592"; color: SkyBlue;}
|
||||
.done1:before {content: "\2588\2592\2592\2592"; color: SkyBlue;}
|
||||
.done2:before {content: "\2588\2588\2592\2592"; color: SkyBlue;}
|
||||
.done3:before {content: "\2588\2588\2588\2592"; color: SkyBlue;}
|
||||
.done4:before {content: "\2588\2588\2588\2588"; color: SkyBlue;}
|
||||
/* comment the next four or five lines out *
|
||||
* if you do not want color-coded todo lists */
|
||||
.done0 {color: #c00000;}
|
||||
.done1 {color: #c08000;}
|
||||
.done2 {color: #80a000;}
|
||||
.done3 {color: #00c000;}
|
||||
.done4 {color: #7f7f7f; text-decoration: line-through;}
|
@ -299,7 +299,7 @@ endfunction "}}}
|
||||
" Keyboard functions "{{{
|
||||
function! s:kbd_create_new_row(cols, goto_first) "{{{
|
||||
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
|
||||
let cmd .= "\<ESC>:call vimwiki_tbl#format(line('.'))\<CR>"
|
||||
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
|
||||
if a:goto_first
|
||||
let cmd .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
|
||||
else
|
||||
@ -341,7 +341,7 @@ endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" Global functions {{{
|
||||
function! vimwiki_tbl#kbd_cr() "{{{
|
||||
function! vimwiki#tbl#kbd_cr() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<CR>"
|
||||
@ -355,7 +355,7 @@ function! vimwiki_tbl#kbd_cr() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#kbd_tab() "{{{
|
||||
function! vimwiki#tbl#kbd_tab() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<Tab>"
|
||||
@ -369,7 +369,7 @@ function! vimwiki_tbl#kbd_tab() "{{{
|
||||
return s:kbd_goto_next_col(last)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#kbd_shift_tab() "{{{
|
||||
function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<S-Tab>"
|
||||
@ -382,7 +382,7 @@ function! vimwiki_tbl#kbd_shift_tab() "{{{
|
||||
return s:kbd_goto_prev_col(first)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#format(lnum, ...) "{{{
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
@ -406,7 +406,7 @@ function! vimwiki_tbl#format(lnum, ...) "{{{
|
||||
let &tw = s:textwidth
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#create(...) "{{{
|
||||
function! vimwiki#tbl#create(...) "{{{
|
||||
if a:0 > 1
|
||||
let cols = a:1
|
||||
let rows = a:2
|
||||
@ -441,15 +441,15 @@ function! vimwiki_tbl#create(...) "{{{
|
||||
call append(line('.'), lines)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#align_or_cmd(cmd) "{{{
|
||||
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||
if s:is_table(getline('.'))
|
||||
call vimwiki_tbl#format(line('.'))
|
||||
call vimwiki#tbl#format(line('.'))
|
||||
else
|
||||
exe 'normal! '.a:cmd
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#reset_tw(lnum) "{{{
|
||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
@ -461,7 +461,7 @@ endfunction "}}}
|
||||
|
||||
" TODO: move_column_left and move_column_right are good candidates to be
|
||||
" refactored.
|
||||
function! vimwiki_tbl#move_column_left() "{{{
|
||||
function! vimwiki#tbl#move_column_left() "{{{
|
||||
if !s:is_table(getline('.'))
|
||||
return
|
||||
endif
|
||||
@ -472,7 +472,7 @@ function! vimwiki_tbl#move_column_left() "{{{
|
||||
endif
|
||||
|
||||
if cur_col > 0
|
||||
call vimwiki_tbl#format(line('.'), cur_col-1, cur_col)
|
||||
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
|
||||
call cursor(line('.'), 1)
|
||||
if !s:is_separator(getline('.'))
|
||||
call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW')
|
||||
@ -482,7 +482,7 @@ function! vimwiki_tbl#move_column_left() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#move_column_right() "{{{
|
||||
function! vimwiki#tbl#move_column_right() "{{{
|
||||
if !s:is_table(getline('.'))
|
||||
return
|
||||
endif
|
||||
@ -493,7 +493,7 @@ function! vimwiki_tbl#move_column_right() "{{{
|
||||
endif
|
||||
|
||||
if cur_col < s:col_count(line('.'))-1
|
||||
call vimwiki_tbl#format(line('.'), cur_col, cur_col+1)
|
||||
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
|
||||
call cursor(line('.'), 1)
|
||||
if !s:is_separator(getline('.'))
|
||||
call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW')
|
||||
@ -503,7 +503,7 @@ function! vimwiki_tbl#move_column_right() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#get_rows(lnum) "{{{
|
||||
function! vimwiki#tbl#get_rows(lnum) "{{{
|
||||
return s:get_rows(a:lnum)
|
||||
endfunction "}}}
|
||||
|
690
doc/vimwiki.txt
690
doc/vimwiki.txt
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@ let b:undo_ftplugin = "setlocal ".
|
||||
" MISC STUFF {{{
|
||||
|
||||
setlocal autowriteall
|
||||
setlocal commentstring=<!--%s-->
|
||||
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 <buffer> '.l_o.' :call vimwiki_lst#kbd_oO("o")<CR>a'
|
||||
exe 'nnoremap <buffer> '.l_o.' :call vimwiki#lst#kbd_oO("o")<CR>a'
|
||||
endif
|
||||
|
||||
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
|
||||
if l_O
|
||||
exe 'nnoremap <buffer> '.l_O.' :call vimwiki_lst#kbd_oO("O")<CR>a'
|
||||
exe 'nnoremap <buffer> '.l_O.' :call vimwiki#lst#kbd_oO("O")<CR>a'
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -64,19 +64,19 @@ 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*$'
|
||||
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#count_first_sym(nnline)
|
||||
let n = vimwiki#base#count_first_sym(nnline)
|
||||
return '<'.n
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
" List item folding...
|
||||
if g:vimwiki_fold_lists
|
||||
@ -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 <bar> call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||
\ expand('%'))
|
||||
command! -buffer Vimwiki2HTMLBrowse
|
||||
\ w <bar> 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(<line1>, <line2>)
|
||||
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
|
||||
|
||||
command! -buffer VimwikiGenerateLinks call vimwiki#generate_links()
|
||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
|
||||
|
||||
exe 'command! -buffer -nargs=* VimwikiSearch vimgrep <args> '.
|
||||
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
|
||||
|
||||
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
|
||||
exe 'command! -buffer -nargs=* VWS vimgrep <args> '.
|
||||
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
|
||||
command! -buffer -nargs=1 VimwikiGoto call vimwiki#goto("<args>")
|
||||
command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("<args>")
|
||||
|
||||
" table commands
|
||||
command! -buffer -nargs=* VimwikiTable call vimwiki_tbl#create(<f-args>)
|
||||
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(<f-args>)
|
||||
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 <buffer> <S-LeftMouse> <NOP>
|
||||
nmap <buffer> <C-LeftMouse> <NOP>
|
||||
noremap <silent><buffer> <2-LeftMouse> :VimwikiFollowLink<CR>
|
||||
noremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
||||
noremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
||||
noremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
||||
nnoremap <silent><buffer> <2-LeftMouse> :VimwikiFollowLink<CR>
|
||||
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
|
||||
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
|
||||
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
|
||||
endif
|
||||
|
||||
|
||||
if !hasmapto('<Plug>Vimwiki2HTML')
|
||||
nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
|
||||
endif
|
||||
nnoremap <script><buffer>
|
||||
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
|
||||
|
||||
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
|
||||
nmap <buffer> <Leader>whh <Plug>Vimwiki2HTMLBrowse
|
||||
endif
|
||||
nnoremap <script><buffer>
|
||||
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiFollowLink')
|
||||
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiSplitLink')
|
||||
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiVSplitLink')
|
||||
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabnewLink')
|
||||
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
|
||||
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiGoBackLink')
|
||||
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiNextLink')
|
||||
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiPrevLink')
|
||||
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDeleteLink')
|
||||
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRenameLink')
|
||||
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||
@ -302,25 +328,25 @@ if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
||||
endif
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
||||
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
|
||||
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
|
||||
endif
|
||||
noremap <silent><script><buffer>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
||||
|
||||
function! s:CR() "{{{
|
||||
let res = vimwiki_lst#kbd_cr()
|
||||
let res = vimwiki#lst#kbd_cr()
|
||||
if res == "\<CR>" && g:vimwiki_table_auto_fmt
|
||||
let res = vimwiki_tbl#kbd_cr()
|
||||
let res = vimwiki#tbl#kbd_cr()
|
||||
endif
|
||||
return res
|
||||
endfunction "}}}
|
||||
@ -329,45 +355,53 @@ endfunction "}}}
|
||||
inoremap <buffer> <expr> <CR> <SID>CR()
|
||||
|
||||
" List mappings
|
||||
nnoremap <buffer> o :call vimwiki_lst#kbd_oO('o')<CR>a
|
||||
nnoremap <buffer> O :call vimwiki_lst#kbd_oO('O')<CR>a
|
||||
nnoremap <buffer> o :<C-U>call vimwiki#lst#kbd_oO('o')<CR>
|
||||
nnoremap <buffer> O :<C-U>call vimwiki#lst#kbd_oO('O')<CR>
|
||||
|
||||
" Table mappings
|
||||
if g:vimwiki_table_auto_fmt
|
||||
inoremap <expr> <buffer> <Tab> vimwiki_tbl#kbd_tab()
|
||||
inoremap <expr> <buffer> <S-Tab> vimwiki_tbl#kbd_shift_tab()
|
||||
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
|
||||
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
|
||||
endif
|
||||
|
||||
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
|
||||
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
|
||||
nnoremap <buffer> <A-Left> :VimwikiTableMoveColumnLeft<CR>
|
||||
nnoremap <buffer> <A-Right> :VimwikiTableMoveColumnRight<CR>
|
||||
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
|
||||
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
|
||||
if !hasmapto('<Plug>VimwikiTableMoveColumnRight')
|
||||
nmap <silent><buffer> <A-Right> <Plug>VimwikiTableMoveColumnRight
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiTableMoveColumnRight :VimwikiTableMoveColumnRight<CR>
|
||||
|
||||
" Misc mappings
|
||||
inoremap <buffer> <S-CR> <br /><CR>
|
||||
|
||||
|
||||
" Text objects {{{
|
||||
onoremap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 0)<CR>
|
||||
vnoremap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 1)<CR>
|
||||
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0)<CR>
|
||||
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> ih :<C-U>call vimwiki#TO_header(1, 0)<CR>
|
||||
vnoremap <silent><buffer> ih :<C-U>call vimwiki#TO_header(1, 1)<CR>
|
||||
onoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 0)<CR>
|
||||
vnoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> a\ :<C-U>call vimwiki#TO_table_cell(0, 0)<CR>
|
||||
vnoremap <silent><buffer> a\ :<C-U>call vimwiki#TO_table_cell(0, 1)<CR>
|
||||
onoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 0)<CR>
|
||||
vnoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> i\ :<C-U>call vimwiki#TO_table_cell(1, 0)<CR>
|
||||
vnoremap <silent><buffer> i\ :<C-U>call vimwiki#TO_table_cell(1, 1)<CR>
|
||||
onoremap <silent><buffer> i\ :<C-U>call vimwiki#base#TO_table_cell(1, 0)<CR>
|
||||
vnoremap <silent><buffer> i\ :<C-U>call vimwiki#base#TO_table_cell(1, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> ac :<C-U>call vimwiki#TO_table_col(0, 0)<CR>
|
||||
vnoremap <silent><buffer> ac :<C-U>call vimwiki#TO_table_col(0, 1)<CR>
|
||||
onoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 0)<CR>
|
||||
vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
|
||||
|
||||
onoremap <silent><buffer> ic :<C-U>call vimwiki#TO_table_col(1, 0)<CR>
|
||||
vnoremap <silent><buffer> ic :<C-U>call vimwiki#TO_table_col(1, 1)<CR>
|
||||
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
|
||||
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
|
||||
|
||||
noremap <silent><buffer> = :call vimwiki#AddHeaderLevel()<CR>
|
||||
noremap <silent><buffer> - :call vimwiki#RemoveHeaderLevel()<CR>
|
||||
nnoremap <silent><buffer> = :call vimwiki#base#AddHeaderLevel()<CR>
|
||||
nnoremap <silent><buffer> - :call vimwiki#base#RemoveHeaderLevel()<CR>
|
||||
|
||||
" }}}
|
||||
|
||||
|
@ -19,22 +19,30 @@ function! s:default(varname, value) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" return longest common prefix of 2 given strings.
|
||||
" 'Hello world', 'Hello worm' => 'Hello wor'
|
||||
function! s:str_common_pfx(str1, str2) "{{{
|
||||
" return longest common path prefix of 2 given paths.
|
||||
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
|
||||
function! s:path_common_pfx(path1, path2) "{{{
|
||||
let p1 = split(a:path1, '[/\\]', 1)
|
||||
let p2 = split(a:path2, '[/\\]', 1)
|
||||
|
||||
let idx = 0
|
||||
let minlen = min([len(a:str1), len(a:str2)])
|
||||
while (idx < minlen) && (a:str1[idx] ==? a:str2[idx])
|
||||
let minlen = min([len(p1), len(p2)])
|
||||
while (idx < minlen) && (p1[idx] ==? p2[idx])
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
return strpart(a:str1, 0, idx)
|
||||
if idx == 0
|
||||
return ''
|
||||
else
|
||||
return join(p1[: idx-1], '/')
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_wiki(path) "{{{
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
let path = vimwiki#chomp_slash(expand(VimwikiGet('path', idx)))
|
||||
if s:str_common_pfx(path, a:path) == path
|
||||
let path = vimwiki#base#chomp_slash(expand(VimwikiGet('path', idx)))
|
||||
let path = vimwiki#base#path_norm(path)
|
||||
if s:path_common_pfx(path, a:path) == path
|
||||
return idx
|
||||
endif
|
||||
let idx += 1
|
||||
@ -53,6 +61,19 @@ function! s:setup_buffer_leave()"{{{
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
function! s:setup_filetype() "{{{
|
||||
" Find what wiki current buffer belongs to.
|
||||
let path = expand('%:p:h')
|
||||
let ext = '.'.expand('%:e')
|
||||
let idx = s:find_wiki(path)
|
||||
|
||||
if idx == -1 && g:vimwiki_global_ext == 0
|
||||
return
|
||||
endif
|
||||
|
||||
set filetype=vimwiki
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_buffer_enter() "{{{
|
||||
if exists("b:vimwiki_idx")
|
||||
let g:vimwiki_current_idx = b:vimwiki_idx
|
||||
@ -81,8 +102,16 @@ function! s:setup_buffer_enter() "{{{
|
||||
let b:vimwiki_idx = g:vimwiki_current_idx
|
||||
endif
|
||||
|
||||
" If you have
|
||||
" au GUIEnter * VimwikiIndex
|
||||
" Then change it to
|
||||
" au GUIEnter * nested VimwikiIndex
|
||||
if &filetype == ''
|
||||
set filetype=vimwiki
|
||||
endif
|
||||
|
||||
" Update existed/non-existed links highlighting.
|
||||
call vimwiki#highlight_links()
|
||||
call vimwiki#base#highlight_links()
|
||||
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
@ -158,9 +187,9 @@ if !exists("*VimwikiWeblinkHandler") "{{{
|
||||
for browser in g:vimwiki_browsers
|
||||
if executable(browser)
|
||||
if has("win32")
|
||||
execute '!start "'.browser.'" ' . a:weblink
|
||||
execute '!start "'.browser.'" "' . a:weblink . '"'
|
||||
else
|
||||
execute '!'.browser.' ' . a:weblink
|
||||
execute '!'.browser.' "' . a:weblink . '"'
|
||||
endif
|
||||
return
|
||||
endif
|
||||
@ -178,8 +207,11 @@ let s:vimwiki_defaults.index = 'index'
|
||||
let s:vimwiki_defaults.ext = '.wiki'
|
||||
let s:vimwiki_defaults.maxhi = 1
|
||||
let s:vimwiki_defaults.syntax = 'default'
|
||||
let s:vimwiki_defaults.html_header = ''
|
||||
let s:vimwiki_defaults.html_footer = ''
|
||||
|
||||
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
|
||||
let s:vimwiki_defaults.template_default = 'default'
|
||||
let s:vimwiki_defaults.template_ext = '.html'
|
||||
|
||||
let s:vimwiki_defaults.nested_syntaxes = {}
|
||||
let s:vimwiki_defaults.auto_export = 0
|
||||
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
|
||||
@ -217,7 +249,7 @@ call s:default('fold_trailing_empty_lines', 0)
|
||||
call s:default('fold_lists', 0)
|
||||
call s:default('menu', 'Vimwiki')
|
||||
call s:default('global_ext', 1)
|
||||
call s:default('hl_headers', 1)
|
||||
call s:default('hl_headers', 0)
|
||||
call s:default('hl_cb_checked', 0)
|
||||
call s:default('camel_case', 1)
|
||||
call s:default('list_ignore_newline', 1)
|
||||
@ -233,6 +265,7 @@ if has("win32")
|
||||
else
|
||||
call s:default('browsers',
|
||||
\ [
|
||||
\ 'chromium-browser',
|
||||
\ 'opera',
|
||||
\ 'firefox',
|
||||
\ 'konqueror',
|
||||
@ -245,7 +278,8 @@ call s:default('w32_dir_enc', '')
|
||||
call s:default('CJK_length', 0)
|
||||
call s:default('dir_link', '')
|
||||
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
|
||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr')
|
||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
|
||||
call s:default('user_htmls', '')
|
||||
|
||||
call s:default('html_header_numbering', 0)
|
||||
call s:default('html_header_numbering_sym', '')
|
||||
@ -273,9 +307,15 @@ else
|
||||
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
|
||||
endif
|
||||
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
|
||||
\'\%('.
|
||||
\'\%('.
|
||||
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
|
||||
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'.
|
||||
\'[().,?]\@<!'
|
||||
\'\%(\%(//\)\|\%(\\\\\)\)'.
|
||||
\'\)'.
|
||||
\'\|\%(mailto:\)'.
|
||||
\'\)'.
|
||||
\'\+\S\+'.
|
||||
\'[().,?\]]\@<!'
|
||||
"}}}
|
||||
|
||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||
@ -297,64 +337,71 @@ augroup end
|
||||
augroup vimwiki
|
||||
autocmd!
|
||||
for ext in keys(extensions)
|
||||
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
||||
exe 'autocmd BufNewFile,BufRead, *'.ext.' setlocal filetype=vimwiki'
|
||||
exe 'autocmd BufNewFile,BufRead, *'.ext.' call s:setup_filetype()'
|
||||
|
||||
" ColorScheme could have or could have not a
|
||||
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
|
||||
" syntax after colorscheme change.
|
||||
exe 'autocmd ColorScheme *'.ext.' call vimwiki#setup_colors()'.
|
||||
\ ' | call vimwiki#highlight_links()'
|
||||
exe 'autocmd ColorScheme *'.ext.' syntax enable'.
|
||||
\ ' | call vimwiki#base#highlight_links()'
|
||||
|
||||
" Format tables when exit from insert mode. Do not use textwidth to
|
||||
" autowrap tables.
|
||||
if g:vimwiki_table_auto_fmt
|
||||
exe 'autocmd InsertLeave *'.ext.' call vimwiki_tbl#format(line("."))'
|
||||
exe 'autocmd InsertEnter *'.ext.' call vimwiki_tbl#reset_tw(line("."))'
|
||||
exe 'autocmd InsertLeave *'.ext.' call vimwiki#tbl#format(line("."))'
|
||||
exe 'autocmd InsertEnter *'.ext.' call vimwiki#tbl#reset_tw(line("."))'
|
||||
endif
|
||||
endfor
|
||||
augroup END
|
||||
"}}}
|
||||
|
||||
" COMMANDS {{{
|
||||
command! VimwikiUISelect call vimwiki#ui_select()
|
||||
command! VimwikiUISelect call vimwiki#base#ui_select()
|
||||
command! -count VimwikiIndex
|
||||
\ call vimwiki#goto_index(v:count1)
|
||||
\ call vimwiki#base#goto_index(v:count1)
|
||||
command! -count VimwikiTabIndex tabedit <bar>
|
||||
\ call vimwiki#goto_index(v:count1)
|
||||
\ call vimwiki#base#goto_index(v:count1)
|
||||
|
||||
command! -count VimwikiDiaryIndex
|
||||
\ call vimwiki#diary#goto_index(v:count1)
|
||||
command! -count VimwikiMakeDiaryNote
|
||||
\ call vimwiki_diary#make_note(v:count1)
|
||||
\ call vimwiki#diary#make_note(v:count1)
|
||||
command! -count VimwikiTabMakeDiaryNote tabedit <bar>
|
||||
\ call vimwiki_diary#make_note(v:count1)
|
||||
\ call vimwiki#diary#make_note(v:count1)
|
||||
"}}}
|
||||
|
||||
" MAPPINGS {{{
|
||||
if !hasmapto('<Plug>VimwikiIndex')
|
||||
map <silent><unique> <Leader>ww <Plug>VimwikiIndex
|
||||
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
|
||||
endif
|
||||
noremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
||||
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabIndex')
|
||||
map <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
|
||||
nmap <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
|
||||
endif
|
||||
noremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
||||
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiUISelect')
|
||||
map <silent><unique> <Leader>ws <Plug>VimwikiUISelect
|
||||
nmap <silent><unique> <Leader>ws <Plug>VimwikiUISelect
|
||||
endif
|
||||
noremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
||||
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryIndex')
|
||||
nmap <silent><unique> <Leader>wi <Plug>VimwikiDiaryIndex
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
|
||||
map <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
|
||||
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
|
||||
endif
|
||||
noremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
||||
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
||||
map <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
|
||||
nmap <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
|
||||
endif
|
||||
noremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
||||
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
||||
\ :VimwikiTabMakeDiaryNote<CR>
|
||||
|
||||
"}}}
|
||||
@ -366,9 +413,9 @@ function! s:build_menu(topmenu)
|
||||
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
|
||||
let norm_path = escape(norm_path, '\ \.')
|
||||
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
||||
\ ' :call vimwiki#goto_index('.(idx + 1).')<CR>'
|
||||
\ ' :call vimwiki#base#goto_index('.(idx + 1).')<CR>'
|
||||
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
||||
\ ' :call vimwiki_diary#make_note('.(idx + 1).')<CR>'
|
||||
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
|
||||
let idx += 1
|
||||
endwhile
|
||||
endfunction
|
||||
@ -390,8 +437,8 @@ endif
|
||||
|
||||
" CALENDAR Hook "{{{
|
||||
if g:vimwiki_use_calendar
|
||||
let g:calendar_action = 'vimwiki_diary#calendar_action'
|
||||
let g:calendar_sign = 'vimwiki_diary#calendar_sign'
|
||||
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
||||
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
||||
endif
|
||||
"}}}
|
||||
|
||||
|
@ -10,7 +10,7 @@ elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Links highlighting is controlled by vimwiki#highlight_links() function.
|
||||
" Links highlighting is controlled by vimwiki#base#highlight_links() function.
|
||||
" It is called from setup_buffer_enter() function in the BufEnter autocommand.
|
||||
|
||||
" Load concrete Wiki syntax
|
||||
@ -20,6 +20,9 @@ execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
|
||||
if exists("+conceallevel")
|
||||
syntax conceal on
|
||||
endif
|
||||
|
||||
syntax spell toplevel
|
||||
|
||||
syn match VimwikiLinkChar contained /\[\[/
|
||||
syn match VimwikiLinkChar contained /\]\]/
|
||||
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.\{-}]]/
|
||||
@ -62,12 +65,12 @@ execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
|
||||
|
||||
|
||||
" Tables
|
||||
" execute 'syntax match VimwikiTable /'.g:vimwiki_rxTable.'/'
|
||||
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
||||
\ transparent contains=VimwikiCellSeparator,VimwikiLinkT,
|
||||
\ VimwikiNoExistsLinkT,VimwikiEmoticons,VimwikiTodo,
|
||||
\ VimwikiBoldT,VimwikiItalicT,VimwikiBoldItalicT,VimwikiItalicBoldT,
|
||||
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT
|
||||
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT,
|
||||
\ @Spell
|
||||
syntax match VimwikiCellSeparator
|
||||
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
||||
|
||||
@ -76,35 +79,36 @@ execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
|
||||
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
|
||||
|
||||
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar'
|
||||
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT'
|
||||
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar'
|
||||
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT'
|
||||
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar,@Spell'
|
||||
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar'
|
||||
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT'
|
||||
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar'
|
||||
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT'
|
||||
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
|
||||
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar'
|
||||
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar'
|
||||
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar,@Spell'
|
||||
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar'
|
||||
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT'
|
||||
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar,@Spell'
|
||||
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar'
|
||||
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT'
|
||||
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar,@Spell'
|
||||
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT,@Spell'
|
||||
|
||||
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
|
||||
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
|
||||
|
||||
|
||||
" <hr> horizontal rule
|
||||
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
|
||||
|
||||
execute 'syntax region VimwikiPre start=/'.g:vimwiki_rxPreStart.
|
||||
\ '/ end=/'.g:vimwiki_rxPreEnd.'/ contains=VimwikiComment'
|
||||
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
|
||||
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
|
||||
|
||||
" List item checkbox
|
||||
syntax match VimwikiCheckBox /\[.\?\]/
|
||||
@ -121,6 +125,7 @@ endif
|
||||
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
|
||||
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
|
||||
syntax match VimwikiPlaceholderParam /\s.*/ contained
|
||||
|
||||
" html tags
|
||||
@ -130,23 +135,44 @@ execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
||||
|
||||
syntax region VimwikiComment start='<!--' end='-->'
|
||||
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
|
||||
|
||||
if g:vimwiki_hl_headers == 0
|
||||
execute 'syntax match VimwikiHeader /'.g:vimwiki_rxHeader.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
else
|
||||
" Header levels, 1-6
|
||||
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo,VimwikiHeaderChar'
|
||||
endif
|
||||
" Header levels, 1-6
|
||||
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
|
||||
|
||||
" group names "{{{
|
||||
|
||||
call vimwiki#setup_colors()
|
||||
if g:vimwiki_hl_headers == 0
|
||||
hi link VimwikiHeader1 Title
|
||||
hi link VimwikiHeader2 Title
|
||||
hi link VimwikiHeader3 Title
|
||||
hi link VimwikiHeader4 Title
|
||||
hi link VimwikiHeader5 Title
|
||||
hi link VimwikiHeader6 Title
|
||||
else
|
||||
if &background == 'light'
|
||||
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed term=bold cterm=bold
|
||||
hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen term=bold cterm=bold
|
||||
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue term=bold cterm=bold
|
||||
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black term=bold cterm=bold
|
||||
hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black term=bold cterm=bold
|
||||
hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black term=bold cterm=bold
|
||||
else
|
||||
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red term=bold cterm=bold
|
||||
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green term=bold cterm=bold
|
||||
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue term=bold cterm=bold
|
||||
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White term=bold cterm=bold
|
||||
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White term=bold cterm=bold
|
||||
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White term=bold cterm=bold
|
||||
endif
|
||||
endif
|
||||
|
||||
hi def link VimwikiMarkers Normal
|
||||
|
||||
hi def VimwikiBold term=bold cterm=bold gui=bold
|
||||
hi def link VimwikiBoldT VimwikiBold
|
||||
@ -164,16 +190,16 @@ hi def VimwikiUnderline gui=underline
|
||||
hi def link VimwikiCode PreProc
|
||||
hi def link VimwikiCodeT VimwikiCode
|
||||
|
||||
hi def link VimwikiNoExistsLink Error
|
||||
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
|
||||
|
||||
hi def link VimwikiPre PreProc
|
||||
hi def link VimwikiPreT VimwikiPre
|
||||
|
||||
hi def link VimwikiLink Underlined
|
||||
hi def link VimwikiLinkT Underlined
|
||||
hi def link VimwikiNoExistsLink SpellBad
|
||||
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
|
||||
|
||||
hi def link VimwikiList Function
|
||||
hi def link VimwikiLink Underlined
|
||||
hi def link VimwikiLinkT VimwikiLink
|
||||
|
||||
hi def link VimwikiList Identifier
|
||||
hi def link VimwikiCheckBox VimwikiList
|
||||
hi def link VimwikiCheckBoxDone Comment
|
||||
hi def link VimwikiEmoticons Character
|
||||
@ -190,33 +216,32 @@ hi def link VimwikiSubScriptT VimwikiSubScript
|
||||
hi def link VimwikiTodo Todo
|
||||
hi def link VimwikiComment Comment
|
||||
|
||||
hi def link VimwikiCellSeparator PreProc
|
||||
|
||||
hi def link VimwikiPlaceholder SpecialKey
|
||||
hi def link VimwikiPlaceholderParam String
|
||||
hi def link VimwikiHTMLtag SpecialKey
|
||||
|
||||
hi def link VimwikiBoldChar VimwikiIgnore
|
||||
hi def link VimwikiItalicChar VimwikiIgnore
|
||||
hi def link VimwikiBoldItalicChar VimwikiIgnore
|
||||
hi def link VimwikiItalicBoldChar VimwikiIgnore
|
||||
hi def link VimwikiDelTextChar VimwikiIgnore
|
||||
hi def link VimwikiSuperScriptChar VimwikiIgnore
|
||||
hi def link VimwikiSubScriptChar VimwikiIgnore
|
||||
hi def link VimwikiCodeChar VimwikiIgnore
|
||||
hi def link VimwikiHeaderChar VimwikiIgnore
|
||||
hi def link VimwikiCellSeparator VimwikiMarkers
|
||||
hi def link VimwikiBoldChar VimwikiMarkers
|
||||
hi def link VimwikiItalicChar VimwikiMarkers
|
||||
hi def link VimwikiBoldItalicChar VimwikiMarkers
|
||||
hi def link VimwikiItalicBoldChar VimwikiMarkers
|
||||
hi def link VimwikiDelTextChar VimwikiMarkers
|
||||
hi def link VimwikiSuperScriptChar VimwikiMarkers
|
||||
hi def link VimwikiSubScriptChar VimwikiMarkers
|
||||
hi def link VimwikiCodeChar VimwikiMarkers
|
||||
hi def link VimwikiHeaderChar VimwikiMarkers
|
||||
hi def link VimwikiLinkChar VimwikiLink
|
||||
hi def link VimwikiNoLinkChar VimwikiNoExistsLink
|
||||
|
||||
hi def link VimwikiBoldCharT VimwikiIgnore
|
||||
hi def link VimwikiItalicCharT VimwikiIgnore
|
||||
hi def link VimwikiBoldItalicCharT VimwikiIgnore
|
||||
hi def link VimwikiItalicBoldCharT VimwikiIgnore
|
||||
hi def link VimwikiDelTextCharT VimwikiIgnore
|
||||
hi def link VimwikiSuperScriptCharT VimwikiIgnore
|
||||
hi def link VimwikiSubScriptCharT VimwikiIgnore
|
||||
hi def link VimwikiCodeCharT VimwikiIgnore
|
||||
hi def link VimwikiHeaderCharT VimwikiIgnore
|
||||
hi def link VimwikiBoldCharT VimwikiMarkers
|
||||
hi def link VimwikiItalicCharT VimwikiMarkers
|
||||
hi def link VimwikiBoldItalicCharT VimwikiMarkers
|
||||
hi def link VimwikiItalicBoldCharT VimwikiMarkers
|
||||
hi def link VimwikiDelTextCharT VimwikiMarkers
|
||||
hi def link VimwikiSuperScriptCharT VimwikiMarkers
|
||||
hi def link VimwikiSubScriptCharT VimwikiMarkers
|
||||
hi def link VimwikiCodeCharT VimwikiMarkers
|
||||
hi def link VimwikiHeaderCharT VimwikiMarkers
|
||||
hi def link VimwikiLinkCharT VimwikiLinkT
|
||||
hi def link VimwikiNoLinkCharT VimwikiNoExistsLinkT
|
||||
"}}}
|
||||
@ -227,7 +252,7 @@ let b:current_syntax="vimwiki"
|
||||
let nested = VimwikiGet('nested_syntaxes')
|
||||
if !empty(nested)
|
||||
for [hl_syntax, vim_syntax] in items(nested)
|
||||
call vimwiki#nested_syntax(vim_syntax,
|
||||
call vimwiki#base#nested_syntax(vim_syntax,
|
||||
\ '^\s*{{{\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*}}}', 'VimwikiPre')
|
||||
|
@ -81,3 +81,5 @@ let g:vimwiki_rxListDefine = '::\(\s\|$\)'
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '{{{'
|
||||
let g:vimwiki_rxPreEnd = '}}}'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
|
@ -65,3 +65,5 @@ let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '<pre>'
|
||||
let g:vimwiki_rxPreEnd = '<\/pre>'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
|
Loading…
Reference in New Issue
Block a user