" Find the column where the completion starts. This must be between 1 and " col('.'). Denote links are of this form: `denote:`. function s:column() " Get the substring from the start of the line until col('.') let l:l = getline('.')[:col('.')] " Take the shortest prefix of a denote link. This may be any of " \matchstrpos('\= 0 return l:res[1] endif let l:res = l:l->matchstrpos('\matchstr('^denote:\zs.*$') let l:flist = glob(g:denote_directory .. '/' .. (l:prefix ? '*' .. l:prefix .. '*' : '*'), 0, v:true) let l:res = [] for filename in l:flist let l:noteId = denote#meta#noteIdFromFile(filename) let l:noteTitle = denote#meta#noteTitleFromFile(filename) if l:noteId == v:false || (l:noteId !~ '^' .. l:prefix && l:noteTitle !~ l:prefix) continue endif let l:noteTitle = l:noteTitle ?? '(no title)' let l:noteTags = denote#meta#noteTagsFromFile(filename) call add(l:res, { \ 'word' : 'denote:' .. l:noteId, \ 'abbr' : l:noteTitle, \ 'menu' : l:noteTags->join(', ') \ }) endfor return l:res endfunction " Completion function for denote links 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