mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/lsp: add per-server name
option
This allows users to override the name used for a given `lsp.servers.*` entry. The default is still the attr-name. This may be useful to inject raw lua, or to configure the same server in different ways via different attrs.
This commit is contained in:
parent
3722f88c5d
commit
29aa60b43a
2 changed files with 21 additions and 11 deletions
|
@ -66,31 +66,32 @@ in
|
||||||
|
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
enabledServers = lib.filterAttrs (_: v: v.enable) cfg.servers;
|
enabledServers = lib.pipe cfg.servers [
|
||||||
|
builtins.attrValues
|
||||||
|
(builtins.filter (server: server.enable))
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
extraPackages = lib.pipe enabledServers [
|
extraPackages = builtins.catAttrs "package" enabledServers;
|
||||||
builtins.attrValues
|
|
||||||
(builtins.catAttrs "package")
|
|
||||||
];
|
|
||||||
|
|
||||||
lsp.luaConfig.content =
|
lsp.luaConfig.content =
|
||||||
let
|
let
|
||||||
mkServerConfig =
|
mkServerConfig =
|
||||||
name: props:
|
server:
|
||||||
let
|
let
|
||||||
luaName = toLuaObject name;
|
luaName = toLuaObject server.name;
|
||||||
|
luaCfg = toLuaObject server.config;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
vim.lsp.config(${luaName}, ${toLuaObject props.config})
|
vim.lsp.config(${luaName}, ${luaCfg})
|
||||||
''
|
''
|
||||||
+ lib.optionalString props.activate ''
|
+ lib.optionalString server.activate ''
|
||||||
vim.lsp.enable(${luaName})
|
vim.lsp.enable(${luaName})
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
lib.mkMerge (
|
lib.mkMerge (
|
||||||
lib.optional cfg.inlayHints.enable "vim.lsp.inlay_hint.enable(true)"
|
lib.optional cfg.inlayHints.enable "vim.lsp.inlay_hint.enable(true)"
|
||||||
++ lib.mapAttrsToList mkServerConfig enabledServers
|
++ builtins.map mkServerConfig enabledServers
|
||||||
);
|
);
|
||||||
|
|
||||||
extraConfigLua = lib.mkIf (cfg.luaConfig.content != "") ''
|
extraConfigLua = lib.mkIf (cfg.luaConfig.content != "") ''
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, ... }:
|
{ lib, name, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
in
|
in
|
||||||
|
@ -6,6 +6,15 @@ in
|
||||||
options = {
|
options = {
|
||||||
enable = lib.mkEnableOption "the language server";
|
enable = lib.mkEnableOption "the language server";
|
||||||
|
|
||||||
|
name = lib.mkOption {
|
||||||
|
type = types.maybeRaw types.str;
|
||||||
|
description = ''
|
||||||
|
The name of the language server, supplied to functions like `vim.lsp.enable()`.
|
||||||
|
'';
|
||||||
|
default = name;
|
||||||
|
defaultText = lib.literalMD "the attribute name";
|
||||||
|
};
|
||||||
|
|
||||||
activate = lib.mkOption {
|
activate = lib.mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
description = ''
|
description = ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue