You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
5.4 KiB

2 years ago
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
local config = {
-- The command that starts the language server
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
autostart = true,
-- autostart = false,
cmd = {
--[[
usage: jdtls [-h] [--validate-java-version | --no-validate-java-version] [--jvm-arg JVM_ARG] [-data DATA]
options:
-h, --help show this help message and exit
--validate-java-version, --no-validate-java-version
--jvm-arg JVM_ARG An additional JVM option (can be used multiple times. Note, use with equal sign. For example: --jvm-arg=-Dlog.level=ALL
-data DATA
]]
'jdtls',
'-configuration',
'/Users/nige/.cache/jdtls/config',
-- '-data', '/Users/nige/.cache/jdtls/workspace'
-- 'jdtls',
-- '--jvm-arg=-Declipse.application=org.eclipse.jdt.ls.core.id1',
-- '--jvm-arg=-Dosgi.bundles.defaultStartLevel=4',
-- '--jvm-arg=-Declipse.product=org.eclipse.jdt.ls.core.product',
-- '--jvm-arg=-Dlog.protocol=true',
-- '--jvm-arg=-Dlog.level=ALL',
-- '--jvm-arg=-Xms1g',
-- '--jvm-arg=--add-modules=ALL-SYSTEM',
-- '--jvm-arg=--add-opens java.base/java.util=ALL-UNNAMED',
-- '--jvm-arg=--add-opens java.base/java.lang=ALL-UNNAMED', -- 💀
'-data', '/Users/nige/.config/jdtls_workspaces/' ..
vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
-- -- 💀
-- 'java', -- or '/path/to/java17_or_newer/bin/java'
-- -- depends on if `java` is in your $PATH env variable and if it points to the right version.
-- '-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',
-- '--add-modules=ALL-SYSTEM', '--add-opens',
-- 'java.base/java.util=ALL-UNNAMED', '--add-opens',
-- 'java.base/java.lang=ALL-UNNAMED', -- 💀
-- '-jar',
-- '/Users/nige/.local/share/lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar',
-- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
-- -- Must point to the Change this to
-- -- eclipse.jdt.ls installation the actual version
--
-- -- 💀
-- '-configuration', '/Users/nige/.local/share/lsp/jdtls/config_mac',
-- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
-- -- Must point to the Change to one of `linux`, `win` or `mac`
-- -- eclipse.jdt.ls installation Depending on your system.
--
-- -- 💀
-- '-data', '/Users/nige/.config/jdtls_workspaces/' ..
-- vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
},
-- 💀
-- This is the default if not provided, you can remove it. Or adjust as needed.
-- One dedicated LSP server & client will be started per unique root_dir
root_dir = require('jdtls.setup').find_root({ '.git', 'mvnw', 'gradlew' }),
-- 💀
-- This is the default if not provided, you can remove it. Or adjust as needed.
-- One dedicated LSP server & client will be started per unique root_dir
-- Here you can configure eclipse.jdt.ls specific settings
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
-- for a list of options
settings = {
java = {
eclipse = { downloadSources = true },
implementationsCodeLens = { enabled = true },
import = { enabled = true },
maven = { downloadSources = true },
references = { includeDecompiledSources = true },
referencesCodeLens = { enabled = true },
rename = { enabled = true },
signatureHelp = { enabled = true }
}
},
-- Language server `initializationOptions`
-- You need to extend the `bundles` with paths to jar files
-- if you want to use additional eclipse.jdt.ls plugins.
--
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
--
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
init_options = {
extendedClientCapabilities = { classFileContentsSupport = true },
-- bundles = {
-- vim.fn.glob(
-- "/Users/nige/.local/share/nvim/dap-servers/com.microsoft.java.debug.plugin_0.43.0.jar",
-- 1)
-- }
},
on_attach = function(client, bufnr)
-- With `hotcodereplace = 'auto' the debug adapter will try to apply code changes
-- you make during a debug session immediately.
-- Remove the option if you do not want that.
-- You can use the `JdtHotcodeReplace` command to trigger it manually
-- require('jdtls').setup_dap({ hotcodereplace = 'auto' })
local jdtls = require('jdtls')
jdtls.setup_dap({ hotcodereplace = 'auto' })
jdtls.setup.add_commands()
end
}
-- This starts a new client & server,
-- or attaches to an existing client & server depending on the `root_dir`.
require('jdtls').start_or_attach(config)