" calendar.vim と howm.vim を連携するための設定 scriptencoding utf-8 if v:version < 700 || &compatible finish endif let g:calendar_action = 'CalendarActionHowm' function! CalendarActionHowm(day, month, year, week, dir) let commands = [ \ ':HowmSchedule', \ ':Calendar', \ ':CalendarH', \ ':NoMatchParen', \ ':DoMatchParen' \ ] for cmd in commands if exists(cmd) != 2 echohl WarningMsg echo cmd . 'がないと calendar_action.vim は動きません' echohl None return endif endfor let g:calendar_focus = {'year': a:year, 'month': a:month, 'day': a:day} let query = g:howm_date_pattern let query = substitute(query, '%Y', printf('%04d', a:year), 'g') let query = substitute(query, '%m', printf('%02d', a:month), 'g') let query = substitute(query, '%d', printf('%02d', a:day), 'g') let bufname = 'howm\ Search\ result' let winnr = bufwinnr(bufname) if winnr == -1 " echo query only | enew let save_ignore_done = g:howm_ignore_done let g:howm_ignore_done = 0 execute ':HowmSchedule ' query let g:howm_ignore_done = save_ignore_done else :NoMatchParen let bufnr = bufnr(bufname) execute winnr . 'wincmd w' let today_i = HowmDate2Int(query, g:howm_date_pattern) let lnum = -1 let i = 1 let n = getbufvar(bufnr, 'searchResultNum') while i <= n let content = getbufvar(bufnr, 'content' . i) if content =~ '^\[' . query . '\][@!.]\d*' let lnum = i break endif let date_pat = '^\[\(\d\{4}-\d\{2}-\d\{2}\)\][@!.]\d*.*$' if content =~ date_pat let date = substitute(content, date_pat, '\1', '') if today_i < HowmDate2Int(date, g:howm_date_pattern) let lnum = i break endif endif let i += 1 endwhile if lnum != -1 " ハイライト syntax clear setlocal ft=howm_importantdate let today_pat = (today_i - 719527) * 86400 let tomorrow_pat = (today_i + 1 - 719527) * 86400 let today_pat = strftime(g:howm_date_pattern, today_pat) let tomorrow_pat = strftime(g:howm_date_pattern, tomorrow_pat) let today_pat = '\%(\[' . today_pat . '\][-!@+.]\d*\)\@<=.*$' let tomorrow_pat = '\%(\[' . tomorrow_pat . '\][-!@+.]\d*\)\@<=.*$' execute 'syntax match howmToday display "' . today_pat . '"' execute 'syntax match howmTomorrow display "' . tomorrow_pat . '"' " カーソル移動 call cursor(lnum, 1) normal zz redraw endif :DoMatchParen endif let cmd = ':Calendar' if a:dir != 'V' | let cmd .= 'H' | endif execute cmd a:year a:month call cursor(1, 1) let [lnum, col] = searchpos('+', 'n') if ((lnum != 0) && (col != 0)) call cursor(lnum, col) else let [lnum, col] = searchpos('*', 'n') if ((lnum != 0) && (col != 0)) call cursor(lnum, col) endif endif endfunction let g:calendar_sign = 'CalendarSignHowm' function! CalendarSignHowm(day,month,year) if !exists('g:calendar_focus') | return 0 | endif if a:year == g:calendar_focus['year'] && \ a:month == g:calendar_focus['month'] && \ a:day == g:calendar_focus['day'] return 1 else return 0 endif endfunction " vim: set et ts=2 sw=2 fdm=marker: