mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/nvim-jdtls: init + tests (#298)
This commit is contained in:
parent
dbd25dffd0
commit
eda519d451
3 changed files with 105 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
|||
./languages/ledger.nix
|
||||
./languages/markdown-preview.nix
|
||||
./languages/nix.nix
|
||||
./languages/nvim-jdtls.nix
|
||||
./languages/plantuml-syntax.nix
|
||||
./languages/rust.nix
|
||||
./languages/sniprun.nix
|
||||
|
|
81
plugins/languages/nvim-jdtls.nix
Normal file
81
plugins/languages/nvim-jdtls.nix
Normal file
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.nvim-jdtls;
|
||||
helpers = import ../helpers.nix {inherit lib;};
|
||||
in {
|
||||
options.plugins.nvim-jdtls =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "nvim-jdtls";
|
||||
|
||||
package = helpers.mkPackageOption "nvim-jdtls" pkgs.vimPlugins.nvim-jdtls;
|
||||
|
||||
cmd = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The command that starts the language server";
|
||||
default = ["${pkgs.jdt-language-server}/bin/jdt-language-server"];
|
||||
};
|
||||
|
||||
rootDir =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.either types.str helpers.rawType)
|
||||
''{ __raw = "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})"; }''
|
||||
''
|
||||
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
|
||||
'';
|
||||
|
||||
settings =
|
||||
helpers.mkNullOrOption (types.attrs)
|
||||
''
|
||||
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.
|
||||
'';
|
||||
|
||||
initOptions =
|
||||
helpers.mkNullOrOption (types.attrs)
|
||||
''
|
||||
Language server `initializationOptions`
|
||||
You need to extend the `bundles` with paths to jar files if you want to use additional
|
||||
eclipse.jdt.ls plugins.
|
||||
|
||||
See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
|
||||
|
||||
If you don't plan on using the debugger or other eclipse.jdt.ls plugins, ignore this option
|
||||
'';
|
||||
};
|
||||
|
||||
config = let
|
||||
options =
|
||||
{
|
||||
inherit (cfg) cmd;
|
||||
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
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue