Browse Source

Adds gzc to create new zettel without link insert

Modifies edit_zettel_new to accept an optional argument that determines
if the newly created zettel id should have a link inserted into the
current buffer.

Fixes #5
virtual-titles
Noah Pederson 1 week ago
parent
commit
c643f25347
2 changed files with 11 additions and 4 deletions
  1. +9
    -4
      autoload/neuron.vim
  2. +2
    -0
      plugin/neuron.vim

+ 9
- 4
autoload/neuron.vim View File

@ -179,20 +179,25 @@ func! neuron#insert_zettel_last(as_folgezettel)
call util#insert(l:zettelid, a:as_folgezettel)
endf
func! neuron#edit_zettel_new(title)
" variable args, the first "variable" arg is a int, either 0 or 1 to determine
" if the new zettel should have a link inserted into the current buffer
func! neuron#edit_zettel_new(title, ...)
if bufname('%') != ''
w
endif
let l:zettel_path = util#new_zettel_path(a:title)
let l:zettel_id = util#zettel_id_from_path(l:zettel_path)
execute "normal! i[[".l:zettel_id."]]#"
call neuron#add_virtual_titles()
let l:insert_new_zettel_link = get(a:, 1, 1)
if l:insert_new_zettel_link == 1
execute "normal! i[[".l:zettel_id."]]#"
call neuron#add_virtual_titles()
endif
exec 'edit '.l:zettel_path
call util#add_empty_zettel_body(a:title)
let g:_neuron_must_refresh_on_write = 1
endf
func! neuron#edit_zettel_new_from_cword()
func! neuron#dit_zettel_new_from_cword()
let l:title = expand("<cword>")
call neuron#edit_zettel_new(l:title)
endf


+ 2
- 0
plugin/neuron.vim View File

@ -48,9 +48,11 @@ nm <silent> <Plug>ToggleBacklinks :<C-U>call neuron#toggle_backlinks()<cr>
nm <silent> <Plug>TagsAddNew :<C-U>call neuron#tags_add_new()<cr>
nm <silent> <Plug>TagsAddSelect :<C-U>call neuron#tags_add_select()<cr>
nm <silent> <Plug>TagsZettelSearch :<C-U>call neuron#tags_search()<cr>
nm <silent> <Plug>NewZettel :<C-U>call neuron#edit_zettel_new('', 0)<cr>
if !exists("g:neuron_no_mappings") || ! g:neuron_no_mappings
nm gzn <Plug>EditZettelNew
nm gzc <Plug>NewZettel
nm gzN <Plug>EditZettelNewFromCword
vm gzN <esc><Plug>EditZettelNewFromVisual
nm gzr <Plug>NeuronRefreshCache


Loading…
Cancel
Save