From 7dcdd6e989b50d1545487b011f141d9db7681f60 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 21 Jun 2024 11:59:22 +0100 Subject: [PATCH] plugins/lsp-lines: switch to mkNeovimPlugin Remove custom options in favor of using `diagnostics` directly. --- plugins/lsp/lsp-lines.nix | 61 +++++++++----------- tests/test-sources/plugins/lsp/lsp-lines.nix | 9 +++ 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/plugins/lsp/lsp-lines.nix b/plugins/lsp/lsp-lines.nix index f7b0ad1e..440593b9 100644 --- a/plugins/lsp/lsp-lines.nix +++ b/plugins/lsp/lsp-lines.nix @@ -6,40 +6,35 @@ ... }: with lib; -let - cfg = config.plugins.lsp-lines; -in -{ - options = { - plugins.lsp-lines = { - enable = mkEnableOption "lsp_lines.nvim"; +helpers.neovim-plugin.mkNeovimPlugin config { + name = "lsp-lines"; + luaName = "lsp_lines"; + originalName = "lsp_lines.nvim"; + defaultPackage = pkgs.vimPlugins.lsp_lines-nvim; - package = helpers.mkPluginPackageOption "lsp_lines.nvim" pkgs.vimPlugins.lsp_lines-nvim; + # This plugin has no settings; it is configured via vim.diagnostic.config + hasSettings = false; - currentLine = mkOption { - type = types.bool; - default = false; - description = "Show diagnostics only on current line"; - }; - }; + maintainers = [ maintainers.MattSturgeon ]; + + # TODO: Introduced 2024-06-25, remove after 24.11 + imports = [ + (mkRenamedOptionModule + [ + "plugins" + "lsp-lines" + "currentLine" + ] + [ + "diagnostics" + "virtual_lines" + "only_current_line" + ] + ) + ]; + + extraConfig = cfg: { + # Strongly recommended by the plugin, to avoid duplication. + diagnostics.virtual_text = mkDefault false; }; - - config = - let - diagnosticConfig = { - virtual_text = false; - virtual_lines = if cfg.currentLine then { only_current_line = true; } else true; - }; - in - mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - - extraConfigLua = '' - do - require("lsp_lines").setup() - - vim.diagnostic.config(${helpers.toLuaObject diagnosticConfig}) - end - ''; - }; } diff --git a/tests/test-sources/plugins/lsp/lsp-lines.nix b/tests/test-sources/plugins/lsp/lsp-lines.nix index aefc7b08..f3f26934 100644 --- a/tests/test-sources/plugins/lsp/lsp-lines.nix +++ b/tests/test-sources/plugins/lsp/lsp-lines.nix @@ -2,4 +2,13 @@ empty = { plugins.lsp-lines.enable = true; }; + + example = { + plugins.lsp-lines.enable = true; + + diagnostics.virtual_lines = { + only_current_line = true; + highlight_whole_line = false; + }; + }; }