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
77if exists (' b:did_indent' )
@@ -27,10 +27,10 @@ set cpo&vim
2727
2828let s: maxoff = 50
2929let 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\}
3535let s: dedent = ' \v^\s*<%(pass|return|raise|break|continue)>'
3636let 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
179179endfunction
180180
181181function ! 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)>'
183183endfunction
184184
185185function ! s: cont () abort
0 commit comments