Home Explore Blog CI



neovim

21th chunk of `runtime/doc/syntax.txt`
6154d555a19e41a2e629fd5c551ab1b1565e993d3093584c0000000100000fa5
 was
flagged as an error.  Since Java 1.1, this is possible (with anonymous
classes); and, therefore, is no longer marked as an error.  If you prefer the
old way, put the following line into your Vim startup file: >
	:let g:java_mark_braces_in_parens_as_errors = 1

All (exported) public types declared in `java.lang` are always automatically
imported and available as simple names.  To highlight them, use: >
	:let g:java_highlight_java_lang_ids = 1
You can also generate syntax items for other public and protected types and
opt in to highlight some of their names; see |java-package-info-url|.

Headers of indented function declarations can be highlighted (along with parts
of lambda expressions and method reference expressions), but it depends on how
you write Java code.  Two formats are recognized:

1) If you write function declarations that are consistently indented by either
a tab, or a space . . . or eight space character(s), you may want to set one
of >
	:let g:java_highlight_functions = "indent"
	:let g:java_highlight_functions = "indent1"
	:let g:java_highlight_functions = "indent2"
	:let g:java_highlight_functions = "indent3"
	:let g:java_highlight_functions = "indent4"
	:let g:java_highlight_functions = "indent5"
	:let g:java_highlight_functions = "indent6"
	:let g:java_highlight_functions = "indent7"
	:let g:java_highlight_functions = "indent8"
Note that in terms of 'shiftwidth', this is the leftmost step of indentation.

2) However, if you follow the Java guidelines about how functions and types
are supposed to be named (with respect to upper- and lowercase) and there is
any amount of indentation, you may want to set >
	:let g:java_highlight_functions = "style"

In addition, you can combine any value of "g:java_highlight_functions" with >
	:let g:java_highlight_signature = 1
to have the name of a function with its parameter list parens distinctly
highlighted from its type parameters, return type, and formal parameters; and
to have the parameter list parens of a lambda expression with its arrow
distinctly highlighted from its formal parameters or identifiers.

If neither setting does work for you, but you would still want headers of
function declarations to be highlighted, modify the current syntax definitions
or compose new ones.

Higher-order function types can be hard to parse by eye, so uniformly toning
down some of their components may be of value.  Provided that such type names
conform to the Java naming guidelines, you may arrange it with >
	:let g:java_highlight_generics = 1

In Java 1.1, the functions `System.out.println()` and `System.err.println()`
should only be used for debugging.  Consider adding the following definition
in your startup file: >
	:let g:java_highlight_debug = 1
to have the bulk of those statements colored as
	`*Debug`	debugging statements,
and to make some of their own items further grouped and linked:
	`*Special`	as DebugSpecial,
	`*String`	as DebugString,
	`*Boolean`	as DebugBoolean,
	`*Type`		as DebugType,
which are used for special characters appearing in strings, strings proper,
boolean literals, and special instance references (`super`, `this`, `null`),
respectively.

Javadoc is a program that takes special comments out of Java program files and
creates HTML pages.  The standard configuration will highlight this HTML code
similarly to HTML files (see |html.vim|).  You can even add JavaScript and CSS
inside this code (see below).  The HTML rendering and the Markdown rendering
diverge as follows:
  1. The first sentence (all characters up to the first period `.`, which is
     followed by a whitespace character or a line terminator, or up to the
     first block tag, e.g. `@param`, `@return`) is colored as
	`*SpecialComment`	special comments.
  2. The text is colored as
	`*Comment`	comments.
  3. HTML comments are colored as
	`*Special`	special symbols.
  4. The standard Javadoc tags (`@code`, `@see`, etc.) are colored as
	`*Special`	special symbols
     and some of their arguments are colored

Title: Advanced Java Syntax Highlighting Options in Vim
Summary
This section delves into advanced customization options for Java syntax highlighting within Vim. It covers highlighting types from `java.lang`, headers of indented function declarations based on indentation style or Java naming conventions, and using `g:java_highlight_signature` for distinct highlighting of function parameter lists and lambda expressions. It also explains how to tone down higher-order function types with `g:java_highlight_generics` and how to highlight `System.out.println()` and `System.err.println()` calls with `g:java_highlight_debug`. Finally, it describes how Javadoc comments are highlighted, differentiating between HTML and Markdown renderings, and highlighting various elements like special comments, text, HTML comments, and standard Javadoc tags.