diff --git a/modules/core/default.nix b/modules/core/build/default.nix similarity index 76% rename from modules/core/default.nix rename to modules/core/build/default.nix index e4703b6c..3b88e648 100644 --- a/modules/core/default.nix +++ b/modules/core/build/default.nix @@ -8,6 +8,7 @@ inherit (lib) nvim; inherit (nvim.lua) toLuaObject; inherit (nvim.vim) valToVim; + inherit (nvim.bool) mkBool; cfg = config.vim; @@ -20,13 +21,6 @@ EOF ''; - mkBool = value: description: - mkOption { - type = types.bool; - default = value; - inherit description; - }; - # Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you! mapConfigOptions = { silent = @@ -93,60 +87,8 @@ inherit mode; }) maps); - - mapOption = types.submodule { - options = - mapConfigOptions - // { - action = mkOption { - type = types.str; - description = "The action to execute."; - }; - - lua = mkOption { - type = types.bool; - description = '' - If true, `action` is considered to be lua code. - Thus, it will not be wrapped in `""`. - ''; - default = false; - }; - }; - }; - - mapOptions = mode: - mkOption { - description = "Mappings for ${mode} mode"; - type = types.attrsOf mapOption; - default = {}; - }; in { options = { - assertions = lib.mkOption { - type = with types; listOf unspecified; - internal = true; - default = []; - example = literalExpression '' - [ - { - assertion = false; - message = "you can't enable this for that reason"; - } - ] - ''; - }; - - warnings = mkOption { - internal = true; - default = []; - type = with types; listOf str; - example = ["The `foo' service is deprecated and will go away soon!"]; - description = lib.mdDoc '' - This option allows modules to show warnings to users during - the evaluation of the system configuration. - ''; - }; - vim = { viAlias = mkOption { description = "Enable vi alias"; @@ -196,17 +138,19 @@ in { Note that these are setup after builtin plugins. ''; example = literalExpression '' - with pkgs.vimPlugins; { + with pkgs.vimPlugins; { aerial = { package = aerial-nvim; setup = "require('aerial').setup {}"; }; + harpoon = { package = harpoon; setup = "require('harpoon').setup {}"; after = ["aerial"]; }; - }''; + } + ''; }; globals = mkOption { @@ -214,40 +158,6 @@ in { description = "Set containing global variable values"; type = types.attrs; }; - - maps = mkOption { - type = types.submodule { - options = { - normal = mapOptions "normal"; - insert = mapOptions "insert"; - select = mapOptions "select"; - visual = mapOptions "visual and select"; - terminal = mapOptions "terminal"; - normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')"; - - visualOnly = mapOptions "visual only"; - operator = mapOptions "operator-pending"; - insertCommand = mapOptions "insert and command-line"; - lang = mapOptions "insert, command-line and lang-arg"; - command = mapOptions "command-line"; - }; - }; - default = {}; - description = '' - Custom keybindings for any mode. - - For plain maps (e.g. just 'map' or 'remap') use maps.normalVisualOp. - ''; - - example = '' - maps = { - normal."m" = { - silent = true; - action = "make"; - }; # Same as nnoremap m make - }; - ''; - }; }; }; diff --git a/modules/core/mappings/default.nix b/modules/core/mappings/default.nix new file mode 100644 index 00000000..f9b3f823 --- /dev/null +++ b/modules/core/mappings/default.nix @@ -0,0 +1,103 @@ +{lib, ...}: let + inherit (lib) mkOption types; + inherit (lib) nvim; + inherit (nvim.bool) mkBool; + + # Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you! + mapConfigOptions = { + silent = + mkBool false + "Whether this mapping should be silent. Equivalent to adding to a map."; + + nowait = + mkBool false + "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; + + script = + mkBool false + "Equivalent to adding