mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
* 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>
39 lines
854 B
Nix
39 lines
854 B
Nix
{ pkgs, config, lib, ... }:
|
|
|
|
{
|
|
mkLsp =
|
|
{ name
|
|
, description ? "Enable ${name}."
|
|
, serverName ? name
|
|
, packages ? [ pkgs.${name} ]
|
|
, cmd ? null
|
|
, settings ? null
|
|
, extraOptions ? { }
|
|
, ...
|
|
}:
|
|
# returns a module
|
|
{ pkgs, config, lib, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.plugins.lsp.servers.${name};
|
|
in
|
|
{
|
|
options = {
|
|
plugins.lsp.servers.${name} = {
|
|
enable = mkEnableOption description;
|
|
} // extraOptions;
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
extraPackages = packages;
|
|
|
|
plugins.lsp.enabledServers = [{
|
|
name = serverName;
|
|
extraOptions = {
|
|
inherit cmd;
|
|
settings = if settings != null then settings cfg else { };
|
|
};
|
|
}];
|
|
};
|
|
};
|
|
}
|