refacotred and split

This commit is contained in:
2026-02-25 15:32:05 +01:00
parent d4ad71543d
commit caf21ab060
10 changed files with 207 additions and 157 deletions

View File

@@ -51,13 +51,8 @@ endfunction
" Load all references to the given note into the location list.
function denote#loclist#references(noteId)
if !exists('t:denote_directory')
echohl WarningMsg
echom "Denote directory not specified, see |vim-denote|."
return
endif
" Populate location list
silent! execute "lvimgrep /\\<denote:" .. a:noteId .. "\\>/gj " .. t:denote_directory .. "*"
silent! execute "lvimgrep /\\<denote:" .. a:noteId .. "\\>/gj " .. g:denote_directory .. "/*"
" Adjust location list: set title and specify display function
let file=denote#meta#fileFromNoteId(a:noteId)
let noteTitle=denote#meta#noteTitleFromFile(file)
@@ -65,3 +60,31 @@ function denote#loclist#references(noteId)
\ {'title': 'References to ' .. noteTitle .. ' (' .. a:noteId .. ')',
\ 'quickfixtextfunc' : 'denote#loclist#textReferences'})
endfunction
" Re-populate location list with denote entries
function denote#loclist#fill(title, files)
" Clear first
call setloclist(0, [], ' ')
" Set properties
call setloclist(0, [], 'r',
\ {'title': a:title,
\ 'quickfixtextfunc' : 'denote#loclist#textNoteList',
\ 'context' : 'denote'})
" Populate
let l:notes=[]
for f in a:files
call add(l:notes, {
\ 'filename' : f,
\ 'lnum' : 1
\ })
endfor
call setloclist(0, l:notes, 'a')
endfunction
" Specify location list as denote-grep list
function denote#loclist#setgrep(title)
call setloclist(0, [], 'r',
\ {'title': a:title,
\ 'quickfixtextfunc' : 'denote#loclist#textReferences',
\ 'context' : 'denote'})
endfunction