feat: open non-note files using "open"

This commit is contained in:
2026-03-04 11:16:59 +01:00
parent 5df2b79938
commit e1c3ea09da
2 changed files with 13 additions and 1 deletions

View File

@@ -50,4 +50,16 @@ if b:context['denote'] == 'list'
xnoremap <buffer> + :DenoteTagAdd xnoremap <buffer> + :DenoteTagAdd
xnoremap <buffer> - :DenoteTagRm xnoremap <buffer> - :DenoteTagRm
xnoremap <buffer> d :DenoteDelete<CR> xnoremap <buffer> d :DenoteDelete<CR>
" Open non-notes using the 'open' command
function OpenDenoteEntry()
let l:item = getloclist(0, {'items': 1})['items'][line('.')-1]
let l:bufnr = l:item['bufnr']
let l:filename = bufname(l:bufnr)
if index(g:denote_note_file_extensions, fnamemodify(l:filename, ':e')) == -1
call system('open ' .. shellescape(l:filename))
else
exe 'edit ' .. fnameescape(l:filename)
endif
endfunction
nnoremap <buffer> <Enter> :call OpenDenoteEntry()<CR>
endif endif

View File

@@ -246,7 +246,7 @@ function denote#notes#copy(origfile)
" Write front matter, if this is supported " Write front matter, if this is supported
if index(g:denote_note_file_extensions, l:ext) >= 0 if index(g:denote_note_file_extensions, l:ext) >= 0
call denote#loclist#jumptowindow() call denote#loclist#jumptowindow()
exe 'edit ' .. l:filename exe 'edit ' .. fnameescape(l:filename)
call appendbufline(l:filename, 0, libdenote#fm_gen(l:ext, l:identifier, l:title), [], g:denote_fm_md_type) call appendbufline(l:filename, 0, libdenote#fm_gen(l:ext, l:identifier, l:title), [], g:denote_fm_md_type)
exe 'w' exe 'w'
endif endif