diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-03-14 09:47:45 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-03-14 09:47:45 +0100 |
commit | fb99d5be8362a32c47296cd5403ba935df3c14a6 (patch) | |
tree | 317c8a6e52329fc816f175ffaca013e3272bc8fc /autoload |
initial commit (move from dotfiles)
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/coc/source/khard.vim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/autoload/coc/source/khard.vim b/autoload/coc/source/khard.vim new file mode 100644 index 0000000..63dd8bd --- /dev/null +++ b/autoload/coc/source/khard.vim @@ -0,0 +1,28 @@ +" global contacts list +let s:contacts = [] + +function! coc#source#khard#init() abort + " read contacts once on init + for line in systemlist('khard email --remove-first-line --parsable') + let [address, name, type] = split(line, "\t") + call add(s:contacts, printf('%s <%s>', name, address)) + endfor + + " plugin config + return { + \ 'priority': 9, + \ 'shortcut': 'khard', + \ 'filetypes': ['mail'], + \} +endfunction + +function coc#source#khard#should_complete(option) + " only complete addresses on to, cc, bcc and reply-to header lines + return tolower(a:option['line']) =~ '^\(to\|cc\|bcc\|reply-to\):' +endfunction + +function! coc#source#khard#complete(option, cb) abort + " init already loaded all the contacts, just forward them to CoC + call a:cb(s:contacts) +endfunction + |