aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/jdtls.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lspconfig/jdtls.lua')
-rw-r--r--lua/lspconfig/jdtls.lua92
1 files changed, 46 insertions, 46 deletions
diff --git a/lua/lspconfig/jdtls.lua b/lua/lspconfig/jdtls.lua
index 61eee49b..5ebf2ee8 100644
--- a/lua/lspconfig/jdtls.lua
+++ b/lua/lspconfig/jdtls.lua
@@ -1,12 +1,12 @@
-local configs = require 'lspconfig/configs'
-local util = require 'lspconfig/util'
-local handlers = require 'vim.lsp.handlers'
+local configs = require "lspconfig/configs"
+local util = require "lspconfig/util"
+local handlers = require "vim.lsp.handlers"
local path = util.path
local server_name = "jdtls"
local cmd = {
- util.path.join(tostring(vim.fn.getenv("JAVA_HOME")), "/bin/java"),
+ util.path.join(tostring(vim.fn.getenv "JAVA_HOME"), "/bin/java"),
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
@@ -15,17 +15,16 @@ local cmd = {
"-Xms1g",
"-Xmx2G",
"-jar",
- tostring(vim.fn.getenv("JAR")),
+ tostring(vim.fn.getenv "JAR"),
"-configuration",
- tostring(vim.fn.getenv("JDTLS_CONFIG")),
+ tostring(vim.fn.getenv "JDTLS_CONFIG"),
"-data",
- tostring(vim.fn.getenv("WORKSPACE")),
+ tostring(vim.fn.getenv "WORKSPACE"),
"--add-modules=ALL-SYSTEM",
"--add-opens java.base/java.util=ALL-UNNAMED",
"--add-opens java.base/java.lang=ALL-UNNAMED",
}
-
--- The presence of one of these files indicates a root directory.
--
-- We search for configuration files of the most common Java build systems. We
@@ -34,16 +33,15 @@ local cmd = {
local root_files = {
-- Single-module projects
{
- 'build.xml', -- Ant
- 'pom.xml', -- Maven
- 'settings.gradle', -- Gradle
- 'settings.gradle.kts', -- Gradle
+ "build.xml", -- Ant
+ "pom.xml", -- Maven
+ "settings.gradle", -- Gradle
+ "settings.gradle.kts", -- Gradle
},
-- Multi-module projects
- {'build.gradle', 'build.gradle.kts'},
+ { "build.gradle", "build.gradle.kts" },
}
-
--- Callback function for the `language/status` notification.
--
-- The server sends a non-standard notification when the status of the language
@@ -51,9 +49,9 @@ local root_files = {
-- starting up.
local function on_language_status(_, _, result)
local command = vim.api.nvim_command
- command('echohl ModeMsg')
+ command "echohl ModeMsg"
command(string.format('echo "%s"', result.message))
- command('echohl None')
+ command "echohl None"
end
-- If the text document version is 0, set it to nil instead so that Neovim
@@ -75,22 +73,24 @@ configs[server_name] = {
default_config = {
cmd = cmd,
cmd_env = {
- JAR=vim.fn.getenv("JAR"),
- GRADLE_HOME=vim.fn.getenv("GRADLE_HOME"),
+ JAR = vim.fn.getenv "JAR",
+ GRADLE_HOME = vim.fn.getenv "GRADLE_HOME",
},
- filetypes = { "java" };
+ filetypes = { "java" },
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
+ if root then
+ return root
+ end
end
return vim.fn.getcwd()
- end;
+ end,
init_options = {
- workspace = path.join { vim.loop.os_homedir(), "workspace" };
- jvm_args = {};
- os_config = nil;
- };
+ workspace = path.join { vim.loop.os_homedir(), "workspace" },
+ jvm_args = {},
+ os_config = nil,
+ },
handlers = {
-- Due to an invalid protocol implementation in the jdtls we have to
-- conform these to be spec compliant.
@@ -99,33 +99,33 @@ configs[server_name] = {
-- CodeAction in org.eclipse.lsp4j -> https://github.com/eclipse/lsp4j/blob/master/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CodeAction.java
-- Command in LSP -> https://microsoft.github.io/language-server-protocol/specification#command
-- CodeAction in LSP -> https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction
- ['textDocument/codeAction'] = function(a, b, actions)
- for _,action in ipairs(actions) do
+ ["textDocument/codeAction"] = function(a, b, actions)
+ for _, action in ipairs(actions) do
-- TODO: (steelsojka) Handle more than one edit?
-- if command is string, then 'ation' is Command in java format,
-- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
- if action.command == 'java.apply.workspaceEdit' then
+ if action.command == "java.apply.workspaceEdit" then
action.edit = fix_zero_version(action.edit or action.arguments[1])
- -- if command is table, then 'action' is CodeAction in java format
- -- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
- elseif type(action.command) == 'table' and action.command.command == 'java.apply.workspaceEdit' then
+ -- if command is table, then 'action' is CodeAction in java format
+ -- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
+ elseif type(action.command) == "table" and action.command.command == "java.apply.workspaceEdit" then
action.edit = fix_zero_version(action.edit or action.command.arguments[1])
end
end
- handlers['textDocument/codeAction'](a, b, actions)
- end;
+ handlers["textDocument/codeAction"](a, b, actions)
+ end,
- ['textDocument/rename'] = function(a, b, workspace_edit)
- handlers['textDocument/rename'](a, b, fix_zero_version(workspace_edit))
- end;
+ ["textDocument/rename"] = function(a, b, workspace_edit)
+ handlers["textDocument/rename"](a, b, fix_zero_version(workspace_edit))
+ end,
- ['workspace/applyEdit'] = function(a, b, workspace_edit)
- handlers['workspace/applyEdit'](a, b, fix_zero_version(workspace_edit))
- end;
+ ["workspace/applyEdit"] = function(a, b, workspace_edit)
+ handlers["workspace/applyEdit"](a, b, fix_zero_version(workspace_edit))
+ end,
- ['language/status'] = vim.schedule_wrap(on_language_status)
- };
- };
+ ["language/status"] = vim.schedule_wrap(on_language_status),
+ },
+ },
docs = {
package_json = "https://raw.githubusercontent.com/redhat-developer/vscode-java/master/package.json",
description = [[
@@ -146,9 +146,9 @@ 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
```
- ]];
+ ]],
default_config = {
- root_dir = [[root_pattern(".git")]];
- };
- };
+ root_dir = [[root_pattern(".git")]],
+ },
+ },
}