2023-08-09 04:41:48 +00:00
|
|
|
{
|
|
|
|
config,
|
2024-03-09 05:49:22 +00:00
|
|
|
pkgs,
|
2023-08-09 04:41:48 +00:00
|
|
|
lib,
|
|
|
|
...
|
2023-11-08 02:16:46 +00:00
|
|
|
}: let
|
2024-03-09 05:49:22 +00:00
|
|
|
inherit (lib.options) mkEnableOption mkOption;
|
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (lib.meta) getExe;
|
|
|
|
inherit (lib.lists) isList;
|
|
|
|
inherit (lib.types) either listOf package str;
|
|
|
|
inherit (lib.nvim.types) mkGrammarOption;
|
|
|
|
inherit (lib.nvim.lua) expToLua;
|
2023-11-08 02:16:46 +00:00
|
|
|
|
2023-08-09 04:41:48 +00:00
|
|
|
cfg = config.vim.languages.java;
|
|
|
|
in {
|
|
|
|
options.vim.languages.java = {
|
|
|
|
enable = mkEnableOption "Java language support";
|
|
|
|
|
|
|
|
treesitter = {
|
2023-10-21 17:15:36 +00:00
|
|
|
enable = mkEnableOption "Java treesitter" // {default = config.vim.languages.enableTreesitter;};
|
2024-03-09 05:49:22 +00:00
|
|
|
package = mkGrammarOption pkgs "java";
|
2023-08-09 04:41:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
lsp = {
|
|
|
|
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;};
|
|
|
|
package = mkOption {
|
2023-09-22 22:28:39 +00:00
|
|
|
description = "java language server package, or the command to run as a list of strings";
|
|
|
|
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
2024-03-09 05:49:22 +00:00
|
|
|
type = either package (listOf str);
|
2023-08-09 04:41:48 +00:00
|
|
|
default = pkgs.jdt-language-server;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
|
|
vim.lsp.lspconfig.enable = true;
|
|
|
|
vim.lsp.lspconfig.sources.jdtls = ''
|
|
|
|
lspconfig.jdtls.setup {
|
2023-09-14 22:20:55 +00:00
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = default_on_attach,
|
2023-09-14 22:17:12 +00:00
|
|
|
cmd = ${
|
|
|
|
if isList cfg.lsp.package
|
2024-03-09 05:49:22 +00:00
|
|
|
then expToLua cfg.lsp.package
|
2024-01-31 14:31:45 +00:00
|
|
|
else ''{"${getExe cfg.lsp.package}", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}''
|
2023-09-14 22:17:12 +00:00
|
|
|
},
|
2023-08-09 04:41:48 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.treesitter.enable {
|
|
|
|
vim.treesitter.enable = true;
|
|
|
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|