|
@ -40,7 +40,7 @@ endfunction |
|
|
|
|
|
|
|
|
" }}} |
|
|
" }}} |
|
|
function! notecrate#apply_template(title) " {{{ |
|
|
function! notecrate#apply_template(title) " {{{ |
|
|
let l:template = "# " . a:title . "\n\n\n---\n\n" |
|
|
let l:template = "\n# " . a:title . "\n\n\n\n\n---\n\n" |
|
|
call setreg("l", l:template) |
|
|
call setreg("l", l:template) |
|
|
silent execute 'normal "lP4j' |
|
|
silent execute 'normal "lP4j' |
|
|
call notecrate#update_backlinks() |
|
|
call notecrate#update_backlinks() |
|
@ -76,6 +76,8 @@ endfunction |
|
|
" }}} |
|
|
" }}} |
|
|
function! notecrate#new_note(title, filename) " {{{ |
|
|
function! notecrate#new_note(title, filename) " {{{ |
|
|
let l:filename = expand('%:t') |
|
|
let l:filename = expand('%:t') |
|
|
|
|
|
let l:notecrate_dir = b:notecrate_dir |
|
|
|
|
|
let l:notecrate_history = b:notecrate_history |
|
|
while !isdirectory(expand(b:notecrate_dir)) |
|
|
while !isdirectory(expand(b:notecrate_dir)) |
|
|
let choice = confirm('', b:notecrate_dir . " does not exist. Create? &Yes\n&No\n") |
|
|
let choice = confirm('', b:notecrate_dir . " does not exist. Create? &Yes\n&No\n") |
|
|
if choice == 1 |
|
|
if choice == 1 |
|
@ -87,8 +89,11 @@ function! notecrate#new_note(title, filename) " {{{ |
|
|
let l:path = b:notecrate_dir . "/" . a:filename |
|
|
let l:path = b:notecrate_dir . "/" . a:filename |
|
|
call add(b:notecrate_history, l:filename) |
|
|
call add(b:notecrate_history, l:filename) |
|
|
silent execute "normal! :w\<CR>:e " . l:path . "\<CR>" |
|
|
silent execute "normal! :w\<CR>:e " . l:path . "\<CR>" |
|
|
|
|
|
let b:notecrate_dir = l:notecrate_dir |
|
|
|
|
|
let b:notecrate_history = l:notecrate_history |
|
|
call notecrate#apply_template(a:title) |
|
|
call notecrate#apply_template(a:title) |
|
|
call notecrate#update_backlinks() |
|
|
call notecrate#update_backlinks() |
|
|
|
|
|
write |
|
|
endfunction |
|
|
endfunction |
|
|
|
|
|
|
|
|
" }}} |
|
|
" }}} |
|
@ -218,6 +223,7 @@ endfunction |
|
|
|
|
|
|
|
|
" }}} |
|
|
" }}} |
|
|
function! notecrate#grep(pattern) " {{{ |
|
|
function! notecrate#grep(pattern) " {{{ |
|
|
|
|
|
echom b:notecrate_dir |
|
|
let l:files = [] |
|
|
let l:files = [] |
|
|
try |
|
|
try |
|
|
silent execute 'vimgrep /' . a:pattern . '/j ' . b:notecrate_dir . '/*.md' |
|
|
silent execute 'vimgrep /' . a:pattern . '/j ' . b:notecrate_dir . '/*.md' |
|
@ -260,6 +266,7 @@ function! notecrate#update_backlinks() " {{{ |
|
|
endif |
|
|
endif |
|
|
call setreg("l", l:backlinks) |
|
|
call setreg("l", l:backlinks) |
|
|
silent execute "normal! /^---\<CR>vG$\"lp" |
|
|
silent execute "normal! /^---\<CR>vG$\"lp" |
|
|
|
|
|
silent execute "normal! gg/^# \<CR>jj" |
|
|
endfunction |
|
|
endfunction |
|
|
|
|
|
|
|
|
" }}} |
|
|
" }}} |
|
|