Version 0.9.9

* NEW: Diary. Help in making daily notes. See ':h vimwiki-diary'. Now you
  can really easy add information into vimwiki that should be sorted out
  later.
* NEW: Tables are redesigned. Syntax is changed. Now they are
  auto-formattable. You can navigate them with <tab> and <cr> in insert
  mode. See 'vimwiki-syntax-tables' and 'vimwiki-tables' for more details.
* NEW: Keyword STARTED: is added.
* NEW: Words TODO:, DONE:, STARTED:, XXX:, FIXME:, FIXED: are highlighed
  inside headers.
* FIX: Export to html external links with 'file://' protocol. Ex:
  '[file:///home/user1/book.pdf my book]'.
* FIX: Menu is corrupted if wiki's path contains spaces.
* FIX: Settings 'wrap' and 'linebreak' are removed from ftplugin. Add them
  into your personal settings file '.vim/after/ftplugin/vimwiki.vim' if
  needed.
* NEW: Headers are highlighted in different colors by default.  See ':h
  g:vimwiki_hl_headers' to turn it off.
* FIX: Issue 40: Links with russian subdirs don't work.
* NEW: It is now possible to generate HTML files automatically on page
  save. See ':h vimwiki-option-auto_export'.
This commit is contained in:
Maxim Kim 2010-02-23 00:00:00 +00:00 committed by Able Scraper
parent 74160d8e3e
commit bb1f5b3c46
8 changed files with 1179 additions and 184 deletions

View File

@ -23,10 +23,17 @@ function! s:chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}}
function! s:is_windows()
return has("win32") || has("win64") || has("win95") || has("win16")
endfunction
function! vimwiki#mkdir(path) "{{{
let path = expand(a:path)
if !isdirectory(path) && exists("*mkdir")
let path = s:chomp_slash(path)
if s:is_windows() && !empty(g:vimwiki_w32_dir_enc)
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
endif
call mkdir(path, "p")
endif
endfunction
@ -62,6 +69,25 @@ function! vimwiki#current_subdir()"{{{
return vimwiki#subdir(VimwikiGet('path'), expand('%:p'))
endfunction"}}}
function! vimwiki#open_link(cmd, link, ...) "{{{
if s:is_link_to_non_wiki_file(a:link)
call s:edit_file(a:cmd, a:link)
else
if a:0
let vimwiki_prev_link = [a:1, []]
elseif &ft == 'vimwiki'
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
endif
call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext'))
if exists('vimwiki_prev_link')
let b:vimwiki_prev_link = vimwiki_prev_link
endif
endif
endfunction
" }}}
function! s:filename(link) "{{{
let result = vimwiki#safe_link(a:link)
if a:link =~ '|'
@ -165,11 +191,13 @@ function! s:print_wiki_list() "{{{
endfunction
" }}}
function! s:wiki_select(wnum)"{{{
function! vimwiki#select(wnum)"{{{
if a:wnum < 1 || a:wnum > len(g:vimwiki_list)
return
endif
if &ft == 'vimwiki'
let b:vimwiki_idx = g:vimwiki_current_idx
endif
let g:vimwiki_current_idx = a:wnum - 1
endfunction
" }}}
@ -260,7 +288,7 @@ function! s:get_wiki_buffers() "{{{
if bufexists(bcount)
let bname = fnamemodify(bufname(bcount), ":p")
if bname =~ VimwikiGet('ext')."$"
let bitem = [bname, getbufvar(bname, "vimwiki_prev_word")]
let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
call add(blist, bitem)
endif
endif
@ -273,7 +301,7 @@ endfunction
function! s:open_wiki_buffer(item) "{{{
call s:edit_file('e', a:item[0])
if !empty(a:item[1])
call setbufvar(a:item[0], "vimwiki_prev_word", a:item[1])
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
endif
endfunction
" }}}
@ -388,8 +416,8 @@ function! vimwiki#WikiFollowWord(split) "{{{
let cmd = ":e "
endif
let word = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiWord))
if word == ""
let link = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiWord))
if link == ""
let weblink = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWeblink))
if weblink != ""
call VimwikiWeblinkHandler(weblink)
@ -399,21 +427,16 @@ function! vimwiki#WikiFollowWord(split) "{{{
return
endif
if s:is_link_to_non_wiki_file(word)
call s:edit_file(cmd, word)
else
let vimwiki_prev_word = [expand('%:p'), getpos('.')]
let subdir = vimwiki#current_subdir()
call s:edit_file(cmd, VimwikiGet('path').subdir.word.VimwikiGet('ext'))
let b:vimwiki_prev_word = vimwiki_prev_word
endif
call vimwiki#open_link(cmd, subdir.link)
endfunction
" }}}
function! vimwiki#WikiGoBackWord() "{{{
if exists("b:vimwiki_prev_word")
if exists("b:vimwiki_prev_link")
" go back to saved WikiWord
let prev_word = b:vimwiki_prev_word
let prev_word = b:vimwiki_prev_link
execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g')
call setpos('.', prev_word[1])
endif
@ -421,7 +444,7 @@ endfunction
" }}}
function! vimwiki#WikiGoHome(index) "{{{
call s:wiki_select(a:index)
call vimwiki#select(a:index)
call vimwiki#mkdir(VimwikiGet('path'))
try
@ -523,7 +546,7 @@ function! vimwiki#WikiRenameWord() "{{{
let &buftype="nofile"
let cur_buffer = [expand('%:p'),
\getbufvar(expand('%:p'), "vimwiki_prev_word")]
\getbufvar(expand('%:p'), "vimwiki_prev_link")]
let blist = s:get_wiki_buffers()

216
autoload/vimwiki_diary.vim Normal file
View File

@ -0,0 +1,216 @@
" Vimwiki autoload plugin file
" Desc: Handle diary notes
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_diary_auto") || &cp
finish
endif
let g:loaded_vimwiki_diary_auto = 1
"}}}
function! s:prefix_zero(num) "{{{
if a:num < 10
return '0'.a:num
endif
return a:num
endfunction "}}}
function! s:desc(d1, d2) "{{{
return a:d1 == a:d2 ? 0 : a:d1 < a:d2 ? 1 : -1
endfunction "}}}
function! s:get_date_link(fmt) "{{{
return strftime(a:fmt)
endfunction "}}}
function! s:link_exists(lines, link) "{{{
let link_exists = 0
for line in a:lines
if line =~ escape(a:link, '[]\')
let link_exists = 1
break
endif
endfor
return link_exists
endfunction "}}}
function! s:diary_path() "{{{
return VimwikiGet('path').VimwikiGet('diary_rel_path')
endfunction "}}}
function! s:diary_index() "{{{
return s:diary_path().VimwikiGet('diary_index').VimwikiGet('ext')
endfunction "}}}
function! s:get_diary_range(lines, header) "{{{
let rx = '\[\[\d\{4}-\d\d-\d\d\]\]'
let idx = 0
let ln_start = -1
let ln_end = -1
for line in a:lines
if ln_start != -1
if line =~ '^\s*\(=\)\+.*\1\s*$' || (line !~ rx && line !~ '^\s*$')
break
endif
endif
if line =~ '^\s*\(=\)\+\s*'.a:header.'\s*\1\s*$'
let ln_start = idx + 1
endif
let idx += 1
endfor
let ln_end = idx - 1
return [ln_start, ln_end]
endfunction "}}}
function! s:diary_date_link() "{{{
return s:get_date_link(VimwikiGet('diary_link_fmt'))
endfunction "}}}
function! s:get_file_contents(file_name) "{{{
let lines = []
let bufnr = bufnr(expand(a:file_name))
if bufnr != -1
let lines = getbufline(bufnr, 1, '$')
else
try
let lines = readfile(expand(a:file_name))
catch
endtry
endif
return [lines, bufnr]
endfunction "}}}
function! s:get_links() "{{{
let rx = '\d\{4}-\d\d-\d\d'
let s_links = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*.wiki')
"let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "g")
let s_links = substitute(s_links, '\.wiki', "", "g")
let links = split(s_links, '\n')
" remove backup files (.wiki~)
call filter(links, 'v:val !~ ''.*\~$''')
" remove paths
call map(links, 'fnamemodify(v:val, ":t")')
call filter(links, 'v:val =~ "'.escape(rx, '\').'"')
call map(links, '"[[".v:val."]]"')
return links
endfunction "}}}
function! s:format_links(links) "{{{
let lines = []
let line = '| '
let idx = 0
let trigger = 0
while idx < len(a:links)
if idx/VimwikiGet('diary_link_count') > trigger
let trigger = idx/VimwikiGet('diary_link_count')
call add(lines, substitute(line, '\s\+$', '', ''))
let line = '| '
endif
let line .= a:links[idx].' | '
let idx += 1
endwhile
call add(lines, substitute(line, '\s\+$', '', ''))
call extend(lines, [''])
return lines
endfunction "}}}
function! s:add_link(page, header, link) "{{{
let [lines, bufnr] = s:get_file_contents(a:page)
let [ln_start, ln_end] = s:get_diary_range(lines, a:header)
let link = '[['.a:link.']]'
let link_exists = s:link_exists(lines[ln_start : ln_end], link)
if !link_exists
if ln_start == -1
call insert(lines, '= '.a:header.' =')
let ln_start = 1
endif
" removing 'old' links
let idx = ln_end - ln_start
while idx > 0
call remove(lines, ln_start)
let idx -= 1
endwhile
" get all diary links from filesystem
let links = s:get_links()
" add current link
if index(links, link) == -1
call add(links, link)
endif
let links = sort(links, 's:desc')
call extend(lines, s:format_links(links), ln_start)
if bufnr != -1
exe 'buffer '.bufnr
if !&readonly
1,$delete _
call append(1, lines)
1,1delete _
endif
else
call writefile(lines, expand(a:page))
endif
endif
endfunction "}}}
function! s:make_date_link(...) "{{{
if a:0
let link = a:1
else
let link = s:diary_date_link()
endif
let header = VimwikiGet('diary_header')
call s:add_link(s:diary_index(), header, 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'))
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())
endfunction "}}}
" Calendar.vim callback.
function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let link = a:year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir == 'V'
vsplit
else
split
endif
else
wincmd p
if !&hidden && &modified
new
endif
endif
" Create diary note for a selected date in default wiki.
call vimwiki_diary#make_note(1, link)
endfunction

View File

@ -3,6 +3,8 @@
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" XXX: This file should be refactored!
" Load only once {{{
if exists("g:loaded_vimwiki_html_auto") || &cp
finish
@ -32,7 +34,7 @@ function! s:remove_blank_lines(lines) " {{{
endfunction "}}}
function! s:is_web_link(lnk) "{{{
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\)'
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\)'
return 1
endif
return 0
@ -83,7 +85,8 @@ function! s:create_default_CSS(path) " {{{
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, 'td {border: 1px solid #ccc; padding: 0.3em;}')
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;}')
@ -515,9 +518,9 @@ function! s:close_tag_para(para, ldest) "{{{
endfunction "}}}
function! s:close_tag_table(table, ldest) "{{{
if a:table
if len(a:table)
call insert(a:ldest, "</table>")
return 0
return []
endif
return a:table
endfunction "}}}
@ -774,45 +777,54 @@ function! s:process_tag_hr(line) "{{{
endfunction "}}}
function! s:process_tag_table(line, table) "{{{
" XXX: This should be refactored!!!
let table = a:table
let lines = []
let processed = 0
if a:line =~ '^||.\+||.*'
if !table
call add(lines, "<table>")
let table = 1
if a:line =~ '^\s*|[-+]\+|\s*$' && len(table)
call add(table, [])
let processed = 1
elseif a:line =~ '^\s*|.\+|\s*$'
if empty(table)
let table = [[]]
else
call add(table, [])
endif
let processed = 1
call add(lines, "<tr>")
let pos1 = 0
let pos2 = 0
let done = 0
while !done
let pos1 = stridx(a:line, '||', pos2)
let pos2 = stridx(a:line, '||', pos1+2)
if pos1==-1 || pos2==-1
let done = 1
let pos2 = len(a:line)
endif
let line = strpart(a:line, pos1+2, pos2-pos1-2)
if line == ''
continue
endif
if strpart(line, 0, 1) == ' ' &&
\ strpart(line, len(line) - 1, 1) == ' '
call add(lines, '<td class="justcenter">'.line.'</td>')
elseif strpart(line, 0, 1) == ' '
call add(lines, '<td class="justright">'.line.'</td>')
else
call add(lines, '<td class="justleft">'.line.'</td>')
endif
endwhile
call add(lines, "</tr>")
call extend(table[-1], split(a:line, '\s*|\s*'))
elseif table
elseif len(table)
call add(lines, "<table>")
let head = 0
for idx in range(len(table))
if empty(table[idx])
let head = idx
break
endif
endfor
if head > 0
for row in table[: head-1]
call add(lines, '<tr>')
call extend(lines, map(row, '"<th>".v:val."</th>"'))
call add(lines, '</tr>')
endfor
for row in table[head+1 :]
call add(lines, '<tr>')
call extend(lines, map(row, '"<td>".v:val."</td>"'))
call add(lines, '</tr>')
endfor
else
for row in table
call add(lines, '<tr>')
call extend(lines, map(row, '"<td>".v:val."</td>"'))
call add(lines, '</tr>')
endfor
endif
call add(lines, "</table>")
let table = 0
let table = []
endif
return [processed, lines, table]
endfunction "}}}
@ -820,12 +832,12 @@ endfunction "}}}
"}}}
" WIKI2HTML "{{{
function! s:wiki2html(line, state) " {{{
function! s:parse_line(line, state) " {{{
let state = {}
let state.para = a:state.para
let state.quote = a:state.quote
let state.pre = a:state.pre
let state.table = a:state.table
let state.table = a:state.table[:]
let state.lists = a:state.lists[:]
let state.deflist = a:state.deflist
let state.placeholder = a:state.placeholder
@ -838,7 +850,7 @@ function! s:wiki2html(line, state) " {{{
let processed = 0
" toc -- placeholder
" toc -- placeholder "{{{
if !processed
if line =~ '^\s*%toc'
let processed = 1
@ -846,14 +858,15 @@ function! s:wiki2html(line, state) " {{{
let state.placeholder = ['toc', param]
endif
endif
"}}}
" pres
" pres "{{{
if !processed
let [processed, lines, state.pre] = s:process_tag_pre(line, state.pre)
if processed && len(state.lists)
call s:close_tag_list(state.lists, lines)
endif
if processed && state.table
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
if processed && state.deflist
@ -867,8 +880,9 @@ function! s:wiki2html(line, state) " {{{
endif
call extend(res_lines, lines)
endif
"}}}
" lists
" lists "{{{
if !processed
let [processed, lines] = s:process_tag_list(line, state.lists)
if processed && state.quote
@ -877,7 +891,7 @@ function! s:wiki2html(line, state) " {{{
if processed && state.pre
let state.pre = s:close_tag_pre(state.pre, lines)
endif
if processed && state.table
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
if processed && state.deflist
@ -891,8 +905,9 @@ function! s:wiki2html(line, state) " {{{
call extend(res_lines, lines)
endif
"}}}
" headers
" headers "{{{
if !processed
let [processed, line, h_level, h_text, h_id] = s:process_tag_h(line, state.toc_id)
if processed
@ -900,6 +915,9 @@ function! s:wiki2html(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 line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo')
call add(res_lines, line)
" gather information for table of contents
@ -907,8 +925,9 @@ function! s:wiki2html(line, state) " {{{
let state.toc_id += 1
endif
endif
"}}}
" quotes
" quotes "{{{
if !processed
let [processed, lines, state.quote] = s:process_tag_quote(line, state.quote)
if processed && len(state.lists)
@ -917,7 +936,7 @@ function! s:wiki2html(line, state) " {{{
if processed && state.deflist
let state.deflist = s:close_tag_def_list(state.deflist, lines)
endif
if processed && state.table
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
if processed && state.pre
@ -931,17 +950,9 @@ function! s:wiki2html(line, state) " {{{
call extend(res_lines, lines)
endif
"}}}
" definition lists
if !processed
let [processed, lines, state.deflist] = s:process_tag_def_list(line, state.deflist)
call map(lines, 's:process_inline_tags(v:val)')
call extend(res_lines, lines)
endif
" tables
" tables "{{{
if !processed
let [processed, lines, state.table] = s:process_tag_table(line, state.table)
@ -949,8 +960,9 @@ function! s:wiki2html(line, state) " {{{
call extend(res_lines, lines)
endif
"}}}
" horizontal lines
" horizontal rules "{{{
if !processed
let [processed, line] = s:process_tag_hr(line)
if processed
@ -960,8 +972,19 @@ function! s:wiki2html(line, state) " {{{
call add(res_lines, line)
endif
endif
"}}}
"" P
" definition lists "{{{
if !processed
let [processed, lines, state.deflist] = s:process_tag_def_list(line, state.deflist)
call map(lines, 's:process_inline_tags(v:val)')
call extend(res_lines, lines)
endif
"}}}
"" P "{{{
if !processed
let [processed, lines, state.para] = s:process_tag_para(line, state.para)
if processed && len(state.lists)
@ -973,7 +996,7 @@ function! s:wiki2html(line, state) " {{{
if processed && state.pre
let state.pre = s:close_tag_pre(state.pre, res_lines)
endif
if processed && state.table
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, res_lines)
endif
@ -981,6 +1004,7 @@ function! s:wiki2html(line, state) " {{{
call extend(res_lines, lines)
endif
"}}}
"" add the rest
if !processed
@ -1015,7 +1039,7 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
let state.para = 0
let state.quote = 0
let state.pre = 0
let state.table = 0
let state.table = []
let state.deflist = 0
let state.lists = []
let state.placeholder = []
@ -1024,7 +1048,7 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
for line in lsource
let oldquote = state.quote
let [lines, state] = s:wiki2html(line, state)
let [lines, state] = s:parse_line(line, state)
" Hack: There could be a lot of empty strings before s:process_tag_quote
" find out `quote` is over. So we should delete them all. Think of the way

335
autoload/vimwiki_tbl.vim Normal file
View File

@ -0,0 +1,335 @@
" Vimwiki autoload plugin file
" Desc: Tables
" | Easily | manageable | text | tables | ! |
" |--------+------------+-------+--------+---------|
" | Have | fun! | Drink | tea | Period. |
"
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_tbl_auto") || &cp
finish
endif
let g:loaded_vimwiki_tbl_auto = 1
"}}}
let s:textwidth = &tw
" Misc functions {{{
function! s:wide_len(str) "{{{
return strlen(substitute(a:str, '.', 'x', 'g'))
endfunction "}}}
function! s:is_table(line) "{{{
return a:line =~ '^\s*\%(|[^|]\+\)\+|\s*$' || s:is_separator(a:line)
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~ '^\s*|\s*-\+'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
return strpart(getline(a:lnum), a:cnum - 1) =~ '^[^|]*|\s*$'
endfunction "}}}
function! s:count_separators(lnum) "{{{
let lnum = a:lnum + 1
while lnum < line('$')
if !s:is_separator(getline(lnum))
break
endif
let lnum += 1
endwhile
return (lnum-a:lnum)
endfunction "}}}
function! s:create_empty_row(cols) "{{{
let first_cell = "| |"
let cell = " |"
let row = first_cell
for c in range(a:cols - 1)
let row .= cell
endfor
return row
endfunction "}}}
function! s:create_row_sep(cols) "{{{
let first_cell = "|---+"
let cell = "---+"
let last_cell = "---|"
if a:cols < 2
return "|---|"
endif
let row = first_cell
for c in range(a:cols - 2)
let row .= cell
endfor
let row .= last_cell
return row
endfunction "}}}
function! s:get_values(line) "{{{
let cells = []
let cnt = 0
let idx = 0
while idx != -1 && idx < strlen(a:line) - 1
let cell = matchstr(a:line, '|\zs[^|]\+\ze|', idx)
let cell = substitute(cell, '^\s*\(.\{-}\)\s*$', '\1', 'g')
call add(cells, [cnt, cell])
let cnt += 1
let idx = matchend(a:line, '|\zs[^|]\+\ze|', idx)
endwhile
return cells
endfunction "}}}
function! s:get_rows(lnum) "{{{
if !s:is_table(getline(a:lnum))
return
endif
let upper_rows = []
let lower_rows = []
let lnum = a:lnum - 1
while lnum > 1
let line = getline(lnum)
if s:is_table(line)
call add(upper_rows, [lnum, line])
else
break
endif
let lnum -= 1
endwhile
call reverse(upper_rows)
let lnum = a:lnum
while lnum <= line('$')
let line = getline(lnum)
if s:is_table(line)
call add(lower_rows, [lnum, line])
else
break
endif
let lnum += 1
endwhile
return upper_rows + lower_rows
endfunction "}}}
function! s:get_cell_max_lens(lnum) "{{{
let max_lens = {}
for [lnum, row] in s:get_rows(a:lnum)
if s:is_separator(row)
continue
endif
for [idx, cell] in s:get_values(row)
if has_key(max_lens, idx)
let max_lens[idx] = max([s:wide_len(cell), max_lens[idx]])
else
let max_lens[idx] = s:wide_len(cell)
endif
endfor
endfor
return max_lens
endfunction "}}}
function! s:get_aligned_rows(lnum, max_lens) "{{{
let rows = []
for [lnum, row] in s:get_rows(a:lnum)
if s:is_separator(row)
let new_row = s:fmt_sep(a:max_lens)
else
let new_row = s:fmt_row(row, a:max_lens)
endif
call add(rows, [lnum, new_row])
endfor
return rows
endfunction "}}}
" }}}
" Format functions {{{
function! s:fmt_cell(cell, max_len) "{{{
let cell = ' '.a:cell.' '
let diff = a:max_len - s:wide_len(a:cell)
if diff == 0 && empty(a:cell)
let diff = 1
endif
let cell .= repeat(' ', diff)
return cell
endfunction "}}}
function! s:fmt_row(line, max_lens) "{{{
let new_line = '|'
let values = s:get_values(a:line)
for [idx, cell] in values
let new_line .= s:fmt_cell(cell, a:max_lens[idx]).'|'
endfor
let idx = len(values)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).'|'
let idx += 1
endwhile
return new_line
endfunction "}}}
function! s:fmt_cell_sep(max_len) "{{{
if a:max_len == 0
return repeat('-', 3)
else
return repeat('-', a:max_len+2)
endif
endfunction "}}}
function! s:fmt_sep(max_lens) "{{{
let sep = '|'
for idx in range(len(a:max_lens))
let sep .= s:fmt_cell_sep(a:max_lens[idx]).'+'
endfor
let sep = substitute(sep, '+$', '|', '')
return sep
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>"
if a:goto_first
let cmd .= "0f|T|a"
else
let cmd .= "0".(col('.')-1)."lT|a"
endif
return cmd
endfunction "}}}
function! s:kbd_goto_next_row() "{{{
let cmd = "\<ESC>jt|T|a"
return cmd
endfunction "}}}
function! s:kbd_goto_next_col(last) "{{{
if col('.') == 1
let cmd = "\<ESC>la"
else
if a:last
let seps = s:count_separators(line('.'))
let cmd = "\<ESC>".seps."j0f|F|la"
else
let cmd = "\<ESC>f|la"
endif
endif
return cmd
endfunction "}}}
"}}}
" Global functions {{{
function! vimwiki_tbl#kbd_cr() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<CR>"
endif
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
let cols = len(s:get_values(getline(lnum)))
return s:kbd_create_new_row(cols, 0)
else
return s:kbd_goto_next_row()
endif
endfunction "}}}
function! vimwiki_tbl#kbd_tab() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<Tab>"
endif
let last = s:is_last_column(lnum, col('.'))
if last && !s:is_table(getline(lnum+1))
let cols = len(s:get_values(getline(lnum)))
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(last)
endfunction "}}}
function! vimwiki_tbl#format(lnum) "{{{
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let max_lens = s:get_cell_max_lens(a:lnum)
for [lnum, row] in s:get_aligned_rows(a:lnum, max_lens)
call setline(lnum, row)
endfor
let &tw = s:textwidth
endfunction "}}}
function! vimwiki_tbl#create(...) "{{{
if a:0 > 1
let cols = a:1
let rows = a:2
elseif a:0 == 1
let cols = a:1
let rows = 2
elseif a:0 == 0
let cols = 5
let rows = 2
endif
if cols < 1
let cols = 5
endif
if rows < 1
let rows = 2
endif
let lines = []
let row = s:create_empty_row(cols)
call add(lines, row)
if rows > 1
call add(lines, s:create_row_sep(cols))
endif
for r in range(rows - 1)
call add(lines, row)
endfor
call append(line('.'), lines)
endfunction "}}}
function! vimwiki_tbl#align_or_cmd(cmd) "{{{
if s:is_table(getline('.'))
call vimwiki_tbl#format(line('.'))
else
exe 'normal! '.a:cmd
endif
endfunction "}}}
function! vimwiki_tbl#reset_tw(lnum) "{{{
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let s:textwidth = &tw
let &tw = 0
endfunction "}}}
"}}}

View File

@ -8,39 +8,41 @@
\ `\___/ /\_____\\ \_\\ \_\ `\___x___/ /\_____\\ \_\ \_\ /\_____\~
`\/__/ \/_____/ \/_/ \/_/'\/__//__/ \/_____/ \/_/\/_/ \/_____/~
Version: 0.9.801 ~
Version: 0.9.9
==============================================================================
CONTENTS *vimwiki-contents*
1. Intro ...................................|vimwiki|
2. Prerequisites ...........................|vimwiki-prerequisites|
3. Mappings ................................|vimwiki-mappings|
3.1. Global mappings .....................|vimwiki-global-mappings|
3.2. Local mappings ......................|vimwiki-local-mappings|
3.3. Text objects ........................|vimwiki-text-objects|
4. Commands ................................|vimwiki-commands|
4.1. Global commands .....................|vimwiki-global-commands|
4.2. Local commands ......................|vimwiki-local-commands|
5. Wiki syntax .............................|vimwiki-syntax|
5.1. Typefaces ...........................|vimwiki-syntax-typefaces|
5.2. Links ...............................|vimwiki-syntax-links|
5.3. Headers .............................|vimwiki-syntax-headers|
5.4. Paragraphs...........................|vimwiki-syntax-paragraphs|
5.5. Lists ...............................|vimwiki-syntax-lists|
5.6. Tables ..............................|vimwiki-syntax-tables|
5.7. Preformatted text ...................|vimwiki-syntax-preformatted|
5.8. Blockquotes .........................|vimwiki-syntax-blockquotes|
5.9. Comments ............................|vimwiki-syntax-comments|
6. Folding/Outline .........................|vimwiki-folding|
7. Placeholders ............................|vimwiki-placeholders|
7.1 Table of Contents ....................|vimwiki-table-of-contents|
8. Todo lists...............................|vimwiki-todo-lists|
9. Options .................................|vimwiki-options|
10. Help ...................................|vimwiki-help|
11. Author .................................|vimwiki-author|
12. Changelog ..............................|vimwiki-changelog|
13. License ................................|vimwiki-license|
1. Intro |vimwiki|
2. Prerequisites |vimwiki-prerequisites|
3. Mappings |vimwiki-mappings|
3.1. Global mappings |vimwiki-global-mappings|
3.2. Local mappings |vimwiki-local-mappings|
3.3. Text objects |vimwiki-text-objects|
4. Commands |vimwiki-commands|
4.1. Global commands |vimwiki-global-commands|
4.2. Local commands |vimwiki-local-commands|
5. Wiki syntax |vimwiki-syntax|
5.1. Typefaces |vimwiki-syntax-typefaces|
5.2. Links |vimwiki-syntax-links|
5.3. Headers |vimwiki-syntax-headers|
5.4. Paragraphs |vimwiki-syntax-paragraphs|
5.5. Lists |vimwiki-syntax-lists|
5.6. Tables |vimwiki-syntax-tables|
5.7. Preformatted text |vimwiki-syntax-preformatted|
5.8. Blockquotes |vimwiki-syntax-blockquotes|
5.9. Comments |vimwiki-syntax-comments|
6. Folding/Outline |vimwiki-folding|
7. Placeholders |vimwiki-placeholders|
7.1 Table of Contents |vimwiki-table-of-contents|
8. Todo lists |vimwiki-todo-lists|
9. Tables |vimwiki-tables|
10. Diary |vimwiki-diary|
11. Options |vimwiki-options|
12. Help |vimwiki-help|
13. Author |vimwiki-author|
14. Changelog |vimwiki-changelog|
15. License |vimwiki-license|
==============================================================================
@ -49,10 +51,10 @@ CONTENTS *vimwiki-contents*
Vimwiki is a personal wiki for Vim -- a number of linked text files that have
their own syntax highlighting.
With vimwiki you can
- organize notes and ideas
- manage todo-lists
- write documentation
With vimwiki you can:
- organize notes and ideas;
- manage todo-lists;
- write documentation.
To do a quick start press <Leader>ww (this is usually \ww) to go to your index
wiki file. By default it is located in: >
@ -71,8 +73,8 @@ errors. 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
ProjectGutenberg. Edit and save it, then press Backspace to return to parent
wiki page. You should see the difference now -- ProjectGutenberg is
ProjectGutenberg. Edit and save it, then press Backspace to return to previous
wiki file. You should see the difference now -- ProjectGutenberg is
highlighted as a link.
@ -95,8 +97,9 @@ There are global and local mappings in vimwiki.
------------------------------------------------------------------------------
3.1. Global mappings *vimwiki-global-mappings*
<Leader>ww or <Plug>VimwikiGoHome
[count]<Leader>ww or <Plug>VimwikiGoHome
Open index file of the [count]'s wiki.
<Leader>ww opens first wiki from |g:vimwiki_list|.
1<Leader>ww as above opens first wiki from |g:vimwiki_list|.
2<Leader>ww opens second wiki from |g:vimwiki_list|.
@ -107,8 +110,10 @@ There are global and local mappings in vimwiki.
<
See also|:VimwikiGoHome|
<Leader>wt or <Plug>VimwikiTabGoHome
[count]<Leader>wt or <Plug>VimwikiTabGoHome
Open index file of the [count]'s wiki in a new tab.
<Leader>wt tabopens first wiki from |g:vimwiki_list|.
1<Leader>wt as above tabopens first wiki from |g:vimwiki_list|.
2<Leader>wt tabopens second wiki from |g:vimwiki_list|.
@ -119,6 +124,7 @@ See also|:VimwikiGoHome|
<
See also|:VimwikiTabGoHome|
<Leader>ws or <Plug>VimwikiUISelect
List and select available wikies.
To remap: >
@ -127,10 +133,46 @@ See also|:VimwikiTabGoHome|
See also|:VimwikiUISelect|
------------------------------------------------------------------------------
3.2. Local mappings *vimwiki-local-mappings*
[count]<Leader>w<Leader>w or <Plug>VimwikiMakeDiaryNote
Open diary wiki-file for today of the [count]'s wiki.
Normal mode (Keyboard):~
<Leader>w<Leader>w opens diary wiki-file for today in the first wiki
from |g:vimwiki_list|.
1<Leader>w<Leader>w as above opens diary wiki-file for today in the
first wiki from |g:vimwiki_list|.
2<Leader>w<Leader>w opens diary wiki-file for today in the second wiki
from |g:vimwiki_list|.
3<Leader>w<Leader>w opens diary wiki-file for today in the third wiki
from |g:vimwiki_list|.
etc.
To remap: >
:map <Leader>d <Plug>VimwikiMakeDiaryNote
<
See also|:VimwikiMakeDiaryNote|
[count]<Leader>w<Leader>t or <Plug>VimwikiTabMakeDiaryNote
Open diary wiki-file for today of the [count]'s wiki in a new tab.
<Leader>w<Leader>t tabopens diary wiki-file for today in the first
wiki from |g:vimwiki_list|.
1<Leader>w<Leader>t as above tabopens diary wiki-file for today in the
first wiki from |g:vimwiki_list|.
2<Leader>w<Leader>t tabopens diary wiki-file for today in the second
wiki from |g:vimwiki_list|.
3<Leader>w<Leader>t tabopens diary wiki-file for today in the third
wiki from |g:vimwiki_list|.
etc.
To remap: >
:map <Leader>dt <Plug>VimwikiTabMakeDiaryNote
<
See also|:VimwikiTabMakeDiaryNote|
------------------------------------------------------------------------------
3.2. Local mappings
NORMAL MODE *vimwiki-local-mappings*
*vimwiki_<CR>*
<CR> Follow/Create WikiWord.
Maps to|:VimwikiFollowWord|.
@ -194,15 +236,39 @@ Normal mode (Keyboard):~
*vimwiki_-*
- Remove header level.
Normal mode (Mouse): ~
*vimwiki_gqq* *vimwiki_gww*
gqq Format table. If you did some changes to a table
or without swapping insert/normal modes this command
gww reformat it.
Works only if |g:vimwiki_use_mouse| is set to 1.
<2-LeftMouse> Follow/Create WikiWord
<S-2-LeftMouse> Split and follow/create WikiWord
<C-2-LeftMouse> Vertical split and follow/create WikiWord
<RightMouse><LeftMouse> Go back to previous WikiWord
Note: <2-LeftMouse> is just left double click.
INSERT MODE *vimwiki-table-mappings*
*vimwiki_i_<CR>*
<CR> Goto table cell down to the current, create new row if
on the last one.
*vimwiki_i_<Tab>*
<Tab> Goto next table cell, create new row if on the last
cell.
------------------------------------------------------------------------------
3.3. Text objects *vimwiki-text-objects*
@ -210,7 +276,7 @@ ah A Header with leading empty lines.
ih Inner Header without leading empty lines.
You can 'vah' to select a header with its contents or 'dah' to delete it or
'yah' to yank it or 'cah' to change it. ;)
'yah' to yank it or 'cah' to change it.
==============================================================================
@ -228,48 +294,75 @@ You can 'vah' to select a header with its contents or 'dah' to delete it or
*:VimwikiUISelect*
Open index file of the selected wiki.
*:VimwikiMakeDiaryNote*
Open diary wiki-file for today of the current wiki.
*:VimwikiTabMakeDiaryNote*
Open diary wiki-file for today of the current wiki in a new tab.
------------------------------------------------------------------------------
4.2. Local commands *vimwiki-local-commands*
*:VimwikiFollowWord*
Follow/create WikiWord.
*:VimwikiGoBackWord*
Go back to previous WikiWord you come from.
*:VimwikiSplitWord*
Split and follow/create WikiWord.
*:VimwikiVSplitWord*
Vertical split and follow/create WikiWord.
*:VimwikiNextWord*
Find next WikiWord.
*:VimwikiPrevWord*
Find previous WikiWord.
*:VimwikiDeleteWord*
Delete WikiWord you are in.
*:VimwikiRenameWord*
Rename WikiWord you are in.
*:Vimwiki2HTML*
Convert current WikiPage to HTML.
*:VimwikiAll2HTML*
Convert all WikiPages to HTML.
*:VimwikiToggleListItem*
Toggle list item on/off (checked/unchecked)
See |vimwiki-todo-lists|.
*:VimwikiSearch* /pattern/
*:VWS* /pattern/
Search for /pattern/ in current wiki.
*:VimwikiTable*
Create a table with 5 cols and 2 rows.
:VimwikiTable cols rows
Create a table with a given cols and rows
:VimwikiTable cols
Create a table with a given cols and 2 rows
==============================================================================
5. Wiki syntax *vimwiki-syntax*
@ -506,30 +599,31 @@ Term 2::
------------------------------------------------------------------------------
5.6. Tables *vimwiki-syntax-tables*
Tables are created by entering the content of each cell separated by ||
Tables are created by entering the content of each cell separated by |
delimiters. You can insert other inline wiki syntax in table cells, including
typeface formatting and links.
For example:
For example: >
||*Year*s||*Temperature (low)*||*Temperature (high)*||
||1900 ||-10 ||25 ||
||1910 ||-15 ||30 ||
||1920 ||-10 ||32 ||
||1930 ||_N/A_ ||_N/A_ ||
||1940 ||-2 ||40 ||
| Year | Temperature (low) | Temperature (high) |
|------+-------------------+--------------------|
| 1900 | -10 | 25 |
| 1910 | -15 | 30 |
| 1920 | -10 | 32 |
| 1930 | _N/A_ | _N/A_ |
| 1940 | -2 | 40 |
>
In html the following part >
| Year | Temperature (low) | Temperature (high) |
|------+-------------------+--------------------|
>
is higlighted as a table header.
For HTML, contents of table cell could be aligned to the right, left and
center:
See |vimwiki-tables| for more details on how to manage tables.
|| Center || Center || Center ||
||Left || Center || Right||
|| Right||Left || Center ||
|| Center || Right||Left ||
No spaces on the left side -- left alignment.
No spaces on the right side -- right alignment.
Spaces on the left and on the right -- center alignment.
Note: You can not use [[link|description]] type of links in tables. Use
[[link][description]] instead.
------------------------------------------------------------------------------
@ -697,8 +791,89 @@ percentage of toggled child items(see also |g:vimwiki_listsyms|): >
It is possible to toggle several list items using visual mode.
==============================================================================
9. Options *vimwiki-options*
9. Tables *vimwiki-tables*
Use :VimwikiTable command to create default table with 5 columns and 2 rows: >
| | | | | |
|---+---+---+---+---|
| | | | | |
<
Tables are auto-formattable. Let's add some text into first cell: >
| First Name | | | | |
|---+---+---+---+---|
| | | | | |
<
Whenever you press <TAB>, <CR> or leave Insert mode table is formatted: >
| First Name | | | | |
|------------+---+---+---+---|
| | | | | |
<
You can easily create nice looking text tables, just press <TAB> and enter new
values: >
| First Name | Last Name | Age | City | e-mail |
|------------+------------+-----+----------+----------------------|
| Vladislav | Pokrishkin | 31 | Moscow | vlad_pok@smail.com |
| James | Esfandiary | 27 | Istanbul | esfandiary@tmail.com |
<
==============================================================================
10. Diary *vimwiki-diary*
Diary helps you make daily notes. You can really easy add information into
vimwiki that should be sorted out later. Just hit <Leader>w<Leader>w to create
new daily note with name based on current date. The link to this newly created
file is added to a diary wiki file.
Usage example with default settings: >
Consider today is 2010-01-27.
Hit \w\w .
~/vimwiki/diary.wiki is created.
2 following lines are added to ~/vimwiki/diary/diary.wiki :
= Diary =
| [[2010-01-27]] |
~/vimwiki/diary/2010-01-27.wiki is created.
You are ready to add your information there.
-------------------------------------------
On the next day.
Hit \w\w .
The first line after = Diary = is changed in ~/vimwiki/diary/diary.wiki :
= Diary =
| [[2010-01-28]] | [[2010-01-27]] |
~/vimwiki/diary/2010-01-28.wiki is created.
You are ready to add your information there.
>
By default there are 4 links on the line. All links are sorted by their dates.
Calendar integration *vimwiki-calendar*
------------------------------------------------------------------------------
If you have Calendar.vim installed you can use it to create diary notes.
Just open calendar with :Calendar and tap <Enter> on the date. Wiki file would
be created in default wiki's diary.
Get it from http://www.vim.org/scripts/script.php?script_id=52
==============================================================================
11. Options *vimwiki-options*
There are global and per wiki(local) options available to tune vimwiki.
All global options are set using the following template: >
@ -733,10 +908,12 @@ Empty |Dictionary| in the g:vimwiki_list is the wiki with default options: >
<
Per wiki options
PER WIKI OPTIONS *viwmiki-local-options*
*vimwiki-option-path*
---------------------
------------------------------------------------------------------------------
Key Default value~
path ~/vimwiki/
@ -746,7 +923,7 @@ Wiki files location: >
<
*vimwiki-option-path_html*
--------------------------
------------------------------------------------------------------------------
Key Default value~
path_html ~/vimwiki_html/
@ -760,9 +937,20 @@ If you omit this option path_html would be path - '/' + '_html/': >
ie, path_html = '~/okidoki_html/'
*vimwiki-option-auto_export*
------------------------------------------------------------------------------
Key Default value Values~
auto_export 0 0, 1
Description~
Set this option to 1 to automatically generate HTML file when corresponding
wiki page is saved: >
let g:vimwiki_list = [{'path': '~/my_site/', 'auto_export': 1}]
This will keep you HTML files up to date.
*vimwiki-option-index*
----------------------
------------------------------------------------------------------------------
Key Default value~
index index
@ -774,7 +962,7 @@ NOTE: Do not add extension.
*vimwiki-option-ext*
--------------------
------------------------------------------------------------------------------
Key Default value~
ext .wiki
@ -785,7 +973,7 @@ Extension of wiki files: >
<
*vimwiki-option-syntax*
-----------------------
------------------------------------------------------------------------------
Key Default value Values~
syntax default default, media
@ -799,7 +987,7 @@ To use MediaWiki's wiki markup: >
<
*vimwiki-option-html_header*
----------------------------
------------------------------------------------------------------------------
Key Default value~
html_header
@ -826,7 +1014,7 @@ where
*vimwiki-option-html_footer*
----------------------------
------------------------------------------------------------------------------
Key Default value~
html_footer
@ -842,7 +1030,7 @@ This footer.tpl could look like: >
<
*vimwiki-option-css_name*
-------------------------
------------------------------------------------------------------------------
Key Default value~
css_name style.css
@ -857,7 +1045,7 @@ or even >
<
*vimwiki-option-gohome*
-----------------------
------------------------------------------------------------------------------
Key Default value Values~
gohome split split, vsplit, tabe
@ -871,7 +1059,7 @@ Ex: >
<
*vimwiki-option-maxhi*
----------------------
------------------------------------------------------------------------------
Key Default value Values~
maxhi 1 0, 1
@ -884,7 +1072,7 @@ This disables filesystem checks for WikiWords.
*vimwiki-option-nested_syntaxes*
--------------------------------
------------------------------------------------------------------------------
Key Default value Values~
nested_syntaxes {} pairs of highlight keyword and vim filetype
@ -927,7 +1115,51 @@ or in: >
Global options
*vimwiki-option-diary_rel_path*
------------------------------------------------------------------------------
Key Default value~
diary_rel_path diary/
Description~
Related to |vimwiki-option-path| path for diary wiki-files.
*vimwiki-option-diary_index*
------------------------------------------------------------------------------
Key Default value~
diary_index diary
Description~
Name of wiki-file that holds all links to dated wiki-files.
*vimwiki-option-diary_header*
------------------------------------------------------------------------------
Key Default value~
diary_header Diary
Description~
Name of the header in |vimwiki-option-diary_index| where links to dated
wiki-files are located.
*vimwiki-option-diary_link_count*
------------------------------------------------------------------------------
Key Default value~
diary_link_count 4
Description~
Number of maximum dated links placed on one line.
Ex:
= Diary =
|| [[2010-01-30]] || [[2010-01-29]] || [[2010-01-28]] || [[2010-01-27]] ||
|| [[2010-01-26]] || [[2010-01-25]] ||
GLOBAL OPTIONS *viwmiki-global-options*
Use: >
let g:option_name=option_value
to set them.
@ -942,7 +1174,7 @@ Value Description~
0 Use |hl-Title| or VimwikiHeader1-VimwikiHeader6 (if defined
in a colorscheme)
Default: 0
Default: 1
------------------------------------------------------------------------------
@ -1115,6 +1347,19 @@ Value Description~
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_use_calendar*
Create new or open existing diary wiki-file for the date selected in Calendar.
See |vimwiki-calendar|.
Value Description~
0 Do not use calendar.
1 Use calendar.
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_browsers* *VimwikiWeblinkHandler*
@ -1136,8 +1381,37 @@ or redefine VimwikiWeblinkHandler function: >
endfunction
------------------------------------------------------------------------------
*g:vimwiki_table_auto_fmt*
Turn on/off table auto-formatting.
Value Description~
0 Do not auto-format tables.
1 Auto-format tables.
Default: 1
------------------------------------------------------------------------------
*g:vimwiki_w32_dir_enc*
Convert directory name from current |encoding| into 'g:vimwiki_w32_dir_enc'
before it is created.
If have 'enc=utf-8' and you set up >
let g:vimwiki_w32_dir_enc = 'cp1251'
<
then following the next link with <CR>: >
[[привет/мир]]
>
would convert utf-8 'привет' to cp1251 and create directory with that name.
Default value: ''
==============================================================================
10. Help *vimwiki-help*
12. Help *vimwiki-help*
As you could see I am not native English speaker (not a writer as well).
Please send me correct phrases instead of that incorrect stuff I have used
@ -1146,7 +1420,7 @@ here.
Any help is really appreciated!
==============================================================================
11. Author *vimwiki-author*
13. Author *vimwiki-author*
I live in Moscow and you may believe me -- there are no polar bears (no brown
too) here in the streets.
@ -1165,7 +1439,30 @@ Vimwiki's website: http://code.google.com/p/vimwiki/
Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226
==============================================================================
12. Changelog *vimwiki-changelog*
14. Changelog *vimwiki-changelog*
0.9.9~
* NEW: Diary. Help in making daily notes. See |vimwiki-diary|. Now you can
really easy add information into vimwiki that should be sorted out
later.
* NEW: Tables are redesigned. Syntax is changed. Now they are
auto-formattable. You can navigate them with <tab> and <cr> in insert
mode. See |vimwiki-syntax-tables| and |vimwiki-tables| for more details.
* NEW: Keyword STARTED: is added.
* NEW: Words TODO:, DONE:, STARTED:, XXX:, FIXME:, FIXED: are highlighed
inside headers.
* FIX: Export to html external links with 'file://' protocol. Ex:
[file:///home/user1/book.pdf my book].
* FIX: Menu is corrupted if wiki's path contains spaces.
* FIX: Settings |wrap| and |linebreak| are removed from ftplugin. Add them
into your personal settings file `.vim/after/ftplugin/vimwiki.vim` if
needed.
* NEW: Headers are highlighted in different colors by default.
See |g:vimwiki_hl_headers| to turn it off.
* FIX: Issue 40: Links with russian subdirs don't work.
* NEW: It is now possible to generate HTML files automatically on page
save. See |vimwiki-option-auto_export|.
0.9.8~
* NEW: Rename |g:vimwiki_fold_empty_lines| to
@ -1517,12 +1814,12 @@ Vim plugins website: http://www.vim.org/scripts/script.php?script_id=2226
* First public version.
==============================================================================
13. License *vimwiki-license*
15. License *vimwiki-license*
The MIT Licence
http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2009 Maxim Kim
Copyright (c) 2010 Maxim Kim
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -9,7 +9,7 @@ let b:did_ftplugin = 1 " Don't load another plugin for this buffer
" UNDO list {{{
" Reset the following options to undo this plugin.
let b:undo_ftplugin = "setlocal wrap< linebreak< ".
let b:undo_ftplugin = "setlocal ".
\ "suffixesadd< isfname< comments< ".
\ "autowriteall< ".
\ "formatoptions< foldtext< ".
@ -18,8 +18,6 @@ let b:undo_ftplugin = "setlocal wrap< linebreak< ".
" MISC STUFF {{{
setlocal wrap
setlocal linebreak
setlocal autowriteall
setlocal commentstring=<!--%s-->
" MISC }}}
@ -39,9 +37,9 @@ else
endif
setlocal formatoptions=tnro
inoremap <expr> <CR> vimwiki_lst#insertCR()
nnoremap o :call vimwiki_lst#insertOo('o')<CR>a
nnoremap O :call vimwiki_lst#insertOo('O')<CR>a
inoremap <buffer> <expr> <CR> vimwiki_lst#insertCR()
nnoremap <buffer> o :call vimwiki_lst#insertOo('o')<CR>a
nnoremap <buffer> O :call vimwiki_lst#insertOo('O')<CR>a
" COMMENTS }}}
@ -213,6 +211,11 @@ exe 'command! -buffer -nargs=* VimwikiSearch vimgrep <args> '.
exe 'command! -buffer -nargs=* VWS vimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
" 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')
" COMMANDS }}}
" KEYBINDINGS {{{
@ -284,6 +287,16 @@ noremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
" Table mappings
if g:vimwiki_table_auto_fmt
inoremap <expr> <buffer> <CR> vimwiki_tbl#kbd_cr()
inoremap <expr> <buffer> <Tab> vimwiki_tbl#kbd_tab()
endif
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
" Text objects {{{
omap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 0)<CR>
vmap <silent><buffer> ah :<C-U>call vimwiki#TO_header(0, 1)<CR>
@ -297,3 +310,13 @@ nmap <silent><buffer> - :call vimwiki#RemoveHeaderLevel()<CR>
" }}}
" KEYBINDINGS }}}
" AUTOCOMMANDS {{{
if VimwikiGet('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer> Vimwiki2HTML
augroup END
endif
" AUTOCOMMANDS }}}

View File

@ -48,6 +48,11 @@ function! s:setup_buffer_leave()"{{{
if &filetype == 'vimwiki' && !exists("b:vimwiki_idx")
let b:vimwiki_idx = g:vimwiki_current_idx
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
endif
endfunction"}}}
function! s:setup_buffer_enter() "{{{
@ -95,6 +100,11 @@ function! s:setup_buffer_enter() "{{{
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
endif
endfunction "}}}
function! s:setup_colors()"{{{
@ -197,6 +207,18 @@ let s:vimwiki_defaults.gohome = 'split'
let s:vimwiki_defaults.html_header = ''
let s:vimwiki_defaults.html_footer = ''
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
" diary
let s:vimwiki_defaults.diary_rel_path = 'diary/'
let s:vimwiki_defaults.diary_index = 'diary'
let s:vimwiki_defaults.diary_header = 'Diary'
" Do not change this! Will wait till vim would be more datetime awareable.
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
let s:vimwiki_defaults.diary_link_count = 4
"}}}
" DEFAULT options {{{
@ -218,7 +240,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', 0)
call s:default('hl_headers', 1)
call s:default('hl_cb_checked', 0)
call s:default('camel_case', 1)
call s:default('list_ignore_newline', 1)
@ -240,6 +262,10 @@ else
\ ])
endif
call s:default('use_calendar', 1)
call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('current_idx', 0)
let upp = g:vimwiki_upper
@ -263,7 +289,7 @@ let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'
"}}}
" FILETYPE setup for all known wiki extensions {{{
" AUTOCOMMANDS for all known wiki extensions {{{
" Getting all extensions that different wikies could have
let extensions = {}
for wiki in g:vimwiki_list
@ -282,12 +308,21 @@ augroup end
augroup vimwiki
autocmd!
for ext in keys(extensions)
execute 'autocmd BufEnter *'.ext.' call s:setup_buffer_enter()'
execute 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
" ColorScheme could have or could have not a VimwikiHeader1..VimwikiHeader6
" highlight groups. We need to refresh syntax after colorscheme change.
execute 'autocmd ColorScheme *'.ext.' call s:setup_colors() | set syntax=vimwiki'
" ColorScheme could have or could have not a
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
" syntax after colorscheme change.
exe 'autocmd ColorScheme *'.ext.' call s:setup_colors()'.
\ ' | set syntax=vimwiki'
" 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("."))'
endif
endfor
augroup END
"}}}
@ -298,6 +333,11 @@ command! -count VimwikiGoHome
\ call vimwiki#WikiGoHome(v:count1)
command! -count VimwikiTabGoHome tabedit <bar>
\ call vimwiki#WikiGoHome(v:count1)
command! -count VimwikiMakeDiaryNote
\ call vimwiki_diary#make_note(v:count1)
command! -count VimwikiTabMakeDiaryNote tabedit <bar>
\ call vimwiki_diary#make_note(v:count1)
"}}}
" MAPPINGS {{{
@ -316,20 +356,49 @@ if !hasmapto('<Plug>VimwikiUISelect')
endif
noremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
map <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
endif
noremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
map <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
endif
noremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
"}}}
" MENU {{{
function! s:build_menu(path)
function! s:build_menu(topmenu)
let idx = 0
while idx < len(g:vimwiki_list)
execute 'menu '.a:path.'.'.VimwikiGet('path', idx).
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ ')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#WikiGoHome('.(idx + 1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
\ ' :call vimwiki_diary#make_note('.(idx + 1).')<CR>'
let idx += 1
endwhile
endfunction
function! s:build_table_menu(topmenu)
exe 'menu '.a:topmenu.'.-Sep- :'
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
exe 'nmenu disable '.a:topmenu.'.Table'
endfunction
if !empty(g:vimwiki_menu)
call s:build_menu(g:vimwiki_menu)
call s:build_table_menu(g:vimwiki_menu)
endif
" }}}
" CALENDAR Hook "{{{
if g:vimwiki_use_calendar
let g:calendar_action = 'vimwiki_diary#calendar_action'
endif
"}}}

View File

@ -32,14 +32,21 @@ execute 'syntax match VimwikiLink `'.g:vimwiki_rxWeblink.'`'
" Emoticons
syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|FIXME:\|FIXED:\|XXX:\)'
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" Load concrete Wiki syntax
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" Tables
execute 'syntax match VimwikiTable /'.g:vimwiki_rxTable.'/'
" execute 'syntax match VimwikiTable /'.g:vimwiki_rxTable.'/'
syntax match VimwikiTableRow /\s*|.\+|\s*/
\ transparent contains=VimwikiCellSeparator,VimwikiWord,
\ VimwikiNoExistsWord,VimwikiEmoticons,VimwikiTodo,
\ VimwikiBold,VimwikiItalic,VimwikiBoldItalic,VimwikiItalicBold,
\ VimwikiDelText,VimwikiSuperScript,VimwikiSubScript,VimwikiCode
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" List items
execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
@ -80,15 +87,15 @@ endif
syntax region VimwikiComment start='<!--' end='-->'
if !vimwiki#hl_exists("VimwikiHeader1")
execute 'syntax match VimwikiHeader /'.g:vimwiki_rxHeader.'/'
execute 'syntax match VimwikiHeader /'.g:vimwiki_rxHeader.'/ contains=VimwikiTodo'
else
" Header levels, 1-6
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/'
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/'
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/'
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/'
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/'
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/'
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo'
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo'
endif
" group names "{{{
@ -117,13 +124,14 @@ hi def link VimwikiLink Underlined
hi def link VimwikiList Function
hi def link VimwikiCheckBox VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiTable PreProc
hi def link VimwikiEmoticons Character
hi def link VimwikiDelText Constant
hi def link VimwikiSuperScript Number
hi def link VimwikiSubScript Number
hi def link VimwikiTodo Todo
hi def link VimwikiComment Comment
hi def link VimwikiCellSeparator SpecialKey
"}}}
let b:current_syntax="vimwiki"