[vim/vim] runtime(python): highlight 'self' and 'cls' (PR #17968)

9 views
Skip to first unread message

Jon Parise

unread,
Aug 11, 2025, 6:57:32 AMAug 11
to vim/vim, Subscribed

These are special names by convention, and giving them distinct highlighting is a nice visual cue (using Identifier by default).

This group is named 'pythonClassVar' to match the name used by python-syntax. Some third-party color schemes are aware of this name and customized their colors accordingly.


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

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

Commit Summary

  • 22a191e runtime(python): highlight 'self' and 'cls'

File Changes

(1 file)

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/17968@github.com>

Jon Parise

unread,
Aug 11, 2025, 7:00:43 AMAug 11
to vim/vim, Subscribed
jparise left a comment (vim/vim#17968)

@zvezdan as discussed, I chose the simplest approach that still allows users to re-link or clear this new highlight group.


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/17968/c3174234726@github.com>

Zvezdan Petkovic

unread,
Aug 12, 2025, 2:48:43 AMAug 12
to vim/vim, Subscribed

@zvezdan commented on this pull request.

Looks good.
I would just make a location change in the file and add a small comment.


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/17968/review/3108795975@github.com>

Zvezdan Petkovic

unread,
Aug 12, 2025, 2:50:41 AMAug 12
to vim/vim, Subscribed

@zvezdan commented on this pull request.

Looks good.
I would just make a location change and add a comment.


In runtime/syntax/python.vim:

> @@ -105,6 +105,7 @@ syn keyword pythonOperator	and in is not or
 syn keyword pythonException	except finally raise try
 syn keyword pythonInclude	from import
 syn keyword pythonAsync		async await
+syn keyword pythonClassVar	self cls

I wouldn't put them in this group of real keywords because they wouldn't be in the output of the command above in the comment (line 95).
Perhaps moving them below soft keywords with an appropriate comment that they are de facto convention, rather than the real keywords. After all, we could call them Bob and Fred and the result would be the same. We don't do that because it's not a convention and wouldn't be nice to the code maintainers. 🙂


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/17968/review/3108801600@github.com>

Jon Parise

unread,
Aug 12, 2025, 11:42:05 AMAug 12
to vim/vim, Push

@jparise pushed 1 commit.

  • b9e5404 runtime(python): give pythonClassVar its own section


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/17968/before/22a191e1fe7092aeddba76a8a057084166abeb9a/after/b9e5404cfd2ba160bc0dab784370ed8ea8249fe2@github.com>

Jon Parise

unread,
Aug 12, 2025, 11:42:58 AMAug 12
to vim/vim, Subscribed

@jparise commented on this pull request.


In runtime/syntax/python.vim:

> @@ -105,6 +105,7 @@ syn keyword pythonOperator	and in is not or
 syn keyword pythonException	except finally raise try
 syn keyword pythonInclude	from import
 syn keyword pythonAsync		async await
+syn keyword pythonClassVar	self cls

Good idea. I relocated them with a comment in the latest commit (b9e5404).


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/17968/review/3111510856@github.com>

Zvezdan Petkovic

unread,
Aug 13, 2025, 12:36:08 AMAug 13
to vim/vim, Subscribed

@zvezdan approved this pull request.

Looks good.
Thanks!


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/17968/review/3113895946@github.com>

Christian Brabandt

unread,
Aug 13, 2025, 4:34:02 PMAug 13
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#17968)

thanks


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/17968/c3185664923@github.com>

Christian Brabandt

unread,
Aug 13, 2025, 4:39:09 PMAug 13
to vim/vim, Subscribed

Closed #17968 via 1ee1d9b.


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/17968/issue_event/19145217288@github.com>

Reply all
Reply to author
Forward
0 new messages