mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/lspkind: refactoring + tests (#259)
This commit is contained in:
parent
86f4067159
commit
e33e62ff61
2 changed files with 53 additions and 45 deletions
|
@ -8,28 +8,22 @@ with lib; let
|
|||
cfg = config.plugins.lspkind;
|
||||
helpers = import ../helpers.nix {inherit lib;};
|
||||
in {
|
||||
options.plugins.lspkind = {
|
||||
options.plugins.lspkind =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "lspkind.nvim";
|
||||
|
||||
package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim;
|
||||
|
||||
mode = mkOption {
|
||||
type = with types; nullOr (enum ["text" "text_symbol" "symbol_text" "symbol"]);
|
||||
default = null;
|
||||
description = "Defines how annotations are shown";
|
||||
};
|
||||
mode =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
["text" "text_symbol" "symbol_text" "symbol"]
|
||||
"symbol_text"
|
||||
"Defines how annotations are shown";
|
||||
|
||||
preset = mkOption {
|
||||
type = with types; nullOr (enum ["default" "codicons"]);
|
||||
default = null;
|
||||
description = "Default symbol map";
|
||||
};
|
||||
preset = helpers.defaultNullOpts.mkEnum ["default" "codicons"] "codicons" "Default symbol map";
|
||||
|
||||
symbolMap = mkOption {
|
||||
type = with types; nullOr (attrsOf str);
|
||||
default = null;
|
||||
description = "Override preset symbols";
|
||||
};
|
||||
symbolMap = helpers.mkNullOrOption (types.attrsOf types.str) "Override preset symbols";
|
||||
|
||||
cmp = {
|
||||
enable = mkOption {
|
||||
|
@ -38,29 +32,19 @@ in {
|
|||
description = "Integrate with nvim-cmp";
|
||||
};
|
||||
|
||||
maxWidth = mkOption {
|
||||
type = with types; nullOr int;
|
||||
default = null;
|
||||
description = "Maximum number of characters to show in the popup";
|
||||
};
|
||||
maxWidth =
|
||||
helpers.mkNullOrOption types.int
|
||||
"Maximum number of characters to show in the popup";
|
||||
|
||||
ellipsisChar = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = "Character to show when the popup exceeds maxwidth";
|
||||
};
|
||||
ellipsisChar =
|
||||
helpers.mkNullOrOption types.str
|
||||
"Character to show when the popup exceeds maxwidth";
|
||||
|
||||
menu = mkOption {
|
||||
type = with types; nullOr (attrsOf str);
|
||||
default = null;
|
||||
description = "Show source names in the popup";
|
||||
};
|
||||
menu = helpers.mkNullOrOption (types.attrsOf types.str) "Show source names in the popup";
|
||||
|
||||
after = mkOption {
|
||||
type = with types; nullOr types.str;
|
||||
default = null;
|
||||
description = "Function to run after calculating the formatting. function(entry, vim_item, kind)";
|
||||
};
|
||||
after =
|
||||
helpers.mkNullOrOption types.str
|
||||
"Function to run after calculating the formatting. function(entry, vim_item, kind)";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -80,7 +64,8 @@ in {
|
|||
menu = cfg.cmp.menu;
|
||||
}
|
||||
else {}
|
||||
);
|
||||
)
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
|
23
tests/plugins/lspkind.nix
Normal file
23
tests/plugins/lspkind.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
# Empty configuration
|
||||
empty = {
|
||||
plugins.lspkind.enable = true;
|
||||
};
|
||||
|
||||
# All the upstream default options of lspkind
|
||||
defaults = {
|
||||
plugins.lspkind = {
|
||||
enable = true;
|
||||
mode = "symbol_text";
|
||||
preset = "codicons";
|
||||
symbolMap = null;
|
||||
cmp = {
|
||||
enable = true;
|
||||
maxWidth = 50;
|
||||
ellipsisChar = "...";
|
||||
menu = null;
|
||||
after = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue