[vim/vim] consolidate python indent config (PR #10929)

31 views
Skip to first unread message

lacygoill

unread,
Aug 16, 2022, 6:45:10 PM8/16/22
to vim/vim, Subscribed

The current python indent plugin relies on 5 global variables for its config:

g:pyindent_continue
g:pyindent_disable_parentheses_indenting
g:pyindent_nested_paren
g:pyindent_open_paren
g:pyindent_searchpair_timeout

This PR consolidates all of them inside a single g:pyindent dictionary variable.


Also, the current plugin indents a multiline dictionary such as:

dict = {
'a': 1,
}

Like this:

dict = {
    'a': 1,
    }

Some people might prefer this:

dict = {
    'a': 1,
}

This is given as an alternative in PEP8.
It seems to be the only way in the Google python style guide.
And it seems to be the default way for the black Python formatter.

This PR adds a new key inside g:pyindent: closed_paren_align_last_line. By default it's true to preserve the old way of aligning closing parens. But when reset to false, the user can get the other type of alignment.

The help is updated, and a test is included.

I'm not sure how reliable it is yet.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/10929

Commit Summary

  • 12e4599 consolidate python indent config

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929@github.com>

lacygoill

unread,
Aug 16, 2022, 6:48:11 PM8/16/22
to vim/vim, Subscribed

Unrelated, but why is the Vim comment leader used inconsistently in html.in?

In particular, there are 2 START_INDENT lines in this file; one is commented with ", the other with %. To be consistent, I think every " used as a comment leader should be replaced with a % character:

diff --git a/runtime/indent/testdir/html.in b/runtime/indent/testdir/html.in
index b62c67ddb..4783a096d 100644
--- a/runtime/indent/testdir/html.in
+++ b/runtime/indent/testdir/html.in
@@ -1,7 +1,7 @@
-" vim: set ft=html sw=4 ts=8 :
+% vim: set ft=html sw=4 ts=8 :
 
 
-" START_INDENT
+% START_INDENT
 <html>
     <body>
 <style>
@@ -50,7 +50,7 @@ text
     </body>
 </html>
 
-" END_INDENT
+% END_INDENT
 
 % START_INDENT
 % INDENT_EXE let g:html_indent_style1 = "inc"


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1217246840@github.com>

lacygoill

unread,
Aug 16, 2022, 7:05:18 PM8/16/22
to vim/vim, Push

@lacygoill pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/push/10746995111@github.com>

Doug Kearns

unread,
Aug 17, 2022, 2:56:27 AM8/17/22
to vim/vim, Subscribed

It might be a good idea to take this opportunity to change the prefix to use the filetype prefix as is generally done for these config variables. Both the syntax file and ftplugin are using the python_ prefix. So, pyindent becomes python_indent.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1217536614@github.com>

Bram Moolenaar

unread,
Aug 17, 2022, 8:33:00 AM8/17/22
to vim/vim, Subscribed


> Unrelated, but why is the Vim comment leader used inconsistently in `html.in`?

>
> In particular, there are 2 `START_INDENT` lines in this file; one is
> commented with `"`, the other with `%`. To be consistent, I think

> every `"` used as a comment leader should be replaced with a `%`
> character:

It should not matter, but keeping it consistent is nicer.


--
I'm sure that I asked CBuilder to do a "full" install. Looks like I got
a "fool" install, instead. Charles E Campbell, Jr, PhD


/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1217948264@github.com>

lacygoill

unread,
Aug 17, 2022, 10:44:58 AM8/17/22
to vim/vim, Push

@lacygoill pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/push/10754234172@github.com>

lacygoill

unread,
Aug 17, 2022, 10:47:05 AM8/17/22
to vim/vim, Push

@lacygoill pushed 1 commit.

  • fe15ad0 update wrong documentation

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/push/10754258987@github.com>

lacygoill

unread,
Aug 17, 2022, 10:48:25 AM8/17/22
to vim/vim, Push

@lacygoill pushed 1 commit.

  • 38db3db remove extra word in documentation

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/push/10754273989@github.com>

lacygoill

unread,
Aug 17, 2022, 10:53:50 AM8/17/22
to vim/vim, Subscribed

It might be a good idea to take this opportunity to change the prefix to the filetype name as is generally done for these config variables. Both the syntax file and ftplugin are using the python_ prefix. So, pyindent becomes python_indent.

OK, I replaced the pyindent_ prefix with the python_indent dictionary.


It should not matter, but keeping it consistent is nicer.

Maybe it doesn't matter here, but I think I was confused and thought it was OK to use " as a comment leader in the python tests. It turns out that we can't because then the syntax – which the indent plugin sometimes inspects – gets wrong (synIDattr() might unexpectedly return pythonQuotes instead of pythonString).


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1218119829@github.com>

codecov[bot]

unread,
Aug 17, 2022, 1:54:00 PM8/17/22
to vim/vim, Subscribed

Codecov Report

Merging #10929 (38db3db) into master (e1f3fd1) will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@

##           master   #10929      +/-   ##

==========================================

- Coverage   82.70%   82.69%   -0.01%     

==========================================

  Files         148      148              

  Lines      173738   173744       +6     

  Branches    39256    39258       +2     

==========================================

  Hits       143684   143684              

- Misses      17463    17471       +8     

+ Partials    12591    12589       -2     
Flag Coverage Δ
huge-clang-none 82.69% <ø> (-0.01%) ⬇️
linux 82.69% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/profiler.c 82.55% <0.00%> (-0.70%) ⬇️
src/message.c 81.09% <0.00%> (-0.25%) ⬇️
src/term.c 73.72% <0.00%> (-0.16%) ⬇️
src/terminal.c 82.14% <0.00%> (-0.10%) ⬇️
src/gui_gtk_x11.c 51.72% <0.00%> (-0.10%) ⬇️
src/regexp_nfa.c 88.89% <0.00%> (-0.08%) ⬇️
src/vim9expr.c 91.25% <0.00%> (-0.01%) ⬇️
src/misc2.c 86.71% <0.00%> (ø)
src/buffer.c 84.13% <0.00%> (ø)
src/normal.c 90.31% <0.00%> (ø)
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1218326032@github.com>

lacygoill

unread,
Aug 19, 2022, 3:34:44 PM8/19/22
to vim/vim, Subscribed

I have no idea how to resolve the conflicts which started after the latest update of the runtime files. I'll open a new PR later.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1221031650@github.com>

lacygoill

unread,
Aug 19, 2022, 3:34:46 PM8/19/22
to vim/vim, Subscribed

Closed #10929.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/issue_event/7224630185@github.com>

Bram Moolenaar

unread,
Oct 11, 2022, 3:45:57 AM10/11/22
to vim/vim, Subscribed


> The current python indent plugin relies on 5 global variables for its config:
>
> g:pyindent_continue
> g:pyindent_disable_parentheses_indenting
> g:pyindent_nested_paren
> g:pyindent_open_paren
> g:pyindent_searchpair_timeout
>
> This PR consolidates all of them inside a single `g:pyindent`
> dictionary variable.

That sounds good. I see backwards compatibility is also taken care of.
Just one thing that might be a problem for (very few) users: if one of
the old variables is changed after the first invocation, then the new
value won't be picked up. Perhaps it's better to not modify the
g:pyindent variable, and instead fill s:pyindent each time it is used.


--
DENNIS: Listen -- strange women lying in ponds distributing swords is no
basis for a system of government. Supreme executive power derives
from a mandate from the masses, not from some farcical aquatic
ceremony.
The Quest for the Holy Grail (Monty Python)


/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10929/c1274237027@github.com>

Reply all
Reply to author
Forward
0 new messages