jdtls
https://projects.eclipse.org/projects/eclipse.jdt.ls
Language server for Java.
See project page for installation instructions.
Due to the nature of java, the settings for eclipse jdtls cannot be automatically inferred. Please set the following environmental variables to match your installation. You can set these locally for your project with the help of direnv. Note version numbers will change depending on your project's version of java, your version of eclipse, and in the case of JDTLS_CONFIG, your OS.
export JAR=/path/to/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_1.6.0.v20200915-1508.jar
export GRADLE_HOME=$HOME/gradle
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::")
export JDTLS_CONFIG=/path/to/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_linux
export WORKSPACE=$HOME/workspace
Setup
require'lspconfig'.jdtls.setup{}
Default values
cmd = { "/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/java", "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dlog.protocol=true", "-Dlog.level=ALL", "-Xms1g", "-Xmx2G", "-jar", "vim.NIL", "-configuration", "vim.NIL", "-data", "vim.NIL", "--add-modules=ALL-SYSTEM", "--add-opens java.base/java.util=ALL-UNNAMED", "--add-opens java.base/java.lang=ALL-UNNAMED" }
cmd_env = {
GRADLE_HOME = "/usr/share/gradle-7.1.1",
JAR = vim.NIL
}
filetypes = { "java" }
handlers = {
["language/status"] = <function 1>,
["textDocument/codeAction"] = <function 2>,
["textDocument/rename"] = <function 3>,
["workspace/applyEdit"] = <function 4>
}
init_options = {
jvm_args = {},
workspace = "/home/runner/workspace"
}
root_dir = function(fname)
for _, patterns in ipairs(root_files) do
local root = util.root_pattern(unpack(patterns))(fname)
if root then
return root
end
end
return vim.fn.getcwd()
end,
Available settings
java.autobuild.enabled
- Type:
boolean
- Default:
true
Enable\/disable the \'auto build\'
java.codeGeneration.generateComments
- Type:
boolean
Generate method comments when generating the methods.
java.codeGeneration.hashCodeEquals.useInstanceof
- Type:
boolean
Use \'instanceof\' to compare types when generating the hashCode and equals methods.
java.codeGeneration.hashCodeEquals.useJava7Objects
- Type:
boolean
Use Objects.hash and Objects.equals when generating the hashCode and equals methods. This setting only applies to Java 7 and higher.
java.codeGeneration.insertionLocation
- Type:
enum { "afterCursor", "beforeCursor", "lastMember" }
- Default:
"afterCursor"
Specifies the insertion location of the code generated by source actions.
java.codeGeneration.toString.codeStyle
- Type:
enum { "STRING_CONCATENATION", "STRING_BUILDER", "STRING_BUILDER_CHAINED", "STRING_FORMAT" }
- Default:
"STRING_CONCATENATION"
The code style for generating the toString method.
java.codeGeneration.toString.limitElements
- Type:
integer
- Default:
0
Limit number of items in arrays\/collections\/maps to list\, if 0 then list all.
java.codeGeneration.toString.listArrayContents
- Type:
boolean
- Default:
true
List contents of arrays instead of using native toString().
java.codeGeneration.toString.skipNullValues
- Type:
boolean
Skip null values when generating the toString method.
java.codeGeneration.toString.template
- Type:
string
- Default:
"${object.className} [${member.name()}=${member.value}, ${otherMembers}]"
The template for generating the toString method.
java.codeGeneration.useBlocks
- Type:
boolean
Use blocks in \'if\' statements when generating the methods.
java.completion.enabled
- Type:
boolean
- Default:
true
Enable\/disable code completion support
java.completion.favoriteStaticMembers
- Type:
array
- Default:
{ "org.junit.Assert.*", "org.junit.Assume.*", "org.junit.jupiter.api.Assertions.*", "org.junit.jupiter.api.Assumptions.*", "org.junit.jupiter.api.DynamicContainer.*", "org.junit.jupiter.api.DynamicTest.*", "org.mockito.Mockito.*", "org.mockito.ArgumentMatchers.*", "org.mockito.Answers.*" }
Defines a list of static members or types with static members. Content assist will propose those static members even if the import is missing.
java.completion.filteredTypes
- Type:
array
- Default:
{ "java.awt.*", "com.sun.*", "sun.*" }
Defines the type filters. All types whose fully qualified name matches the selected filter strings will be ignored in content assist or quick fix proposals and when organizing imports. For example \'java.awt.*\' will hide all types from the awt packages.
java.completion.guessMethodArguments
- Type:
boolean
When set to true\, method arguments are guessed when a method is selected from as list of code assist proposals.
java.completion.importOrder
- Type:
array
- Default:
{ "java", "javax", "com", "org" }
Defines the sorting order of import statements. A package or type name prefix (e.g. \'org.eclipse\') is a valid entry. An import is always added to the most specific group.
java.completion.maxResults
- Type:
integer
- Default:
0
null
java.completion.overwrite
- Type:
boolean
- Default:
true
When set to true\, code completion overwrites the current text. When set to false\, code is simply added instead.
java.configuration.checkProjectSettingsExclusions
- Type:
boolean
- Default:
true
Controls whether to exclude extension-generated project settings files (.project\, .classpath\, .factorypath\, .settings\/) from the file explorer.
java.configuration.maven.globalSettings
- Type:
string
- Default:
vim.NIL
Path to Maven\'s global settings.xml
java.configuration.maven.notCoveredPluginExecutionSeverity
- Type:
enum { "ignore", "warning", "error" }
- Default:
"warning"
Specifies severity if the plugin execution is not covered by Maven build lifecycle.
java.configuration.maven.userSettings
- Type:
string
- Default:
vim.NIL
Path to Maven\'s user settings.xml
java.configuration.runtimes
- Type:
array
- Default:
{}
- Array items:
Map Java Execution Environments to local JDKs.
java.configuration.updateBuildConfiguration
- Type:
enum { "disabled", "interactive", "automatic" }
- Default:
"interactive"
Specifies how modifications on build files update the Java classpath\/configuration
java.contentProvider.preferred
- Type:
string
- Default:
vim.NIL
Preferred content provider (a 3rd party decompiler id\, usually)
java.eclipse.downloadSources
- Type:
boolean
Enable\/disable download of Maven source artifacts for Eclipse projects.
java.errors.incompleteClasspath.severity
- Type:
enum { "ignore", "info", "warning", "error" }
- Default:
"warning"
Specifies the severity of the message when the classpath is incomplete for a Java file
java.foldingRange.enabled
- Type:
boolean
- Default:
true
Enable\/disable smart folding range support. If disabled\, it will use the default indentation-based folding range provided by VS Code.
java.format.comments.enabled
- Type:
boolean
- Default:
true
Includes the comments during code formatting.
java.format.enabled
- Type:
boolean
- Default:
true
Enable\/disable default Java formatter
java.format.onType.enabled
- Type:
boolean
- Default:
true
Enable\/disable automatic block formatting when typing `\;`\, `\<enter>` or `}`
java.format.settings.profile
- Type:
string
- Default:
vim.NIL
Optional formatter profile name from the Eclipse formatter settings.
java.format.settings.url
- Type:
string
- Default:
vim.NIL
null
java.home
- Type:
string|null
- Default:
vim.NIL
Specifies the folder path to the JDK (11 or more recent) used to launch the Java Language Server. On Windows\, backslashes must be escaped\, i.e. \"java.home\"\:\"C\:\\Program Files\\Java\\jdk11.0_8\"
java.implementationsCodeLens.enabled
- Type:
boolean
Enable\/disable the implementations code lens.
java.import.exclusions
- Type:
array
- Default:
{ "**/node_modules/**", "**/.metadata/**", "**/archetype-resources/**", "**/META-INF/maven/**" }
Configure glob patterns for excluding folders. Use `!` to negate patterns to allow subfolders imports. You have to include a parent directory. The order is important.
java.import.gradle.arguments
- Type:
string
- Default:
vim.NIL
Arguments to pass to Gradle.
java.import.gradle.enabled
- Type:
boolean
- Default:
true
Enable\/disable the Gradle importer.
java.import.gradle.home
- Type:
string
- Default:
vim.NIL
Use Gradle from the specified local installation directory or GRADLE_HOME if the Gradle wrapper is missing or disabled and no \'java.import.gradle.version\' is specified.
java.import.gradle.java.home
- Type:
string
- Default:
vim.NIL
The location to the JVM used to run the Gradle daemon.
java.import.gradle.jvmArguments
- Type:
string
- Default:
vim.NIL
JVM arguments to pass to Gradle.
java.import.gradle.offline.enabled
- Type:
boolean
Enable\/disable the Gradle offline mode.
java.import.gradle.user.home
- Type:
string
- Default:
vim.NIL
Setting for GRADLE_USER_HOME.
java.import.gradle.version
- Type:
string
- Default:
vim.NIL
Use Gradle from the specific version if the Gradle wrapper is missing or disabled.
java.import.gradle.wrapper.enabled
- Type:
boolean
- Default:
true
Use Gradle from the \'gradle-wrapper.properties\' file.
java.import.maven.enabled
- Type:
boolean
- Default:
true
Enable\/disable the Maven importer.
java.imports.gradle.wrapper.checksums
- Type:
array
- Default:
{}
- Array items:
Defines allowed\/disallowed SHA-256 checksums of Gradle Wrappers
java.jdt.ls.vmargs
- Type:
string|null
- Default:
"-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m"
Specifies extra VM arguments used to launch the Java Language Server. Eg. use `-XX\:+UseParallelGC -XX\:GCTimeRatio\=4 -XX\:AdaptiveSizePolicyWeight\=90 -Dsun.zip.disableMemoryMapping\=true -Xmx1G -Xms100m ` to optimize memory usage with the parallel garbage collector
java.maven.downloadSources
- Type:
boolean
Enable\/disable download of Maven source artifacts as part of importing Maven projects.
java.maven.updateSnapshots
- Type:
boolean
Force update of Snapshots\/Releases.
java.maxConcurrentBuilds
- Type:
integer
- Default:
1
Max simultaneous project builds
java.progressReports.enabled
- Type:
boolean
- Default:
true
[Experimental] Enable\/disable progress reports from background processes on the server.
java.project.importHint
- Type:
boolean
- Default:
true
Enable\/disable the server-mode switch information\, when Java projects import is skipped on startup.
java.project.importOnFirstTimeStartup
- Type:
enum { "disabled", "interactive", "automatic" }
- Default:
"automatic"
Specifies whether to import the Java projects\, when opening the folder in Hybrid mode for the first time.
java.project.outputPath
- Type:
string|null
- Default:
""
null
java.project.referencedLibraries
- Type:
array|object
- Default:
{ "lib/**/*.jar" }
Configure glob patterns for referencing local libraries to a Java project.
java.project.resourceFilters
- Type:
array
- Default:
{ "node_modules", ".git" }
Excludes files and folders from being refreshed by the Java Language Server\, which can improve the overall performance. For example\, [\"node_modules\"\,\".git\"] will exclude all files and folders named \'node_modules\' or \'.git\'. Defaults to [\"node_modules\"\,\".git\"].
java.project.sourcePaths
- Type:
array
- Default:
{}
- Array items:
null
java.recommendations.dependency.analytics.show
- Type:
boolean
- Default:
true
Show the recommended Dependency Analytics extension.
java.references.includeAccessors
- Type:
boolean
- Default:
true
Include getter\, setter and builder\/constructor when finding references.
java.references.includeDecompiledSources
- Type:
boolean
- Default:
true
Include the decompiled sources when finding references.
java.referencesCodeLens.enabled
- Type:
boolean
Enable\/disable the references code lens.
java.saveActions.organizeImports
- Type:
boolean
Enable\/disable auto organize imports on save action
java.selectionRange.enabled
- Type:
boolean
- Default:
true
Enable\/disable Smart Selection support for Java. Disabling this option will not affect the VS Code built-in word-based and bracket-based smart selection.
java.semanticHighlighting.enabled
- Type:
boolean
- Default:
true
Enable\/disable the semantic highlighting.
java.server.launchMode
- Type:
enum { "Standard", "LightWeight", "Hybrid" }
- Default:
"Hybrid"
The launch mode for the Java extension
java.settings.url
- Type:
string
- Default:
vim.NIL
null
java.showBuildStatusOnStart.enabled
- Type:
boolean
Automatically show build status on startup.
java.signatureHelp.enabled
- Type:
boolean
Enable\/disable the signature help.
java.sources.organizeImports.starThreshold
- Type:
integer
- Default:
99
Specifies the number of imports added before a star-import declaration is used.
java.sources.organizeImports.staticStarThreshold
- Type:
integer
- Default:
99
Specifies the number of static imports added before a star-import declaration is used.
java.symbols.includeSourceMethodDeclarations
- Type:
boolean
null
java.templates.fileHeader
- Type:
array
- Default:
{}
null
java.templates.typeComment
- Type:
array
- Default:
{}
null
java.trace.server
- Type:
enum { "off", "messages", "verbose" }
- Default:
"off"
Traces the communication between VS Code and the Java language server.
java.typeHierarchy.lazyLoad
- Type:
boolean
Enable\/disable lazy loading the content in type hierarchy. Lazy loading could save a lot of loading time but every type should be expanded manually to load its content.