Skip to content

Commit d722133

Browse files
committed
Refine
1 parent 4511cc7 commit d722133

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

indent/python.vim

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

77
if 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
169167
endfunction
170168

171169
function! 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)
173171
endfunction
174172

175173
function! 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)>'
177175
endfunction
178176

179177
function! s:cont() abort
@@ -189,7 +187,7 @@ function! s:ml_stmt() abort
189187
endfunction
190188

191189
function! 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))
193191
endfunction
194192

195193
let &cpo = s:save_cpo

test/.themisrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ call themis#helper('command').with(s:assert)
33

44
set debug=throw
55

6-
syntax on
76
filetype plugin indent on
7+
syntax on
88

99
function! Insert(cmds)
10-
execute 'normal! i' . a:cmds . "\<Esc>"
10+
execute 'normal! i' . a:cmds
1111
return join(getline(1, '$'), "\n")
1212
endfunction
1313

0 commit comments

Comments
 (0)