39 lines
1.5 KiB
VimL
39 lines
1.5 KiB
VimL
" 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
|
|
return
|
|
endif
|
|
" Register user commands
|
|
command -nargs=* Denote call denote#notes#list(<q-args>) | lcl | lopen
|
|
command -nargs=1 -complete=custom,s:tagList DenoteByTag call denote#notes#bytag(<q-args>) | lcl | lopen
|
|
command -nargs=+ DenoteGrep call denote#notes#grep(<q-args>) | lcl | lopen
|
|
command -nargs=1 DenoteNew call denote#notes#new(<q-args>)
|
|
|
|
" Register auto commands
|
|
autocmd BufReadPost quickfix call denote#ft#qf()
|
|
let l:aupat = map(copy(g:denote_note_file_extensions), {_, v -> '*.' .. v})->join(',')
|
|
exe 'autocmd BufReadPost,BufNewFile ' .. l:aupat .. ' call denote#ft#denote()'
|
|
|
|
" Useful key mappings
|
|
" nnoremap <silent> <Plug>DenoteList :DenoteSearch<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
|
|
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
|