1
0
mirror of https://github.com/amix/vimrc synced 2025-07-09 02:25:00 +08:00

rename vim_plugins_src to vim_plugin_candinates_src and used as an plugin candinate dir

This commit is contained in:
hustcalm
2012-10-29 18:20:36 +08:00
parent b27590fbb4
commit b64930e3e7
486 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,172 @@
" calutil.vim: some calendar utilities
" Author: Charles E. Campbell, Jr.
" with modifications by Herbert Sitz for VimOrganizer
" Date: Oct 08, 2008
" Version: 3b ASTRO-ONLY
" ---------------------------------------------------------------------
if exists("loaded_calutil")
finish
endif
let g:loaded_calutil= "v3b"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of calutil needs vim 7.0"
echohl Normal
finish
endif
function! calutil#dayname(date)
return calutil#DayOfWeek(split(a:date,'-')[0],split(a:date,'-')[1],split(a:date,'-')[2],2)
endfunction
function! calutil#dow(date)
return calutil#DayOfWeek(split(a:date,'-')[0],split(a:date,'-')[1],split(a:date,'-')[2],1)
endfunction
function! calutil#jul(date)
return calutil#Cal2Jul(split(a:date,'-')[0],split(a:date,'-')[1],split(a:date,'-')[2])
endfunction
function! calutil#cal(julian)
return calutil#Jul2Cal(a:julian)
endfunction
" ---------------------------------------------------------------------
" DayOfWeek: {{{1
" Usage : call calutil#DayOfWeek(y,m,d,[0|1|2])
" g:CalUtilDayOfWeek: if 0-> integer (default)
" 1-> 3-letter English abbreviation for name of day
" 2-> English name of day
" Returns
" g:CalUtilDayOfWeek
" ---------
" 1 : 0 1 2 3 4 5 6
" 2 : Mon Tue Wed Thu Fri Sat Sun
" 3 : Monday Tuesday Wednesday Thursday Friday Saturday Sunday
fun! calutil#DayOfWeek(y,m,d,...)
if a:0 > 0
let g:CalUtilDayOfWeek= a:1
endif
let z = calutil#Cal2Jul(a:y,a:m,a:d)
if z >= 0
let z= z%7
else
let z= 7 - (-z%7)
endif
if exists("g:CalUtilDayOfWeek")
if g:CalUtilDayOfWeek == 2
let dow0="Mon"
let dow1="Tue"
let dow2="Wed"
let dow3="Thu"
let dow4="Fri"
let dow5="Sat"
let dow6="Sun"
return dow{z}
elseif g:CalUtilDayOfWeek == 3
let dow0="Monday"
let dow1="Tuesday"
let dow2="Wednesday"
let dow3="Thursday"
let dow4="Friday"
let dow5="Saturday"
let dow6="Sunday"
return dow{z}
endif
endif
return z
endfun
" ---------------------------------------------------------------------
" calutil#Cal2Jul: convert a (after 9/14/1752) Gregorian calendar date to Julian day {{{1
" (on,before " ) Julian calendar date to Julian day
" (proleptic)
fun! calutil#Cal2Jul(y,m,d)
let year = a:y
let month= a:m
let day = a:d
" there is no year zero
if year == 0
let year= -1
elseif year < 0
let year= year + 1
endif
let julday= day - 32075 +
\ 1461*(year + 4800 + (month - 14)/12)/4 +
\ 367*(month - 2 - ((month - 14)/12)*12)/12 -
\ 3*((year + 4900 + (month - 14)/12)/100)/4
" 2361221 == Sep 2, 1752, which was followed immediately by
" Sep 14, 1752 (in England). Various countries
" adopted the Gregorian calendar at different times.
if julday <= 2361221
let a = (14-month)/12
let y = year + 4800 - a
let m = month + 12*a - 3
let julday = day + (153*m + 2)/5 + y*365 + y/4 - 32083
endif
return julday
endfun
" ---------------------------------------------------------------------
" calutil#Jul2Cal: convert a Julian day to a date: {{{1
" Default year/month/day
" julday,1 julday,"ymd" year/month/day
" julday,2 julday,"mdy" month/day/year
" julday,3 julday,"dmy" day/month/year
fun! calutil#Jul2Cal(julday,...)
let julday= a:julday
if julday <= 2361221
" Proleptic Julian Calendar:
" 2361210 == Sep 2, 1752, which was followed immediately by Sep 14, 1752
" in England
let c = julday + 32082
let d = (4*c + 3)/1461
let e = c - (1461*d)/4
let m = (5*e + 2)/153
let day = e - (153*m + 2)/5 + 1
let month = m + 3 - 12*(m/10)
let year = d - 4800 + m/10
if year <= 0
" proleptic Julian Calendar: there *is* no year 0!
let year= year - 1
endif
else
" Gregorian calendar
let t1 = julday + 68569
let t2 = 4*t1/146097
let t1 = t1 - (146097*t2 + 3)/4
let yr = 4000*(t1 + 1)/1461001
let t1 = t1 - (1461*yr/4 - 31)
let mo = 80*t1/2447
let day = (t1 - 2447*mo/80)
let t1 = mo/11
let month = (mo + 2 - 12*t1)
let year = (100*(t2 - 49) + yr + t1)
endif
let month = (month<10) ? '0' . month : month
let day = (day < 10) ? '0' . day : day
if a:0 > 0
if a:1 == 1 || a:1 =~ "ymd"
return year."-".month."/".day
elseif a:1 == 2 || a:1 =~ "mdy"
return month."-".day."/".year
elseif a:1 == 3 || a:1 =~ "dmy"
return day."-".month."/".year
else
return year."-".month."/".day
endif
else
return year."-".month."-".day
endif
endfun
" ---------------------------------------------------------------------
" vim: ts=4 fdm=marker

View File

@ -0,0 +1,77 @@
" org.vim - VimOrganizer plugin for Vim
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
" Copyright: (c) 2010, 2011 by Herbert Sitz
" The VIM LICENSE applies to all files in the
" VimOrganizer plugin.
" (See the Vim copyright except read "VimOrganizer"
" in places where that copyright refers to "Vim".)
" http://vimdoc.sourceforge.net/htmldoc/uganda.html#license
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk *** ***
if exists("g:org_autoload_funcs")
finish
endif
let g:org_autoload_funcs=1
function! org#SetOrgFileType()
"if expand("%:e") == 'org'
if &filetype != 'org'
execute "set filetype=org"
" if !exists('g:org_todo_setup')
" let g:org_todo_setup = 'TODO | DONE'
" endif
" if !exists('g:org_tag_setup')
" let g:org_tag_setup = '{home(h) work(w)}'
" endif
"
" call OrgProcessConfigLines()
" exec "syntax match DONETODO '" . b:v.todoDoneMatch . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
" exec "syntax match NOTDONETODO '" . b:v.todoNotDoneMatch . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
endif
"endif
endfunction
function! org#Pad(s,amt)
return a:s . repeat(' ',a:amt - len(a:s))
endfunction
function! org#Timestamp()
return strftime("%Y-%m-%d %a %H:%M")
endfunction
function! org#GetGroupHighlight(group)
" this code was copied and modified from code posted on StackOverflow
" http://stackoverflow.com/questions/1331213/how-to-modify-existing-highlight-group-in-vim
" Redirect the output of the "hi" command into a variable
" and find the highlighting
redir => GroupDetails
exe "silent hi " . a:group
redir END
" Resolve linked groups to find the root highlighting scheme
while GroupDetails =~ "links to"
let index = stridx(GroupDetails, "links to") + len("links to")
let LinkedGroup = strpart(GroupDetails, index + 1)
redir => GroupDetails
exe "silent hi " . LinkedGroup
redir END
endwhile
" Extract the highlighting details (the bit after "xxx")
let MatchGroups = matchlist(GroupDetails, '\<xxx\>\s\+\(.*\)')
let ExistingHighlight = MatchGroups[1]
return ExistingHighlight
endfunction

View File

@ -0,0 +1,525 @@
" 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 org#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! org#tbl#next_col(last)
return s:kbd_goto_next_col(a:last)
endfunction
function! s:kbd_goto_next_col(last) "{{{
if a:last
let seps = s:count_separators_down(line('.'))
if mode() == 'n'
let cmd = seps . "j0:call search('|', 'c', line('.'))\<CR>l"
else
let cmd = "\<ESC>".seps."j0:call search('|', 'c', line('.'))\<CR>la"
endif
else
if mode() == 'n'
let cmd = ":call search('|', 'c', line('.'))\<CR>l"
else
let cmd = "\<ESC>:call search('|', 'c', line('.'))\<CR>la"
endif
endif
return cmd
endfunction "}}}
function! org#tbl#prev_col(first)
return s:kbd_goto_prev_col(a:first)
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! org#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! org#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! org#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! org#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! org#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! org#tbl#align_or_cmd(cmd) "{{{
if s:is_table(getline('.'))
call org#tbl#format(line('.'))
else
exe 'normal! '.a:cmd
endif
endfunction "}}}
function! org#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! org#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 org#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! org#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 org#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! org#tbl#get_rows(lnum) "{{{
return s:get_rows(a:lnum)
endfunction "}}}
"}}}