Commit: runtime(python): highlight the 'lazy' soft keyword

Christian Brabandt <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
runtime(python): highlight the 'lazy' soft keyword

Commit: https://github.com/vim/vim/commit/916809ae1e3e562e0a6220a6e7e08f38b8a23b62
Author: Jon Parise <[email protected]>
Date:   Sun Jul 26 15:20:02 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
index e48346899..c66fee665 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 <[email protected]>
 "		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     "\<type\ze\s\+\h\w*" nextgroup=pythonType skipwhite
 
 " These names are special by convention. While they aren't real keywords,
diff --git a/runtime/syntax/testdir/dumps/python_import_00.dump b/runtime/syntax/testdir/dumps/python_import_00.dump
new file mode 100644
index 000000000..900834837
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/python_import_00.dump
@@ -0,0 +1,20 @@
+>#+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 000000000..4cad61611
--- /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

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wo0nk-00F6xv-Ps%40256bit.org.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.