diff --git a/autoload/denote/commands.vim b/autoload/denote/commands.vim index f64ffab..9e7f790 100644 --- a/autoload/denote/commands.vim +++ b/autoload/denote/commands.vim @@ -1,14 +1,3 @@ -" This function is used to autocomplete the tags in user commands. -function s:tagList(ArgLead, cmdLine, CursorPos) - let l:files=glob(g:denote_directory .. '/*', 0, v:true) - let l:tags=[] - for f in l:files - let l:tags=extend(l:tags, denote#meta#noteTagsFromFile(f)) - endfor - return uniq(sort(l:tags))->join("\n") -endfunction - - " Public commands function denote#commands#load() if exists('g:denote_commands_loaded') && g:denote_commands_loaded @@ -16,7 +5,7 @@ function denote#commands#load() endif " Register user commands command -nargs=* Denote call denote#notes#list() | lcl | lopen - command -nargs=1 -complete=custom,s:tagList DenoteByTag call denote#notes#bytag() | lcl | lopen + command -nargs=1 -complete=custom,denote#completion#tags DenoteByTag call denote#notes#bytag() | lcl | lopen command -nargs=+ DenoteGrep call denote#notes#grep() | lcl | lopen command -nargs=1 DenoteNew call denote#notes#new() diff --git a/autoload/denote/completion.vim b/autoload/denote/completion.vim index 96f2731..6f05c45 100644 --- a/autoload/denote/completion.vim +++ b/autoload/denote/completion.vim @@ -47,3 +47,13 @@ endfunction function denote#completion#get(findstart, base) return a:findstart == 1 ? s:column() : s:suggestions(a:base) endfunction + +" Completion function for denote tags +function denote#completion#tags(ArgLead, cmdLine, CursorPos) + let l:files=glob(g:denote_directory .. '/*', 0, v:true) + let l:tags=[] + for f in l:files + let l:tags=extend(l:tags, denote#meta#noteTagsFromFile(f)) + endfor + return uniq(sort(l:tags))->join("\n") +endfunction diff --git a/autoload/denote/ft.vim b/autoload/denote/ft.vim index 09599f8..1cf3484 100644 --- a/autoload/denote/ft.vim +++ b/autoload/denote/ft.vim @@ -43,7 +43,10 @@ function denote#ft#qf() " Denote-list specific configuration if l:context['denote'] == 'list' command! -nargs=1 -range -buffer DenoteSetTitle :call denote#notes#settitle(, ) - command! -nargs=1 -range -buffer DenoteTagAdd :call denote#notes#tagmod(, , , v:true) - command! -nargs=1 -range -buffer DenoteTagRm :call denote#notes#tagmod(, , , v:false) + command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagAdd :call denote#notes#tagmod(, , , v:true) + command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagRm :call denote#notes#tagmod(, , , v:false) + nnoremap C :DenoteSetTitle + nnoremap + :DenoteTagAdd + nnoremap - :DenoteTagRm endif endfunction diff --git a/autoload/denote/notes.vim b/autoload/denote/notes.vim index 02c8e37..97c7948 100644 --- a/autoload/denote/notes.vim +++ b/autoload/denote/notes.vim @@ -99,7 +99,7 @@ function denote#notes#tagmod(line1, line2, tag, add) if l:idx == -1 continue endif - call remove(l:notetags, a:tag) + call remove(l:notetags, l:idx) endif let l:notesignature = denote#meta#noteSignatureFromFile(l:filename) let l:title = denote#meta#noteTitleFromFile(l:filename)