2023-02-25 18:25:28 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.plugins.neorg;
|
|
|
|
helpers = import ../helpers.nix {inherit lib;};
|
|
|
|
in
|
|
|
|
with lib; {
|
|
|
|
options.plugins.neorg =
|
|
|
|
helpers.extraOptionsOptions
|
|
|
|
// {
|
|
|
|
enable = mkEnableOption "neorg";
|
|
|
|
|
|
|
|
package = helpers.mkPackageOption "neorg" pkgs.vimPlugins.neorg;
|
|
|
|
|
|
|
|
lazyLoading =
|
|
|
|
helpers.defaultNullOpts.mkBool false ''
|
|
|
|
'';
|
|
|
|
|
|
|
|
logger = let
|
|
|
|
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";
|
2023-06-28 22:00:55 +02:00
|
|
|
level = 5;
|
2023-02-25 18:25:28 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
levelNames = attrNames modes;
|
|
|
|
in {
|
|
|
|
plugin = helpers.defaultNullOpts.mkStr "neorg" ''
|
|
|
|
Name of the plugin. Prepended to log messages
|
|
|
|
'';
|
|
|
|
|
|
|
|
useConsole = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Should print the output to neovim while running
|
|
|
|
'';
|
|
|
|
|
|
|
|
highlights = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Should highlighting be used in console (using echohl)
|
|
|
|
'';
|
|
|
|
|
|
|
|
useFile = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Should write to a file
|
|
|
|
'';
|
|
|
|
|
|
|
|
level = helpers.defaultNullOpts.mkEnum levelNames "warn" ''
|
|
|
|
Any messages above this level will be logged
|
|
|
|
'';
|
|
|
|
|
|
|
|
modes =
|
2023-06-28 22:00:55 +02:00
|
|
|
mapAttrs
|
|
|
|
(mode: defaults: {
|
|
|
|
hl = helpers.defaultNullOpts.mkStr defaults.hl ''
|
|
|
|
Highlight for mode ${mode}
|
|
|
|
'';
|
|
|
|
level = mkOption {
|
|
|
|
type = with types; either int (enum levelNames);
|
|
|
|
default = defaults.level;
|
|
|
|
description = "Level for mode ${mode}";
|
|
|
|
};
|
2023-02-25 18:25:28 +01:00
|
|
|
})
|
2023-06-28 22:00:55 +02:00
|
|
|
modes;
|
2023-02-25 18:25:28 +01:00
|
|
|
|
|
|
|
floatPrecision = helpers.defaultNullOpts.mkNullable types.float "0.01" ''
|
|
|
|
Can limit the number of decimals displayed for floats
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-28 22:00:55 +02:00
|
|
|
modules = mkOption {
|
|
|
|
type = with types; attrsOf attrs;
|
|
|
|
description = "Modules configuration.";
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
"core.defaults" = {__empty = null;};
|
|
|
|
"core.dirman" = {
|
2023-02-25 18:25:28 +01:00
|
|
|
config = {
|
|
|
|
workspaces = {
|
2023-06-28 22:00:55 +02:00
|
|
|
work = "~/notes/work";
|
|
|
|
home = "~/notes/home";
|
2023-02-25 18:25:28 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-06-28 22:00:55 +02:00
|
|
|
};
|
2023-02-25 18:25:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = let
|
2023-06-28 22:00:55 +02:00
|
|
|
setupOptions = with cfg;
|
2023-02-25 18:25:28 +01:00
|
|
|
{
|
2023-06-28 22:00:55 +02:00
|
|
|
lazy_loading = lazyLoading;
|
2023-02-25 18:25:28 +01:00
|
|
|
|
2023-06-28 22:00:55 +02:00
|
|
|
logger = with logger; {
|
|
|
|
inherit plugin;
|
|
|
|
use_console = useConsole;
|
|
|
|
inherit highlights;
|
|
|
|
use_file = useFile;
|
|
|
|
inherit level;
|
2023-02-25 18:25:28 +01:00
|
|
|
|
|
|
|
modes =
|
2023-06-28 22:00:55 +02:00
|
|
|
mapAttrsToList
|
|
|
|
(mode: modeConfig: {
|
|
|
|
name = mode;
|
|
|
|
inherit (modeConfig) hl;
|
|
|
|
level = let
|
|
|
|
inherit (modeConfig) level;
|
|
|
|
in
|
|
|
|
if (isInt level)
|
|
|
|
then level
|
|
|
|
else helpers.mkRaw "vim.log.levels.${strings.toUpper level}";
|
|
|
|
})
|
|
|
|
modes;
|
|
|
|
float_precision = floatPrecision;
|
2023-02-25 18:25:28 +01:00
|
|
|
};
|
|
|
|
|
2023-06-28 22:00:55 +02:00
|
|
|
load = modules;
|
2023-02-25 18:25:28 +01:00
|
|
|
}
|
|
|
|
// cfg.extraOptions;
|
2023-06-28 22:00:55 +02:00
|
|
|
|
|
|
|
telescopeSupport = hasAttr "core.integrations.telescope" cfg.modules;
|
2023-02-25 18:25:28 +01:00
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
2023-06-28 22:00:55 +02:00
|
|
|
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
|
|
|
|
);
|
2023-02-25 18:25:28 +01:00
|
|
|
|
|
|
|
extraConfigLua = ''
|
2023-06-28 22:00:55 +02:00
|
|
|
require('neorg').setup(${helpers.toLuaObject setupOptions})
|
2023-02-25 18:25:28 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|