mirror of
https://github.com/amix/vimrc
synced 2025-07-06 16:05:01 +08:00
add various usefull plugins from vim.org and sourfeforge
This commit is contained in:
1056
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/base.vim
Normal file
1056
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/base.vim
Normal file
File diff suppressed because it is too large
Load Diff
11
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/default.tpl
Normal file
11
vim_plugins_src/vimwiki-1-2/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>
|
286
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/diary.vim
Normal file
286
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/diary.vim
Normal file
@ -0,0 +1,286 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" 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
|
||||
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').
|
||||
\ '*'.VimwikiGet('ext'))
|
||||
|
||||
let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "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, '\').'"')
|
||||
return links
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_position_links(link) "{{{
|
||||
let idx = -1
|
||||
let links = []
|
||||
if a:link =~ '\d\{4}-\d\d-\d\d'
|
||||
let links = s:get_links()
|
||||
" include 'today' into links
|
||||
if index(links, s:diary_date_link()) == -1
|
||||
call add(links, s:diary_date_link())
|
||||
endif
|
||||
call sort(links)
|
||||
let idx = index(links, a:link)
|
||||
endif
|
||||
return [idx, links]
|
||||
endfunction "}}}
|
||||
|
||||
function! s:format_links(links) "{{{
|
||||
let lines = []
|
||||
let line = '| '
|
||||
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
|
||||
let ln_end = 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()
|
||||
call map(links, '"[[".v:val."]]"')
|
||||
|
||||
" 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#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#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) "{{{
|
||||
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 "}}}
|
||||
|
||||
" Calendar.vim sign function.
|
||||
function vimwiki#diary#calendar_sign(day, month, year) "{{{
|
||||
let day = s:prefix_zero(a:day)
|
||||
let month = s:prefix_zero(a:month)
|
||||
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
|
||||
\ a:year.'-'.month.'-'.day.VimwikiGet('ext')
|
||||
return filereadable(expand(sfile))
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#diary#goto_next_day() "{{{
|
||||
let link = ''
|
||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||
|
||||
if idx == (len(links) - 1)
|
||||
return
|
||||
endif
|
||||
|
||||
if idx != -1 && idx < len(links) - 1
|
||||
let link = VimwikiGet('diary_rel_path').links[idx+1]
|
||||
else
|
||||
" goto today
|
||||
let link = VimwikiGet('diary_rel_path').s:diary_date_link()
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
call vimwiki#base#open_link(':e ', link)
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#diary#goto_prev_day() "{{{
|
||||
let link = ''
|
||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||
|
||||
if idx == 0
|
||||
return
|
||||
endif
|
||||
|
||||
if idx > 0
|
||||
let link = VimwikiGet('diary_rel_path').links[idx-1]
|
||||
else
|
||||
" goto today
|
||||
let link = VimwikiGet('diary_rel_path').s:diary_date_link()
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
call vimwiki#base#open_link(':e ', link)
|
||||
endif
|
||||
endfunction "}}}
|
1441
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/html.vim
Normal file
1441
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/html.vim
Normal file
File diff suppressed because it is too large
Load Diff
369
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/lst.vim
Normal file
369
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/lst.vim
Normal file
@ -0,0 +1,369 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Todo lists related stuff here.
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
if exists("g:loaded_vimwiki_list_auto") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_vimwiki_lst_auto = 1
|
||||
|
||||
" Script variables {{{
|
||||
let s:rx_li_box = '\[.\?\]'
|
||||
" }}}
|
||||
|
||||
" Script functions {{{
|
||||
|
||||
" Get checkbox regexp
|
||||
function! s:rx_li_symbol(rate) "{{{
|
||||
let result = ''
|
||||
if a:rate == 100
|
||||
let result = g:vimwiki_listsyms[4]
|
||||
elseif a:rate == 0
|
||||
let result = g:vimwiki_listsyms[0]
|
||||
elseif a:rate >= 67
|
||||
let result = g:vimwiki_listsyms[3]
|
||||
elseif a:rate >= 34
|
||||
let result = g:vimwiki_listsyms[2]
|
||||
else
|
||||
let result = g:vimwiki_listsyms[1]
|
||||
endif
|
||||
|
||||
return '\['.result.'\]'
|
||||
endfunction "}}}
|
||||
|
||||
" Get regexp of the list item.
|
||||
function! s:rx_list_item() "{{{
|
||||
return '\('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)'
|
||||
endfunction "}}}
|
||||
|
||||
" Get regexp of the list item with checkbox.
|
||||
function! s:rx_cb_list_item() "{{{
|
||||
return s:rx_list_item().'\s*\zs\[.\?\]'
|
||||
endfunction "}}}
|
||||
|
||||
" Get level of the list item.
|
||||
function! s:get_level(lnum) "{{{
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
let level = vimwiki#base#count_first_sym(getline(a:lnum))
|
||||
else
|
||||
let level = indent(a:lnum)
|
||||
endif
|
||||
return level
|
||||
endfunction "}}}
|
||||
|
||||
" Get previous list item.
|
||||
" Returns: line number or 0.
|
||||
function! s:prev_list_item(lnum) "{{{
|
||||
let c_lnum = a:lnum - 1
|
||||
while c_lnum >= 1
|
||||
let line = getline(c_lnum)
|
||||
if line =~ s:rx_list_item()
|
||||
return c_lnum
|
||||
endif
|
||||
if line =~ '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
let c_lnum -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
" Get next list item in the list.
|
||||
" Returns: line number or 0.
|
||||
function! s:next_list_item(lnum) "{{{
|
||||
let c_lnum = a:lnum + 1
|
||||
while c_lnum <= line('$')
|
||||
let line = getline(c_lnum)
|
||||
if line =~ s:rx_list_item()
|
||||
return c_lnum
|
||||
endif
|
||||
if line =~ '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
let c_lnum += 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
" Find next list item in the buffer.
|
||||
" Returns: line number or 0.
|
||||
function! s:find_next_list_item(lnum) "{{{
|
||||
let c_lnum = a:lnum + 1
|
||||
while c_lnum <= line('$')
|
||||
let line = getline(c_lnum)
|
||||
if line =~ s:rx_list_item()
|
||||
return c_lnum
|
||||
endif
|
||||
let c_lnum += 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
" Set state of the list item on line number "lnum" to [ ] or [x]
|
||||
function! s:set_state(lnum, rate) "{{{
|
||||
let line = getline(a:lnum)
|
||||
let state = s:rx_li_symbol(a:rate)
|
||||
let line = substitute(line, s:rx_li_box, state, '')
|
||||
call setline(a:lnum, line)
|
||||
endfunction "}}}
|
||||
|
||||
" Get state of the list item on line number "lnum"
|
||||
function! s:get_state(lnum) "{{{
|
||||
let state = 0
|
||||
let line = getline(a:lnum)
|
||||
let opt = matchstr(line, s:rx_cb_list_item())
|
||||
if opt =~ s:rx_li_symbol(100)
|
||||
let state = 100
|
||||
elseif opt =~ s:rx_li_symbol(0)
|
||||
let state = 0
|
||||
elseif opt =~ s:rx_li_symbol(25)
|
||||
let state = 25
|
||||
elseif opt =~ s:rx_li_symbol(50)
|
||||
let state = 50
|
||||
elseif opt =~ s:rx_li_symbol(75)
|
||||
let state = 75
|
||||
endif
|
||||
return state
|
||||
endfunction "}}}
|
||||
|
||||
" Returns 1 if there is checkbox on a list item, 0 otherwise.
|
||||
function! s:is_cb_list_item(lnum) "{{{
|
||||
return getline(a:lnum) =~ s:rx_cb_list_item()
|
||||
endfunction "}}}
|
||||
|
||||
" Returns start line number of list item, 0 if it is not a list.
|
||||
function! s:is_list_item(lnum) "{{{
|
||||
let c_lnum = a:lnum
|
||||
while c_lnum >= 1
|
||||
let line = getline(c_lnum)
|
||||
if line =~ s:rx_list_item()
|
||||
return c_lnum
|
||||
endif
|
||||
if line =~ '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
if indent(c_lnum) > indent(a:lnum)
|
||||
return 0
|
||||
endif
|
||||
let c_lnum -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
" Returns char column of checkbox. Used in parent/child checks.
|
||||
function! s:get_li_pos(lnum) "{{{
|
||||
return stridx(getline(a:lnum), '[')
|
||||
endfunction "}}}
|
||||
|
||||
" Returns list of line numbers of parent and all its child items.
|
||||
function! s:get_child_items(lnum) "{{{
|
||||
let result = []
|
||||
let lnum = a:lnum
|
||||
let p_pos = s:get_level(lnum)
|
||||
|
||||
" add parent
|
||||
call add(result, lnum)
|
||||
|
||||
let lnum = s:next_list_item(lnum)
|
||||
while lnum != 0 && s:is_list_item(lnum) && s:get_level(lnum) > p_pos
|
||||
call add(result, lnum)
|
||||
let lnum = s:next_list_item(lnum)
|
||||
endwhile
|
||||
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" Returns list of line numbers of all items of the same level.
|
||||
function! s:get_sibling_items(lnum) "{{{
|
||||
let result = []
|
||||
let lnum = a:lnum
|
||||
let ind = s:get_level(lnum)
|
||||
|
||||
while lnum != 0 && s:get_level(lnum) >= ind
|
||||
if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
|
||||
call add(result, lnum)
|
||||
endif
|
||||
let lnum = s:next_list_item(lnum)
|
||||
endwhile
|
||||
|
||||
let lnum = s:prev_list_item(a:lnum)
|
||||
while lnum != 0 && s:get_level(lnum) >= ind
|
||||
if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
|
||||
call add(result, lnum)
|
||||
endif
|
||||
let lnum = s:prev_list_item(lnum)
|
||||
endwhile
|
||||
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" Returns line number of the parent of lnum item
|
||||
function! s:get_parent_item(lnum) "{{{
|
||||
let lnum = a:lnum
|
||||
let ind = s:get_level(lnum)
|
||||
|
||||
let lnum = s:prev_list_item(lnum)
|
||||
while lnum != 0 && s:is_list_item(lnum) && s:get_level(lnum) >= ind
|
||||
let lnum = s:prev_list_item(lnum)
|
||||
endwhile
|
||||
|
||||
if s:is_cb_list_item(lnum)
|
||||
return lnum
|
||||
else
|
||||
return a:lnum
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" Creates checkbox in a list item.
|
||||
function! s:create_cb_list_item(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
let m = matchstr(line, s:rx_list_item())
|
||||
if m != ''
|
||||
let li_content = substitute(strpart(line, len(m)), '^\s*', '', '')
|
||||
let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content
|
||||
call setline(a:lnum, line)
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" Tells if all of the sibling list items are checked or not.
|
||||
function! s:all_siblings_checked(lnum) "{{{
|
||||
let result = 0
|
||||
let cnt = 0
|
||||
let siblings = s:get_sibling_items(a:lnum)
|
||||
for lnum in siblings
|
||||
let cnt += s:get_state(lnum)
|
||||
endfor
|
||||
let result = cnt/len(siblings)
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" Creates checkbox on a list item if there is no one.
|
||||
function! s:TLI_create_checkbox(lnum) "{{{
|
||||
if a:lnum && !s:is_cb_list_item(a:lnum)
|
||||
if g:vimwiki_auto_checkbox
|
||||
call s:create_cb_list_item(a:lnum)
|
||||
endif
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
" Switch state of the child list items.
|
||||
function! s:TLI_switch_child_state(lnum) "{{{
|
||||
let current_state = s:get_state(a:lnum)
|
||||
if current_state == 100
|
||||
let new_state = 0
|
||||
else
|
||||
let new_state = 100
|
||||
endif
|
||||
for lnum in s:get_child_items(a:lnum)
|
||||
call s:set_state(lnum, new_state)
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
" Switch state of the parent list items.
|
||||
function! s:TLI_switch_parent_state(lnum) "{{{
|
||||
let c_lnum = a:lnum
|
||||
while s:is_cb_list_item(c_lnum)
|
||||
let parent_lnum = s:get_parent_item(c_lnum)
|
||||
if parent_lnum == c_lnum
|
||||
break
|
||||
endif
|
||||
call s:set_state(parent_lnum, s:all_siblings_checked(c_lnum))
|
||||
|
||||
let c_lnum = parent_lnum
|
||||
endwhile
|
||||
endfunction "}}}
|
||||
|
||||
function! s:TLI_toggle(lnum) "{{{
|
||||
if !s:TLI_create_checkbox(a:lnum)
|
||||
call s:TLI_switch_child_state(a:lnum)
|
||||
endif
|
||||
call s:TLI_switch_parent_state(a:lnum)
|
||||
endfunction "}}}
|
||||
|
||||
" Script functions }}}
|
||||
|
||||
" Toggle list item between [ ] and [X]
|
||||
function! vimwiki#lst#ToggleListItem(line1, line2) "{{{
|
||||
let line1 = a:line1
|
||||
let line2 = a:line2
|
||||
|
||||
if line1 != line2 && !s:is_list_item(line1)
|
||||
let line1 = s:find_next_list_item(line1)
|
||||
endif
|
||||
|
||||
let c_lnum = line1
|
||||
while c_lnum != 0 && c_lnum <= line2
|
||||
let li_lnum = s:is_list_item(c_lnum)
|
||||
|
||||
if li_lnum
|
||||
let li_level = s:get_level(li_lnum)
|
||||
if c_lnum == line1
|
||||
let start_li_level = li_level
|
||||
endif
|
||||
|
||||
if li_level <= start_li_level
|
||||
call s:TLI_toggle(li_lnum)
|
||||
let start_li_level = li_level
|
||||
endif
|
||||
endif
|
||||
|
||||
let c_lnum = s:find_next_list_item(c_lnum)
|
||||
endwhile
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
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()
|
||||
let cr .= '[ ] '
|
||||
endif
|
||||
return cr
|
||||
endfunction "}}}
|
||||
|
||||
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'
|
||||
let lnum = end_lnum
|
||||
let line = getline(beg_lnum)
|
||||
else
|
||||
let line = getline('.')
|
||||
let lnum = line('.')
|
||||
endif
|
||||
|
||||
" let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content
|
||||
let m = matchstr(line, s:rx_list_item())
|
||||
let res = ''
|
||||
if line =~ s:rx_cb_list_item()
|
||||
let res = substitute(m, '\s*$', ' ', '').'[ ] '
|
||||
elseif line =~ s:rx_list_item()
|
||||
let res = substitute(m, '\s*$', ' ', '')
|
||||
elseif &autoindent || &smartindent
|
||||
let res = matchstr(line, '^\s*')
|
||||
endif
|
||||
|
||||
if a:cmd ==# 'o'
|
||||
call append(lnum, res)
|
||||
call cursor(lnum + 1, col('$'))
|
||||
else
|
||||
call append(lnum - 1, res)
|
||||
call cursor(lnum, col('$'))
|
||||
endif
|
||||
|
||||
let l:count -= 1
|
||||
endwhile
|
||||
|
||||
startinsert!
|
||||
|
||||
endfunction "}}}
|
||||
|
39
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/style.css
Normal file
39
vim_plugins_src/vimwiki-1-2/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;}
|
510
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/tbl.vim
Normal file
510
vim_plugins_src/vimwiki-1-2/autoload/vimwiki/tbl.vim
Normal file
@ -0,0 +1,510 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" 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) "{{{
|
||||
" vim73 has new function that gives correct string width.
|
||||
if exists("*strdisplaywidth")
|
||||
return strdisplaywidth(a:str)
|
||||
endif
|
||||
|
||||
" get str display width in vim ver < 7.2
|
||||
if !g:vimwiki_CJK_length
|
||||
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
|
||||
else
|
||||
let savemodified = &modified
|
||||
let save_cursor = getpos('.')
|
||||
exe "norm! o\<esc>"
|
||||
call setline(line("."), a:str)
|
||||
let ret = virtcol("$") - 1
|
||||
d
|
||||
call setpos('.', save_cursor)
|
||||
let &modified = savemodified
|
||||
endif
|
||||
return ret
|
||||
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:is_first_column(lnum, cnum) "{{{
|
||||
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
|
||||
return line =~ '^\s*|[^|]*$' || line =~ '^\s*$'
|
||||
endfunction "}}}
|
||||
|
||||
function! s:count_separators_up(lnum) "{{{
|
||||
let lnum = a:lnum - 1
|
||||
while lnum > 1
|
||||
if !s:is_separator(getline(lnum))
|
||||
break
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
|
||||
return (a:lnum-lnum)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:count_separators_down(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) "{{{
|
||||
return split(a:line, '\s*|\s*', 1)[1:-2]
|
||||
endfunction "}}}
|
||||
|
||||
function! s:col_count(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_separator(line)
|
||||
return len(split(line, '\s*|\s*', 1)[1:-2])
|
||||
else
|
||||
return len(split(line, '-+-', 1))
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_indent(lnum) "{{{
|
||||
if !s:is_table(getline(a:lnum))
|
||||
return
|
||||
endif
|
||||
|
||||
let indent = 0
|
||||
|
||||
let lnum = a:lnum - 1
|
||||
while lnum > 1
|
||||
let line = getline(lnum)
|
||||
if !s:is_table(line)
|
||||
let indent = indent(lnum+1)
|
||||
break
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
|
||||
return indent
|
||||
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
|
||||
let cells = s:get_values(row)
|
||||
for idx in range(len(cells))
|
||||
let value = cells[idx]
|
||||
if has_key(max_lens, idx)
|
||||
let max_lens[idx] = max([s:wide_len(value), max_lens[idx]])
|
||||
else
|
||||
let max_lens[idx] = s:wide_len(value)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
return max_lens
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_aligned_rows(lnum, col1, col2) "{{{
|
||||
let max_lens = s:get_cell_max_lens(a:lnum)
|
||||
let rows = []
|
||||
for [lnum, row] in s:get_rows(a:lnum)
|
||||
if s:is_separator(row)
|
||||
let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
|
||||
else
|
||||
let new_row = s:fmt_row(row, max_lens, a:col1, a:col2)
|
||||
endif
|
||||
call add(rows, [lnum, new_row])
|
||||
endfor
|
||||
return rows
|
||||
endfunction "}}}
|
||||
|
||||
" Number of the current column. Starts from 0.
|
||||
function! s:cur_column() "{{{
|
||||
let line = getline('.')
|
||||
if !s:is_table(line)
|
||||
return -1
|
||||
endif
|
||||
if s:is_separator(line)
|
||||
let sep = '[+|]'
|
||||
else
|
||||
let sep = '|'
|
||||
endif
|
||||
|
||||
let curs_pos = col('.')
|
||||
let mpos = match(line, '|', 0)
|
||||
let col = -1
|
||||
while mpos < curs_pos && mpos != -1
|
||||
let mpos = match(line, sep, mpos+1)
|
||||
if mpos != -1
|
||||
let col += 1
|
||||
endif
|
||||
endwhile
|
||||
return col
|
||||
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, col1, col2) "{{{
|
||||
let new_line = '|'
|
||||
let cells = s:get_values(a:line)
|
||||
for idx in range(len(cells))
|
||||
if idx == a:col1
|
||||
let idx = a:col2
|
||||
elseif idx == a:col2
|
||||
let idx = a:col1
|
||||
endif
|
||||
let value = cells[idx]
|
||||
let new_line .= s:fmt_cell(value, a:max_lens[idx]).'|'
|
||||
endfor
|
||||
|
||||
let idx = len(cells)
|
||||
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, col1, col2) "{{{
|
||||
let sep = '|'
|
||||
for idx in range(len(a:max_lens))
|
||||
if idx == a:col1
|
||||
let idx = a:col2
|
||||
elseif idx == a:col2
|
||||
let idx = a:col1
|
||||
endif
|
||||
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 .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
|
||||
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_prev_row() "{{{
|
||||
let cmd = "\<ESC>jt|T|a"
|
||||
return cmd
|
||||
endfunction "}}}
|
||||
|
||||
function! s:kbd_goto_next_col(last) "{{{
|
||||
if a:last
|
||||
let seps = s:count_separators_down(line('.'))
|
||||
let cmd = "\<ESC>".seps."j0:call search('|', 'c', line('.'))\<CR>la"
|
||||
else
|
||||
let cmd = "\<ESC>:call search('|', 'c', line('.'))\<CR>la"
|
||||
endif
|
||||
return cmd
|
||||
endfunction "}}}
|
||||
|
||||
function! s:kbd_goto_prev_col(first) "{{{
|
||||
if a:first
|
||||
let seps = s:count_separators_up(line('.'))
|
||||
let cmd = "\<ESC>".seps."k$:call search('|', 'b', line('.'))\<CR>la"
|
||||
else
|
||||
let cmd = "\<ESC>2F|la"
|
||||
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#kbd_shift_tab() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<S-Tab>"
|
||||
endif
|
||||
|
||||
let first = s:is_first_column(lnum, col('.'))
|
||||
if first && !s:is_table(getline(lnum-1))
|
||||
return ""
|
||||
endif
|
||||
return s:kbd_goto_prev_col(first)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
endif
|
||||
|
||||
if a:0 == 2
|
||||
let col1 = a:1
|
||||
let col2 = a:2
|
||||
else
|
||||
let col1 = 0
|
||||
let col2 = 0
|
||||
endif
|
||||
|
||||
let indent = s:get_indent(a:lnum)
|
||||
|
||||
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
|
||||
let row = repeat(' ', indent).row
|
||||
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 "}}}
|
||||
|
||||
" TODO: move_column_left and move_column_right are good candidates to be
|
||||
" refactored.
|
||||
function! vimwiki#tbl#move_column_left() "{{{
|
||||
if !s:is_table(getline('.'))
|
||||
return
|
||||
endif
|
||||
|
||||
let cur_col = s:cur_column()
|
||||
if cur_col == -1
|
||||
return
|
||||
endif
|
||||
|
||||
if cur_col > 0
|
||||
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')
|
||||
else
|
||||
call search('|\%([^+]\++\)\{'.(cur_col-1).'}--', 'eW')
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#move_column_right() "{{{
|
||||
if !s:is_table(getline('.'))
|
||||
return
|
||||
endif
|
||||
|
||||
let cur_col = s:cur_column()
|
||||
if cur_col == -1
|
||||
return
|
||||
endif
|
||||
|
||||
if cur_col < s:col_count(line('.'))-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')
|
||||
else
|
||||
call search('|\%([^+]\++\)\{'.(cur_col+1).'}--', 'eW')
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#get_rows(lnum) "{{{
|
||||
return s:get_rows(a:lnum)
|
||||
endfunction "}}}
|
||||
|
||||
"}}}
|
2339
vim_plugins_src/vimwiki-1-2/doc/vimwiki.txt
Normal file
2339
vim_plugins_src/vimwiki-1-2/doc/vimwiki.txt
Normal file
File diff suppressed because it is too large
Load Diff
418
vim_plugins_src/vimwiki-1-2/ftplugin/vimwiki.vim
Normal file
418
vim_plugins_src/vimwiki-1-2/ftplugin/vimwiki.vim
Normal file
@ -0,0 +1,418 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki filetype plugin file
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
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 ".
|
||||
\ "suffixesadd< isfname< comments< ".
|
||||
\ "autowriteall< ".
|
||||
\ "formatoptions< foldtext< ".
|
||||
\ "foldmethod< foldexpr< commentstring< "
|
||||
" UNDO }}}
|
||||
|
||||
" MISC STUFF {{{
|
||||
|
||||
setlocal autowriteall
|
||||
setlocal commentstring=%%%s
|
||||
|
||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
||||
let &conceallevel = g:vimwiki_conceallevel
|
||||
endif
|
||||
|
||||
" MISC }}}
|
||||
|
||||
" GOTO FILE: gf {{{
|
||||
execute 'setlocal suffixesadd='.VimwikiGet('ext')
|
||||
setlocal isfname-=[,]
|
||||
" gf}}}
|
||||
|
||||
" Autocreate list items {{{
|
||||
" for list items, and list items with checkboxes
|
||||
if VimwikiGet('syntax') == 'default'
|
||||
setl comments=b:*,b:#,b:-
|
||||
setl formatlistpat=^\\s*[*#-]\\s*
|
||||
else
|
||||
setl comments=n:*,n:#
|
||||
endif
|
||||
setlocal formatoptions=tnro
|
||||
|
||||
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'
|
||||
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'
|
||||
endif
|
||||
endif
|
||||
|
||||
" COMMENTS }}}
|
||||
|
||||
" FOLDING for headers and list items using expr fold method. {{{
|
||||
function! VimwikiFoldLevel(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
|
||||
" Header folding...
|
||||
if line =~ g:vimwiki_rxHeader
|
||||
let n = vimwiki#base#count_first_sym(line)
|
||||
return '>'.n
|
||||
endif
|
||||
|
||||
if g:vimwiki_fold_trailing_empty_lines == 0 && line =~ '^\s*$'
|
||||
let nnline = getline(nextnonblank(a:lnum + 1))
|
||||
else
|
||||
let nnline = getline(a:lnum + 1)
|
||||
endif
|
||||
if nnline =~ g:vimwiki_rxHeader
|
||||
let n = vimwiki#base#count_first_sym(nnline)
|
||||
return '<'.n
|
||||
endif
|
||||
|
||||
" List item folding...
|
||||
if g:vimwiki_fold_lists
|
||||
let base_level = s:get_base_level(a:lnum)
|
||||
|
||||
let rx_list_item = '\('.
|
||||
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
|
||||
\ '\)'
|
||||
|
||||
|
||||
if line =~ rx_list_item
|
||||
let [nnum, nline] = s:find_forward(rx_list_item, a:lnum)
|
||||
let level = s:get_li_level(a:lnum)
|
||||
let leveln = s:get_li_level(nnum)
|
||||
let adj = s:get_li_level(s:get_start_list(rx_list_item, a:lnum))
|
||||
|
||||
if leveln > level
|
||||
return ">".(base_level+leveln-adj)
|
||||
else
|
||||
return (base_level+level-adj)
|
||||
endif
|
||||
else
|
||||
" process multilined list items
|
||||
let [pnum, pline] = s:find_backward(rx_list_item, a:lnum)
|
||||
if pline =~ rx_list_item
|
||||
if indent(a:lnum) > indent(pnum)
|
||||
let level = s:get_li_level(pnum)
|
||||
let adj = s:get_li_level(s:get_start_list(rx_list_item, pnum))
|
||||
|
||||
let [nnum, nline] = s:find_forward(rx_list_item, a:lnum)
|
||||
if nline =~ rx_list_item
|
||||
let leveln = s:get_li_level(nnum)
|
||||
if leveln > level
|
||||
return (base_level+leveln-adj)
|
||||
endif
|
||||
endif
|
||||
|
||||
return (base_level+level-adj)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
return base_level
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_base_level(lnum) "{{{
|
||||
let lnum = a:lnum - 1
|
||||
while lnum > 0
|
||||
if getline(lnum) =~ g:vimwiki_rxHeader
|
||||
return vimwiki#base#count_first_sym(getline(lnum))
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_forward(rx_item, lnum) "{{{
|
||||
let lnum = a:lnum + 1
|
||||
|
||||
while lnum <= line('$')
|
||||
let line = getline(lnum)
|
||||
if line =~ a:rx_item
|
||||
\ || line =~ '^\S'
|
||||
\ || line =~ g:vimwiki_rxHeader
|
||||
break
|
||||
endif
|
||||
let lnum += 1
|
||||
endwhile
|
||||
|
||||
return [lnum, getline(lnum)]
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_backward(rx_item, lnum) "{{{
|
||||
let lnum = a:lnum - 1
|
||||
|
||||
while lnum > 1
|
||||
let line = getline(lnum)
|
||||
if line =~ a:rx_item
|
||||
\ || line =~ '^\S'
|
||||
break
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
|
||||
return [lnum, getline(lnum)]
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_li_level(lnum) "{{{
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
let level = vimwiki#base#count_first_sym(getline(a:lnum))
|
||||
else
|
||||
let level = (indent(a:lnum) / &sw)
|
||||
endif
|
||||
return level
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_start_list(rx_item, lnum) "{{{
|
||||
let lnum = a:lnum
|
||||
while lnum >= 1
|
||||
let line = getline(lnum)
|
||||
if line !~ a:rx_item && line =~ '^\S'
|
||||
return nextnonblank(lnum + 1)
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! VimwikiFoldText() "{{{
|
||||
let line = substitute(getline(v:foldstart), '\t',
|
||||
\ repeat(' ', &tabstop), 'g')
|
||||
return line.' ['.(v:foldend - v:foldstart).']'
|
||||
endfunction "}}}
|
||||
|
||||
" FOLDING }}}
|
||||
|
||||
" COMMANDS {{{
|
||||
command! -buffer Vimwiki2HTML
|
||||
\ 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')))
|
||||
|
||||
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 VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
|
||||
|
||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
|
||||
|
||||
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 lvimgrep <args> '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
|
||||
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()
|
||||
|
||||
" diary commands
|
||||
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
||||
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
||||
|
||||
" COMMANDS }}}
|
||||
|
||||
" KEYBINDINGS {{{
|
||||
if g:vimwiki_use_mouse
|
||||
nmap <buffer> <S-LeftMouse> <NOP>
|
||||
nmap <buffer> <C-LeftMouse> <NOP>
|
||||
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
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiSplitLink')
|
||||
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiVSplitLink')
|
||||
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
|
||||
endif
|
||||
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
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiNextLink')
|
||||
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiPrevLink')
|
||||
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDeleteLink')
|
||||
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiRenameLink')
|
||||
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiToggleListItem')
|
||||
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
|
||||
vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
|
||||
if has("unix")
|
||||
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
|
||||
endif
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryNextDay')
|
||||
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
|
||||
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
|
||||
|
||||
function! s:CR() "{{{
|
||||
let res = vimwiki#lst#kbd_cr()
|
||||
if res == "\<CR>" && g:vimwiki_table_auto_fmt
|
||||
let res = vimwiki#tbl#kbd_cr()
|
||||
endif
|
||||
return res
|
||||
endfunction "}}}
|
||||
|
||||
" List and Table <CR> mapping
|
||||
inoremap <buffer> <expr> <CR> <SID>CR()
|
||||
|
||||
" List mappings
|
||||
nnoremap <buffer> o :<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()
|
||||
endif
|
||||
|
||||
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
|
||||
nnoremap <buffer> gww :VimwikiTableAlignW<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#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#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#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#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#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#base#TO_table_col(1, 0)<CR>
|
||||
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
|
||||
|
||||
nnoremap <silent><buffer> = :call vimwiki#base#AddHeaderLevel()<CR>
|
||||
nnoremap <silent><buffer> - :call vimwiki#base#RemoveHeaderLevel()<CR>
|
||||
|
||||
" }}}
|
||||
|
||||
" KEYBINDINGS }}}
|
||||
|
||||
" AUTOCOMMANDS {{{
|
||||
if VimwikiGet('auto_export')
|
||||
" Automatically generate HTML on page write.
|
||||
augroup vimwiki
|
||||
au BufWritePost <buffer> Vimwiki2HTML
|
||||
augroup END
|
||||
endif
|
||||
|
||||
" AUTOCOMMANDS }}}
|
445
vim_plugins_src/vimwiki-1-2/plugin/vimwiki.vim
Normal file
445
vim_plugins_src/vimwiki-1-2/plugin/vimwiki.vim
Normal file
@ -0,0 +1,445 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki plugin file
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
|
||||
|
||||
if exists("loaded_vimwiki") || &cp
|
||||
finish
|
||||
endif
|
||||
let loaded_vimwiki = 1
|
||||
|
||||
let s:old_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" HELPER functions {{{
|
||||
function! s:default(varname, value) "{{{
|
||||
if !exists('g:vimwiki_'.a:varname)
|
||||
let g:vimwiki_{a:varname} = a:value
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" 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(p1), len(p2)])
|
||||
while (idx < minlen) && (p1[idx] ==? p2[idx])
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
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#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
|
||||
endwhile
|
||||
return -1
|
||||
endfunction "}}}
|
||||
|
||||
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_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
|
||||
else
|
||||
" Find what wiki current buffer belongs to.
|
||||
" If wiki does not exist in g:vimwiki_list -- add new wiki there with
|
||||
" buffer's path and ext.
|
||||
" Else set g:vimwiki_current_idx to that wiki index.
|
||||
let path = expand('%:p:h')
|
||||
let ext = '.'.expand('%:e')
|
||||
let idx = s:find_wiki(path)
|
||||
|
||||
" The buffer's file is not in the path and user do not want his wiki
|
||||
" extension to be global -- do not add new wiki.
|
||||
if idx == -1 && g:vimwiki_global_ext == 0
|
||||
return
|
||||
endif
|
||||
|
||||
if idx == -1
|
||||
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'temp': 1})
|
||||
let g:vimwiki_current_idx = len(g:vimwiki_list) - 1
|
||||
else
|
||||
let g:vimwiki_current_idx = idx
|
||||
endif
|
||||
|
||||
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#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
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding == 1 && &fdm != 'expr'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
endif
|
||||
|
||||
" And conceal level too.
|
||||
if g:vimwiki_conceallevel && exists("+conceallevel")
|
||||
let &conceallevel = g:vimwiki_conceallevel
|
||||
endif
|
||||
|
||||
" Set up menu
|
||||
if g:vimwiki_menu != ""
|
||||
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" OPTION get/set functions {{{
|
||||
" return value of option for current wiki or if second parameter exists for
|
||||
" wiki with a given index.
|
||||
function! VimwikiGet(option, ...) "{{{
|
||||
if a:0 == 0
|
||||
let idx = g:vimwiki_current_idx
|
||||
else
|
||||
let idx = a:1
|
||||
endif
|
||||
if !has_key(g:vimwiki_list[idx], a:option) &&
|
||||
\ has_key(s:vimwiki_defaults, a:option)
|
||||
if a:option == 'path_html'
|
||||
let g:vimwiki_list[idx][a:option] =
|
||||
\VimwikiGet('path', idx)[:-2].'_html/'
|
||||
else
|
||||
let g:vimwiki_list[idx][a:option] =
|
||||
\s:vimwiki_defaults[a:option]
|
||||
endif
|
||||
endif
|
||||
|
||||
" if path's ending is not a / or \
|
||||
" then add it
|
||||
if a:option == 'path' || a:option == 'path_html'
|
||||
let p = g:vimwiki_list[idx][a:option]
|
||||
" resolve doesn't work quite right with symlinks ended with / or \
|
||||
let p = substitute(p, '[/\\]\+$', '', '')
|
||||
let p = resolve(expand(p))
|
||||
let g:vimwiki_list[idx][a:option] = p.'/'
|
||||
endif
|
||||
|
||||
return g:vimwiki_list[idx][a:option]
|
||||
endfunction "}}}
|
||||
|
||||
" set option for current wiki or if third parameter exists for
|
||||
" wiki with a given index.
|
||||
function! VimwikiSet(option, value, ...) "{{{
|
||||
if a:0 == 0
|
||||
let idx = g:vimwiki_current_idx
|
||||
else
|
||||
let idx = a:1
|
||||
endif
|
||||
let g:vimwiki_list[idx][a:option] = a:value
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" }}}
|
||||
|
||||
" CALLBACK function "{{{
|
||||
" User can redefine it.
|
||||
if !exists("*VimwikiWeblinkHandler") "{{{
|
||||
function VimwikiWeblinkHandler(weblink)
|
||||
for browser in g:vimwiki_browsers
|
||||
if executable(browser)
|
||||
if has("win32")
|
||||
execute '!start "'.browser.'" "' . a:weblink . '"'
|
||||
else
|
||||
execute '!'.browser.' "' . a:weblink . '"'
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
endif "}}}
|
||||
" CALLBACK }}}
|
||||
|
||||
" DEFAULT wiki {{{
|
||||
let s:vimwiki_defaults = {}
|
||||
let s:vimwiki_defaults.path = '~/vimwiki/'
|
||||
let s:vimwiki_defaults.path_html = '~/vimwiki_html/'
|
||||
let s:vimwiki_defaults.css_name = 'style.css'
|
||||
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.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
|
||||
" file.
|
||||
let s:vimwiki_defaults.temp = 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 become more datetime awareable.
|
||||
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
|
||||
|
||||
let s:vimwiki_defaults.diary_link_count = 4
|
||||
|
||||
"}}}
|
||||
|
||||
" DEFAULT options {{{
|
||||
call s:default('list', [s:vimwiki_defaults])
|
||||
if &encoding == 'utf-8'
|
||||
call s:default('upper', 'A-Z\u0410-\u042f')
|
||||
call s:default('lower', 'a-z\u0430-\u044f')
|
||||
else
|
||||
call s:default('upper', 'A-Z')
|
||||
call s:default('lower', 'a-z')
|
||||
endif
|
||||
call s:default('other', '0-9')
|
||||
call s:default('stripsym', '_')
|
||||
call s:default('badsyms', '')
|
||||
call s:default('auto_checkbox', 1)
|
||||
call s:default('use_mouse', 0)
|
||||
call s:default('folding', 0)
|
||||
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_cb_checked', 0)
|
||||
call s:default('camel_case', 1)
|
||||
call s:default('list_ignore_newline', 1)
|
||||
call s:default('listsyms', ' .oOX')
|
||||
if has("win32")
|
||||
call s:default('browsers',
|
||||
\ [
|
||||
\ expand('~').'\Local Settings\Application Data\Google\Chrome\Application\chrome.exe',
|
||||
\ 'C:\Program Files\Opera\opera.exe',
|
||||
\ 'C:\Program Files\Mozilla Firefox\firefox.exe',
|
||||
\ 'C:\Program Files\Internet Explorer\iexplore.exe',
|
||||
\ ])
|
||||
else
|
||||
call s:default('browsers',
|
||||
\ [
|
||||
\ 'chromium-browser',
|
||||
\ 'opera',
|
||||
\ 'firefox',
|
||||
\ 'konqueror',
|
||||
\ ])
|
||||
endif
|
||||
|
||||
call s:default('use_calendar', 1)
|
||||
call s:default('table_auto_fmt', 1)
|
||||
call s:default('w32_dir_enc', '')
|
||||
call s:default('CJK_length', 0)
|
||||
call s:default('dir_link', '')
|
||||
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
|
||||
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
|
||||
call s:default('user_htmls', '')
|
||||
|
||||
call s:default('html_header_numbering', 0)
|
||||
call s:default('html_header_numbering_sym', '')
|
||||
call s:default('conceallevel', 3)
|
||||
|
||||
call s:default('current_idx', 0)
|
||||
|
||||
let upp = g:vimwiki_upper
|
||||
let low = g:vimwiki_lower
|
||||
let oth = g:vimwiki_other
|
||||
let nup = low.oth
|
||||
let nlo = upp.oth
|
||||
let any = upp.nup
|
||||
|
||||
let wword = '\C\<['.upp.']['.nlo.']*['.low.']['.nup.']*['.upp.']['.any.']*\>'
|
||||
let g:vimwiki_rxWikiWord = '!\@<!'.wword
|
||||
let g:vimwiki_rxNoWikiWord = '!'.wword
|
||||
|
||||
let g:vimwiki_rxWikiLink1 = '\[\[[^\]]\+\]\]'
|
||||
let g:vimwiki_rxWikiLink2 = '\[\[[^\]]\+\]\[[^\]]\+\]\]'
|
||||
if g:vimwiki_camel_case
|
||||
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiWord.'\|'.
|
||||
\ g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
|
||||
else
|
||||
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
|
||||
endif
|
||||
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
|
||||
\'\%('.
|
||||
\'\%('.
|
||||
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
|
||||
\'\%(\%(//\)\|\%(\\\\\)\)'.
|
||||
\'\)'.
|
||||
\'\|\%(mailto:\)'.
|
||||
\'\)'.
|
||||
\'\+\S\+'.
|
||||
\'[().,?\]]\@<!'
|
||||
"}}}
|
||||
|
||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||
" Getting all extensions that different wikies could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
augroup filetypedetect
|
||||
" clear FlexWiki's stuff
|
||||
au! * *.wiki
|
||||
augroup end
|
||||
|
||||
augroup vimwiki
|
||||
autocmd!
|
||||
for ext in keys(extensions)
|
||||
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
||||
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.' 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("."))'
|
||||
endif
|
||||
endfor
|
||||
augroup END
|
||||
"}}}
|
||||
|
||||
" COMMANDS {{{
|
||||
command! VimwikiUISelect call vimwiki#base#ui_select()
|
||||
command! -count VimwikiIndex
|
||||
\ call vimwiki#base#goto_index(v:count1)
|
||||
command! -count VimwikiTabIndex tabedit <bar>
|
||||
\ 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)
|
||||
command! -count VimwikiTabMakeDiaryNote tabedit <bar>
|
||||
\ call vimwiki#diary#make_note(v:count1)
|
||||
"}}}
|
||||
|
||||
" MAPPINGS {{{
|
||||
if !hasmapto('<Plug>VimwikiIndex')
|
||||
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabIndex')
|
||||
nmap <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiUISelect')
|
||||
nmap <silent><unique> <Leader>ws <Plug>VimwikiUISelect
|
||||
endif
|
||||
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')
|
||||
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
||||
nmap <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
|
||||
endif
|
||||
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
||||
\ :VimwikiTabMakeDiaryNote<CR>
|
||||
|
||||
"}}}
|
||||
|
||||
" MENU {{{
|
||||
function! s:build_menu(topmenu)
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
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#base#goto_index('.(idx + 1).')<CR>'
|
||||
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
||||
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
|
||||
let idx += 1
|
||||
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 '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
|
||||
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
|
||||
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'
|
||||
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
||||
endif
|
||||
"}}}
|
||||
|
||||
let &cpo = s:old_cpo
|
261
vim_plugins_src/vimwiki-1-2/syntax/vimwiki.vim
Normal file
261
vim_plugins_src/vimwiki-1-2/syntax/vimwiki.vim
Normal file
@ -0,0 +1,261 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" Quit if syntax file is already loaded
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" 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
|
||||
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
|
||||
|
||||
" Concealed chars
|
||||
if exists("+conceallevel")
|
||||
syntax conceal on
|
||||
endif
|
||||
|
||||
syntax spell toplevel
|
||||
|
||||
syn match VimwikiLinkChar contained /\[\[/
|
||||
syn match VimwikiLinkChar contained /\]\]/
|
||||
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.\{-}]]/
|
||||
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}]\[\ze.\{-}]]/
|
||||
|
||||
syn match VimwikiNoLinkChar contained /\[\[/
|
||||
syn match VimwikiNoLinkChar contained /\]\]/
|
||||
syn match VimwikiNoLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.*]]/
|
||||
syn match VimwikiNoLinkChar contained /\[\[[^\[\]\|]\{-}]\[\ze.*]]/
|
||||
|
||||
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
|
||||
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'
|
||||
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'
|
||||
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'
|
||||
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'
|
||||
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'
|
||||
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'
|
||||
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'
|
||||
if exists("+conceallevel")
|
||||
syntax conceal off
|
||||
endif
|
||||
|
||||
" Non concealed chars
|
||||
syn match VimwikiHeaderChar contained /\%(^\s*=\+\)\|\%(=\+\s*$\)/
|
||||
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
|
||||
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
|
||||
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
|
||||
execute 'syn match VimwikiItalicBoldCharT contained /'.g:vimwiki_char_italicbold.'/'
|
||||
execute 'syn match VimwikiCodeCharT contained /'.g:vimwiki_char_code.'/'
|
||||
execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
|
||||
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
|
||||
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
|
||||
|
||||
|
||||
" Emoticons
|
||||
syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
|
||||
|
||||
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
|
||||
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
|
||||
|
||||
|
||||
" Tables
|
||||
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
|
||||
\ transparent contains=VimwikiCellSeparator,VimwikiLinkT,
|
||||
\ VimwikiNoExistsLinkT,VimwikiEmoticons,VimwikiTodo,
|
||||
\ VimwikiBoldT,VimwikiItalicT,VimwikiBoldItalicT,VimwikiItalicBoldT,
|
||||
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT,
|
||||
\ @Spell
|
||||
syntax match VimwikiCellSeparator
|
||||
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
|
||||
|
||||
" List items
|
||||
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,@Spell'
|
||||
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
|
||||
|
||||
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,@Spell'
|
||||
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
|
||||
|
||||
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,@Spell'
|
||||
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
|
||||
|
||||
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,@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=/^\s*'.g:vimwiki_rxPreStart.
|
||||
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
|
||||
|
||||
" List item checkbox
|
||||
syntax match VimwikiCheckBox /\[.\?\]/
|
||||
if g:vimwiki_hl_cb_checked
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.
|
||||
\ g:vimwiki_rxListBullet.'\s*\['.g:vimwiki_listsyms[4].'\].*$/'.
|
||||
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
|
||||
execute 'syntax match VimwikiCheckBoxDone /'.
|
||||
\ g:vimwiki_rxListNumber.'\s*\['.g:vimwiki_listsyms[4].'\].*$/'.
|
||||
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
|
||||
endif
|
||||
|
||||
" placeholders
|
||||
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
|
||||
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
|
||||
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
|
||||
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
|
||||
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
|
||||
|
||||
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
|
||||
|
||||
" 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 "{{{
|
||||
|
||||
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
|
||||
|
||||
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
||||
hi def link VimwikiItalicT VimwikiItalic
|
||||
|
||||
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
|
||||
hi def link VimwikiItalicBold VimwikiBoldItalic
|
||||
hi def link VimwikiBoldItalicT VimwikiBoldItalic
|
||||
hi def link VimwikiItalicBoldT VimwikiBoldItalic
|
||||
|
||||
hi def VimwikiUnderline gui=underline
|
||||
|
||||
hi def link VimwikiCode PreProc
|
||||
hi def link VimwikiCodeT VimwikiCode
|
||||
|
||||
hi def link VimwikiPre PreProc
|
||||
hi def link VimwikiPreT VimwikiPre
|
||||
|
||||
hi def link VimwikiNoExistsLink SpellBad
|
||||
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
|
||||
|
||||
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
|
||||
|
||||
hi def link VimwikiDelText Constant
|
||||
hi def link VimwikiDelTextT VimwikiDelText
|
||||
|
||||
hi def link VimwikiSuperScript Number
|
||||
hi def link VimwikiSuperScriptT VimwikiSuperScript
|
||||
|
||||
hi def link VimwikiSubScript Number
|
||||
hi def link VimwikiSubScriptT VimwikiSubScript
|
||||
|
||||
hi def link VimwikiTodo Todo
|
||||
hi def link VimwikiComment Comment
|
||||
|
||||
hi def link VimwikiPlaceholder SpecialKey
|
||||
hi def link VimwikiPlaceholderParam String
|
||||
hi def link VimwikiHTMLtag SpecialKey
|
||||
|
||||
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 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
|
||||
"}}}
|
||||
|
||||
let b:current_syntax="vimwiki"
|
||||
|
||||
" EMBEDDED syntax setup "{{{
|
||||
let nested = VimwikiGet('nested_syntaxes')
|
||||
if !empty(nested)
|
||||
for [hl_syntax, vim_syntax] in items(nested)
|
||||
call vimwiki#base#nested_syntax(vim_syntax,
|
||||
\ '^\s*{{{\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*}}}', 'VimwikiPre')
|
||||
endfor
|
||||
endif
|
||||
"}}}
|
85
vim_plugins_src/vimwiki-1-2/syntax/vimwiki_default.vim
Normal file
85
vim_plugins_src/vimwiki-1-2/syntax/vimwiki_default.vim
Normal file
@ -0,0 +1,85 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" Default syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" text: *strong*
|
||||
" let g:vimwiki_rxBold = '\*[^*]\+\*'
|
||||
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'\*'.
|
||||
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
|
||||
\'\*'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_bold = '*'
|
||||
|
||||
" text: _emphasis_
|
||||
" let g:vimwiki_rxItalic = '_[^_]\+_'
|
||||
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'_'.
|
||||
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
|
||||
\'_'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_italic = '_'
|
||||
|
||||
" text: *_bold italic_* or _*italic bold*_
|
||||
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'\*_'.
|
||||
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
|
||||
\'_\*'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_bolditalic = '\*_'
|
||||
|
||||
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
|
||||
\'_\*'.
|
||||
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
|
||||
\'\*_'.
|
||||
\'\%([[:punct:]]\|\s\|$\)\@='
|
||||
let g:vimwiki_char_italicbold = '_\*'
|
||||
|
||||
" text: `code`
|
||||
let g:vimwiki_rxCode = '`[^`]\+`'
|
||||
let g:vimwiki_char_code = '`'
|
||||
|
||||
" text: ~~deleted text~~
|
||||
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
|
||||
let g:vimwiki_char_deltext = '\~\~'
|
||||
|
||||
" text: ^superscript^
|
||||
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
|
||||
let g:vimwiki_char_superscript = '^'
|
||||
|
||||
" text: ,,subscript,,
|
||||
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
|
||||
let g:vimwiki_char_subscript = ',,'
|
||||
|
||||
" Header levels, 1-6
|
||||
let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$'
|
||||
let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$'
|
||||
let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$'
|
||||
let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$'
|
||||
let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$'
|
||||
let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$'
|
||||
let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH2.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH3.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH4.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH5.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH6.'\)'
|
||||
|
||||
let g:vimwiki_char_header = '\%(^\s*=\+\)\|\%(=\+\s*$\)'
|
||||
|
||||
" <hr>, horizontal rule
|
||||
let g:vimwiki_rxHR = '^----.*$'
|
||||
|
||||
" List items start with optional whitespace(s) then '* ' or '# '
|
||||
let g:vimwiki_rxListBullet = '^\s*\%(\*\|-\)\s'
|
||||
let g:vimwiki_rxListNumber = '^\s*#\s'
|
||||
|
||||
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '{{{'
|
||||
let g:vimwiki_rxPreEnd = '}}}'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
69
vim_plugins_src/vimwiki-1-2/syntax/vimwiki_media.vim
Normal file
69
vim_plugins_src/vimwiki-1-2/syntax/vimwiki_media.vim
Normal file
@ -0,0 +1,69 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki syntax file
|
||||
" MediaWiki syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
" text: '''strong'''
|
||||
let g:vimwiki_rxBold = "'''[^']\\+'''"
|
||||
let g:vimwiki_char_bold = "'''"
|
||||
|
||||
" text: ''emphasis''
|
||||
let g:vimwiki_rxItalic = "''[^']\\+''"
|
||||
let g:vimwiki_char_italic = "''"
|
||||
|
||||
" text: '''''strong italic'''''
|
||||
let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''"
|
||||
let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic
|
||||
let g:vimwiki_char_bolditalic = "'''''"
|
||||
let g:vimwiki_char_italicbold = g:vimwiki_char_bolditalic
|
||||
|
||||
" text: `code`
|
||||
let g:vimwiki_rxCode = '`[^`]\+`'
|
||||
let g:vimwiki_char_code = '`'
|
||||
|
||||
" text: ~~deleted text~~
|
||||
let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~'
|
||||
let g:vimwiki_char_deltext = '\~\~'
|
||||
|
||||
" text: ^superscript^
|
||||
let g:vimwiki_rxSuperScript = '\^[^^]\+\^'
|
||||
let g:vimwiki_char_superscript = '^'
|
||||
|
||||
" text: ,,subscript,,
|
||||
let g:vimwiki_rxSubScript = ',,[^,]\+,,'
|
||||
let g:vimwiki_char_subscript = ',,'
|
||||
|
||||
" Header levels, 1-6
|
||||
let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$'
|
||||
let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$'
|
||||
let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$'
|
||||
let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$'
|
||||
let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$'
|
||||
let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$'
|
||||
let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH2.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH3.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH4.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH5.'\)\|'.
|
||||
\ '\%('.g:vimwiki_rxH6.'\)'
|
||||
let g:vimwiki_char_header = '\%(^\s*=\+\)\|\%(=\+\s*$\)'
|
||||
|
||||
" <hr>, horizontal rule
|
||||
let g:vimwiki_rxHR = '^----.*$'
|
||||
|
||||
" Tables. Each line starts and ends with '||'; each cell is separated by '||'
|
||||
let g:vimwiki_rxTable = '||'
|
||||
|
||||
" Bulleted list items start with whitespace(s), then '*'
|
||||
" highlight only bullets and digits.
|
||||
let g:vimwiki_rxListBullet = '^\s*\*\+\([^*]*$\)\@='
|
||||
let g:vimwiki_rxListNumber = '^\s*#\+'
|
||||
|
||||
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
|
||||
|
||||
" Preformatted text
|
||||
let g:vimwiki_rxPreStart = '<pre>'
|
||||
let g:vimwiki_rxPreEnd = '<\/pre>'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
Reference in New Issue
Block a user