[vim/vim] improper Python syntax highlight (Issue #20160)

1 view
Skip to first unread message

barbarianguitar

unread,
11:54 AM (9 hours ago) 11:54 AM
to vim/vim, Subscribed
barbarianguitar created an issue (vim/vim#20160)

if there is 'type' in a variable name, e.g., 'typeids', 'type' would be improperly highlighted.

2026-05-07.11.45.59.png (view on web)

replacing line 325, runtime/syntax/python.vim

syn match   pythonBuiltin	"\<type\>\ze\(\s\+\h\w*\)\@!"

with:

syn match pythonBuiltin "\<type\>\ze[^a-zA-Z0-9_]"

should solve this problem

currently I'm using ~/.vim/after/syntax/python.vim to override.

syntax clear pythonBuiltin
if !exists("python_no_builtin_highlight")
  " built-in constants
  " 'False', 'True', and 'None' are also reserved words in Python 3
  syn keyword pythonBuiltin False True None
  syn keyword pythonBuiltin NotImplemented Ellipsis __debug__
  " constants added by the `site` module
  syn keyword pythonBuiltin quit exit copyright credits license
  " built-in functions
  syn keyword pythonBuiltin abs all any ascii bin bool breakpoint bytearray
  syn keyword pythonBuiltin bytes callable chr classmethod compile complex
  syn keyword pythonBuiltin delattr dict dir divmod enumerate eval exec
  syn keyword pythonBuiltin filter float format frozenset getattr globals
  syn keyword pythonBuiltin hasattr hash help hex id input int isinstance
  syn keyword pythonBuiltin issubclass iter len list locals map max
  syn keyword pythonBuiltin memoryview min next object oct open ord pow
  syn keyword pythonBuiltin print property range repr reversed round set
  syn keyword pythonBuiltin setattr slice sorted staticmethod str sum super
  syn keyword pythonBuiltin tuple vars zip __import__
  " only match `type` as a builtin when it's not followed by an identifier
  syn match pythonBuiltin "\<type\>\ze[^a-zA-Z0-9_]"                         
  " avoid highlighting attributes as builtins
  syn match   pythonAttribute   /\.\h\w*/hs=s+1
    \ contains=ALLBUT,pythonBuiltin,pythonClass,pythonFunction,pythonType,pythonAsync
    \ transparent
  " the ellipsis literal `...` can be used in multiple syntactic contexts
  syn match   pythonEllipsis    "\.\@1<!.\.\.\ze\.\@!" display
endif


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160@github.com>

dkearns

unread,
12:30 PM (8 hours ago) 12:30 PM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#20160)

The \> atom can only match at a word boundary (as defined by 'iskeyword') which you're attempting to recreate with [^a-zA-Z0-9_]. You must have a butchered 'iskeyword' setting.

What happens when you edit the file with vim --clean?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4399003029@github.com>

barbarianguitar

unread,
12:45 PM (8 hours ago) 12:45 PM
to vim/vim, Subscribed
barbarianguitar left a comment (vim/vim#20160)

I got this when I edit the file with vim --clean

2026-05-08.12.36.11.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4399121283@github.com>

dkearns

unread,
1:01 PM (8 hours ago) 1:01 PM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#20160)

Does the following return anything unusual?

:verbose set iskeyword? | syn iskeyword


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4399237292@github.com>

barbarianguitar

unread,
1:10 PM (8 hours ago) 1:10 PM
to vim/vim, Subscribed
barbarianguitar left a comment (vim/vim#20160)

clean mode:

2026-05-08.1.03.41.png (view on web)

normal :

2026-05-08.1.03.59.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4399305418@github.com>

dkearns

unread,
1:27 PM (7 hours ago) 1:27 PM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#20160)

Are you running with the latest version of the syntax file? You didn't give any version info.

This issue appears to have been fixed in commit 900c747


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4399464704@github.com>

barbarianguitar

unread,
2:50 PM (6 hours ago) 2:50 PM
to vim/vim, Subscribed
barbarianguitar left a comment (vim/vim#20160)

I tried the latest version and it was fixed!

I was using macOS's default VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Feb 21 2026 19:49:52) rather than HomeBrew version or compile from source code, that's why I didn't upgrade in time. This should be an issue with Apple.

Anyway thanks for your help!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4400110608@github.com>

Christian Brabandt

unread,
2:58 PM (6 hours ago) 2:58 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20160)

please report as bug to Apple then.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20160/4400170831@github.com>

Christian Brabandt

unread,
2:58 PM (6 hours ago) 2:58 PM
to vim/vim, Subscribed

Closed #20160 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/20160/issue_event/25275700335@github.com>

Reply all
Reply to author
Forward
0 new messages