diff --git a/configuration.nix b/configuration.nix index 718b4d25..9718a4ba 100644 --- a/configuration.nix +++ b/configuration.nix @@ -64,6 +64,7 @@ inputs: let enable = isMaximal; crates.enable = true; }; + java.enable = isMaximal; ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; diff --git a/docs/release-notes/rl-0.5.adoc b/docs/release-notes/rl-0.5.adoc index 5b45d110..78c18f5e 100644 --- a/docs/release-notes/rl-0.5.adoc +++ b/docs/release-notes/rl-0.5.adoc @@ -16,7 +16,9 @@ https://github.com/horriblename[horriblename]: https://github.com/amanse[amanse]: -* Added daily notes options for obsidian plugin.a +* Added daily notes options for obsidian plugin. + +* Added jdt-language-server for Java. https://github.com/yavko[yavko]: diff --git a/modules/languages/default.nix b/modules/languages/default.nix index 9a5135e0..20119719 100644 --- a/modules/languages/default.nix +++ b/modules/languages/default.nix @@ -23,6 +23,7 @@ in { ./zig.nix ./html.nix ./svelte.nix + ./java.nix ]; options.vim.languages = { diff --git a/modules/languages/java.nix b/modules/languages/java.nix new file mode 100644 index 00000000..1792824f --- /dev/null +++ b/modules/languages/java.nix @@ -0,0 +1,45 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.languages.java; +in { + options.vim.languages.java = { + enable = mkEnableOption "Java language support"; + + treesitter = { + enable = mkEnableOption "Enable Java treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = nvim.types.mkGrammarOption pkgs "java"; + }; + + lsp = { + enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "java language server"; + type = types.package; + 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 { + cmd = {"${cfg.lsp.package}/bin/jdt-language-server", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}, + } + ''; + }) + + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + ]); +}