2024-05-07 22:49:00 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-12-22 00:04:13 -05:00
|
|
|
inherit (lib) getExe mkIf;
|
2024-11-22 02:48:41 -05:00
|
|
|
|
|
|
|
cfg = config.programs.neovim;
|
2024-05-07 22:49:00 -04:00
|
|
|
|
2024-12-22 00:04:13 -05:00
|
|
|
javaSdk = pkgs.temurin-bin-21;
|
2024-12-21 23:34:10 -05:00
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable {
|
2024-05-07 22:49:00 -04:00
|
|
|
programs = {
|
2024-12-22 00:04:13 -05:00
|
|
|
# We keep the packages here because java is a bit complicated
|
2024-05-07 22:49:00 -04:00
|
|
|
java = {
|
|
|
|
enable = true;
|
|
|
|
package = javaSdk;
|
|
|
|
};
|
|
|
|
|
|
|
|
neovim = {
|
|
|
|
extraLuaConfig =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-05-07 22:49:00 -04:00
|
|
|
''
|
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
|
2024-08-31 19:16:06 -04:00
|
|
|
plugin = pkgs.vimPlugins.nvim-jdtls;
|
2024-05-11 19:27:26 -04:00
|
|
|
type = "lua";
|
|
|
|
config =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-05-11 19:27:26 -04:00
|
|
|
''
|
|
|
|
local startJdtls = function()
|
2024-07-28 02:54:34 -04:00
|
|
|
local config = {
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
|
|
|
|
2024-08-31 19:16:06 -04:00
|
|
|
cmd = { '${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 = {
|
|
|
|
{
|
2024-12-22 00:04:13 -05:00
|
|
|
name = 'JavaSE-21',
|
2024-05-11 19:27:26 -04:00
|
|
|
path = '${javaSdk}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-07-28 02:54:34 -04:00
|
|
|
};
|
2024-05-11 19:27:26 -04:00
|
|
|
|
|
|
|
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
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-12-21 23:34:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
# For accurate stack trace
|
|
|
|
_file = ./default.nix;
|
|
|
|
}
|