lsp: add support for several LSP clients (#111)

* nvim-lsp: Allow to pass settings to clients

Some clients (like rust-analyzer, nil_ls, ...) can take settings
specified in the setup function. This commit adds two fields for the
'mkLsp' function to handle this:

- extraOptions: define nix module options
- settings: A function that takes the corresponding lsp module config
  and formats it as a settings object compatible with the server.

* nvim-lsp: Add nil-ls (for Nix)

* nvim-lsp: Add bashls (for Bash)

* nvim-lsp: Add dartls, for dart

Co-authored-by: Pedro Alves <pta2002@users.noreply.github.com>
This commit is contained in:
traxys 2023-01-10 23:47:52 +01:00 committed by GitHub
parent 02f28c7b48
commit b1ba5f873e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 132 additions and 1 deletions

View file

@ -7,6 +7,8 @@
, serverName ? name
, packages ? [ pkgs.${name} ]
, cmd ? null
, settings ? null
, extraOptions ? { }
, ...
}:
# returns a module
@ -19,7 +21,7 @@
options = {
plugins.lsp.servers.${name} = {
enable = mkEnableOption description;
};
} // extraOptions;
};
config = mkIf cfg.enable {
@ -29,6 +31,7 @@
name = serverName;
extraOptions = {
inherit cmd;
settings = if settings != null then settings cfg else { };
};
}];
};