itchyny / calendar.vim

A calendar application for Vim
MIT License
1.95k stars 71 forks source link

Calendar Questions #193

Closed rickalex21 closed 1 year ago

rickalex21 commented 3 years ago

Hello, thanks for creating this plugin. It's awesome! How long did it take to create? I have a few questions about it.

  1. User mappings are overridden by default? I have two functions that allow me to resize my windows with repeat.vim. Calendar.vim uses these keys as well as many other keys that I need. So do I have to do this autocommand for all my mappings that are used by calendar.vim ?
function! MoveRight(mycount) abort
    let defaultRepeat=15 
    let size=  a:mycount == 0 ? 1 : a:mycount
    execute "vert resize +"  . size
        call repeat#set("\<Plug>(MoveRight)",size == 1 ? defaultRepeat:size)
endfunction
function! MoveLeft(mycount) abort
    let defaultRepeat=15 
    let size=  a:mycount == 0 ? 1 : a:mycount
    execute "vert resize -"  . size
        call repeat#set("\<Plug>(MoveLeft)",size == 1 ? defaultRepeat:size)
endfunction

nnoremap <silent> <Plug>(MoveRight) :<C-u>call MoveRight(v:count)<CR>
nmap <c-l> <Plug>(MoveRight)
nnoremap <silent> <Plug>(MoveLeft) :<C-u>call MoveLeft(v:count)<CR>
nmap <c-h> <Plug>(MoveLeft)

augroup calendar-mappings
        autocmd!
        autocmd FileType calendar nunmap <buffer> <c-l>
        autocmd FileType calendar nunmap <buffer> <c-h>
        "This is needed to enter the command line q:
        autocmd FileType calendar nunmap <buffer> q
        autocmd FileType calendar nunmap <buffer> <c-g>
        autocmd FileType calendar noremap <buffer> q q
        autocmd FileType calendar nmap <buffer> <c-k> <Plug>(calendar_view_left)
        autocmd FileType calendar nmap <buffer> <c-j> <Plug>(calendar_view_right)
        autocmd FileType calendar nmap <buffer> J <Plug>(calendar_down_large)
        autocmd FileType calendar nmap <buffer> K <Plug>(calendar_up_large)
        nnoremap <c-G> :tabn<cr>
augroup END

Maybe a setting 'g:calendar_override_user_mappings=0'?

  1. Can I edit the ~/.cache/calendar.vim/ files or will that break something in the plugin? I presume my edits would have to be made before calling Calendar. My idea is to import ics events into these json files. It would look something like this:

    function! AddEvents() abort
    if  'saved_md5sum' !~ 'events_file_md5sum'
    "Events file was changed
    call system('Script to read/write events to json files in ~/.cache/calendar.vim.')
    endif
    execute "normal!  :Calendar -position=topleft  -width=100 \r"
    endfunction
    command! Cal call AddEvents()

    This would replace the call back function from script 52 'calendar_sign' Ideally an ics import feature as mentioned before would be nice in calendar.vim. This is pretty much irrelevant if I decide to stay with google calendar but would like to know for future reference.

  2. What is the difference between agenda and event? It looks like they both add an event when 'i' is entered. Here is my setup.

    let g:calendar_views =['year', 'month', 'week', 'day_3', 'day','event', 'agenda']
  3. How do I change the syntax for the current calendar buffer? I read the docs for ownsyntax, I could not figure it out. When attempting to change the background I end up changing all of my window buffers background.

  4. How do you create a task with a note? According to the docs I should add the 'note:' item to it but don't know if it's saving properly as a note because the json file looks different. It saves it as a title and without an entry for 'note' or 'notes'. I think that the notes section is only relevant for google calendar and not the local/.

    :Task:Some Task note:This is something that needs to get done.
    {"id":"202101301628360005","items":[{"id":"202101311716540004","title":"Some Task note:This is something that needs to get done."}],"title":"Task list"}

    According to the docs : Task with note: TASK: [task-title] note: [task-note]

Is there a way to view the note in a task or just enter 'i' and view it in the command line?

  1. Events - How come for the events on google I can't see the details but for the tasks I can? Tasks seem to work fine but I can't add an event with a note or read the notes in an event.

Thanks for everyone's contributions to this project.

itchyny commented 1 year ago

Sorry for keeping this unanswered for years, several questions at the same time demotivated me from answering. Let me close with a few comments.

  1. Yes, currently there's no way to disable the plugin mappings. If you could send me a patch, I can review that.
  2. You can modify the cache files at your own risk, but there's no guarantee that the file structure does not change in the future.
  3. The agenda view shows the upcoming events (including the events starting tomorrow), as requested by #88.
  4. You can overwrite the syntax with something like autocmd FileType calendar highlight CalendarToday ....
  5. Yes, the note: is implemented only for Google Task.
  6. Maybe you mean the description in calendar events? Unfortunately it's not supported in this plugin.