add jdtls maybe
This commit is contained in:
parent
4bd901cbda
commit
960e958868
2 changed files with 55 additions and 0 deletions
|
@ -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
|
||||
];
|
||||
};
|
||||
|
|
36
config/programs/vim/nvim-jdtls.lua
Normal file
36
config/programs/vim/nvim-jdtls.lua
Normal 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
|
||||
})
|
Loading…
Reference in a new issue