neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

commit bc155252296f64d50c5deb3ab9f7e5766c866d72
parent ac79ba5aa65ee729bcf504015811bdabbf69bc7c
Author: Tomas Nemec <owl@gtms.dev>
Date:   Tue, 16 Jul 2024 10:33:15 +0200

update

Diffstat:
Mafter/plugin/lsp.lua | 2++
Mftplugin/java.lua | 64++++++++++++++++++++++++++++++++++++++++++----------------------
2 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua @@ -167,6 +167,8 @@ if pcall(require, 'mason') then end, ['jsonls'] = function() end, + ['jdtls'] = function() + end, ['lua_ls'] = function() end, } diff --git a/ftplugin/java.lua b/ftplugin/java.lua @@ -1,8 +1,8 @@ --- require('jdtls').start_or_attach({cmd = 'java-lsp.sh'}) --- +vim.o.shiftwidth = 4 + -- If you started neovim within `~/dev/xy/project-1` this would resolve to `project-1` local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') -local workspace_dir = '/home/tms/.cache/jdtls/' .. project_name +local root_dir = vim.fs.root(0, { ".git", "pom.xml", "mvnw", "gradlew" }) -- See `:help vim.lsp.start_client` for an overview of the supported `config` options. local config = { @@ -11,7 +11,7 @@ local config = { cmd = { -- 💀 - 'java', -- or '/path/to/java11_or_newer/bin/java' + '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', @@ -19,42 +19,59 @@ local config = { '-Declipse.product=org.eclipse.jdt.ls.core.product', '-Dlog.protocol=true', '-Dlog.level=ALL', - '-Xms1g', + '-Xmx1g', '--add-modules=ALL-SYSTEM', - '--add-opens', - 'java.base/java.util=ALL-UNNAMED', - '--add-opens', - 'java.base/java.lang=ALL-UNNAMED', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + + -- repository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar + "-javaagent:" .. vim.env.XDG_DATA_HOME .. "/maven/repository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar", -- 💀 - '-jar', - '/usr/share/java/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 + '-jar', vim.env.MASON .. '/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.800.v20240330-1250.jar', + -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ + -- Must point to the Change this to + -- eclipse.jdt.ls installation the actual version + -- 💀 - '-configuration', - '/usr/share/java/jdtls/config_linux', + '-configuration', vim.env.MASON .. '/packages/jdtls/config_linux', -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ -- Must point to the Change to one of `linux`, `win` or `mac` -- eclipse.jdt.ls installation Depending on your system. + -- 💀 -- See `data directory configuration` section in the README - '-data', - workspace_dir, + '-data', vim.env.XDG_CACHE_HOME .. '/jdtls/' .. project_name }, -- 💀 -- 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' }), + -- + -- vim.fs.root requires Neovim 0.10. + -- If you're using an earlier version, use: require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}), + root_dir = 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 = {} }, + settings = { + -- java.configuration.maven.userSettings + java = { + configuration = { + jdt = { + ls = { + lombokSupport = { enabled = false } + } + }, + maven = { + userSettings = root_dir .. '/maven-settings.xml' + } + } + } + }, -- Language server `initializationOptions` -- You need to extend the `bundles` with paths to jar files @@ -63,9 +80,12 @@ local config = { -- 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 = { bundles = {} }, + init_options = { + bundles = {}, + }, } + -- This starts a new client & server, -- or attaches to an existing client & server depending on the `root_dir`. --- require('jdtls').start_or_attach(config) +require('jdtls').start_or_attach(config) -- require('jdtls').setup_dap()