Browse Source

lazygit 2022-03-22 16:30

master
Gregory Leeman 3 years ago
parent
commit
896f4a8a7b
  1. 9
      autoload/notecrate.vim
  2. 24
      ftplugin/notecrate.vim
  3. 4
      syntax/notecrate.vim

9
autoload/notecrate.vim

@ -109,15 +109,21 @@ endfunction
" }}} " }}}
function! notecrate#open_note(filename) " {{{ function! notecrate#open_note(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
let l:path = b:notecrate_dir . "/" . a:filename let l:path = b:notecrate_dir . "/" . a:filename
let l:reg = getreg('')
if !filereadable(expand(l:path)) if !filereadable(expand(l:path))
echo "Note does't exist!" echo "Note does't exist!"
return return
endif endif
call add(b:notecrate_history, l:filename) call add(b:notecrate_history, l:filename)
silent execute "e " . l:path silent execute "e " . l:path
let b:notecrate_dir = l:notecrate_dir
let b:notecrate_history = l:notecrate_history
call notecrate#update_backlinks() call notecrate#update_backlinks()
silent execute "normal! /^#\<CR>" silent execute "normal! /^#\<CR>"
call setreg('', l:reg)
endfunction endfunction
" }}} " }}}
@ -252,11 +258,8 @@ function! notecrate#update_backlinks() " {{{
else else
let l:backlinks = l:backlinks . join(uniq(l:links), "\n") . "\n\n* [Index](index.md)" let l:backlinks = l:backlinks . join(uniq(l:links), "\n") . "\n\n* [Index](index.md)"
endif endif
let l:oldreg = getreg("0")
call setreg("l", l:backlinks) call setreg("l", l:backlinks)
silent execute "normal! /^---\<CR>vG$\"lp" silent execute "normal! /^---\<CR>vG$\"lp"
call setreg("0", l:oldreg)
call setreg("", l:oldreg)
endfunction endfunction
" }}} " }}}

24
ftplugin/notecrate.vim

@ -4,13 +4,13 @@ setlocal comments+=b:*
setlocal foldlevel=3 setlocal foldlevel=3
setlocal formatoptions=cro setlocal formatoptions=cro
command! SearchOpen :call notecrate#base#search_open() command! SearchOpen :call notecrate#search_open()
command! SearchInsertLink :call notecrate#base#search_insert_link() command! SearchInsertLink :call notecrate#search_insert_link()
command! UpdateBacklinks :call notecrate#base#update_backlinks() command! UpdateBacklinks :call notecrate#update_backlinks()
command! NewNote :call notecrate#base#new_note_from_prompt() command! NewNote :call notecrate#new_note_from_prompt()
command! DeleteNote :call notecrate#base#delete_note() command! DeleteNote :call notecrate#delete_note()
command! Convert :call notecrate#base#convert() command! Convert :call notecrate#convert()
command! Save :call notecrate#base#save() command! Save :call notecrate#save()
" inoremap <buffer> <Esc> <Esc>mmgqis`m " inoremap <buffer> <Esc> <Esc>mmgqis`m
nnoremap <buffer> <leader>c :Convert<CR> nnoremap <buffer> <leader>c :Convert<CR>
@ -19,16 +19,16 @@ nnoremap <buffer> <leader>i :SearchInsertLink<CR>
nnoremap <buffer> <leader>b :UpdateBacklinks<CR> nnoremap <buffer> <leader>b :UpdateBacklinks<CR>
nnoremap <buffer> <leader>n :NewNote<CR> nnoremap <buffer> <leader>n :NewNote<CR>
nnoremap <buffer> <leader>d :DeleteNote<CR> nnoremap <buffer> <leader>d :DeleteNote<CR>
nnoremap <buffer> <leader>s :Convert<CR>:Save<CR> nnoremap <buffer> <leader>s :Save<CR>
nnoremap <buffer> <CR> :call notecrate#base#follow_link()<CR> nnoremap <buffer> <CR> :call notecrate#follow_link()<CR>
vnoremap <buffer> <CR> :call notecrate#base#new_note_from_selection()<CR> vnoremap <buffer> <CR> :call notecrate#new_note_from_selection()<CR>
nnoremap <buffer> <backspace> :call notecrate#base#open_previous()<CR> nnoremap <buffer> <backspace> :call notecrate#open_previous()<CR>
nnoremap <buffer> <S-j> /\[[^\]]*\]([^)]*)<CR>:noh<CR> nnoremap <buffer> <S-j> /\[[^\]]*\]([^)]*)<CR>:noh<CR>
nnoremap <buffer> <S-l> /\[[^\]]*\]([^)]*)<CR>:noh<CR> nnoremap <buffer> <S-l> /\[[^\]]*\]([^)]*)<CR>:noh<CR>
nnoremap <buffer> <Tab> /\[[^\]]*\]([^)]*)<CR>:noh<CR> nnoremap <buffer> <Tab> /\[[^\]]*\]([^)]*)<CR>:noh<CR>
nnoremap <buffer> <S-Tab> /\[[^\]]*\]([^)]*)<CR>NN:noh<CR> nnoremap <buffer> <S-Tab> /\[[^\]]*\]([^)]*)<CR>NN:noh<CR>
nnoremap <buffer> <S-h> /\[[^\]]*\]([^)]*)<CR>NN:noh<CR> nnoremap <buffer> <S-h> /\[[^\]]*\]([^)]*)<CR>NN:noh<CR>
nnoremap <buffer> <S-k> /\[[^\]]*\]([^)]*)<CR>NN:noh<CR> nnoremap <buffer> <S-k> /\[[^\]]*\]([^)]*)<CR>NN:noh<CR>
vnoremap <buffer> <leader>i :call notecrate#base#search_insert_link_selection()<CR> vnoremap <buffer> <leader>i :call notecrate#search_insert_link_selection()<CR>
inoremap <buffer> <Tab> <C-t> inoremap <buffer> <Tab> <C-t>
inoremap <buffer> <S-Tab> <C-d> inoremap <buffer> <S-Tab> <C-d>

4
syntax/notecrate.vim

@ -1,6 +1,6 @@
setlocal foldmethod=expr setlocal foldmethod=expr
setlocal foldexpr=notecrate#base#nested_markdown_folds(v:lnum) setlocal foldexpr=notecrate#nested_markdown_folds(v:lnum)
setlocal foldtext=notecrate#base#fold_text() setlocal foldtext=notecrate#fold_text()
setlocal conceallevel=2 setlocal conceallevel=2
set comments=b:* set comments=b:*
setlocal nowrap setlocal nowrap