From: Jon Parise Date: Sun, 26 Jul 2026 15:20:02 +0000 (+0000) Subject: runtime(python): highlight the 'lazy' soft keyword X-Git-Tag: v9.2.0859~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=916809ae1e3e562e0a6220a6e7e08f38b8a23b62;p=thirdparty%2Fvim.git runtime(python): highlight the 'lazy' soft keyword Lazy imports (PEP 810, to be released in Python 3.15) introduces a `lazy` soft keyword that's recognized when it precedes a `from` or `import` keyword. closes: #20342 Signed-off-by: Jon Parise Signed-off-by: Christian Brabandt --- diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index e483468995..c66fee6652 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -6,6 +6,7 @@ " 2025 Dec 03 by Vim Project: highlight t-strings #18679 " 2026 Jan 26 by Vim Project: highlight constants #18922 " 2026 Mar 11 by Vim Project: fix number performance #19630 +" 2026 May 27 by Vim Project: highlight `lazy` soft keyword (PEP 810) #20342 " Credits: Neil Schemenauer " Dmitry Vasiliev " Rob B @@ -120,6 +121,7 @@ syn keyword pythonAsync async await " for more on this. syn match pythonConditional "^\s*\zscase\%(\s\+.*:.*$\)\@=" syn match pythonConditional "^\s*\zsmatch\%(\s\+.*:\s*\%(#.*\)\=$\)\@=" +syn match pythonInclude "^\s*\zslazy\ze\s\+\%(from\|import\)\>" syn match pythonStatement "\#+0#0000e05#ffffff0| |I|m|p|o|r|t|s| +0#0000000&@65 +|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|s|o|n| @63 +|i+0#e000e06&|m|p|o|r|t| +0#0000000&|o|s|.|p|a|t|h| |a+0#af5f00255&|s| +0#0000000&|p| @55 +|f+0#e000e06&|r|o|m| +0#0000000&|j|s|o|n| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|d|u|m|p|s|,| |l|o|a|d|s| @45 +|f+0#e000e06&|r|o|m| +0#0000000&|j|s|o|n| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|d|u|m|p|s| |a+0#af5f00255&|s| +0#0000000&|d| @47 +|f+0#e000e06&|r|o|m| +0#0000000&|o|s| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|*| @58 +|f+0#e000e06&|r|o|m| +0#0000000&|.| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|s|u|b|m|o|d|u|l|e| @51 +|f+0#e000e06&|r|o|m| +0#0000000&|.+0#00e0e07&@2|p+0#0000000&|k|g|.|s|u|b| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|t|h|i|n|g| @46 +@75 +|#+0#0000e05&| |L|a|z|y| |i|m|p|o|r|t|s| |(|P|E|P| |8|1|0|)| +0#0000000&@50 +|l+0#e000e06&|a|z|y| +0#0000000&|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|s|o|n| @58 +|l+0#e000e06&|a|z|y| +0#0000000&|f+0#e000e06&|r|o|m| +0#0000000&|j|s|o|n| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|d|u|m|p|s| @47 +|l+0#e000e06&|a|z|y| +0#0000000&|f+0#e000e06&|r|o|m| +0#0000000&|.| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|s|u|b|m|o|d|u|l|e| @46 +|l+0#e000e06&|a|z|y| +0#0000000&|f+0#e000e06&|r|o|m| +0#0000000&|c|o|l@1|e|c|t|i|o|n|s| |i+0#e000e06&|m|p|o|r|t| +0#0000000&|O|r|d|e|r|e|d|D|i|c|t| |a+0#af5f00255&|s| +0#0000000&|O|D| @28 +@75 +|#+0#0000e05&| |`|l|a|z|y|`| |i|s| |a| |s|o|f|t| |k|e|y|w|o|r|d| |t|h|a|t|'|s| |o|n|l|y| |r|e|c|o|g|n|i|z|e|d| |i|n| |i|m|p|o|r|t|s| +0#0000000&@14 +|l|a|z|y| |=| |1+0#e000002&| +0#0000000&@66 +|d+0#af5f00255&|e|f| +0#0000000&|l+0#00e0e07&|a|z|y|(+0#0000000&|)|:| |p+0#af5f00255&|a|s@1| +0#0000000&@58 +|~+0#4040ff13&| @73 +| +0#0000000&@56|1|,|1| @10|A|l@1| diff --git a/runtime/syntax/testdir/input/python_import.py b/runtime/syntax/testdir/input/python_import.py new file mode 100644 index 0000000000..4cad61611f --- /dev/null +++ b/runtime/syntax/testdir/input/python_import.py @@ -0,0 +1,18 @@ +# Imports +import json +import os.path as p +from json import dumps, loads +from json import dumps as d +from os import * +from . import submodule +from ...pkg.sub import thing + +# Lazy imports (PEP 810) +lazy import json +lazy from json import dumps +lazy from . import submodule +lazy from collections import OrderedDict as OD + +# `lazy` is a soft keyword that's only recognized in imports +lazy = 1 +def lazy(): pass