From 864b678b9ea0072f79e898573d8238e897f715d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Thu, 26 Feb 2026 14:20:03 +0100 Subject: [PATCH] feat: reload key --- autoload/denote/commands.vim | 6 ++++++ autoload/denote/ft.vim | 10 +++++++++- autoload/denote/loclist.vim | 18 ++++++++++++++---- autoload/denote/notes.vim | 9 ++++++--- doc/denote.txt | 8 ++++++++ 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/autoload/denote/commands.vim b/autoload/denote/commands.vim index cacc089..9d42aa5 100644 --- a/autoload/denote/commands.vim +++ b/autoload/denote/commands.vim @@ -30,3 +30,9 @@ function denote#commands#load() " nnoremap DenoteBackReferences :DenoteBackReferences:lclose:lopen:resize 20 let g:denote_commands_loaded = v:true endfunction + +" " Public commands for the denote-list location list +" function denote#commands#loadll() +" command DenoteReload call denote# +" " command -nargs=1 DenoteSetTitle call denote#notes#settitle() +" endfunction diff --git a/autoload/denote/ft.vim b/autoload/denote/ft.vim index 8ea513b..57749e7 100644 --- a/autoload/denote/ft.vim +++ b/autoload/denote/ft.vim @@ -28,7 +28,8 @@ endfunction " This will be called for every location and quickfix, when data is loaded into " the list. This does nothing for such lists that are note 'denote' lists. function denote#ft#qf() - if getloclist(0, {'context': 1})['context'] != 'denote' + let l:context = getloclist(0, {'context': 1})['context'] + if type(l:context) != v:t_dict || !has_key(l:context, 'denote') " Clear settings set spell< nmapclear @@ -36,4 +37,11 @@ function denote#ft#qf() endif setlocal nospell nnoremap q :lclose + if has_key(l:context, 'gfun') + nnoremap r :call denote#loclist#reload() + endif + " Denote-list specific configuration + " if l:context == 'denote-list' + " call denote#commands#loadll() + " endif endfunction diff --git a/autoload/denote/loclist.vim b/autoload/denote/loclist.vim index 10dc0ce..87a4455 100644 --- a/autoload/denote/loclist.vim +++ b/autoload/denote/loclist.vim @@ -50,14 +50,14 @@ endfor endfunction " Re-populate location list with denote entries -function denote#loclist#fill(title, files) +function denote#loclist#fill(title, files, Gfun) " Clear first call setloclist(0, [], ' ') " Set properties call setloclist(0, [], 'r', \ {'title': a:title, \ 'quickfixtextfunc' : 'denote#loclist#textNoteList', - \ 'context' : 'denote'}) + \ 'context' : {'denote': 'list', 'gfun': a:Gfun}}) " Populate let l:notes=[] for f in a:files @@ -70,9 +70,19 @@ function denote#loclist#fill(title, files) endfunction " Specify location list as denote-grep list -function denote#loclist#setgrep(title) +function denote#loclist#setgrep(title, Gfun) call setloclist(0, [], 'r', \ {'title': a:title, \ 'quickfixtextfunc' : 'denote#loclist#textReferences', - \ 'context' : 'denote'}) + \ 'context' : {'denote': 'grep', 'gfun': a:Gfun}}) +endfunction + +" Reload location list +function denote#loclist#reload() + let l:context = getloclist(0, {'context': 1})['context'] + if has_key(l:context, 'denote') && has_key(l:context, 'gfun') + execute ':lclose' + call l:context['gfun']() + execute ':lwindow' + endif endfunction diff --git a/autoload/denote/notes.vim b/autoload/denote/notes.vim index 5cfa1a5..7b7b225 100644 --- a/autoload/denote/notes.vim +++ b/autoload/denote/notes.vim @@ -4,7 +4,8 @@ function denote#notes#list(search) let l:s = substitute(' ' .. a:search .. ' ', ' ', '*', 'g') let l:files = glob(g:denote_directory .. '/' .. l:s, 0, v:true) let l:title = 'Denote notes search:' .. a:search - call denote#loclist#fill(l:title, l:files) + let l:Gfun = function('denote#notes#list', [a:search]) + call denote#loclist#fill(l:title, l:files, l:Gfun) endfunction " Put all notes of the given tag to the location list. The tag argument is @@ -12,7 +13,8 @@ endfunction function denote#notes#bytag(tag) let l:files = glob(g:denote_directory .. '/*_' .. a:tag .. '*', 0, v:true)->filter('v:val->split("/")[-1] =~ "_' .. a:tag .. '\\(==\\|@@\\|__\\|_\\|\\.\\)"') let l:title = 'Denote notes: ' .. a:tag - call denote#loclist#fill(l:title, l:files) + let l:Gfun = function('denote#notes#bytag', [a:tag]) + call denote#loclist#fill(l:title, l:files, l:Gfun) endfunction " Search in denote notes @@ -20,7 +22,8 @@ function denote#notes#grep(re) let l:title = 'Grep results for: ' .. a:re let l:fpat=map(copy(g:denote_note_file_extensions), {_, e -> g:denote_directory .. '/*.' .. e})->join() execute 'silent! lvimgrep ' .. a:re .. ' ' .. l:fpat - call denote#loclist#setgrep(l:title) + let l:Gfun = function('denote#notes#grep', [a:re]) + call denote#loclist#setgrep(l:title, l:Gfun) endfunction " This creates a new denote entry with the given title and of the given diff --git a/doc/denote.txt b/doc/denote.txt index dd8ecdf..037fba9 100644 --- a/doc/denote.txt +++ b/doc/denote.txt @@ -8,6 +8,7 @@ CONTENTS *vim-denote* *denote* 1. Introduction |denote-intro| 2. Commands |denote-commands| 3. Settings |denote-settings| +4. Keys |denote-keys| ============================================================================== *denote-intro* @@ -143,4 +144,11 @@ generator and to specify, e.g., < + *denote-keys* +Keys ~ + *denote-r* +r Reload the location list showing denote entries or denote grep matches + found. This key is only active in location lists generated by the + present package. + vim:tw=78:sw=4:ts=8:noet:ft=help:norl: