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

Commit3e37c3c

Browse files
committed
updated vim files according to2082d0b (various improvements)
1 parent70a39ab commit3e37c3c

File tree

12 files changed

+190
-194
lines changed

12 files changed

+190
-194
lines changed

‎after/ftplugin/python.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ if g:pymode_rope && g:pymode_rope_completion
5353
iftolower(g:pymode_rope_completion_bind)=='<c-space>'
5454
exe"inoremap <silent> <buffer> <Nul> <C-R>=pymode#rope#complete(0)<CR>"
5555
endif
56-
end
56+
endif
5757

58-
end
58+
endif

‎autoload/pymode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ endfunction "}}}
7171
fun!pymode#trim_whitespaces()"{{{
7272
ifg:pymode_trim_whitespaces
7373
let cursor_pos=getpos('.')
74-
silent!%s/\s\+$//
74+
silent!%s/\s\+$//e
7575
callsetpos('.', cursor_pos)
7676
endif
7777
endfunction"}}}

‎autoload/pymode/folding.vim

Lines changed: 63 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
" Python-mode folding functions
2-
32
" Notice that folding is based on single line so complex regular expressions
43
" that take previous line into consideration are not fit for the job.
54

@@ -8,13 +7,13 @@ let s:def_regex = g:pymode_folding_regex
87
lets:blank_regex='^\s*$'
98
" Spyder, a very popular IDE for python has a template which includes
109
" '@author:' ; thus the regex below.
11-
lets:decorator_regex='^\s*@\(author:\)\@!'
12-
lets:doc_begin_regex='^\s*[uUrR]\=\%("""\|''''''\)'
13-
lets:doc_end_regex='\%("""\|''''''\)\s*$'
10+
lets:decorator_regex='^\s*@\(author:\)\@!'
11+
lets:docstring_line_regex='^\s*[uUrR]\=\("""\|''''''\).\+\1\s*$'
12+
lets:docstring_begin_regex='^\s*[uUrR]\=\%("""\|''''''\).*\S'
13+
lets:docstring_end_regex='\%("""\|''''''\)\s*$'
1414
" This one is needed for the while loop to count for opening and closing
1515
" docstrings.
16-
lets:doc_general_regex='\%("""\|''''''\)'
17-
lets:doc_line_regex='^\s*[uUrR]\=\("""\|''''''\).\+\1\s*$'
16+
lets:docstring_general_regex='\%("""\|''''''\)'
1817
lets:symbol=matchstr(&fillchars,'fold:\zs.')" handles multibyte characters
1918
ifs:symbol==''
2019
lets:symbol=''
@@ -24,10 +23,10 @@ endif
2423

2524
fun!pymode#folding#text()" {{{
2625
letfs=v:foldstart
27-
whilegetline(fs)!~s:def_regex&&getline(fs)!~s:doc_begin_regex
26+
whilegetline(fs)!~s:def_regex&&getline(fs)!~s:docstring_begin_regex
2827
letfs=nextnonblank(fs+1)
2928
endwhile
30-
ifgetline(fs)=~s:doc_end_regex&&getline(fs)=~s:doc_begin_regex
29+
ifgetline(fs)=~s:docstring_end_regex&&getline(fs)=~s:docstring_begin_regex
3130
letfs=nextnonblank(fs+1)
3231
endif
3332
letline=getline(fs)
@@ -83,7 +82,11 @@ fun! pymode#folding#expr(lnum) "{{{
8382
if decorated
8483
return'='
8584
else
85+
" The line below may improve folding.
8686
return">".(indent / &shiftwidth+1)
87+
" This was the previous rule. It grouped classes definitions
88+
" together (undesired).
89+
" return indent / &shiftwidth + 1
8790
endif
8891
endif"}}}
8992

@@ -95,80 +98,43 @@ fun! pymode#folding#expr(lnum) "{{{
9598

9699
" Notice that an effect of this is that other docstring matches will not
97100
" be one liners.
98-
ifline=~s:doc_line_regex
101+
ifline=~s:docstring_line_regex
99102
return"="
100103
endif
101104

102-
ifline=~s:doc_begin_regex
103-
" echom 'just entering'
105+
ifline=~s:docstring_begin_regex
104106
ifs:Is_opening_folding(a:lnum)
105-
" echom 'entering at line ' . a:lnum
106107
return">".(indent / &shiftwidth+1)
107108
endif
108109
endif
109-
ifline=~s:doc_end_regex
110+
ifline=~s:docstring_end_regex
110111
if!s:Is_opening_folding(a:lnum)
111-
" echom 'leaving at line ' . a:lnum
112112
return"<".(indent / &shiftwidth+1)
113113
endif
114114
endif"}}}
115115

116-
" Nested Definitions {{{
117-
" Handle nested defs but only for files shorter than
118-
" g:pymode_folding_nest_limit lines due to performance concerns
119-
ifline('$') <g:pymode_folding_nest_limit&&indent(prevnonblank(a:lnum))
120-
let curpos=getpos('.')
121-
try
122-
let last_block=s:BlockStart(a:lnum)
123-
let last_block_indent=indent(last_block)
124-
125-
" Check if last class/def is not indented and therefore can't be
126-
" nested.
127-
if last_block_indent
128-
callcursor(a:lnum,0)
129-
let next_def=searchpos(s:def_regex,'nW')[0]
130-
let next_def_indent= next_def ?indent(next_def) :-1
131-
let last_block_end=s:BlockEnd(last_block)
132-
133-
" If the next def has greater indent than the previous def, it
134-
" is nested one level deeper and will have its own fold. If
135-
" the class/def containing the current line is on the first
136-
" line it can't be nested, and if this block ends on the last
137-
" line, it contains no trailing code that should not be
138-
" folded. Finally, if the next non-blank line after the end of
139-
" the previous def is less indented than the previous def, it
140-
" is not part of the same fold as that def. Otherwise, we know
141-
" the current line is at the end of a nested def.
142-
if next_def_indent<= last_block_indent&& last_block >1&& last_block_end <line('$')
143-
\&&indent(nextnonblank(last_block_end))>= last_block_indent
144-
145-
" Include up to one blank line in the fold
146-
ifgetline(last_block_end)=~s:blank_regex
147-
let fold_end=min([prevnonblank(last_block_end-1), last_block_end])+1
148-
else
149-
let fold_end= last_block_end
150-
endif
151-
ifa:lnum== fold_end
152-
return's1'
153-
else
154-
return'='
155-
endif
156-
endif
157-
endif
158-
finally
159-
callsetpos('.', curpos)
160-
endtry
161-
endif" }}}
116+
" Blocks. {{{
117+
let save_cursor=getcurpos()
118+
ifline!~s:blank_regex
119+
let line_block_start=s:BlockStart(a:lnum)
120+
let prev_line_block_start=s:BlockStart(a:lnum-1)
121+
callsetpos('.', save_cursor)
122+
if line_block_start== prev_line_block_start||a:lnum- line_block_start==1
123+
return'='
124+
elseifindent <indent(prevnonblank(a:lnum-1))
125+
returnindent(line_block_start) / &shiftwidth+1
126+
else
127+
endif
128+
endif
129+
" endif " }}}
162130

163131
" Blank Line {{{
164132
ifline=~s:blank_regex
165133
if prev_line=~s:blank_regex
166-
ifindent(a:lnum+1)==0&& next_line!~s:blank_regex&& next_line!~s:doc_general_regex
134+
ifindent(a:lnum+1)==0&& next_line!~s:blank_regex&& next_line!~s:docstring_general_regex
167135
ifs:Is_opening_folding(a:lnum)
168-
" echom a:lnum
169136
return"="
170137
else
171-
" echom "not " . a:lnum
172138
return0
173139
endif
174140
endif
@@ -182,15 +148,25 @@ fun! pymode#folding#expr(lnum) "{{{
182148

183149
endfunction"}}}
184150

185-
fun!s:BlockStart(lnum)"{{{
151+
fun!s:BlockStart(line_number)"{{{
152+
" Returns the definition statement which encloses the current line.
153+
186154
" Note: Make sure to reset cursor position after using this function.
187-
callcursor(a:lnum,0)
155+
callcursor(a:line_number,0)
188156

189157
" In case the end of the block is indented to a higher level than the def
190158
" statement plus one shiftwidth, we need to find the indent level at the
191159
" bottom of that if/for/try/while/etc. block.
192-
let last_def=searchpos(s:def_regex,'bcnW')[0]
160+
let previous_definition=searchpos(s:def_regex,'bcnW')
161+
if previous_definition!= [0,0]
162+
while previous_definition!= [0,0]&&indent(previous_definition[0])>=indent(a:line_number)
163+
let previous_definition=searchpos(s:def_regex,'bncW')
164+
callcursor(previous_definition[0]-1,0)
165+
endwhile
166+
endif
167+
let last_def= previous_definition[0]
193168
if last_def
169+
callcursor(last_def,0)
194170
let last_def_indent=indent(last_def)
195171
callcursor(last_def,0)
196172
let next_stmt_at_def_indent=searchpos('\v^\s{'.last_def_indent.'}[^[:space:]#]','nW')[0]
@@ -200,19 +176,33 @@ fun! s:BlockStart(lnum) "{{{
200176

201177
" Now find the class/def one shiftwidth lower than the start of the
202178
" aforementioned indent block.
203-
if next_stmt_at_def_indent&& next_stmt_at_def_indent <a:lnum
179+
if next_stmt_at_def_indent&& next_stmt_at_def_indent <a:line_number
204180
let max_indent=max([indent(next_stmt_at_def_indent)- &shiftwidth,0])
205181
else
206-
let max_indent=max([indent(prevnonblank(a:lnum))- &shiftwidth,0])
182+
let max_indent=max([indent(prevnonblank(a:line_number))- &shiftwidth,0])
207183
endif
184+
185+
" " Debug:
186+
208187
returnsearchpos('\v^\s{,'.max_indent.'}(def |class )\w','bcnW')[0]
188+
209189
endfunction"}}}
190+
function!Blockstart(x)
191+
let save_cursor=getcurpos()
192+
returns:BlockStart(a:x)
193+
callsetpos('.', save_cursor)
194+
endfunction
210195

211196
fun!s:BlockEnd(lnum)"{{{
212197
" Note: Make sure to reset cursor position after using this function.
213198
callcursor(a:lnum,0)
214199
returnsearchpos('\v^\s{,'.indent('.').'}\S','nW')[0]-1
215200
endfunction"}}}
201+
function!Blockend(lnum)
202+
let save_cursor=getcurpos()
203+
returns:BlockEnd(a:lnum)
204+
callsetpos('.', save_cursor)
205+
endfunction
216206

217207
function!s:Is_opening_folding(lnum)"{{{
218208
" Helper function to see if docstring is opening or closing
@@ -238,13 +228,11 @@ function! s:Is_opening_folding(lnum) "{{{
238228

239229
let i_line=getline(i)
240230

241-
if i_line=~s:doc_line_regex
242-
" echom "case 00 on line " . i
231+
if i_line=~s:docstring_line_regex
243232
continue
244233
endif
245234

246-
if i_line=~s:doc_begin_regex&& ! has_open_docstring
247-
" echom "case 01 on line " . i
235+
if i_line=~s:docstring_begin_regex&& ! has_open_docstring
248236
" This causes the loop to continue if there is a triple quote which
249237
" is not a docstring.
250238
if extra_docstrings >0
@@ -255,15 +243,13 @@ function! s:Is_opening_folding(lnum) "{{{
255243
let number_of_folding= number_of_folding+1
256244
endif
257245
" If it is an end doc and has an open docstring.
258-
elseif i_line=~s:doc_end_regex&& has_open_docstring
259-
" echom "case 02 on line " . i
246+
elseif i_line=~s:docstring_end_regex&& has_open_docstring
260247
let has_open_docstring=0
261248
let number_of_folding= number_of_folding+1
262249

263-
elseif i_line=~s:doc_general_regex
264-
" echom "extra docstrings on line " . i
250+
elseif i_line=~s:docstring_general_regex
265251
let extra_docstrings= extra_docstrings+1
266-
endif
252+
endif
267253
endfor
268254

269255
calladd(b:fold_cache, number_of_folding%2)

‎autoload/pymode/lint.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ call pymode#tools#loclist#init()
55

66

77
fun!pymode#lint#auto()"{{{
8-
if!pymode#save()
8+
if !pymode#save()
99
return0
1010
endif
1111
PymodePython from pymodeimport auto
@@ -42,7 +42,7 @@ fun! pymode#lint#toggle() "{{{
4242
callpymode#wide_message("Code checking is enabled.")
4343
else
4444
callpymode#wide_message("Code checking is disabled.")
45-
end
45+
endif
4646
endfunction"}}}
4747

4848

‎autoload/pymode/motion.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fun! pymode#motion#vmove(pattern, flags) range "{{{
2121
callcursor(a:firstline,0)
2222
normal!v
2323
callcursor(end)
24-
endfunction"}}}
24+
endfunction"}}}
2525

2626

2727
fun!pymode#motion#pos_le(pos1, pos2)"{{{

‎autoload/pymode/rope.vim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
" Python-mode Rope support
2-
"
2+
3+
if !g:pymode_rope
4+
finish
5+
endif
6+
37
PymodePython from pymodeimport rope
48

59
callpymode#tools#loclist#init()
@@ -12,23 +16,23 @@ endfunction
1216
fun!pymode#rope#complete(dot)
1317
ifpumvisible()
1418
return"\<C-n>"
15-
end
19+
endif
1620
ifa:dot
1721
PymodePython rope.complete(True)
1822
else
1923
PymodePython rope.complete()
20-
end
24+
endif
2125
returnpumvisible() ?"\<C-p>\<Down>" :""
2226
endfunction
2327

2428
fun!pymode#rope#complete_on_dot()"{{{
2529
if!exists("*synstack")
2630
return""
27-
end
31+
endif
2832
for groupinmap(synstack(line('.'),col('.')-1),'synIDattr(v:val, "name")')
2933
for namein ['pythonString','pythonComment','pythonNumber','pythonDocstring']
3034
if group== name
31-
return""
35+
return""
3236
endif
3337
endfor
3438
endfor
@@ -73,7 +77,7 @@ fun! pymode#rope#show_doc()
7377
setlocalnomodified
7478
setlocalfiletype=rst
7579
wincmdp
76-
end
80+
endif
7781
endfunction
7882

7983

‎autoload/pymode/tools/loclist.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ fun! g:PymodeLocList.show() "{{{
7777
callsetwinvar(winnr(),'quickfix_title',self._title .' <' .self._name .'>')
7878
exe num ."wincmd w"
7979
endif
80-
end
80+
endif
8181
endfunction"}}}

‎autoload/pymode/troubleshooting.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fun! pymode#troubleshooting#test() "{{{
1818

1919
callappend('0', ['Pymode diagnostic',
2020
\'===================',
21-
\'VIM:' .v:version .', OS:' . os .', multi_byte:' .has('multi_byte') .', pymode:' .g:pymode_version .', pymode-python:' .g:pymode_python,
21+
\'VIM:' .v:version .', OS:' . os .', multi_byte:' .has('multi_byte') .', pymode:' .g:pymode_version .', pymode-python:' .g:pymode_python,
2222
\''])
2323

2424
if!exists('#filetypeplugin')
@@ -85,5 +85,5 @@ EOF
8585
callappend('$','let pymode_virtualenv =' .string(g:pymode_virtualenv))
8686
callappend('$','let pymode_virtualenv_enabled =' .string(g:pymode_virtualenv_enabled))
8787
callappend('$','let pymode_virtualenv_path =' .string(g:pymode_virtualenv_path))
88-
88+
8989
endfunction"}}}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp