mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
New file google_python_style.vim.
This commit is contained in:
parent
7f003d3547
commit
222e6da82a
36
google_python_style.vim
Normal file
36
google_python_style.vim
Normal file
@ -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"
|
@ -100,7 +100,7 @@
|
||||
<H1>Google Python Style Guide</H1>
|
||||
<p align="right">
|
||||
|
||||
Revision 2.18
|
||||
Revision 2.19
|
||||
</p>
|
||||
|
||||
<address>
|
||||
@ -168,6 +168,10 @@
|
||||
programs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To help you format code correctly, we've created a <a href="google_python_style.vim">settings
|
||||
file for Vim</a>. For Emacs, the default settings should be fine.
|
||||
</p>
|
||||
|
||||
|
||||
</DIV>
|
||||
@ -2025,7 +2029,7 @@ Don'<span class="external"></span>t do this.
|
||||
|
||||
|
||||
<p align="right">
|
||||
Revision 2.18
|
||||
Revision 2.19
|
||||
</p>
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user