add jdtls maybe

This commit is contained in:
Charlotte 🦝 Delenk 2022-07-20 13:01:06 +01:00
parent 4bd901cbda
commit 960e958868
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
2 changed files with 55 additions and 0 deletions

View file

@ -1,5 +1,20 @@
{pkgs, ...}: let
dsquotes = "''";
nvim-jdtls = pkgs.stdenvNoCC.mkDerivation rec {
name = "nvim-jdtls.lua";
src = ./nvim-jdtls.lua;
dontUnpack = true;
java = pkgs.openjdk;
jdtLanguageServer = pkgs.jdt-language-server;
buildInputs = [java jdtLanguageServer];
buildPhase = ''
export launcher="$(ls $jdtLanguageServer/share/java/plugins/org.eclipse.equinox.launcher_* | sort -V | tail -n1)"
substituteAll $src nvim-jdtls.lua
'';
installPhase = ''
cp nvim-jdtls.lua $out
'';
};
in {
programs.neovim = {
enable = true;
@ -65,6 +80,10 @@ in {
plugin = rust-tools-nvim;
config = "lua dofile(\"${./rust-tools.lua}\")";
}
{
plugin = nvim-jdtls;
config = "lua dofile(\"${nvim-jdtls}\")";
}
nvim-dap
];
};

View file

@ -0,0 +1,36 @@
vim.api.nvim_create_autocmd({"FileType"}, {
pattern = {"java"},
callback = function()
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local workspace_dir = '@userhome@/.cache/jdtls/' .. project_name
local config = {
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', '@launcher@',
'-configuration', '@jdtLanguageServer@/share/config',
'-data', workspace_dir,
}
root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),
settings = {
java = {
}
},
init_options = {
bundles = {}
},
};
require('jdtls').start_or_attach(config)
end
})