Add vimorganizer
git-svn-id: http://photonzero.com/dotfiles/trunk@119 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
e85ab4a082
commit
523fde6acd
17 changed files with 12634 additions and 0 deletions
172
.vim/bundle/VimOrganizer/autoload/calutil.vim
Normal file
172
.vim/bundle/VimOrganizer/autoload/calutil.vim
Normal 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
|
||||
|
||||
217
.vim/bundle/VimOrganizer/autoload/org.vim
Normal file
217
.vim/bundle/VimOrganizer/autoload/org.vim
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
" 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#redir(command)
|
||||
let save_a = @a
|
||||
try
|
||||
silent! redir @a
|
||||
silent! exe a:command
|
||||
redir END
|
||||
finally
|
||||
"let res = split(@a,"\n")
|
||||
let res = @a
|
||||
|
||||
" restore register
|
||||
let @a = save_a
|
||||
return res
|
||||
endtry
|
||||
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
|
||||
try
|
||||
exe "silent hi " . a:group
|
||||
catch
|
||||
" skip error message if no such group exists
|
||||
endtry
|
||||
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
|
||||
|
||||
if GroupDetails ># ''
|
||||
" Extract the highlighting details (the bit after "xxx")
|
||||
let MatchGroups = matchlist(GroupDetails, '\<xxx\>\s\+\(.*\)')
|
||||
let ExistingHighlight = MatchGroups[1] !~? 'cleared' ? MatchGroups[1] : ''
|
||||
else
|
||||
" Group does not exist
|
||||
let ExistingHighlight = ''
|
||||
endif
|
||||
|
||||
return ExistingHighlight
|
||||
|
||||
endfunction
|
||||
|
||||
function! org#ISODateToYWD(date)
|
||||
"returns y,w,d which are iso week spec for date
|
||||
let date = a:date
|
||||
"let d = 1 + ((calutil#dow(date) + 4) % 7)
|
||||
let d = 1 + calutil#dow(date)
|
||||
let jul_nThur = calutil#jul(date) + 4 - d
|
||||
let y = calutil#cal(jul_nThur)[0:3]
|
||||
let julJan1 = calutil#jul(date[0:3] . '-01-01')
|
||||
let w = 1 + ((jul_nThur - julJan1) / 7)
|
||||
return [y,w,d]
|
||||
endfunction
|
||||
|
||||
function! org#LocateFile(filename)
|
||||
let filename = a:filename
|
||||
|
||||
if bufwinnr(filename) >= 0
|
||||
silent execute bufwinnr(filename)."wincmd w"
|
||||
else
|
||||
if org#redir('tabs') =~ fnamemodify(filename, ':t')
|
||||
" proceed on assumption that file is open
|
||||
" if match found in tablist
|
||||
let this_tab = tabpagenr()
|
||||
let last_tab = tabpagenr('$')
|
||||
for i in range(1 , last_tab)
|
||||
exec i . 'tabn'
|
||||
if bufwinnr(filename) >= 0
|
||||
silent execute bufwinnr(filename)."wincmd w"
|
||||
break
|
||||
" if file not found then use tab drop to open new file
|
||||
elseif i == last_tab
|
||||
execute 'tab drop ' . filename
|
||||
if (&ft != 'org') && (filename != '__Agenda__')
|
||||
call org#SetOrgFileType()
|
||||
endif
|
||||
endif
|
||||
tabn
|
||||
endfor
|
||||
else
|
||||
exe 'tabn ' . tabpagenr('$')
|
||||
execute 'tab drop ' . filename
|
||||
if (&ft != 'org') && (filename != '__Agenda__')
|
||||
call org#SetOrgFileType()
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if (&fdm != 'expr') && !exists('g:in_agenda_search')
|
||||
set fdm=expr
|
||||
set foldlevel=1
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! org#SaveLocation()
|
||||
let file_loc = bufname('%') ==? '__Agenda__' ? '__Agenda__' : expand('%:p')
|
||||
let g:location = [ file_loc , getpos('.') ]
|
||||
endfunction
|
||||
function! org#RestoreLocation()
|
||||
if expand('%:p') != g:location[0]
|
||||
call org#LocateFile( g:location[0] )
|
||||
endif
|
||||
call setpos( '.', g:location[1] )
|
||||
endfunction
|
||||
|
||||
|
||||
function! org#OpenCaptureFile()
|
||||
call org#LocateFile(g:org_capture_file)
|
||||
endfunction
|
||||
|
||||
function! org#CaptureBuffer()
|
||||
if !exists('g:org_capture_file') || empty(g:org_capture_file)
|
||||
echo 'Capture is not set up. Please read docs at :h vimorg-capture.'
|
||||
return
|
||||
endif
|
||||
if bufnr('_Org_Capture_') > 0
|
||||
exec 'bwipeout! ' . bufnr('_Org_Capture_')
|
||||
endif
|
||||
sp _Org_Capture_
|
||||
autocmd BufWriteCmd <buffer> :call <SID>ProcessCapture()
|
||||
"autocmd BufLeave <buffer> :bwipeout
|
||||
autocmd BufUnload <buffer> :set nomodified
|
||||
set nobuflisted
|
||||
set ft=org
|
||||
setlocal buftype=acwrite
|
||||
setlocal noswapfile
|
||||
command! -buffer W :call <SID>ProcessCapture()
|
||||
" below is the basic template
|
||||
" a first level head with date timestamp
|
||||
normal ggVGd
|
||||
normal i*
|
||||
silent exec "normal o:<".org#Timestamp().">"
|
||||
normal gg
|
||||
set nomodified
|
||||
startinsert!
|
||||
|
||||
endfunction
|
||||
function! s:ProcessCapture()
|
||||
"normal ggVG"xy
|
||||
let curbufnr = bufnr(g:org_capture_file)
|
||||
" check if capture file is already open or not
|
||||
if curbufnr == -1
|
||||
exe '1,$write >> ' . g:org_capture_file
|
||||
bw! _Org_Capture_
|
||||
else
|
||||
normal ggVG"xy
|
||||
bw! _Org_Capture_
|
||||
call org#SaveLocation()
|
||||
call org#LocateFile(g:org_capture_file)
|
||||
normal G"xp
|
||||
silent write
|
||||
call org#RestoreLocation()
|
||||
endif
|
||||
exe 'bwipeout! ' . g:org_capture_file
|
||||
|
||||
endfunction
|
||||
|
||||
525
.vim/bundle/VimOrganizer/autoload/org/tbl.vim
Normal file
525
.vim/bundle/VimOrganizer/autoload/org/tbl.vim
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue