Skip to content

Commit

Permalink
plugins/nvim-jdtls: use jdtLanguageServerPackage option
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Sep 15, 2024
1 parent b42d458 commit 61be7a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
36 changes: 22 additions & 14 deletions plugins/by-name/nvim-jdtls/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ in
];
};

jdtLanguageServerPackage = lib.mkPackageOption pkgs "jdt-language-server" {
nullable = true;
};

cmd = helpers.mkNullOrOption (types.listOf types.str) ''
The command that starts the language server.
Expand Down Expand Up @@ -94,21 +98,11 @@ in
config =
let
cmd =
if (cfg.cmd == null) then
let
data =
if (cfg.data == null) then
throw ''
You have to either set the 'plugins.nvim-jdtls.data' or the 'plugins.nvim-jdtls.cmd'
option.
''
else
cfg.data;
in
[ (lib.getExe pkgs.jdt-language-server) ]
if (cfg.cmd == null && cfg.jdtLanguageServerPackage != null) then
[ (lib.getExe cfg.jdtLanguageServerPackage) ]
++ [
"-data"
data
cfg.data
]
++ (optionals (cfg.configuration != null) [
"-configuration"
Expand All @@ -125,9 +119,23 @@ in
} // cfg.extraOptions;
in
mkIf cfg.enable {
assertions = [
{
assertion = cfg.cmd != null || cfg.data != null;
message = "You have to either set the `plugins.nvim-jdtls.data` or the `plugins.nvim-jdtls.cmd` option.";
}
{
assertion = cfg.cmd == null -> cfg.jdtLanguageServerPackage != null;
message = ''
Nixvim (plugins.nvim-jdtls) You haven't defined a `cmd` or `jdtLanguageServerPackage`.
The default `cmd` requires `plugins.nvim-jdtls.jdtLanguageServerPackage` to be set.
'';
}
];
extraPlugins = [ cfg.package ];

extraPackages = [ pkgs.jdt-language-server ];
extraPackages = [ cfg.jdtLanguageServerPackage ];

autoCmd = [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test-sources/plugins/by-name/nvim-jdtls/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
example = {
plugins.nvim-jdtls = {
enable = true;

jdtLanguageServerPackage = null;
cmd = [
"${pkgs.jdt-language-server}/bin/jdt-language-server"
"-data"
Expand Down

0 comments on commit 61be7a6

Please sign in to comment.