Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commitd00e2a2

Browse files
committed
autopep8 format
1 parent60b244d commitd00e2a2

File tree

4 files changed

+95
-45
lines changed

4 files changed

+95
-45
lines changed

‎pythonx/neovim_rpc_methods.py‎

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,133 +4,174 @@
44
importmsgpack
55

66
# vim's python binding doesn't have the `call` method, wrap it here
7-
defnvim_call_function(method,args):
7+
8+
9+
defnvim_call_function(method,args):
810
vim.vars['_neovim_rpc_tmp_args']=args
911
# vim.eval('getcurpos()') return an array of string, it should be an array
1012
# of int. Use json_encode to workaround this
1113
returnvim.bindeval('call("%s",g:_neovim_rpc_tmp_args)'%method)
1214

15+
1316
defnvim_get_current_buf():
1417
returnvim.current.buffer
1518

19+
1620
defnvim_list_bufs():
1721
returnlist(vim.buffers)
1822

1923
# {'return_type': 'Integer', 'since': 1, 'method': True, 'parameters': [['Buffer', 'buffer']], 'name': 'nvim_buf_get_number'}
24+
25+
2026
defnvim_buf_get_number(buf):
2127
returnbuf.number
2228

29+
2330
defnvim_buf_get_name(buffer):
2431
returnbuffer.name
2532

33+
2634
defnvim_get_var(name):
2735
returnvim.vars[name]
2836

29-
defnvim_set_var(name,val):
37+
38+
defnvim_set_var(name,val):
3039
vim.vars[name]=val
3140
returnval
3241

33-
defnvim_buf_get_var(buffer,name):
42+
43+
defnvim_buf_get_var(buffer,name):
3444
returnbuffer.vars[name]
3545

36-
defnvim_buf_set_var(buffer,name,val):
46+
47+
defnvim_buf_set_var(buffer,name,val):
3748
buffer.vars[name]=val
3849

39-
defnvim_buf_get_lines(buffer,start,end,*args):
50+
51+
defnvim_buf_get_lines(buffer,start,end,*args):
4052
ifstart<0:
4153
start=len(buffer)+1+start
4254
ifend<0:
4355
end=len(buffer)+1+end
4456
returnbuffer[start:end]
4557

58+
4659
defnvim_eval(expr):
47-
returnnvim_call_function('eval',[expr])
60+
returnnvim_call_function('eval', [expr])
61+
4862

49-
defnvim_buf_set_lines(buffer,start,end,err,lines):
63+
defnvim_buf_set_lines(buffer,start,end,err,lines):
5064
ifstart<0:
5165
start=len(buffer)+1+start
5266
ifend<0:
5367
end=len(buffer)+1+end
5468
buffer[start:end]=lines
5569

56-
ifnvim_call_function('bufwinnr',[buffer.number])!=-1:
70+
ifnvim_call_function('bufwinnr',[buffer.number])!=-1:
5771
# vim needs' redraw to update the screen, it seems to be a bug
5872
vim.command('redraw')
5973

74+
6075
buffer_set_lines=nvim_buf_set_lines
6176

77+
6278
defbuffer_line_count(buffer):
6379
returnlen(buffer)
6480

81+
6582
defnvim_buf_line_count(buffer):
6683
returnlen(buffer)
6784

85+
6886
defnvim_get_option(name):
6987
returnvim.options[name]
7088

89+
7190
defnvim_buf_get_option(buf,name):
7291
returnbuf.options[name]
7392

93+
7494
defnvim_set_option(name,val):
7595
vim.options[name]=val
7696

97+
7798
defnvim_command(cmd):
7899
vim.command(cmd)
79100

101+
80102
defnvim_get_current_win():
81103
returnvim.current.window
82104

105+
83106
defnvim_win_get_cursor(window):
84107
returnwindow.cursor
85108

109+
86110
defnvim_win_get_buf(window):
87111
returnwindow.buffer
88112

113+
89114
defnvim_win_get_width(window):
90115
returnwindow.width
91116

117+
92118
defnvim_win_set_width(window,width):
93119
window.width=width
94120

121+
95122
defnvim_win_get_height(window):
96123
returnwindow.height
97124

125+
98126
defnvim_win_set_height(window,height):
99127
window.height=height
100128

129+
101130
defnvim_win_get_var(window,name):
102131
returnwindow.vars[name]
103132

133+
104134
defnvim_win_set_var(window,name,val):
105135
window.vars[name]=val
106136

137+
107138
defnvim_win_get_option(window,name):
108139
returnwindow.options[name]
109140

141+
110142
defnvim_win_set_option(window,name,val):
111143
window.options[name]=val
112144

145+
113146
defnvim_win_get_position(window):
114147
return (window.row,window.col)
115148

149+
116150
defnvim_win_get_number(window):
117151
returnwindow.number
118152

153+
119154
defnvim_win_is_valid(window):
120155
returnwindow.valid
121156

157+
122158
defnvim_out_write(s):
123159
nvim_call_function('neovim_rpc#_nvim_out_write', [s])
124160

161+
125162
defnvim_err_write(s):
126163
nvim_call_function('neovim_rpc#_nvim_err_write', [s])
127164

128165
# NOTE https://github.com/autozimu/LanguageClient-neovim/pull/151#issuecomment-339198527
129166
# TODO
167+
168+
130169
defnvim_buf_add_highlight(buf,src_id,*args):
131170
returnsrc_id
132171

133172
# NOTE https://github.com/autozimu/LanguageClient-neovim/pull/151#issuecomment-339198527
134173
# TODO
174+
175+
135176
defnvim_buf_clear_highlight(*args):
136177
pass

‎pythonx/neovim_rpc_protocol.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
WINDOW_TYPE=type(vim.current.window)
1919
WINDOW_TYPE_ID=neovim_rpc_server_api_info.API_INFO['types']['Window']['id']
2020

21+
2122
defwalk(fn,obj):
2223
iftype(obj)in [list,tuple,vim.List]:
2324
returnlist(walk(fn,o)foroinobj)
@@ -26,6 +27,7 @@ def walk(fn, obj):
2627
obj.items())
2728
returnfn(obj)
2829

30+
2931
ifvim.eval("has('patch-8.0.1280')"):
3032
deffrom_client(msg):
3133
defhandler(obj):
@@ -34,11 +36,11 @@ def handler(obj):
3436
returnvim.buffers[msgpack.unpackb(obj.data)]
3537
ifobj.code==WINDOW_TYPE_ID:
3638
returnvim.windows[msgpack.unpackb(obj.data)-1]
37-
ifsys.version_info.major!=2:
39+
ifsys.version_info.major!=2:
3840
# python3 needs decode
3941
obj=decode_if_bytes(obj)
4042
returnobj
41-
returnwalk(handler,msg)
43+
returnwalk(handler,msg)
4244
else:
4345
deffrom_client(msg):
4446
defhandler(obj):
@@ -49,14 +51,15 @@ def handler(obj):
4951
returnvim.windows[msgpack.unpackb(obj.data)-1]
5052
elifobjisNone:
5153
return''
52-
ifsys.version_info.major!=2:
54+
ifsys.version_info.major!=2:
5355
# python3 needs decode
5456
obj=decode_if_bytes(obj)
5557
returnobj
56-
returnwalk(handler,msg)
58+
returnwalk(handler,msg)
59+
5760

5861
defto_client(msg):
59-
defhandler(obj):
62+
defhandler(obj):
6063
iftype(obj)==BUFFER_TYPE:
6164
returnmsgpack.ExtType(BUFFER_TYPE_ID,msgpack.packb(obj.number))
6265
iftype(obj)==WINDOW_TYPE:
@@ -65,4 +68,3 @@ def handler( obj):
6568
returnobj.name
6669
returnobj
6770
returnwalk(handler,msg)
68-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp