mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
meta: extend meta.nixvimInfo
support treewide
Rather than supplying a `kind` and `name` pair, we now supply a raw path. This path could point to any nixvim option.
This commit is contained in:
parent
b2a477260d
commit
f34fda8d99
4 changed files with 28 additions and 23 deletions
|
@ -67,17 +67,18 @@ let
|
||||||
filterAttrs (_: component: component.isOption && (isVisible component)) opts;
|
filterAttrs (_: component: component.isOption && (isVisible component)) opts;
|
||||||
path = removeWhitespace (concatStringsSep "/" path);
|
path = removeWhitespace (concatStringsSep "/" path);
|
||||||
moduleDoc =
|
moduleDoc =
|
||||||
if builtins.length path >= 2 && lib.hasAttrByPath path nixvimInfo then
|
let
|
||||||
let
|
info = optionalAttrs (hasAttrByPath path nixvimInfo) (getAttrFromPath path nixvimInfo);
|
||||||
info = lib.getAttrFromPath path nixvimInfo;
|
maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]);
|
||||||
maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]);
|
maintainersNames = builtins.map (m: m.name) maintainers;
|
||||||
maintainersNames = builtins.map (m: m.name) maintainers;
|
in
|
||||||
in
|
# Make sure this path has a valid info attrset
|
||||||
|
if info ? file && info ? description && info ? url then
|
||||||
"# ${lib.last path}\n\n"
|
"# ${lib.last path}\n\n"
|
||||||
+ (lib.optionalString (info.description != null) "${info.description}\n\n")
|
+ (lib.optionalString (info.description != null) "${info.description}\n\n")
|
||||||
+ (lib.optionalString (info.url != null) "**Url:** [${info.url}](${info.url})\n\n")
|
+ (lib.optionalString (info.url != null) "**Url:** [${info.url}](${info.url})\n\n")
|
||||||
+ (lib.optionalString (
|
+ (lib.optionalString (
|
||||||
builtins.length maintainers > 0
|
maintainers != [ ]
|
||||||
) "**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n")
|
) "**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n")
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
|
@ -26,20 +26,17 @@
|
||||||
with lib;
|
with lib;
|
||||||
{
|
{
|
||||||
# Attribute may contain the following fields:
|
# Attribute may contain the following fields:
|
||||||
# - name: Name of the module
|
# - path: Path to the module, e.g. [ "plugins" "<name>" ]
|
||||||
# - kind: Either colorschemes or plugins
|
|
||||||
# - description: A short description of the plugin
|
# - description: A short description of the plugin
|
||||||
# - url: Url for the plugin
|
# - url: Url for the plugin
|
||||||
#
|
#
|
||||||
# [kind name] will identify the plugin
|
|
||||||
#
|
|
||||||
# We need to use an attrs instead of a submodule to handle the merge.
|
# We need to use an attrs instead of a submodule to handle the merge.
|
||||||
options.meta.nixvimInfo = mkOption {
|
options.meta.nixvimInfo = mkOption {
|
||||||
type = (types.nullOr types.attrs) // {
|
type = (types.nullOr types.attrs) // {
|
||||||
# This will create an attrset of the form:
|
# This will create an attrset of the form:
|
||||||
# {
|
#
|
||||||
# "path"."to"."plugin" = { "<name>" = <info>; };
|
# { path.to.plugin.name = <info>; }
|
||||||
# }
|
#
|
||||||
#
|
#
|
||||||
# Where <info> is an attrset of the form:
|
# Where <info> is an attrset of the form:
|
||||||
# {
|
# {
|
||||||
|
@ -52,12 +49,13 @@
|
||||||
lib.foldl'
|
lib.foldl'
|
||||||
(
|
(
|
||||||
acc: def:
|
acc: def:
|
||||||
lib.recursiveUpdate acc {
|
lib.recursiveUpdate acc (
|
||||||
"${def.value.kind}"."${def.value.name}" = {
|
setAttrByPath def.value.path {
|
||||||
inherit (def.value) url description;
|
|
||||||
inherit (def) file;
|
inherit (def) file;
|
||||||
};
|
url = def.value.url or null;
|
||||||
}
|
description = def.value.description or null;
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
plugins = { };
|
plugins = { };
|
||||||
|
|
|
@ -65,8 +65,11 @@ rec {
|
||||||
meta = {
|
meta = {
|
||||||
inherit maintainers;
|
inherit maintainers;
|
||||||
nixvimInfo = {
|
nixvimInfo = {
|
||||||
inherit description name url;
|
inherit description url;
|
||||||
kind = namespace;
|
path = [
|
||||||
|
namespace
|
||||||
|
name
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,11 @@ with lib;
|
||||||
meta = {
|
meta = {
|
||||||
inherit maintainers;
|
inherit maintainers;
|
||||||
nixvimInfo = {
|
nixvimInfo = {
|
||||||
inherit description name url;
|
inherit description url;
|
||||||
kind = namespace;
|
path = [
|
||||||
|
namespace
|
||||||
|
name
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
options.${namespace}.${name} = {
|
options.${namespace}.${name} = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue