2023-03-28 18:20:54 +02:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2023-03-28 18:20:54 +02:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.plugins.nvim-jdtls;
|
|
|
|
in
|
|
|
|
{
|
2023-03-31 18:05:56 +02:00
|
|
|
options.plugins.nvim-jdtls = helpers.neovim-plugin.extraOptionsOptions // {
|
|
|
|
enable = mkEnableOption "nvim-jdtls";
|
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = helpers.mkPluginPackageOption "nvim-jdtls" pkgs.vimPlugins.nvim-jdtls;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-31 18:05:56 +02:00
|
|
|
cmd = helpers.mkNullOrOption (types.listOf types.str) ''
|
|
|
|
The command that starts the language server.
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-31 18:05:56 +02:00
|
|
|
You should either set a value for this option, or, you can instead set the `data` (and
|
|
|
|
`configuration`) options.
|
|
|
|
|
2024-05-05 19:39:35 +02:00
|
|
|
```nix
|
2023-03-31 18:05:56 +02:00
|
|
|
plugins.nvim-jdtls = {
|
|
|
|
enable = true;
|
|
|
|
cmd = [
|
2024-04-03 23:38:07 -05:00
|
|
|
(lib.getExe pkgs.jdt-language-server)
|
2023-03-31 18:05:56 +02:00
|
|
|
"-data" "/path/to/your/workspace"
|
|
|
|
"-configuration" "/path/to/your/configuration"
|
|
|
|
"-foo" "bar"
|
2024-05-05 19:39:35 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
2023-03-31 18:05:56 +02:00
|
|
|
Or,
|
2024-05-05 19:39:35 +02:00
|
|
|
```nix
|
2023-03-31 18:05:56 +02:00
|
|
|
plugins.nvim-jdtls = {
|
|
|
|
enable = true;
|
|
|
|
data = "/path/to/your/workspace";
|
|
|
|
configuration = "/path/to/your/configuration";
|
2023-03-28 18:20:54 +02:00
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
```
|
|
|
|
'';
|
|
|
|
|
2023-03-31 18:05:56 +02:00
|
|
|
data = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "/home/YOUR_USERNAME/.cache/jdtls/workspace";
|
|
|
|
description = ''
|
|
|
|
eclipse.jdt.ls stores project specific data within the folder set via the -data flag.
|
|
|
|
If you're using eclipse.jdt.ls with multiple different projects you must use a dedicated
|
|
|
|
data directory per project.
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-03-31 18:05:56 +02:00
|
|
|
configuration = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "/home/YOUR_USERNAME/.cache/jdtls/config";
|
|
|
|
description = "Path to the configuration file.";
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-03-28 18:20:54 +02:00
|
|
|
|
|
|
|
rootDir =
|
2024-06-11 16:52:49 +01:00
|
|
|
helpers.defaultNullOpts.mkStr
|
|
|
|
{ __raw = "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})"; }
|
2023-03-28 18:20:54 +02:00
|
|
|
''
|
|
|
|
This is the default if not provided, you can remove it. Or adjust as needed.
|
|
|
|
One dedicated LSP server & client will be started per unique root_dir
|
|
|
|
'';
|
|
|
|
|
2023-05-22 15:45:47 +05:30
|
|
|
settings = helpers.mkNullOrOption types.attrs ''
|
2023-03-28 18:20:54 +02:00
|
|
|
Here you can configure eclipse.jdt.ls specific settings
|
|
|
|
See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
|
|
|
for a list of options.
|
|
|
|
'';
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-05-22 15:45:47 +05:30
|
|
|
initOptions = helpers.mkNullOrOption types.attrs ''
|
2023-03-28 18:20:54 +02:00
|
|
|
Language server `initializationOptions`
|
|
|
|
You need to extend the `bundles` with paths to jar files if you want to use additional
|
|
|
|
eclipse.jdt.ls plugins.
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-28 18:20:54 +02:00
|
|
|
See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-28 18:20:54 +02:00
|
|
|
If you don't plan on using the debugger or other eclipse.jdt.ls plugins, ignore this option
|
|
|
|
'';
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-28 18:20:54 +02:00
|
|
|
config =
|
|
|
|
let
|
2023-03-31 18:05:56 +02:00
|
|
|
cmd =
|
2023-05-22 15:45:47 +05:30
|
|
|
if (cfg.cmd == null) then
|
2023-03-31 18:05:56 +02:00
|
|
|
let
|
|
|
|
data =
|
2023-05-22 15:45:47 +05:30
|
|
|
if (cfg.data == null) then
|
2023-03-31 18:05:56 +02:00
|
|
|
throw ''
|
|
|
|
You have to either set the 'plugins.nvim-jdtls.data' or the 'plugins.nvim-jdtls.cmd'
|
|
|
|
option.
|
|
|
|
''
|
|
|
|
else
|
|
|
|
cfg.data;
|
|
|
|
in
|
2024-04-03 23:38:07 -05:00
|
|
|
[ (lib.getExe pkgs.jdt-language-server) ]
|
2023-03-31 18:05:56 +02:00
|
|
|
++ [
|
|
|
|
"-data"
|
|
|
|
data
|
|
|
|
]
|
2023-05-22 15:45:47 +05:30
|
|
|
++ (optionals (cfg.configuration != null) [
|
2023-03-31 18:05:56 +02:00
|
|
|
"-configuration"
|
|
|
|
cfg.configuration
|
|
|
|
])
|
|
|
|
else
|
|
|
|
cfg.cmd;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-28 18:20:54 +02:00
|
|
|
options = {
|
2023-03-31 18:05:56 +02:00
|
|
|
inherit cmd;
|
2023-03-28 18:20:54 +02:00
|
|
|
root_dir = cfg.rootDir;
|
|
|
|
inherit (cfg) settings;
|
|
|
|
init_options = cfg.initOptions;
|
|
|
|
} // cfg.extraOptions;
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
|
|
|
|
extraPackages = [ pkgs.jdt-language-server ];
|
|
|
|
|
|
|
|
autoCmd = [
|
|
|
|
{
|
|
|
|
event = "FileType";
|
|
|
|
pattern = "java";
|
|
|
|
callback.__raw = ''
|
|
|
|
function ()
|
|
|
|
require('jdtls').start_or_attach(${helpers.toLuaObject options})
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|