feat: reload key

This commit is contained in:
2026-02-26 14:20:03 +01:00
parent 7a82fe32db
commit 864b678b9e
5 changed files with 43 additions and 8 deletions

View File

@@ -30,3 +30,9 @@ function denote#commands#load()
" nnoremap <silent> <Plug>DenoteBackReferences :DenoteBackReferences<CR>:lclose<CR>:lopen<CR>:resize 20<CR>
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(<q-args>)
" endfunction

View File

@@ -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 <buffer>
@@ -36,4 +37,11 @@ function denote#ft#qf()
endif
setlocal nospell
nnoremap <buffer> q :lclose<CR>
if has_key(l:context, 'gfun')
nnoremap <buffer> <silent> r :call denote#loclist#reload()<CR>
endif
" Denote-list specific configuration
" if l:context == 'denote-list'
" call denote#commands#loadll()
" endif
endfunction

View File

@@ -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

View File

@@ -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

View File

@@ -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: