Pārlūkot izejas kodu

Initial commit

master
Maxime Wack pirms 5 gadiem
revīzija
37713a29ef
6 mainītis faili ar 95 papildinājumiem un 0 dzēšanām
  1. +8
    -0
      .gitignore
  2. +20
    -0
      LICENSE
  3. +4
    -0
      README.md
  4. +33
    -0
      autoload/ncm2_khard.vim
  5. +1
    -0
      ncm2-plugin/ncm2_khard.vim
  6. +29
    -0
      pythonx/ncm2_khard.py

+ 8
- 0
.gitignore Parādīt failu

@@ -0,0 +1,8 @@
*.swp
*.pyc
__pycache__
/node_modules
/doc/tags
/.envrc
/test.vim
/nvim.log*

+ 20
- 0
LICENSE Parādīt failu

@@ -0,0 +1,20 @@
Copyright © 2019 maximewack@free.fr

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


+ 4
- 0
README.md Parādīt failu

@@ -0,0 +1,4 @@
# ncm2-khard

This ncm2 plugin provide email address completion from khard.


+ 33
- 0
autoload/ncm2_khard.vim Parādīt failu

@@ -0,0 +1,33 @@
if get(s:, 'loaded', 0)
finish
endif
let s:loaded = 1

let g:ncm2_khard#proc = yarp#py3({
\ 'module': 'ncm2_khard',
\ 'on_load': { -> ncm2#set_ready(g:ncm2_khard#source)}
\ })

let g:ncm2_khard#source = extend(get(g:, 'ncm2_khard#source', {}), {
\ 'name': 'khard',
\ 'ready': 0,
\ 'priority': 5,
\ 'mark': 'b',
\ 'scope': ['mail'],
\ 'complete_pattern': ['^To: ', '^Cc: ', '^Bcc: '],
\ 'on_complete': 'ncm2_khard#on_complete',
\ 'on_warmup': 'ncm2_khard#on_warmup',
\ }, 'keep')

func! ncm2_khard#init()
call ncm2#register_source(g:ncm2_khard#source)
endfunc

func! ncm2_khard#on_warmup(ctx)
call g:ncm2_khard#proc.jobstart()
endfunc

func! ncm2_khard#on_complete(ctx)
call g:ncm2_khard#proc.try_notify('on_complete', a:ctx)
endfunc


+ 1
- 0
ncm2-plugin/ncm2_khard.vim Parādīt failu

@@ -0,0 +1 @@
call ncm2_khard#init()

+ 29
- 0
pythonx/ncm2_khard.py Parādīt failu

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-

import vim
import subprocess
from ncm2 import Ncm2Source, getLogger
import re
from copy import deepcopy

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')

def on_complete(self, ctx):
base = ctx['base']
# matcher = self.matcher_get(ctx)
# matches = []


self.complete(ctx, ctx['startccol'], self.dictionary)


source = Source(vim)

on_complete = source.on_complete

Notiek ielāde…
Atcelt
Saglabāt