forked from google/styleguide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f003d3
commit 222e6da
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
" Indent Python in the Google way. | ||
|
||
setlocal indentexpr=GetGooglePythonIndent(v:lnum) | ||
|
||
let s:maxoff = 50 " maximum number of lines to look backwards. | ||
|
||
function GetGooglePythonIndent(lnum) | ||
|
||
" Indent inside parens. | ||
" Align with the open paren unless it is at the end of the line. | ||
" E.g. | ||
" open_paren_not_at_EOL(100, | ||
" (200, | ||
" 300), | ||
" 400) | ||
" open_paren_at_EOL( | ||
" 100, 200, 300, 400) | ||
call cursor(a:lnum, 1) | ||
let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW', | ||
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" | ||
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" | ||
\ . " =~ '\\(Comment\\|String\\)$'") | ||
if par_line > 0 | ||
call cursor(par_line, 1) | ||
if par_col != col("$") - 1 | ||
return par_col | ||
endif | ||
endif | ||
|
||
" Delegate the rest to the original function. | ||
return GetPythonIndent(a:lnum) | ||
|
||
endfunction | ||
|
||
let pyindent_nested_paren="&sw*2" | ||
let pyindent_open_paren="&sw*2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters