diff --git a/autoload/notecrate.vim b/autoload/notecrate.vim index 3d94035..f1b61ec 100644 --- a/autoload/notecrate.vim +++ b/autoload/notecrate.vim @@ -109,15 +109,21 @@ endfunction " }}} function! notecrate#open_note(filename) " {{{ let l:filename = expand('%:t') + let l:notecrate_dir = b:notecrate_dir + let l:notecrate_history = b:notecrate_history let l:path = b:notecrate_dir . "/" . a:filename + let l:reg = getreg('') if !filereadable(expand(l:path)) echo "Note does't exist!" return endif call add(b:notecrate_history, l:filename) silent execute "e " . l:path + let b:notecrate_dir = l:notecrate_dir + let b:notecrate_history = l:notecrate_history call notecrate#update_backlinks() silent execute "normal! /^#\" + call setreg('', l:reg) endfunction " }}} @@ -252,11 +258,8 @@ function! notecrate#update_backlinks() " {{{ else let l:backlinks = l:backlinks . join(uniq(l:links), "\n") . "\n\n* [Index](index.md)" endif - let l:oldreg = getreg("0") call setreg("l", l:backlinks) silent execute "normal! /^---\vG$\"lp" - call setreg("0", l:oldreg) - call setreg("", l:oldreg) endfunction " }}} diff --git a/ftplugin/notecrate.vim b/ftplugin/notecrate.vim index adf5227..4f758b1 100644 --- a/ftplugin/notecrate.vim +++ b/ftplugin/notecrate.vim @@ -4,13 +4,13 @@ setlocal comments+=b:* setlocal foldlevel=3 setlocal formatoptions=cro -command! SearchOpen :call notecrate#base#search_open() -command! SearchInsertLink :call notecrate#base#search_insert_link() -command! UpdateBacklinks :call notecrate#base#update_backlinks() -command! NewNote :call notecrate#base#new_note_from_prompt() -command! DeleteNote :call notecrate#base#delete_note() -command! Convert :call notecrate#base#convert() -command! Save :call notecrate#base#save() +command! SearchOpen :call notecrate#search_open() +command! SearchInsertLink :call notecrate#search_insert_link() +command! UpdateBacklinks :call notecrate#update_backlinks() +command! NewNote :call notecrate#new_note_from_prompt() +command! DeleteNote :call notecrate#delete_note() +command! Convert :call notecrate#convert() +command! Save :call notecrate#save() " inoremap mmgqis`m nnoremap c :Convert @@ -19,16 +19,16 @@ nnoremap i :SearchInsertLink nnoremap b :UpdateBacklinks nnoremap n :NewNote nnoremap d :DeleteNote -nnoremap s :Convert:Save -nnoremap :call notecrate#base#follow_link() -vnoremap :call notecrate#base#new_note_from_selection() -nnoremap :call notecrate#base#open_previous() +nnoremap s :Save +nnoremap :call notecrate#follow_link() +vnoremap :call notecrate#new_note_from_selection() +nnoremap :call notecrate#open_previous() nnoremap /\[[^\]]*\]([^)]*):noh nnoremap /\[[^\]]*\]([^)]*):noh nnoremap /\[[^\]]*\]([^)]*):noh nnoremap /\[[^\]]*\]([^)]*)NN:noh nnoremap /\[[^\]]*\]([^)]*)NN:noh nnoremap /\[[^\]]*\]([^)]*)NN:noh -vnoremap i :call notecrate#base#search_insert_link_selection() +vnoremap i :call notecrate#search_insert_link_selection() inoremap inoremap diff --git a/syntax/notecrate.vim b/syntax/notecrate.vim index b5b6bd7..7f8fb7c 100644 --- a/syntax/notecrate.vim +++ b/syntax/notecrate.vim @@ -1,6 +1,6 @@ setlocal foldmethod=expr -setlocal foldexpr=notecrate#base#nested_markdown_folds(v:lnum) -setlocal foldtext=notecrate#base#fold_text() +setlocal foldexpr=notecrate#nested_markdown_folds(v:lnum) +setlocal foldtext=notecrate#fold_text() setlocal conceallevel=2 set comments=b:* setlocal nowrap