-
Notifications
You must be signed in to change notification settings - Fork 268
/
Copy pathvim.py
88 lines (64 loc) · 1.82 KB
/
vim.py
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
# -*- coding: utf-8 -*-
class VimWindow(object):
u""" Docstring for VimWindow """
def __init__(self, test):
object.__init__(self)
self._test = test
self.cursor = (1, 0)
def buffer():
def fget(self):
return self._test.buffer
def fset(self, value):
self._test.buffer = value
return locals()
buffer = property(**buffer())
class VimBuffer(list):
def __init__(self, iterable=None):
self.number = 0
if iterable is not None:
list.__init__(self, iterable)
else:
list.__init__(self)
def append(self, o):
u"""
mimic the specific behavior of vim.current.buffer
"""
if isinstance(o, list) or isinstance(o, tuple):
for i in o:
list.append(self, i)
else:
list.append(self, o)
class VimTest(object):
u""" Replacement for vim API """
def __init__(self):
object.__init__(self)
self._buffer = VimBuffer()
self.window = VimWindow(self)
def buffer():
def fget(self):
return self._buffer
def fset(self, value):
self._buffer = VimBuffer(value)
return locals()
buffer = property(**buffer())
EVALHISTORY = []
EVALRESULTS = {
u'exists("g:org_debug")': 0,
u'exists("b:org_debug")': 0,
u'exists("*repeat#set()")': 0,
u'exists("b:org_plugins")': 0,
u'exists("g:org_plugins")': 0,
u'b:changedtick': 0,
}
def eval(cmd):
u""" evaluate command
:returns: results stored in EVALRESULTS
"""
EVALHISTORY.append(cmd)
return EVALRESULTS.get(cmd, None)
CMDHISTORY = []
CMDRESULTS = {}
def command(cmd):
CMDHISTORY.append(cmd)
return CMDRESULTS.get(cmd, None)
current = VimTest()