-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathapi.py
More file actions
90 lines (68 loc) · 1.73 KB
/
Copy pathapi.py
File metadata and controls
90 lines (68 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import functools
import logging
from . import load_completer, load as _load, vim, set_current_completer, \
get_current_completer
logger = logging.getLogger('completor')
def _api(func):
@functools.wraps(func)
def wrapper():
try:
return func(vim.bindeval('a:'))
except Exception as e:
logger.exception(e)
raise
return wrapper
@_api
def get_completer(args):
c = load_completer(args['ft'], args['inputted'])
set_current_completer(c)
return c.get_cmd_info(b'complete') if c else vim.Dictionary()
@_api
def load(args):
c = _load(args['ft'], args['inputted'])
set_current_completer(c)
if not c:
return vim.Dictionary()
try:
c.meta = args['meta']
return c.get_cmd_info(args['action'])
finally:
c.meta = None
@_api
def on_data(args):
c = get_current_completer()
return c.on_data(args['action'], args['msg']) if c else []
@_api
def get_start_column(args):
c = get_current_completer()
return c.start_column() if c else -1
@_api
def gen_request(args):
c = get_current_completer()
return c.gen_request(args['action'], args['args']) if c else ''
@_api
def is_message_end(args):
c = get_current_completer()
return c.is_message_end(args['msg']) if c else False
@_api
def reset(args):
c = get_current_completer()
if not c:
return
c.reset()
@_api
def on_stream(args):
c = get_current_completer()
if not c:
return
name = args['name'].decode()
parts = name.split(':', 1)
if parts:
name = parts[0]
c.handle_stream(name, args['action'], args['msg'])
@_api
def on_exit(args):
c = get_current_completer()
if not c:
return
c.on_exit()