From 58f9847e783d12d90c6b8d5d97f9632de38bfa6f Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Thu, 24 Feb 2022 18:08:59 +0200 Subject: [PATCH] =?UTF-8?q?Nvim:=20add=20jdtls=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 6 +++++- home/.config/nvim/ftplugin/java.lua | 19 +++++++++++++++++++ home/.config/nvim/lua/pluginconf/lsp.lua | 6 ++++-- home/.config/nvim/lua/pluginmanager.lua | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 home/.config/nvim/ftplugin/java.lua diff --git a/config.yaml b/config.yaml index f73a601e..4c276d58 100644 --- a/config.yaml +++ b/config.yaml @@ -33,6 +33,9 @@ dotfiles: - nvim-packer-sync dst: ~/.config/nvim/lua src: .config/nvim/lua + d_nvim_ftplugin: + dst: ~/.config/nvim/ftplugin + src: .config/nvim/ftplugin d_sway: dst: ~/.config/sway src: .config/sway @@ -193,8 +196,9 @@ profiles: - f_ranger.conf - f_ssh.conf - f_authorized_keys - - d_nvim_lua - f_nvim_init + - d_nvim_lua + - d_nvim_ftplugin - f_gitconfig - f_alacritty.yml email: diff --git a/home/.config/nvim/ftplugin/java.lua b/home/.config/nvim/ftplugin/java.lua new file mode 100644 index 00000000..0ec274e1 --- /dev/null +++ b/home/.config/nvim/ftplugin/java.lua @@ -0,0 +1,19 @@ +local nvim_local_dir = vim.fn.expand('~/.local/share/nvim') + +local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') +local workspace_dir = nvim_local_dir .. '/jdtls-workspaces/' .. project_name +require('jdtls').start_or_attach({ + cmd = { + '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', + '--add-modules=ALL-SYSTEM', '--add-opens', + 'java.base/java.util=ALL-UNNAMED', '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', -- 💀 + '-jar', nvim_local_dir .. + '/lsp_servers/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar', + '-configuration', nvim_local_dir .. '/lsp_servers/jdtls/config_linux', + '-data', workspace_dir + } +}) diff --git a/home/.config/nvim/lua/pluginconf/lsp.lua b/home/.config/nvim/lua/pluginconf/lsp.lua index 9a56dbb3..b75d372a 100644 --- a/home/.config/nvim/lua/pluginconf/lsp.lua +++ b/home/.config/nvim/lua/pluginconf/lsp.lua @@ -49,8 +49,10 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) -- Register a handler that will be called for all installed servers. --- Alternatively, you may also register handlers on specific server instances instead (see example below). lsp_installer.on_server_ready(function(server) + -- Don't setup jdtls here since it is done by nvim-jdtls + if server.name == "jdtls" then return end + local opts = {} -- Lua specific settings @@ -79,6 +81,6 @@ lsp_installer.on_server_ready(function(server) end opts.on_attach = buf_map_keys - opts.capabilities = capabilities + opts.capabilities = capabilities server:setup(opts) end) diff --git a/home/.config/nvim/lua/pluginmanager.lua b/home/.config/nvim/lua/pluginmanager.lua index 83cca4c0..8c6bd285 100644 --- a/home/.config/nvim/lua/pluginmanager.lua +++ b/home/.config/nvim/lua/pluginmanager.lua @@ -64,6 +64,9 @@ require('packer').startup(function() -- Install LSP server executables use 'williamboman/nvim-lsp-installer' + -- Additional LSP features for Java + use 'mfussenegger/nvim-jdtls' + -- Completion use 'hrsh7th/nvim-cmp' -- Autocompletion plugin use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp