diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-03-14 09:07:24 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-03-14 09:07:24 +0100 |
commit | 7dcb2f8946ef727330341930f304598140077a94 (patch) | |
tree | 8609195a25a5d862dbbf9301a266a1e7558274e3 | |
parent | 5b384e5d76cc1c9f02b424146b71331a5bebaf0e (diff) |
add coc autocomplete source for completing contact email addresses from khard
-rw-r--r-- | .config/coc/extensions/package.json | 1 | ||||
-rw-r--r-- | .config/nvim/autoload/coc/source/khard.vim | 28 | ||||
-rw-r--r-- | .config/nvim/init.vim | 1 |
3 files changed, 28 insertions, 2 deletions
diff --git a/.config/coc/extensions/package.json b/.config/coc/extensions/package.json index 24d9e5d..81db5f2 100644 --- a/.config/coc/extensions/package.json +++ b/.config/coc/extensions/package.json @@ -6,7 +6,6 @@ "coc-html": ">=1.8.0", "coc-java": ">=1.15.2", "coc-json": ">=1.9.2", - "coc-neosnippet": ">=1.2.2", "coc-python": ">=1.2.13", "coc-rust-analyzer": ">=0.75.2", "coc-tsserver": ">=2.1.4", diff --git a/.config/nvim/autoload/coc/source/khard.vim b/.config/nvim/autoload/coc/source/khard.vim new file mode 100644 index 0000000..63dd8bd --- /dev/null +++ b/.config/nvim/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 + diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 25d7fe3..056e9ed 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -77,7 +77,6 @@ Plug 'octol/vim-cpp-enhanced-highlight' Plug 'vim-python/python-syntax' Plug 'dart-lang/dart-vim-plugin' Plug 'bartlomiejdanek/vim-dart' -Plug 'natebosch/dartlang-snippets' Plug 'HerringtonDarkholme/yats.vim' Plug 'cespare/vim-toml' Plug 'tikhomirov/vim-glsl' |