Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork768
Expand file tree
/
Copy pathpymode.vim
More file actions
258 lines (197 loc) · 8.56 KB
/
pymode.vim
File metadata and controls
258 lines (197 loc) · 8.56 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
if!g:pymode||pymode#default('b:pymode',1)
finish
endif
ifg:pymode_python=='disable'
ifg:pymode_warning
callpymode#error("Pymode requires vim compiled with +python3 (exclusively). Most of features will be disabled.")
endif
finish
else
letb:pymode_modified= &modified
" Init paths
if!pymode#default('g:pymode_init',1)
callpymode#init(expand('<sfile>:p:h:h:h'),g:pymode_paths)
callpymode#virtualenv#init()
callpymode#breakpoint#init()
PymodePython from pymode.utilsimport patch_paths
PymodePythonpatch_paths()
endif
endif
command!-buffer -nargs=1 PymodeVirtualenvcallpymode#virtualenv#activate(<args>)
" Setup events for pymode
au! pymodeBufWritePre<buffer>callpymode#buffer_pre_write()
au! pymodeBufWritePost<buffer>callpymode#buffer_post_write()
" Run python code
ifg:pymode_run
command!-buffer -nargs=0 -range=% PymodeRuncallpymode#run#code_run(<f-line1>,<f-line2>)
exe"nnoremap <silent> <buffer>"g:pymode_run_bind":PymodeRun<CR>"
exe"vnoremap <silent> <buffer>"g:pymode_run_bind":PymodeRun<CR>"
endif
" Add/remove breakpoints
ifg:pymode_breakpoint
exe"nnoremap <silent> <buffer>"g:pymode_breakpoint_bind":call pymode#breakpoint#operate(line('.'))<CR>"
endif
" Python folding
ifg:pymode_folding
setlocalfoldmethod=expr
setlocalfoldexpr=pymode#folding#expr(v:lnum)
setlocalfoldtext=pymode#folding#text()
endif
" Remove unused whitespaces
ifg:pymode_trim_whitespaces
auBufWritePre<buffer>callpymode#trim_whitespaces()
endif
" Custom options
ifg:pymode_options
setlocalcomplete+=t
setlocalformatoptions-=t
ifv:version >702&&!&relativenumber
setlocalnumber
endif
setlocalnowrap
exe"setlocal textwidth=" .g:pymode_options_max_line_length
ifg:pymode_options_colorcolumn&&exists('+colorcolumn')
setlocalcolorcolumn=+1
endif
setlocalcommentstring=#%s
setlocaldefine=^\s*\\(def\\\\|class\\)
endif
ifg:pymode_lint
command!-buffer -nargs=0 PymodeLintAuto :callpymode#lint#auto()
command!-buffer -nargs=0 PymodeLintToggle :callpymode#lint#toggle()
command!-buffer -nargs=0 PymodeLint :callpymode#lint#check()
ifv:version >703|| (v:version==703&&has('patch544'))
au!QuitPre<buffer>callpymode#quit()
else
au! pymodeBufWinLeave*silent!lclose
endif
letb:pymode_error_line=-1
ifg:pymode_lint_on_fly
au! pymodeInsertLeave<buffer> PymodeLint
endif
ifg:pymode_lint_message
au! pymodeCursorMoved<buffer>
au! pymodeCursorMoved<buffer>callpymode#lint#show_errormessage()
endif
" Disabled for current release
ifg:pymode_lint_async
" let &l:updatetime = g:pymode_lint_async_updatetime
" au! BufEnter <buffer> call pymode#lint#start()
" au! BufLeave <buffer> call pymode#lint#stop()
endif
endif
" Show python documentation
ifg:pymode_doc
" Set commands
command!-buffer -nargs=1 PymodeDoccallpymode#doc#show("<args>")
" Set keys
exe"nnoremap <silent> <buffer>"g:pymode_doc_bind":call pymode#doc#find()<CR>"
exe"vnoremap <silent> <buffer>"g:pymode_doc_bind":<C-U>call pymode#doc#show(@*)<CR>"
endif
" Rope support
ifg:pymode_rope
ifg:pymode_rope_goto_definition_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_goto_definition_bind ." :call pymode#rope#goto_definition()<CR>"
endif
ifg:pymode_rope_show_doc_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_show_doc_bind ." :call pymode#rope#show_doc()<CR>"
endif
ifg:pymode_rope_find_it_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_find_it_bind ." :call pymode#rope#find_it()<CR>"
endif
ifg:pymode_rope_organize_imports_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_organize_imports_bind ." :call pymode#rope#organize_imports()<CR>"
endif
ifg:pymode_rope_rename_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_rename_bind ." :call pymode#rope#rename()<CR>"
endif
ifg:pymode_rope_rename_module_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_rename_module_bind ." :call pymode#rope#rename_module()<CR>"
endif
ifg:pymode_rope_extract_method_bind!=""
exe"vnoremap <silent> <buffer>" .g:pymode_rope_extract_method_bind ." :call pymode#rope#extract_method()<CR>"
endif
ifg:pymode_rope_extract_variable_bind!=""
exe"vnoremap <silent> <buffer>" .g:pymode_rope_extract_variable_bind ." :call pymode#rope#extract_variable()<CR>"
endif
ifg:pymode_rope_inline_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_inline_bind ." :call pymode#rope#inline()<CR>"
endif
ifg:pymode_rope_move_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_move_bind ." :call pymode#rope#move()<CR>"
endif
ifg:pymode_rope_change_signature_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_change_signature_bind ." :call pymode#rope#signature()<CR>"
endif
ifg:pymode_rope_use_function_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_use_function_bind ." :call pymode#rope#use_function()<CR>"
endif
ifg:pymode_rope_generate_function_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_generate_function_bind ." :call pymode#rope#generate_function()<CR>"
endif
ifg:pymode_rope_generate_package_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_generate_package_bind ." :call pymode#rope#generate_package()<CR>"
endif
ifg:pymode_rope_generate_class_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_generate_class_bind ." :call pymode#rope#generate_class()<CR>"
endif
ifg:pymode_rope_module_to_package_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_module_to_package_bind ." :call pymode#rope#module_to_package()<CR>"
endif
ifg:pymode_rope_autoimport_bind!=""
exe"noremap <silent> <buffer>" .g:pymode_rope_autoimport_bind ." :PymodeRopeAutoImport<CR>"
endif
ifg:pymode_rope_completion&&g:pymode_rope_complete_on_dot
inoremap<silent><buffer>. .<C-R>=pymode#rope#complete_on_dot()<CR>
endif
command!-buffer -nargs=? PymodeRopeNewProjectcallpymode#rope#new(<f-args>)
command!-buffer PymodeRopeUndocallpymode#rope#undo()
command!-buffer PymodeRopeRedocallpymode#rope#redo()
command!-buffer PymodeRopeRenameModulecallpymode#rope#rename_module()
command!-buffer PymodeRopeModuleToPackagecallpymode#rope#module_to_package()
command!-buffer PymodeRopeRegeneratecallpymode#rope#regenerate()
ifg:pymode_rope_autoimport
command!-buffer PymodeRopeAutoImportcallpymode#rope#autoimport(expand('<cword>'))
endif
endif
ifg:pymode_debug
" Redefine functions to be debugged here functions here.
" NOTE: The redraw seems to be necessary to force messages to get echoed to
" the screen. See:
" https://groups.google.com/forum/#!topic/vim_use/EfcXOjq_rKE
" for details.
" silent! redraw!
" TODO: when loading with 'vim -u ./debug.vim' the messages shown in vim
" are unduly cleared. Need a fix.
" Start debbuging environment. {{{
if ! &verbosefile
" Get a system independent temporary filename. The 'marker' variable is
" used to get rid of a null character getting inserted at position.
" substitute() was not able to remove it.
" TODO: see https://superuser.com/questions/935574/get-rid-of-null-character-in-vim-variable
letg:pymode_debug_tempfile=matchstr(
\execute(
\g:pymode_python
\." import os;import tempfile; marker='|';"
\." print(marker, tempfile.gettempdir(), os.sep,"
\."'pymode_debug_file.txt', marker, sep='', end='')"),
\'|\zs.*\ze|')
execute"set verbosefile=" .g:pymode_debug_tempfile
endif
callpymode#debug('Starting debug on:'
\.strftime("\%Y-\%m-\%d\%H:\%M:\%S")
\.' with file' . &verbosefile)
" }}}
" Redefine folding expression. {{{
ifg:pymode_folding
setlocalfoldexpr=pymode#debug#foldingexpr(v:lnum)
endif
callpymode#debug#sysinfo()
" }}}
" Define auto commands for vim. {{{
augroupaugroup_save_issue_commands
autocmd!
autocmdVimLeave*.py |callpymode#debug('Session history:') |silent!history
augroupEND
" }}}
endif