dotfiles

personal configuration files and scripts
git clone https://tongong.net/git/dotfiles.git
Log | Files | Refs | README

notes.vim (771B)


      1 function OpenNotesDir()
      2     exe "e " . g:notes_dir . "/refile.md"
      3 endfunction
      4 
      5 function NewNote()
      6     call OpenNotesDir()
      7     call feedkeys("Go- ")
      8 endfunction
      9 
     10 function NewAnnotation()
     11     let location = expand("%:p") . ":" . line(".")
     12     call OpenNotesDir()
     13     call feedkeys("Go-  [" . location . "]\<esc>0la")
     14 endfunction
     15 
     16 nmap gN :call OpenNotesDir()<CR>
     17 nmap gM :call NewNote()<CR>
     18 nmap gA :call NewAnnotation()<CR>
     19 
     20 
     21 function InitNotesFile()
     22     " echomsg "loaded notes buffer"
     23     " it is super annoying that you cant set the cwd per buffer
     24     " and this is a really bad fix
     25     exe "nnoremap <buffer> <leader>f :Files " . g:notes_dir . "<CR>"
     26 endfunction
     27 
     28 augroup notes
     29     autocmd!
     30     exe "au BufEnter " . g:notes_dir . "/* call InitNotesFile()"
     31 augroup END