mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-03 05:44:31 +02:00
plugins/neorg: refactor + test + neorg-telescope
This commit is contained in:
parent
6e0a5ba7ec
commit
4a9a3c1f6c
2 changed files with 147 additions and 55 deletions
|
@ -43,7 +43,7 @@ in
|
||||||
};
|
};
|
||||||
fatal = {
|
fatal = {
|
||||||
hl = "ErrorMsg";
|
hl = "ErrorMsg";
|
||||||
level = "5";
|
level = 5;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,88 +70,105 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
modes =
|
modes =
|
||||||
helpers.mkNullOrOption
|
mapAttrs
|
||||||
(types.submodule {
|
(mode: defaults: {
|
||||||
options =
|
hl = helpers.defaultNullOpts.mkStr defaults.hl ''
|
||||||
mapAttrs
|
Highlight for mode ${mode}
|
||||||
(mode: defaults: {
|
'';
|
||||||
hl = helpers.defaultNullOpts.mkStr defaults.hl ''
|
level = mkOption {
|
||||||
Highlight for mode ${mode}
|
type = with types; either int (enum levelNames);
|
||||||
'';
|
default = defaults.level;
|
||||||
level = mkOption {
|
description = "Level for mode ${mode}";
|
||||||
type = with types; either int (enum levelNames);
|
};
|
||||||
default = defaults.level;
|
|
||||||
description = "Level for mode ${mode}";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
modes;
|
|
||||||
})
|
})
|
||||||
"Level configuration";
|
modes;
|
||||||
|
|
||||||
floatPrecision = helpers.defaultNullOpts.mkNullable types.float "0.01" ''
|
floatPrecision = helpers.defaultNullOpts.mkNullable types.float "0.01" ''
|
||||||
Can limit the number of decimals displayed for floats
|
Can limit the number of decimals displayed for floats
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
modules = helpers.mkNullOrOption (types.attrsOf types.attrs) ''
|
modules = mkOption {
|
||||||
Modules configuration.
|
type = with types; attrsOf attrs;
|
||||||
|
description = "Modules configuration.";
|
||||||
Example:
|
default = {};
|
||||||
|
example = {
|
||||||
modules = {
|
"core.defaults" = {__empty = null;};
|
||||||
"core.defaults" = {};
|
"core.dirman" = {
|
||||||
"core.norg.dirman" = {
|
|
||||||
config = {
|
config = {
|
||||||
workspaces = {
|
workspaces = {
|
||||||
work = "~/notes/work";
|
work = "~/notes/work";
|
||||||
home = "~/notes/home";
|
home = "~/notes/home";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'';
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
config = let
|
||||||
options =
|
setupOptions = with cfg;
|
||||||
{
|
{
|
||||||
lazy_loading = cfg.lazyLoading;
|
lazy_loading = lazyLoading;
|
||||||
|
|
||||||
logger = {
|
logger = with logger; {
|
||||||
inherit (cfg.logger) plugin;
|
inherit plugin;
|
||||||
use_console = cfg.logger.useConsole;
|
use_console = useConsole;
|
||||||
inherit (cfg.logger) highlights;
|
inherit highlights;
|
||||||
use_file = cfg.logger.useFile;
|
use_file = useFile;
|
||||||
inherit (cfg.logger) level;
|
inherit level;
|
||||||
|
|
||||||
modes =
|
modes =
|
||||||
if (cfg.logger.modes == null)
|
mapAttrsToList
|
||||||
then null
|
(mode: modeConfig: {
|
||||||
else
|
name = mode;
|
||||||
attrsets.mapAttrsToList
|
inherit (modeConfig) hl;
|
||||||
(mode: modeConfig: {
|
level = let
|
||||||
name = mode;
|
inherit (modeConfig) level;
|
||||||
inherit (modeConfig) hl;
|
in
|
||||||
level = let
|
if (isInt level)
|
||||||
inherit (modeConfig) level;
|
then level
|
||||||
in
|
else helpers.mkRaw "vim.log.levels.${strings.toUpper level}";
|
||||||
if (isInt level)
|
})
|
||||||
then level
|
modes;
|
||||||
else helpers.mkRaw "vim.log.levels.${strings.toUpper level}";
|
float_precision = floatPrecision;
|
||||||
})
|
|
||||||
cfg.logger.modes;
|
|
||||||
float_precision = cfg.logger.floatPrecision;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
load = cfg.modules;
|
load = modules;
|
||||||
}
|
}
|
||||||
// cfg.extraOptions;
|
// cfg.extraOptions;
|
||||||
|
|
||||||
|
telescopeSupport = hasAttr "core.integrations.telescope" cfg.modules;
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
extraPlugins = [cfg.package];
|
warnings =
|
||||||
|
(
|
||||||
|
optional
|
||||||
|
(telescopeSupport && (!config.plugins.telescope.enable))
|
||||||
|
''
|
||||||
|
Telescope support for neorg (`core.integrations.telescope`) is enabled but the
|
||||||
|
telescope plugin is not.
|
||||||
|
''
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
optional
|
||||||
|
((hasAttr "core.defaults" cfg.modules) && (!config.plugins.treesitter.enable))
|
||||||
|
''
|
||||||
|
Neorg's `core.defaults` module is enabled but `plugins.treesitter` is not.
|
||||||
|
Treesitter is required when using the `core.defaults`.
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
extraPlugins =
|
||||||
|
[cfg.package]
|
||||||
|
++ (
|
||||||
|
optional
|
||||||
|
telescopeSupport
|
||||||
|
pkgs.vimPlugins.neorg-telescope
|
||||||
|
);
|
||||||
|
|
||||||
extraConfigLua = ''
|
extraConfigLua = ''
|
||||||
require('neorg').setup(${helpers.toLuaObject options})
|
require('neorg').setup(${helpers.toLuaObject setupOptions})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
75
tests/test-sources/plugins/utils/neorg.nix
Normal file
75
tests/test-sources/plugins/utils/neorg.nix
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.neorg.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins = {
|
||||||
|
# Treesitter is required when using the "core.defaults" module.
|
||||||
|
treesitter.enable = true;
|
||||||
|
|
||||||
|
neorg = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
lazyLoading = false;
|
||||||
|
logger = {
|
||||||
|
plugin = "neorg";
|
||||||
|
useConsole = true;
|
||||||
|
highlights = true;
|
||||||
|
useFile = true;
|
||||||
|
level = "warn";
|
||||||
|
modes = {
|
||||||
|
trace = {
|
||||||
|
hl = "Comment";
|
||||||
|
level = "trace";
|
||||||
|
};
|
||||||
|
debug = {
|
||||||
|
hl = "Comment";
|
||||||
|
level = "debug";
|
||||||
|
};
|
||||||
|
info = {
|
||||||
|
hl = "None";
|
||||||
|
level = "info";
|
||||||
|
};
|
||||||
|
warn = {
|
||||||
|
hl = "WarningMsg";
|
||||||
|
level = "warn";
|
||||||
|
};
|
||||||
|
error = {
|
||||||
|
hl = "ErrorMsg";
|
||||||
|
level = "error";
|
||||||
|
};
|
||||||
|
fatal = {
|
||||||
|
hl = "ErrorMsg";
|
||||||
|
level = 5;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
floatPrecision = 0.01;
|
||||||
|
};
|
||||||
|
|
||||||
|
modules = {
|
||||||
|
"core.defaults" = {__empty = null;};
|
||||||
|
"core.dirman" = {
|
||||||
|
config = {
|
||||||
|
workspaces = {
|
||||||
|
work = "~/notes/work";
|
||||||
|
home = "~/notes/home";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
telescope-integration = {
|
||||||
|
plugins = {
|
||||||
|
telescope.enable = false;
|
||||||
|
|
||||||
|
neorg = {
|
||||||
|
enable = false;
|
||||||
|
modules."core.integrations.telescope".__empty = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue