FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vim-python-docstring/python/vimenv.py at master · pixelneo/vim-python-docstring · GitHub
pixelneo
/
vim-python-docstring
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
47
Code
Issues
5
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vim-python-docstring
/
python
/
vimenv.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
106 lines (83 loc) · 2.73 KB
Breadcrumbs
vim-python-docstring
/
python
/
vimenv.py
Copy path
File metadata and controls
106 lines (83 loc) · 2.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import
vim
import
abc
class
Enviroment
(
abc
.
ABC
):
@
property
@
abc
.
abstractmethod
def
plugin_root_dir
(
self
):
"""Return absolute path to directory one level above of directory
containing python scripts.
"""
@
property
@
abc
.
abstractmethod
def
python_style
(
self
):
"""Returns string containing docstring style: google, numpy, etc.
The style has to have corresponding template of name
<style>-method.txt end <style>-class.txt in folder 'styles'.
"""
@
property
@
abc
.
abstractmethod
def
python_indent
(
self
):
"""Returns indentation of python source (tab, 4 spaces, ...)"""
@
property
@
abc
.
abstractmethod
def
current_line_nr
(
self
):
"""Returns number of the current line, indexed from 0."""
@
property
@
abc
.
abstractmethod
def
current_line
(
self
):
"""Returns current line."""
@
abc
.
abstractmethod
def
append_after_line
(
self
,
line_nr
,
text
):
"""Print to buffer
Append `text` to buffer on line below `line_nr`.
Args:
line_nr: (int)
text: (str)
"""
@
abc
.
abstractmethod
def
lines_following_cursor
(
self
):
"""Generator that iterates lines in buffer, starting from current line."""
# #TODO will this work???
# @abc.abstractmethod
# def lines_till_end(self):
# """ Returns all lines from the current one until the end. """
class
VimEnviroment
(
Enviroment
):
def
__init__
(
self
):
pass
def
_get_var
(
self
,
name
):
return
vim
.
eval
(
name
)
@
property
def
plugin_root_dir
(
self
):
return
self
.
_get_var
(
"s:plugin_root_dir"
)
@
property
def
python_style
(
self
):
if
not
int
(
vim
.
eval
(
'exists("g:python_style")'
)):
return
"google"
else
:
return
self
.
_get_var
(
"g:python_style"
)
@
property
def
python_indent
(
self
):
if
not
int
(
vim
.
eval
(
'exists("g:vpd_indent")'
)):
return
" "
else
:
return
self
.
_get_var
(
"g:vpd_indent"
)
@
property
def
current_line_nr
(
self
):
return
vim
.
current
.
window
.
cursor
[
0
]
-
1
@
property
def
current_line
(
self
):
return
vim
.
current
.
line
def
append_after_line
(
self
,
line_nr
,
text
):
line_nr
+=
1
for
line
in
reversed
(
text
.
split
(
"
\n
"
)):
vim
.
current
.
buffer
.
append
(
line
,
line_nr
)
def
lines_following_cursor
(
self
):
import
vim
buffer
=
vim
.
current
.
buffer
cursor_row
=
vim
.
current
.
window
.
cursor
[
0
]
-
1
current_row
=
cursor_row
while
True
:
if
current_row
>
len
(
vim
.
current
.
buffer
)
-
1
:
raise
StopIteration
(
"Buffer is out of lines."
)
yield
current_row
,
buffer
[
current_row
]
current_row
+=
1
Back
|
FazBrowse Home
|
New Git URL