calendar.vim 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. "=============================================================================
  2. " What Is This: Calendar
  3. " File: calendar.vim
  4. " Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
  5. " Last Change: 2013 Okt 27
  6. " Version: 2.9
  7. " Thanks:
  8. " Tobias Columbus : customizable key bindings
  9. " Daniel P. Wright : doc/calendar.txt
  10. " SethMilliken : gave a hint for 2.4
  11. " bw1 : bug fix, new weeknm format
  12. " Ingo Karkat : bug fix
  13. " Thinca : bug report, bug fix
  14. " Yu Pei : bug report
  15. " Per Winkvist : bug fix
  16. " Serge (gentoosiast) Koksharov : bug fix
  17. " Vitor Antunes : bug fix
  18. " Olivier Mengue : bug fix
  19. " Noel Henson : today action
  20. " Per Winkvist : bug report
  21. " Peter Findeisen : bug fix
  22. " Chip Campbell : gave a hint for 1.3z
  23. " PAN Shizhu : gave a hint for 1.3y
  24. " Eric Wald : bug fix
  25. " Sascha Wuestemann : advise
  26. " Linas Vasiliauskas : bug report
  27. " Per Winkvist : bug report
  28. " Ronald Hoelwarth : gave a hint for 1.3s
  29. " Vikas Agnihotri : bug report
  30. " Steve Hall : gave a hint for 1.3q
  31. " James Devenish : bug fix
  32. " Carl Mueller : gave a hint for 1.3o
  33. " Klaus Fabritius : bug fix
  34. " Stucki : gave a hint for 1.3m
  35. " Rosta : bug report
  36. " Richard Bair : bug report
  37. " Yin Hao Liew : bug report
  38. " Bill McCarthy : bug fix and gave a hint
  39. " Srinath Avadhanula : bug fix
  40. " Ronald Hoellwarth : few advices
  41. " Juan Orlandini : added higlighting of days with data
  42. " Ray : bug fix
  43. " Ralf.Schandl : gave a hint for 1.3
  44. " Bhaskar Karambelkar : bug fix
  45. " Suresh Govindachar : gave a hint for 1.2, bug fix
  46. " Michael Geddes : bug fix
  47. " Leif Wickland : bug fix
  48. " ChangeLog:
  49. " 2.8 : bug fix
  50. " 2.7 : vim7ish, customizable key bindings
  51. " 2.6 : new week number format
  52. " 2.5 : bug fix, 7.2 don't have relativenumber.
  53. " 2.4 : added g:calendar_options.
  54. " 2.3 : week number like ISO8601
  55. " g:calendar_monday and g:calendar_weeknm work together
  56. " 2.2 : http://gist.github.com/355513#file_customizable_keymap.diff
  57. " http://gist.github.com/355513#file_winfixwidth.diff
  58. " 2.1 : bug fix, set filetype 'calendar'.
  59. " 2.0 : bug fix, many bug fix and enhancements.
  60. " 1.9 : bug fix, use nnoremap.
  61. " 1.8 : bug fix, E382 when close diary.
  62. " 1.7 : bug fix, week number was broken on 2008.
  63. " 1.6 : added calendar_begin action.
  64. " added calendar_end action.
  65. " 1.5 : bug fix, fixed ruler formating with strpart.
  66. " bug fix, using winfixheight.
  67. " 1.4a : bug fix, week number was broken on 2005.
  68. " added calendar_today action.
  69. " bug fix, about wrapscan.
  70. " bug fix, about today mark.
  71. " bug fix, about today navigation.
  72. " 1.4 : bug fix, and one improvement.
  73. " bug 1:
  74. " when marking the current date, there is not distinguished e.g. between
  75. " 20041103 and 20040113, both dates are marked as today
  76. " bug 2:
  77. " the navigation mark "today" doesn't work
  78. " improvement:
  79. " the mapping t worked only when today was displayed, now it works always
  80. " and redisplays the cuurent month and today
  81. " 1.3z : few changes
  82. " asign <Left>, <Right> for navigation.
  83. " set ws for search navigation.
  84. " add tag for GetLatestVimScripts(AutoInstall)
  85. " 1.3y : bug fix, few changes
  86. " changed color syntax name. (ex. CalNavi, see bottom of this)
  87. " changed a map CalendarV for <Leader>cal
  88. " changed a map CalendarH for <Leader>caL
  89. " (competitive map for cvscommand.vim)
  90. " the date on the right-hand side didn't work correctoly.
  91. " make a map to rebuild Calendar window(r).
  92. " 1.3x : bug fix
  93. " viweek can't refer when not set calendar_weeknm.
  94. " 1.3w : bug fix
  95. " on leap year, week number decreases.
  96. " 1.3v : bug fix
  97. " add nowrapscan
  98. " use s:bufautocommandsset for making title
  99. " don't focus to navi when doubleclick bottom next>.
  100. " 1.3u : bug fix
  101. " when enter diary first time,
  102. " it don't warn that you don't have diary directory.
  103. " 1.3t : bug fix
  104. " make sure the variables for help
  105. " 1.3s : bug fix
  106. " make a map CalendarV for <Leader>ca
  107. " add option calendar_navi_label
  108. " see Additional:
  109. " add option calendar_focus_today
  110. " see Additional:
  111. " add map ? for help
  112. " 1.3r : bug fix
  113. " if clicked navigator, cursor go to strange position.
  114. " 1.3q : bug fix
  115. " coundn't set calendar_navi
  116. " in its horizontal direction
  117. " 1.3p : bug fix
  118. " coundn't edit diary when the calendar is
  119. " in its horizontal direction
  120. " 1.3o : add option calendar_mark, and delete calendar_rmark
  121. " see Additional:
  122. " add option calendar_navi
  123. " see Additional:
  124. " 1.3n : bug fix
  125. " s:CalendarSign() should use filereadable(expand(sfile)).
  126. " 1.3m : tuning
  127. " using topleft or botright for opening Calendar.
  128. " use filereadable for s:CalendarSign().
  129. " 1.3l : bug fix
  130. " if set calendar_monday, it can see that Sep 1st is Sat
  131. " as well as Aug 31st.
  132. " 1.3k : bug fix
  133. " it didn't escape the file name on calendar.
  134. " 1.3j : support for fixed Gregorian
  135. " added the part of Sep 1752.
  136. " 1.3i : bug fix
  137. " Calculation mistake for week number.
  138. " 1.3h : add option for position of displaying '*' or '+'.
  139. " see Additional:
  140. " 1.3g : centering header
  141. " add option for show name of era.
  142. " see Additional:
  143. " bug fix
  144. " <Leader>ca didn't show current month.
  145. " 1.3f : bug fix
  146. " there was yet another bug of today's sign.
  147. " 1.3e : added usage for <Leader>
  148. " support handler for sign.
  149. " see Additional:
  150. " 1.3d : added higlighting of days that have calendar data associated
  151. " with it.
  152. " bug fix for calculates date.
  153. " 1.3c : bug fix for MakeDir()
  154. " if CalendarMakeDir(sfile) != 0
  155. " v
  156. " if s:CalendarMakeDir(sfile) != 0
  157. " 1.3b : bug fix for calendar_monday.
  158. " it didn't work g:calendar_monday correctly.
  159. " add g:calendar_version.
  160. " add argument on action handler.
  161. " see Additional:
  162. " 1.3a : bug fix for MakeDir().
  163. " it was not able to make directory.
  164. " 1.3 : support handler for action.
  165. " see Additional:
  166. " 1.2g : bug fix for today's sign.
  167. " it could not display today's sign correctly.
  168. " 1.2f : bug fix for current Date.
  169. " vtoday variable calculates date as 'YYYYMMDD'
  170. " while the loop calculates date as 'YYYYMMD' i.e just 1 digit
  171. " for date if < 10 so if current date is < 10 , the if condiction
  172. " to check for current date fails and current date is not
  173. " highlighted.
  174. " simple solution changed vtoday calculation line divide the
  175. " current-date by 1 so as to get 1 digit date.
  176. " 1.2e : change the way for setting title.
  177. " auto configuration for g:calendar_wruler with g:calendar_monday
  178. " 1.2d : add option for show week number.
  179. " let g:calendar_weeknm = 1
  180. " add separator if horizontal.
  181. " change all option's name
  182. " g:calendar_mnth -> g:calendar_mruler
  183. " g:calendar_week -> g:calendar_wruler
  184. " g:calendar_smnd -> g:calendar_monday
  185. " 1.2c : add option for that the week starts with monday.
  186. " let g:calendar_smnd = 1
  187. " 1.2b : bug fix for modifiable.
  188. " setlocal nomodifiable (was set)
  189. " 1.2a : add default options.
  190. " nonumber,foldcolumn=0,nowrap... as making gap
  191. " 1.2 : support wide display.
  192. " add a command CalendarH
  193. " add map <s-left> <s-right>
  194. " 1.1c : extra.
  195. " add a titlestring for today.
  196. " 1.1b : bug fix by Michael Geddes.
  197. " it happend when do ':Calender' twice
  198. " 1.1a : fix misspell.
  199. " Calender -> Calendar
  200. " 1.1 : bug fix.
  201. " it"s about strftime("%m")
  202. " 1.0a : bug fix by Leif Wickland.
  203. " it"s about strftime("%w")
  204. " 1.0 : first release.
  205. " TODO:
  206. " add the option for diary which is separate or single file.
  207. " GetLatestVimScripts: 52 1 :AutoInstall: calendar.vim
  208. if &compatible
  209. finish
  210. endif
  211. "*****************************************************************
  212. "* Calendar commands
  213. "*****************************************************************
  214. command! -nargs=* Calendar call calendar#show(0,<f-args>)
  215. command! -nargs=* CalendarVR call calendar#show(3,<f-args>)
  216. command! -nargs=* CalendarH call calendar#show(1,<f-args>)
  217. command! -nargs=* CalendarT call calendar#show(2,<f-args>)
  218. command! -nargs=* CalendarSearch call calendar#search("<args>")
  219. if !get(g:, 'calendar_no_mappings', 0)
  220. if !hasmapto('<Plug>CalendarV')
  221. nmap <unique> <Leader>cal <Plug>CalendarV
  222. endif
  223. if !hasmapto('<Plug>CalendarH')
  224. nmap <unique> <Leader>caL <Plug>CalendarH
  225. endif
  226. endif
  227. nnoremap <silent> <Plug>CalendarV :cal calendar#show(0)<CR>
  228. nnoremap <silent> <Plug>CalendarH :cal calendar#show(1)<CR>
  229. nnoremap <silent> <Plug>CalendarT :cal calendar#show(2)<CR>
  230. " vi: et sw=2 ts=2