diff --git a/autoload/ncm2_khard.vim b/autoload/ncm2_khard.vim index aca0946..ad66254 100644 --- a/autoload/ncm2_khard.vim +++ b/autoload/ncm2_khard.vim @@ -12,7 +12,7 @@ let g:ncm2_khard#source = extend(get(g:, 'ncm2_khard#source', {}), { \ 'name': 'khard', \ 'ready': 0, \ 'priority': 5, - \ 'mark': 'b', + \ 'mark': 'email', \ 'scope': ['mail'], \ 'complete_pattern': ['^To: ', '^Cc: ', '^Bcc: '], \ 'on_complete': 'ncm2_khard#on_complete', @@ -24,10 +24,13 @@ func! ncm2_khard#init() endfunc func! ncm2_khard#on_warmup(ctx) - call g:ncm2_khard#proc.jobstart() + call g:ncm2_khard#proc.try_notify('on_warmup', a:ctx) endfunc func! ncm2_khard#on_complete(ctx) call g:ncm2_khard#proc.try_notify('on_complete', a:ctx) endfunc +func! ncm2_khard#on_event(event) + call g:ncm2_khard#proc.try_notify('on_event', a:event, bufnr('%')) + endfunc diff --git a/pythonx/ncm2_khard.py b/pythonx/ncm2_khard.py index d8b9a88..f3b41c3 100644 --- a/pythonx/ncm2_khard.py +++ b/pythonx/ncm2_khard.py @@ -3,8 +3,6 @@ import vim import subprocess from ncm2 import Ncm2Source, getLogger -import re -from copy import deepcopy logger = getLogger(__name__) @@ -12,18 +10,15 @@ logger = getLogger(__name__) class Source(Ncm2Source): def on_warmup(self, ctx): - shell_command = 'khard email --parsable | cut -f 1,2' - self.dictionary = subprocess.run(shell_command, shell = True, capture_output = True).stdout.decode('utf8').split('\n') + bufnr = ctx['bufnr'] + shell_cmd = "khard email --parsable | cut -f 1,2 | sed -r 's/(.*)\t(.*)/\\2 <\\1>/'" + self.matches = subprocess.run(shell_cmd, shell = True, capture_output = True).stdout.decode('utf8').split('\n') def on_complete(self, ctx): - base = ctx['base'] - # matcher = self.matcher_get(ctx) - # matches = [] - - - self.complete(ctx, ctx['startccol'], self.dictionary) + self.complete(ctx, ctx['startccol'], self.matches) source = Source(vim) +on_warmup = source.on_warmup on_complete = source.on_complete