Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ one that colors types only where they are types: parameter and return
annotations, `x: T` and `self.attr: T`, class bases, and PEP 695 type
parameters and `type` aliases.

![Before and after: Vim's built-in Python syntax next to python-syntax-enhanced, colorscheme retrobox](https://github.com/user-attachments/assets/e3f130c2-17f7-454b-95ce-0d3ebe375438)
![Before and after: Vim's built-in Python syntax next to python-syntax-enhanced, colorscheme retrobox](https://github.com/user-attachments/assets/fbeb9a79-df8d-4e06-a339-2d4fc1ca70ef)

## Features

Expand Down Expand Up @@ -77,9 +77,9 @@ Run `:helptags ALL` once afterwards to enable `:help python-syntax-enhanced`.

### Compatibility

Tested in CI on Vim 9.2 (Linux, macOS, Windows) and Neovim 0.12, and locally
with Vim 9.1. It replaces Vim's built-in `syntax/python.vim`, so disable other
Python syntax plugins (see [Troubleshooting](#troubleshooting)).
Tested in CI on Vim 9.1 (Linux), Vim 9.2 (macOS, Windows) and Neovim 0.12.
It replaces Vim's built-in `syntax/python.vim`, so disable other Python syntax
plugins (see [Troubleshooting](#troubleshooting)).

In Neovim this is a regular syntax file: it applies when Python is highlighted
by the syntax engine (Neovim's default). If Tree-sitter highlighting is enabled
Expand Down
16 changes: 16 additions & 0 deletions tests/test_syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ call setline(1, [
\ ' pass',
\ 'n = 1 # type: int',
\ 'o = f() # type: ignore[attr-defined]',
\ 'match command:',
\ ' case Point(x=0):',
\ ' pass',
\ 'match = re.match(p, s)',
\ 'def fwd(u: "User") -> "list[User]": ...',
\ 'case = 1',
\ ])
setlocal filetype=python
syntax sync fromstart
Expand Down Expand Up @@ -283,6 +289,16 @@ call s:AssertGroup(105, s:ColOf(105, 'type'), 'pythonComment', '# type: prefix')
call s:AssertGroup(105, s:ColOf(105, 'int'), 'pythonPrimitiveType', '# type: int')
call s:AssertGroup(106, s:ColOf(106, 'ignore'), 'pythonComment', '# type: ignore')

" match/case are keywords only as statements (soft keywords)
call s:AssertGroup(107, s:ColOf(107, 'match'), 'pythonConditional', 'match statement')
call s:AssertGroup(108, s:ColOf(108, 'case'), 'pythonConditional', 'case clause')
call s:AssertNotGroup(110, s:ColOf(110, 'match'), 'pythonConditional', 'match as a variable')
call s:AssertNotGroup(112, s:ColOf(112, 'case'), 'pythonConditional', 'case as a variable')

" Quoted forward references in annotations
call s:AssertGroup(111, s:ColOf(111, '"User"'), 'pythonTypeString', 'forward ref param')
call s:AssertGroup(111, s:ColOf(111, '"list'), 'pythonTypeString', 'forward ref return')

" Palette: builtins get their own color, not the Function link
call s:AssertGroup(4, s:ColOf(4, 'list'), 'pythonBuiltin', 'list() call for palette check')
if synIDattr(synIDtrans(hlID('pythonBuiltin')), 'fg', 'cterm') !=# '139'
Expand Down
Loading