mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-09 04:07:16 +00:00
modules: start breaking down core modules; simplify tree structure
This commit is contained in:
parent
4703ed7731
commit
370913e827
242 changed files with 178 additions and 124 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
inherit (lib) nvim;
|
inherit (lib) nvim;
|
||||||
inherit (nvim.lua) toLuaObject;
|
inherit (nvim.lua) toLuaObject;
|
||||||
inherit (nvim.vim) valToVim;
|
inherit (nvim.vim) valToVim;
|
||||||
|
inherit (nvim.bool) mkBool;
|
||||||
|
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
|
|
||||||
|
|
@ -20,13 +21,6 @@
|
||||||
EOF
|
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!
|
# Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you!
|
||||||
mapConfigOptions = {
|
mapConfigOptions = {
|
||||||
silent =
|
silent =
|
||||||
|
|
@ -93,60 +87,8 @@
|
||||||
inherit mode;
|
inherit mode;
|
||||||
})
|
})
|
||||||
maps);
|
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 {
|
in {
|
||||||
options = {
|
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 = {
|
vim = {
|
||||||
viAlias = mkOption {
|
viAlias = mkOption {
|
||||||
description = "Enable vi alias";
|
description = "Enable vi alias";
|
||||||
|
|
@ -201,12 +143,14 @@ in {
|
||||||
package = aerial-nvim;
|
package = aerial-nvim;
|
||||||
setup = "require('aerial').setup {}";
|
setup = "require('aerial').setup {}";
|
||||||
};
|
};
|
||||||
|
|
||||||
harpoon = {
|
harpoon = {
|
||||||
package = harpoon;
|
package = harpoon;
|
||||||
setup = "require('harpoon').setup {}";
|
setup = "require('harpoon').setup {}";
|
||||||
after = ["aerial"];
|
after = ["aerial"];
|
||||||
};
|
};
|
||||||
}'';
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
globals = mkOption {
|
globals = mkOption {
|
||||||
|
|
@ -214,40 +158,6 @@ in {
|
||||||
description = "Set containing global variable values";
|
description = "Set containing global variable values";
|
||||||
type = types.attrs;
|
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."<leader>m" = {
|
|
||||||
silent = true;
|
|
||||||
action = "<cmd>make<CR>";
|
|
||||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
|
||||||
};
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
103
modules/core/mappings/default.nix
Normal file
103
modules/core/mappings/default.nix
Normal file
|
|
@ -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 <silent> to a map.";
|
||||||
|
|
||||||
|
nowait =
|
||||||
|
mkBool false
|
||||||
|
"Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
|
||||||
|
|
||||||
|
script =
|
||||||
|
mkBool false
|
||||||
|
"Equivalent to adding <script> to a map.";
|
||||||
|
|
||||||
|
expr =
|
||||||
|
mkBool false
|
||||||
|
"Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
|
||||||
|
|
||||||
|
unique =
|
||||||
|
mkBool false
|
||||||
|
"Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
||||||
|
|
||||||
|
noremap =
|
||||||
|
mkBool true
|
||||||
|
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
||||||
|
|
||||||
|
desc = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
vim = {
|
||||||
|
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."<leader>m" = {
|
||||||
|
silent = true;
|
||||||
|
action = "<cmd>make<CR>";
|
||||||
|
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
31
modules/core/warnings/default.nix
Normal file
31
modules/core/warnings/default.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib) types;
|
||||||
|
inherit (lib.options) mkOption literalExpression;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
assertions = 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 = ''
|
||||||
|
This option allows modules to show warnings to users during
|
||||||
|
the evaluation of the system configuration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -3,33 +3,43 @@
|
||||||
lib,
|
lib,
|
||||||
check ? true,
|
check ? true,
|
||||||
}: let
|
}: let
|
||||||
|
inherit (lib) mkDefault;
|
||||||
|
|
||||||
|
plugins = builtins.map (p: ./plugins + "/${p}") [
|
||||||
|
"completion"
|
||||||
|
"theme"
|
||||||
|
"statusline"
|
||||||
|
"tabline"
|
||||||
|
"filetree"
|
||||||
|
"visuals"
|
||||||
|
"lsp"
|
||||||
|
"treesitter"
|
||||||
|
"autopairs"
|
||||||
|
"snippets"
|
||||||
|
"git"
|
||||||
|
"minimap"
|
||||||
|
"dashboard"
|
||||||
|
"utility"
|
||||||
|
"rich-presence"
|
||||||
|
"notes"
|
||||||
|
"terminal"
|
||||||
|
"ui"
|
||||||
|
"assistant"
|
||||||
|
"session"
|
||||||
|
"comments"
|
||||||
|
"projects"
|
||||||
|
"languages"
|
||||||
|
"debugger"
|
||||||
|
];
|
||||||
|
|
||||||
|
core = builtins.map (p: ./core + "/${p}") [
|
||||||
|
"build"
|
||||||
|
"mappings"
|
||||||
|
"warnings"
|
||||||
|
];
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
./completion
|
./neovim
|
||||||
./theme
|
|
||||||
./core
|
|
||||||
./basic
|
|
||||||
./statusline
|
|
||||||
./tabline
|
|
||||||
./filetree
|
|
||||||
./visuals
|
|
||||||
./lsp
|
|
||||||
./treesitter
|
|
||||||
./autopairs
|
|
||||||
./snippets
|
|
||||||
./git
|
|
||||||
./minimap
|
|
||||||
./dashboard
|
|
||||||
./utility
|
|
||||||
./rich-presence
|
|
||||||
./notes
|
|
||||||
./terminal
|
|
||||||
./ui
|
|
||||||
./assistant
|
|
||||||
./session
|
|
||||||
./comments
|
|
||||||
./projects
|
|
||||||
./languages
|
|
||||||
./debugger
|
|
||||||
];
|
];
|
||||||
|
|
||||||
pkgsModule = {config, ...}: {
|
pkgsModule = {config, ...}: {
|
||||||
|
|
@ -38,11 +48,11 @@
|
||||||
inherit check;
|
inherit check;
|
||||||
args = {
|
args = {
|
||||||
baseModules = modules;
|
baseModules = modules;
|
||||||
pkgsPath = lib.mkDefault pkgs.path;
|
pkgsPath = mkDefault pkgs.path;
|
||||||
pkgs = lib.mkDefault pkgs;
|
pkgs = mkDefault pkgs;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
modules ++ [pkgsModule]
|
[pkgsModule] ++ (lib.concatLists [core modules plugins])
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue