|
3 | 3 | " Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
|
4 | 4 | " Former Maintainer: Claudio Fleiner <[email protected]>
|
5 | 5 | " Repository: https://github.com/zzzyxwvut/java-vim.git
|
6 |
| -" Last Change: 2024 Apr 22 |
| 6 | +" Last Change: 2024 Apr 28 |
7 | 7 |
|
8 | 8 | " Please check :help java.vim for comments on some of the options available.
|
9 | 9 |
|
@@ -292,10 +292,23 @@ syn cluster javaTop add=javaString,javaStrTempl,javaCharacter,javaNumber,javaSpe
|
292 | 292 | if exists("java_highlight_functions")
|
293 | 293 | syn cluster javaFuncParams contains=javaAnnotation,@javaClasses,javaType,javaVarArg,javaComment,javaLineComment
|
294 | 294 |
|
295 |
| - if java_highlight_functions == "indent" |
| 295 | + if java_highlight_functions =~# '^indent[1-8]\=$' |
| 296 | + let s:last = java_highlight_functions[-1 :] |
| 297 | + let s:indent = s:last != 't' ? repeat("\x20", s:last) : "\t" |
296 | 298 | syn cluster javaFuncParams add=javaScopeDecl,javaConceptKind,javaStorageClass,javaExternal
|
297 |
| - syn match javaFuncDef "^\%(\t\| \%( \{6\}\)\=\)\K\%(\k\|[ .,<>\[\]]\)*([^-+*/]*)" contains=@javaFuncParams |
298 |
| - syn region javaFuncDef start=+^\%(\t\| \%( \{6\}\)\=\)\K\%(\k\|[ .,<>\[\]]\)*([^-+*/]*,\s*+ end=+)+ contains=@javaFuncParams |
| 299 | + " Try to not match other type members, initialiser blocks, enum |
| 300 | + " constants (JLS-17, §8.9.1), and constructors (JLS-17, §8.1.7): |
| 301 | + " at any _conventional_ indentation, skip over all fields with |
| 302 | + " "[^=]*", all records with "\<record\s", and let the "*Skip*" |
| 303 | + " definitions take care of constructor declarations and enum |
| 304 | + " constants (with no support for @Foo(value = "bar")). |
| 305 | + exec 'syn region javaFuncDef start=+^' . s:indent . '\%(<[^>]\+>\+\s\+\|\%(\%(@\%(\K\k*\.\)*\K\k*\>\)\s\+\)\+\)\=\%(\<\K\k*\>\.\)*\K\k*\>[^=]*\%(\<record\)\@6<!\s\K\k*\s*(+ end=+)+ contains=@javaFuncParams' |
| 306 | + " As long as package-private constructors cannot be matched with |
| 307 | + " javaFuncDef, do not look with javaConstructorSkipDeclarator for |
| 308 | + " them. |
| 309 | + exec 'syn match javaConstructorSkipDeclarator transparent +^' . s:indent . '\%(\%(@\%(\K\k*\.\)*\K\k*\>\)\s\+\)*p\%(ublic\|rotected\|rivate\)\s\+\%(<[^>]\+>\+\s\+\)\=\K\k*\s*\ze(+ contains=javaAnnotation,javaScopeDecl' |
| 310 | + exec 'syn match javaEnumSkipArgumentativeConstant transparent +^' . s:indent . '\%(\%(@\%(\K\k*\.\)*\K\k*\>\)\s\+\)*\K\k*\s*\ze(+ contains=javaAnnotation' |
| 311 | + unlet s:indent s:last |
299 | 312 | else
|
300 | 313 | " This is the "style" variant (:help ft-java-syntax).
|
301 | 314 | syn cluster javaFuncParams add=javaScopeDecl,javaConceptKind,javaStorageClass,javaExternal
|
|
0 commit comments