feat: reload key
This commit is contained in:
@@ -30,3 +30,9 @@ function denote#commands#load()
|
|||||||
" nnoremap <silent> <Plug>DenoteBackReferences :DenoteBackReferences<CR>:lclose<CR>:lopen<CR>:resize 20<CR>
|
" nnoremap <silent> <Plug>DenoteBackReferences :DenoteBackReferences<CR>:lclose<CR>:lopen<CR>:resize 20<CR>
|
||||||
let g:denote_commands_loaded = v:true
|
let g:denote_commands_loaded = v:true
|
||||||
endfunction
|
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
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ endfunction
|
|||||||
" This will be called for every location and quickfix, when data is loaded into
|
" 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.
|
" the list. This does nothing for such lists that are note 'denote' lists.
|
||||||
function denote#ft#qf()
|
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
|
" Clear settings
|
||||||
set spell<
|
set spell<
|
||||||
nmapclear <buffer>
|
nmapclear <buffer>
|
||||||
@@ -36,4 +37,11 @@ function denote#ft#qf()
|
|||||||
endif
|
endif
|
||||||
setlocal nospell
|
setlocal nospell
|
||||||
nnoremap <buffer> q :lclose<CR>
|
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
|
endfunction
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ endfor
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Re-populate location list with denote entries
|
" Re-populate location list with denote entries
|
||||||
function denote#loclist#fill(title, files)
|
function denote#loclist#fill(title, files, Gfun)
|
||||||
" Clear first
|
" Clear first
|
||||||
call setloclist(0, [], ' ')
|
call setloclist(0, [], ' ')
|
||||||
" Set properties
|
" Set properties
|
||||||
call setloclist(0, [], 'r',
|
call setloclist(0, [], 'r',
|
||||||
\ {'title': a:title,
|
\ {'title': a:title,
|
||||||
\ 'quickfixtextfunc' : 'denote#loclist#textNoteList',
|
\ 'quickfixtextfunc' : 'denote#loclist#textNoteList',
|
||||||
\ 'context' : 'denote'})
|
\ 'context' : {'denote': 'list', 'gfun': a:Gfun}})
|
||||||
" Populate
|
" Populate
|
||||||
let l:notes=[]
|
let l:notes=[]
|
||||||
for f in a:files
|
for f in a:files
|
||||||
@@ -70,9 +70,19 @@ function denote#loclist#fill(title, files)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Specify location list as denote-grep list
|
" Specify location list as denote-grep list
|
||||||
function denote#loclist#setgrep(title)
|
function denote#loclist#setgrep(title, Gfun)
|
||||||
call setloclist(0, [], 'r',
|
call setloclist(0, [], 'r',
|
||||||
\ {'title': a:title,
|
\ {'title': a:title,
|
||||||
\ 'quickfixtextfunc' : 'denote#loclist#textReferences',
|
\ '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
|
endfunction
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ function denote#notes#list(search)
|
|||||||
let l:s = substitute(' ' .. a:search .. ' ', ' ', '*', 'g')
|
let l:s = substitute(' ' .. a:search .. ' ', ' ', '*', 'g')
|
||||||
let l:files = glob(g:denote_directory .. '/' .. l:s, 0, v:true)
|
let l:files = glob(g:denote_directory .. '/' .. l:s, 0, v:true)
|
||||||
let l:title = 'Denote notes search:' .. a:search
|
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
|
endfunction
|
||||||
|
|
||||||
" Put all notes of the given tag to the location list. The tag argument is
|
" 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)
|
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:files = glob(g:denote_directory .. '/*_' .. a:tag .. '*', 0, v:true)->filter('v:val->split("/")[-1] =~ "_' .. a:tag .. '\\(==\\|@@\\|__\\|_\\|\\.\\)"')
|
||||||
let l:title = 'Denote notes: ' .. 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
|
endfunction
|
||||||
|
|
||||||
" Search in denote notes
|
" Search in denote notes
|
||||||
@@ -20,7 +22,8 @@ function denote#notes#grep(re)
|
|||||||
let l:title = 'Grep results for: ' .. a: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()
|
let l:fpat=map(copy(g:denote_note_file_extensions), {_, e -> g:denote_directory .. '/*.' .. e})->join()
|
||||||
execute 'silent! lvimgrep ' .. a:re .. ' ' .. l:fpat
|
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
|
endfunction
|
||||||
|
|
||||||
" This creates a new denote entry with the given title and of the given
|
" This creates a new denote entry with the given title and of the given
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ CONTENTS *vim-denote* *denote*
|
|||||||
1. Introduction |denote-intro|
|
1. Introduction |denote-intro|
|
||||||
2. Commands |denote-commands|
|
2. Commands |denote-commands|
|
||||||
3. Settings |denote-settings|
|
3. Settings |denote-settings|
|
||||||
|
4. Keys |denote-keys|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*denote-intro*
|
*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:
|
vim:tw=78:sw=4:ts=8:noet:ft=help:norl:
|
||||||
|
|||||||
Reference in New Issue
Block a user