11" Vim indent file
22" Language: Python
33" Author: Akinori Hattori <hattya@gmail.com>
4- " Last Change: 2020-03-16
4+ " Last Change: 2020-10-04
55" License: MIT License
66
77if exists (' b:did_indent' )
@@ -45,7 +45,7 @@ function! GetPEP8PythonIndent() abort
4545
4646 " keep current indent
4747 let l = getline (v: lnum )
48- let colon = l [col (' .' ) - 2 ] == # ' :'
48+ let colon = l [col (' .' )- 2 ] == # ' :'
4949 if s: synmatch (v: lnum , 1 , s: syn_str ) != -1 && s: synmatch (v: lnum - 1 , 1 , s: syn_str ) != -1
5050 " inside string
5151 return -1
@@ -72,7 +72,7 @@ function! GetPEP8PythonIndent() abort
7272 endif
7373 endif
7474 else
75- let ind = strdisplaywidth (l [: pos[1 ] - 1 ])
75+ let ind = strdisplaywidth (l [: pos[1 ]- 1 ])
7676 if s: ml_stmt () && s: is_compound_stmt (l )
7777 let ind += shiftwidth ()
7878 endif
@@ -152,9 +152,7 @@ function! s:searchbrkt(lnum) abort
152152 let pos = getpos (' .' )
153153 try
154154 call cursor (a: lnum , 1 )
155- let skip = " s:synmatch(line('.'), col('.'), s:syn_skip) != -1"
156- let stopline = max ([1 , line (' .' ) - s: maxoff ])
157- return searchpairpos (' [({[]' , ' ' , ' []})]' , ' bnW' , skip , stopline)
155+ return searchpairpos (' [({[]' , ' ' , ' []})]' , ' bnW' , ' s:synmatch(line("."), col("."), s:syn_skip) != -1' , max ([1 , line (' .' ) - s: maxoff ]))
158156 finally
159157 call setpos (' .' , pos)
160158 endtry
@@ -169,11 +167,11 @@ function! s:prevstmt(lnum, pat) abort
169167endfunction
170168
171169function ! s: synmatch (lnum, col , pat) abort
172- return match (map (synstack (a: lnum , a: col ), " synIDattr(v:val, ' name') " ), a: pat )
170+ return match (map (synstack (a: lnum , a: col ), ' synIDattr(v:val, " name") ' ), a: pat )
173171endfunction
174172
175173function ! s: is_compound_stmt (str, ... ) abort
176- return (get ( a: 000 , 0 ) && a: str = ~# ' \v^\s*<%(class|def)>' ) || a: str = ~# ' \v^\s*<%(if|elif|while|for|except|with)>'
174+ return (a: 0 && a: 1 && a: str = ~# ' \v^\s*<%(class|def)>' ) || a: str = ~# ' \v^\s*<%(if|elif|while|for|except|with)>'
177175endfunction
178176
179177function ! s: cont () abort
@@ -189,7 +187,7 @@ function! s:ml_stmt() abort
189187endfunction
190188
191189function ! s: getvar (name, ... ) abort
192- return get (b: , a: name , get (g: , a: name , a: 0 > 0 ? a: 1 : 0 ))
190+ return get (b: , a: name , get (g: , a: name , a: 0 ? a: 1 : 0 ))
193191endfunction
194192
195193let &cpo = s: save_cpo
0 commit comments