plugins/lsp-lines: switch to mkNeovimPlugin

Remove custom options in favor of using `diagnostics` directly.
This commit is contained in:
Matt Sturgeon 2024-06-21 11:59:22 +01:00
parent 7c35bdb3f7
commit 7dcdd6e989
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 37 additions and 33 deletions

View file

@ -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
'';
};
}

View file

@ -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;
};
};
}