2023-02-25 18:25:28 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
2023-02-25 18:25:28 +01:00
|
|
|
config,
|
2023-11-06 15:04:08 +01:00
|
|
|
pkgs,
|
2023-02-25 18:25:28 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.plugins.neorg;
|
|
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
2024-01-25 16:15:55 +01:00
|
|
|
options.plugins.neorg = helpers.neovim-plugin.extraOptionsOptions // {
|
2023-02-25 18:25:28 +01:00
|
|
|
enable = mkEnableOption "neorg";
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = helpers.mkPluginPackageOption "neorg" pkgs.vimPlugins.neorg;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-02-25 18:25:28 +01:00
|
|
|
lazyLoading = helpers.defaultNullOpts.mkBool false '''';
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-02-25 18:25:28 +01:00
|
|
|
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
|
|
|
};
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
in
|
|
|
|
{
|
2023-02-25 18:25:28 +01:00
|
|
|
plugin = helpers.defaultNullOpts.mkStr "neorg" ''
|
|
|
|
Name of the plugin. Prepended to log messages
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-02-25 18:25:28 +01:00
|
|
|
useConsole = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Should print the output to neovim while running
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-02-25 18:25:28 +01:00
|
|
|
highlights = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Should highlighting be used in console (using echohl)
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-02-25 18:25:28 +01:00
|
|
|
useFile = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Should write to a file
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2023-02-25 18:25:28 +01:00
|
|
|
|
2023-11-30 15:50:24 +01:00
|
|
|
level = helpers.defaultNullOpts.mkEnum (attrNames modes) "warn" ''
|
2023-02-25 18:25:28 +01:00
|
|
|
Any messages above this level will be logged
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-11-30 15:50:24 +01:00
|
|
|
modes = mapAttrs (
|
|
|
|
mode: defaults:
|
|
|
|
helpers.mkCompositeOption "Settings for mode ${mode}." {
|
|
|
|
hl = helpers.defaultNullOpts.mkStr defaults.hl ''
|
|
|
|
Highlight for mode ${mode}.
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-11-30 15:50:24 +01:00
|
|
|
level = helpers.defaultNullOpts.mkLogLevel defaults.level ''
|
|
|
|
Level for mode ${mode}.
|
2024-05-05 19:39:35 +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
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
2024-05-05 19:39:35 +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
|
|
|
|
2023-11-30 15:50:24 +01:00
|
|
|
modes = filter (v: v != null) (
|
|
|
|
mapAttrsToList (
|
|
|
|
mode: modeConfig:
|
|
|
|
helpers.ifNonNull' modeConfig {
|
|
|
|
name = mode;
|
|
|
|
inherit (modeConfig) hl level;
|
|
|
|
}
|
|
|
|
) modes
|
|
|
|
);
|
2023-06-28 22:00:55 +02:00
|
|
|
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`.
|
|
|
|
'');
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-06-28 22:00:55 +02:00
|
|
|
extraPlugins = [ cfg.package ] ++ (optional telescopeSupport pkgs.vimPlugins.neorg-telescope);
|
2024-05-05 19:39:35 +02:00
|
|
|
|
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
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|