aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2024-04-29 23:44:53 +0200
committerChristian Clason <c.clason@uni-graz.at>2024-04-30 00:10:02 +0200
commitb7e5769132e865122fe4bf8588be9ca1820db802 (patch)
treeb64fd2c8896954a7618bb56a87a5167dbe5e6f48 /runtime/doc
parent672138245f7ed41bba516d50e9f8373b7e5036e2 (diff)
downloadrneovim-b7e5769132e865122fe4bf8588be9ca1820db802.tar.gz
rneovim-b7e5769132e865122fe4bf8588be9ca1820db802.tar.bz2
rneovim-b7e5769132e865122fe4bf8588be9ca1820db802.zip
vim-patch:c4d0c8c81245
runtime(java): Improve the recognition of the "indent" method declarations (vim/vim#14659) There is a flaw in the current implementation that has been exacerbated around v5.2. It lies in the recognition of all three indentation styles simultaneously: a tab, two space, and eight space character(s). With it, it is not uncommon to misidentify various constructs as method declarations when they belong to two-space indented members and other blocks of a type and are offset at eight space characters or a tab from the start of the line. For example, ------------------------------------------------------------ class Test { static String hello() { return "hello"; } public static void main(String[] args) { try { if (args.length > 0) { // FIXME: eight spaces. System.out.println(args[0]); } else { // FIXME: a tab. System.out.println(hello()); } } catch (Exception e) { throw new Error(e); } } } ------------------------------------------------------------ ------------------------------------------------------------ :let g:java_highlight_functions = 'indent' :doautocmd Syntax ------------------------------------------------------------ A better approach is to pick an only indentation style out of all supported styles (so either two spaces _or_ eight spaces _or_ a tab). Note that tabs and spaces can still be mixed, only the leading tab or the leading run of spaces matters for the recognition. And there is no reason to not complement the set of valid styles with any number of spaces from 1 to 8, inclusively. Please proceed with the necessary change as follows: - rename from "indent" to "indent2" for a 2-space run; - rename from "indent" to "indent8" for an 8-space run; - continue to have "indent" for a tab run; - define an "indent" variable with a suffix number denoting the preferred amount of indentation for any other run of spaces [1-8]. As before, this alternative style of recognition of method declarations still does not prescribe naming conventions and still cannot recognise method declarations in nested types that are conventionally indented. The proposed changes also follow suit of "style" in stopping the claiming of constructor and enum constant declarations. https://github.com/vim/vim/commit/c4d0c8c81245918632a9d3c2c20a390546fad065 Co-authored-by: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com>
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/syntax.txt22
1 files changed, 16 insertions, 6 deletions
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 9e26e7cdb5..07d360ce29 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1542,15 +1542,25 @@ Function names are not highlighted, as the way to find functions depends on
how you write Java code. The syntax file knows two possible ways to highlight
functions:
-If you write function declarations that are always indented by either
-a tab, 8 spaces or 2 spaces you may want to set >
+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 >
:let java_highlight_functions="indent"
+ :let java_highlight_functions="indent1"
+ :let java_highlight_functions="indent2"
+ :let java_highlight_functions="indent3"
+ :let java_highlight_functions="indent4"
+ :let java_highlight_functions="indent5"
+ :let java_highlight_functions="indent6"
+ :let java_highlight_functions="indent7"
+ :let java_highlight_functions="indent8"
+Note that in terms of 'shiftwidth', this is the leftmost step of indentation.
However, if you follow the Java guidelines about how functions and classes are
-supposed to be named (with respect to upper and lowercase), use >
+supposed to be named (with respect to upper- and lowercase) and there is any
+amount of indentation, you may want to set >
:let java_highlight_functions="style"
-If both options do not work for you, but you would still want function
-declarations to be highlighted create your own definitions by changing the
-definitions in java.vim or by creating your own java.vim which includes the
+If neither setting does work for you, but you would still want function
+declarations to be highlighted, create your own definitions by changing the
+definitions in java.vim or by creating your own java.vim that includes the
original one and then adds the code to highlight functions.
In Java 1.1 the functions System.out.println() and System.err.println() should