2024-05-07 22:49:00 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit (pkgs) vimPlugins;
|
|
|
|
inherit (config.vars) neovimIde;
|
|
|
|
|
|
|
|
javaSdk = pkgs.temurin-bin-17;
|
|
|
|
javaPkgs = with pkgs; [gradle maven];
|
|
|
|
in
|
|
|
|
lib.mkIf neovimIde {
|
|
|
|
home.packages = javaPkgs;
|
|
|
|
|
|
|
|
xdg.dataFile.".gradle/gradle.properties".text = ''
|
|
|
|
org.gradle.java.home = ${javaSdk}
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
java = {
|
|
|
|
enable = true;
|
|
|
|
package = javaSdk;
|
|
|
|
};
|
|
|
|
|
|
|
|
neovim = {
|
|
|
|
extraPackages = javaPkgs;
|
|
|
|
|
|
|
|
extraLuaConfig =
|
|
|
|
/*
|
|
|
|
lua
|
|
|
|
*/
|
|
|
|
''
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-05-07 22:49:00 -04:00
|
|
|
pattern = 'java',
|
|
|
|
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
|
|
|
});
|
|
|
|
'';
|
|
|
|
|
|
|
|
plugins = [
|
2024-05-11 19:27:26 -04:00
|
|
|
{
|
|
|
|
# TOOD: setup debugger https://github.com/mfussenegger/nvim-jdtls#debugger-via-nvim-dap
|
|
|
|
plugin = vimPlugins.nvim-jdtls;
|
|
|
|
type = "lua";
|
|
|
|
config =
|
|
|
|
/*
|
|
|
|
lua
|
|
|
|
*/
|
|
|
|
''
|
|
|
|
local startJdtls = function()
|
|
|
|
local config = require('coq').lsp_ensure_capabilities({
|
2024-05-15 18:55:07 -04:00
|
|
|
cmd = { '${lib.getExe pkgs.jdt-language-server}' },
|
2024-05-11 19:27:26 -04:00
|
|
|
root_dir = vim.fs.dirname(vim.fs.find(
|
|
|
|
{ 'gradlew', '.git', 'mvnw', 'pom.xml' },
|
|
|
|
{ upward = true }
|
|
|
|
)[1]),
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
java = {
|
|
|
|
configuration = {
|
|
|
|
runtimes = {
|
|
|
|
{
|
|
|
|
name = 'JavaSE-17',
|
|
|
|
path = '${javaSdk}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
require('jdtls').start_or_attach(config);
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
|
|
pattern = 'java',
|
|
|
|
callback = startJdtls,
|
|
|
|
});
|
|
|
|
'';
|
|
|
|
}
|
2024-05-07 22:49:00 -04:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|