0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

runtime(java): Optionally recognise _module_ import declarations

Define "g:java_syntax_previews" and include number 476 in
its list to enable this recognition:
------------------------------------------------------------
        let g:java_syntax_previews = [476]
------------------------------------------------------------

Reference:
https://openjdk.org/jeps/476

closes: #15709

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Aliaksei Budavei 2024-09-20 21:37:46 +02:00 committed by Christian Brabandt
parent 35699f1749
commit 50423ab808
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
6 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,4 @@
*syntax.txt* For Vim version 9.1. Last change: 2024 Sep 18 *syntax.txt* For Vim version 9.1. Last change: 2024 Sep 19
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -2176,11 +2176,12 @@ cycles for such a feature to become either integrated into the platform or
withdrawn from this effort. To cater for early adopters, there is optional withdrawn from this effort. To cater for early adopters, there is optional
support in Vim for syntax related preview features that are implemented. You support in Vim for syntax related preview features that are implemented. You
can request it by specifying a list of preview feature numbers as follows: > can request it by specifying a list of preview feature numbers as follows: >
:let g:java_syntax_previews = [455] :let g:java_syntax_previews = [455, 476]
The supported JEP numbers are to be drawn from this table: The supported JEP numbers are to be drawn from this table:
`430`: String Templates [JDK 21] `430`: String Templates [JDK 21]
`455`: Primitive types in Patterns, instanceof, and switch `455`: Primitive types in Patterns, instanceof, and switch
`476`: Module Import Declarations
Note that as soon as the particular preview feature will have been integrated Note that as soon as the particular preview feature will have been integrated
into the Java platform, its entry will be removed from the table and related into the Java platform, its entry will be removed from the table and related

View File

@ -3,7 +3,7 @@
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com> " Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com> " Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
" Repository: https://github.com/zzzyxwvut/java-vim.git " Repository: https://github.com/zzzyxwvut/java-vim.git
" Last Change: 2024 Sep 18 " Last Change: 2024 Sep 19
" Please check :help java.vim for comments on some of the options available. " Please check :help java.vim for comments on some of the options available.
@ -92,6 +92,13 @@ syn keyword javaTypedef this super
syn keyword javaOperator new instanceof syn keyword javaOperator new instanceof
syn match javaOperator "\<var\>\%(\s*(\)\@!" syn match javaOperator "\<var\>\%(\s*(\)\@!"
if s:ff.IsRequestedPreviewFeature(476)
" Module imports can be used in any source file.
syn match javaExternal "\<import\s\+module\>" contains=javaModuleImport
syn keyword javaModuleImport contained module
hi def link javaModuleImport Statement
endif
" Since the yield statement, which could take a parenthesised operand, " Since the yield statement, which could take a parenthesised operand,
" and _qualified_ yield methods get along within the switch block " and _qualified_ yield methods get along within the switch block
" (JLS-17, §3.8), it seems futile to make a region definition for this " (JLS-17, §3.8), it seems futile to make a region definition for this

View File

@ -1,6 +1,6 @@
>/+0#0000e05#ffffff0@1| |T|h|i|s| |m|o|d|u|l|e| |d|e|c|l|a|r|a|t|i|o|n| |b|e|l|o|n|g|s| |t|o| |t|h|e| |s|a|m|p|l|e| |p|r|o|j|e|c|t| |p|u|b|l|i|s|h|e|d| |a|t| +0#0000000&@5 >/+0#0000e05#ffffff0@1| |T|h|i|s| |m|o|d|u|l|e| |d|e|c|l|a|r|a|t|i|o|n| |b|e|l|o|n|g|s| |t|o| |t|h|e| |s|a|m|p|l|e| |p|r|o|j|e|c|t| |p|u|b|l|i|s|h|e|d| |a|t| +0#0000000&@5
|/+0#0000e05&@1| |h|t@1|p|s|:|/@1|g|i|t|h|u|b|.|c|o|m|/|z@2|y|x|w|v|u|t|/|m|o|d|u|l|e|-|i|n|f|o|.|g|i|t| |.| +0#0000000&@25 |/+0#0000e05&@1| |h|t@1|p|s|:|/@1|g|i|t|h|u|b|.|c|o|m|/|z@2|y|x|w|v|u|t|/|m|o|d|u|l|e|-|i|n|f|o|.|g|i|t| |.| +0#0000000&@25
@75 |i+0#e000e06&|m|p|o|r|t| |m+0#af5f00255&|o|d|u|l|e| +0#0000000&|j|a|v|a|.|b|a|s|e|;| @50
|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|S|e|r|v|i|c|e|L|o|a|d|e|r|;| @43 |i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|S|e|r|v|i|c|e|L|o|a|d|e|r|;| @43
@75 @75
|/+0#0000e05&|*@1| +0#0000000&@71 |/+0#0000e05&|*@1| +0#0000000&@71
@ -12,7 +12,7 @@
| +0#0000e05&|*| |@+0#e000e06&|p|r|o|v|i|d|e|s| |o+0#00e0e07&|r|g|.|d|e|m|o|.|i|n|t|e|r|n|a|l|.|T|e|s|t|a|b|l|e| +0#0000000&@35 | +0#0000e05&|*| |@+0#e000e06&|p|r|o|v|i|d|e|s| |o+0#00e0e07&|r|g|.|d|e|m|o|.|i|n|t|e|r|n|a|l|.|T|e|s|t|a|b|l|e| +0#0000000&@35
| +0#0000e05&|*| |@+0#e000e06&|s|e@1| +0#0000e05&|S+0#00e0e07&|e|r|v|i|c|e|L|o|a|d|e|r| +0#0000000&@53 | +0#0000e05&|*| |@+0#e000e06&|s|e@1| +0#0000e05&|S+0#00e0e07&|e|r|v|i|c|e|L|o|a|d|e|r| +0#0000000&@53
| +0#0000e05&|*|/| +0#0000000&@71 | +0#0000e05&|*|/| +0#0000000&@71
|m+0#00e0003&|o|d|u|l|e| +0#0000000&|o|r|g|.|m+0#00e0003&|o|d|u|l|e|.+0#0000000&|i|n|f|o|.|d|e|m|o| @47 |m+0#00e0003&|o|d|u|l|e| +0#0000000&|o|r|g|.|m+0#00e0003&|o|d|u|l|e|.+0#0000000&|i|n|f|o|.|d|e|m|o| |/+0#0000e05&@1| |J|D|K| |2|3|+| |(|-@1|e|n|a|b|l|e|-|p|r|e|v|i|e|w| |-@1|r|e|l|e|a|s|e| |2|3|)|.| +0#0000000&@3
|{| @73 |{| @73
@4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|s+0#00e0003&|t|a|t|i|c| +0#0000000&|j|d|k|.|j|f|r|;| @46 @4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|s+0#00e0003&|t|a|t|i|c| +0#0000000&|j|d|k|.|j|f|r|;| @46
@4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|j|a|v|a|.|b|a|s|e|;| @51 @4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|j|a|v|a|.|b|a|s|e|;| @51

View File

@ -1,5 +1,5 @@
| +0#0000e05#ffffff0|*|/| +0#0000000&@71 | +0#0000e05#ffffff0|*|/| +0#0000000&@71
|m+0#00e0003&|o|d|u|l|e| +0#0000000&|o|r|g|.|m+0#00e0003&|o|d|u|l|e|.+0#0000000&|i|n|f|o|.|d|e|m|o| @47 |m+0#00e0003&|o|d|u|l|e| +0#0000000&|o|r|g|.|m+0#00e0003&|o|d|u|l|e|.+0#0000000&|i|n|f|o|.|d|e|m|o| |/+0#0000e05&@1| |J|D|K| |2|3|+| |(|-@1|e|n|a|b|l|e|-|p|r|e|v|i|e|w| |-@1|r|e|l|e|a|s|e| |2|3|)|.| +0#0000000&@3
|{| @73 |{| @73
@4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|s+0#00e0003&|t|a|t|i|c| +0#0000000&|j|d|k|.|j|f|r|;| @46 @4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|s+0#00e0003&|t|a|t|i|c| +0#0000000&|j|d|k|.|j|f|r|;| @46
@4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|j|a|v|a|.|b|a|s|e|;| @51 @4|r+0#af5f00255&|e|q|u|i|r|e|s| +0#0000000&|j|a|v|a|.|b|a|s|e|;| @51

View File

@ -1,6 +1,6 @@
// This module declaration belongs to the sample project published at // This module declaration belongs to the sample project published at
// https://github.com/zzzyxwvut/module-info.git . // https://github.com/zzzyxwvut/module-info.git .
import module java.base;
import java.util.ServiceLoader; import java.util.ServiceLoader;
/** /**
@ -12,7 +12,7 @@ import java.util.ServiceLoader;
* @provides org.demo.internal.Testable * @provides org.demo.internal.Testable
* @see ServiceLoader * @see ServiceLoader
*/ */
module org.module.info.demo module org.module.info.demo // JDK 23+ (--enable-preview --release 23).
{ {
requires static jdk.jfr; requires static jdk.jfr;
requires java.base; requires java.base;

View File

@ -28,3 +28,5 @@ autocmd_add([{
cmd: 'RestoreFilename()', cmd: 'RestoreFilename()',
once: true, once: true,
}]) }])
g:java_syntax_previews = [476]