Skip to content

Commit 3a276bc

Browse files
committed
Refine
1 parent c29d60f commit 3a276bc

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

indent/python.vim

Lines changed: 7 additions & 7 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: 2023-05-21
4+
" Last Change: 2023-06-24
55
" License: MIT License
66

77
if exists('b:did_indent')
@@ -27,10 +27,10 @@ set cpo&vim
2727

2828
let s:maxoff = 50
2929
let s:compound_stmts = {
30-
\ '^\s*\<elif\>': '\v^\s*<%(if|elif)>',
31-
\ '^\s*\<else\>': '\v^\s*<%(if|elif|for|try|except)>',
32-
\ '^\s*\<except\>': '\v^\s*<%(try|except)>',
33-
\ '^\s*\<finally\>': '\v^\s*<%(try|except|else)>',
30+
\ '\v^\s*<elif>': '\v^\s*<%(if|elif)>',
31+
\ '\v^\s*<else>': '\v^\s*<%(if|elif|for|try|except)>',
32+
\ '\v^\s*<except>': '\v^\s*<%(try|except)>',
33+
\ '\v^\s*<finally>': '\v^\s*<%(try|except|else)>',
3434
\}
3535
let s:dedent = '\v^\s*<%(pass|return|raise|break|continue)>'
3636
let s:ellipsis = '\v^\s*\.{3}\.@!'
@@ -108,7 +108,7 @@ function! GetPEP8PythonIndent() abort
108108
let lnum = s:prevstmt(v:lnum - 1, s:syn_cmt)
109109
let buf = []
110110
while lnum > 0
111-
call insert(buf, matchlist(getline(lnum), '\v^(.{-})\\=$')[1])
111+
call insert(buf, matchstr(getline(lnum), '\v^.{-}\ze\\=$'))
112112
if getline(lnum - 1) =~# s:lcont
113113
let lnum -= 1
114114
elseif s:synmatch(lnum, 1, s:syn_str) != -1
@@ -179,7 +179,7 @@ function! s:synmatch(lnum, col, pat) abort
179179
endfunction
180180

181181
function! s:is_compound_stmt(str, ...) abort
182-
return (a:0 && a:1 && a:str =~# '\v^\s*<%(class|def)>') || a:str =~# '\v^\s*<%(if|elif|while|for|except|with)>'
182+
return (a:0 && a:1 && a:str =~# '\v^\s*<%(def|class)>') || a:str =~# '\v^\s*<%(if|elif|while|for|except|with)>'
183183
endfunction
184184

185185
function! s:cont() abort

0 commit comments

Comments
 (0)