modules/lsp: check if server settings is empty

Avoid unnecessary lua lines by checking if `server.settings` is empty
before writing `vim.lsp.config()` to `init.lua`.
This commit is contained in:
Matt Sturgeon 2025-05-01 00:32:51 +01:00
parent f2e96b67a3
commit b6e2016b7f
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -179,16 +179,14 @@ in
luaName = toLuaObject server.name; luaName = toLuaObject server.name;
luaSettings = toLuaObject server.settings; luaSettings = toLuaObject server.settings;
in in
'' [
vim.lsp.config(${luaName}, ${luaSettings}) (lib.mkIf (server.settings != { }) "vim.lsp.config(${luaName}, ${luaSettings})")
'' (lib.mkIf (server.activate or false) "vim.lsp.enable(${luaName})")
+ lib.optionalString (server.activate or false) '' ];
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)"
++ builtins.map mkServerConfig enabledServers ++ builtins.concatMap mkServerConfig enabledServers
); );
extraConfigLua = lib.mkIf (cfg.luaConfig.content != "") '' extraConfigLua = lib.mkIf (cfg.luaConfig.content != "") ''