From fb1943a673ea78db68e194c89bbb82b150bf74c4 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 22 Oct 2024 23:11:37 -0500 Subject: [PATCH] plugins/lsp-format: remove with lib and helpers --- plugins/by-name/lsp-format/default.nix | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/plugins/by-name/lsp-format/default.nix b/plugins/by-name/lsp-format/default.nix index b6d70887..8bd44939 100644 --- a/plugins/by-name/lsp-format/default.nix +++ b/plugins/by-name/lsp-format/default.nix @@ -1,17 +1,15 @@ { lib, - helpers, config, pkgs, ... }: -with lib; let cfg = config.plugins.lsp-format; in { - options.plugins.lsp-format = helpers.neovim-plugin.extraOptionsOptions // { - enable = mkEnableOption "lsp-format.nvim"; + options.plugins.lsp-format = lib.nixvim.neovim-plugin.extraOptionsOptions // { + enable = lib.mkEnableOption "lsp-format.nvim"; package = lib.mkPackageOption pkgs "lsp-format.nvim" { default = [ @@ -20,29 +18,29 @@ in ]; }; - setup = mkOption { + setup = lib.mkOption { type = - with types; + with lib.types; attrsOf (submodule { # Allow the user to provide other options freeformType = types.attrs; options = { - exclude = helpers.mkNullOrOption (listOf str) "List of client names to exclude from formatting."; + exclude = lib.nixvim.mkNullOrOption (listOf str) "List of client names to exclude from formatting."; - order = helpers.mkNullOrOption (listOf str) '' + order = lib.nixvim.mkNullOrOption (listOf str) '' List of client names. Formatting is requested from clients in the following order: first all clients that are not in the `order` table, then the remaining clients in the order as they occur in the `order` table. (same logic as |vim.lsp.buf.formatting_seq_sync()|). ''; - sync = helpers.defaultNullOpts.mkBool false '' + sync = lib.nixvim.defaultNullOpts.mkBool false '' Whether to turn on synchronous formatting. The editor will block until formatting is done. ''; - force = helpers.defaultNullOpts.mkBool false '' + force = lib.nixvim.defaultNullOpts.mkBool false '' If true, the format result will always be written to the buffer, even if the buffer changed. ''; @@ -63,9 +61,9 @@ in default = { }; }; - lspServersToEnable = mkOption { + lspServersToEnable = lib.mkOption { type = - with types; + with lib.types; either (enum [ "none" "all" @@ -93,21 +91,21 @@ in let setupOptions = cfg.setup // cfg.extraOptions; in - mkIf cfg.enable { - warnings = mkIf (!config.plugins.lsp.enable) [ + lib.mkIf cfg.enable { + warnings = lib.mkIf (!config.plugins.lsp.enable) [ "You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled." ]; extraPlugins = [ cfg.package ]; plugins.lsp = { - onAttach = mkIf (cfg.lspServersToEnable == "all") '' + onAttach = lib.mkIf (cfg.lspServersToEnable == "all") '' require("lsp-format").on_attach(client) ''; servers = - if (isList cfg.lspServersToEnable) then - genAttrs cfg.lspServersToEnable (serverName: { + if (lib.isList cfg.lspServersToEnable) then + lib.genAttrs cfg.lspServersToEnable (serverName: { onAttach.function = '' require("lsp-format").on_attach(client) ''; @@ -117,7 +115,7 @@ in }; extraConfigLua = '' - require("lsp-format").setup(${helpers.toLuaObject setupOptions}) + require("lsp-format").setup(${lib.nixvim.toLuaObject setupOptions}) ''; }; }