diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index 7da3e2a..66246e3 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -1,15 +1,19 @@ # Home Manager module packages: inputs: { - pkgs, config, + pkgs, lib ? pkgs.lib, - self, ... -}: -with lib; let +}: let + inherit (lib) maintainers; + inherit (lib.modules) mkIf; + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) attrsOf anything; + cfg = config.programs.neovim-flake; inherit (import ../../configuration.nix inputs) neovimConfiguration; - set = neovimConfiguration { + + builtPackage = neovimConfiguration { inherit pkgs; modules = [cfg.settings]; }; @@ -17,10 +21,10 @@ in { meta.maintainers = with maintainers; [NotAShelf]; options.programs.neovim-flake = { - enable = mkEnableOption "A NeoVim IDE with a focus on configurability and extensibility."; + enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper"; settings = mkOption { - type = types.attrsOf types.anything; + type = attrsOf anything; default = {}; example = literalExpression '' { @@ -44,6 +48,6 @@ in { }; config = mkIf cfg.enable { - home.packages = [set.neovim]; + home.packages = [builtPackage]; }; } diff --git a/lib/default.nix b/lib/default.nix index 94db90b..333e832 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,6 +1,5 @@ {lib}: { types = import ./types {inherit lib;}; - binds = import ./binds.nix {inherit lib;}; dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; diff --git a/modules/basic/config.nix b/modules/basic/config.nix deleted file mode 100644 index a74a6a9..0000000 --- a/modules/basic/config.nix +++ /dev/null @@ -1,188 +0,0 @@ -{ - lib, - config, - ... -}: let - inherit (builtins) concatStringsSep; - inherit (lib.modules) mkIf; - inherit (lib.lists) optionals; - inherit (lib.strings) optionalString; - inherit (lib.nvim.dag) entryAfter; - - cfg = config.vim; -in { - config = { - vim.startPlugins = ["plenary-nvim"] ++ optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"]; - - vim.maps.normal = - mkIf cfg.disableArrows { - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - } - // mkIf cfg.mapLeaderSpace { - "" = { - action = ""; - }; - }; - - vim.maps.insert = mkIf cfg.disableArrows { - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - }; - - vim.configRC.basic = entryAfter ["globalsScript"] '' - " Settings that are set for everything - set encoding=utf-8 - set mouse=${cfg.mouseSupport} - set tabstop=${toString cfg.tabWidth} - set shiftwidth=${toString cfg.tabWidth} - set softtabstop=${toString cfg.tabWidth} - set expandtab - set cmdheight=${toString cfg.cmdHeight} - set updatetime=${toString cfg.updateTime} - set shortmess+=c - set tm=${toString cfg.mapTimeout} - set hidden - set cursorlineopt=${toString cfg.cursorlineOpt} - set scrolloff=${toString cfg.scrollOffset} - - ${optionalString cfg.debugMode.enable '' - " Debug mode settings - set verbose=${toString cfg.debugMode.level} - set verbosefile=${cfg.debugMode.logFile} - ''} - - ${optionalString cfg.splitBelow '' - set splitbelow - ''} - - ${optionalString cfg.splitRight '' - set splitright - ''} - - ${optionalString cfg.showSignColumn '' - set signcolumn=yes - ''} - - ${optionalString cfg.autoIndent '' - set autoindent - ''} - - ${optionalString cfg.preventJunkFiles '' - set noswapfile - set nobackup - set nowritebackup - ''} - - ${optionalString (cfg.bell == "none") '' - set noerrorbells - set novisualbell - ''} - - ${optionalString (cfg.bell == "on") '' - set novisualbell - ''} - - ${optionalString (cfg.bell == "visual") '' - set noerrorbells - ''} - - ${optionalString (cfg.lineNumberMode == "relative") '' - set relativenumber - ''} - - ${optionalString (cfg.lineNumberMode == "number") '' - set number - ''} - - ${optionalString (cfg.lineNumberMode == "relNumber") '' - set number relativenumber - ''} - - ${optionalString cfg.useSystemClipboard '' - set clipboard+=unnamedplus - ''} - - ${optionalString cfg.mapLeaderSpace '' - let mapleader=" " - let maplocalleader=" " - ''} - - ${optionalString cfg.syntaxHighlighting '' - syntax on - ''} - - ${optionalString (!cfg.wordWrap) '' - set nowrap - ''} - - ${optionalString cfg.hideSearchHighlight '' - set nohlsearch - set incsearch - ''} - - ${optionalString cfg.colourTerm '' - set termguicolors - set t_Co=256 - ''} - - ${optionalString (!cfg.enableEditorconfig) '' - let g:editorconfig = v:false - ''} - - ${optionalString cfg.spellChecking.enable '' - set spell - set spelllang=${concatStringsSep "," cfg.spellChecking.languages}${optionalString cfg.spellChecking.enableProgrammingWordList ",programming"} - ''} - - ${optionalString (cfg.leaderKey != null) '' - let mapleader = "${toString cfg.leaderKey}" - ''} - - ${optionalString (cfg.searchCase == "ignore") '' - set nosmartcase - set ignorecase - ''} - - ${optionalString (cfg.searchCase == "smart") '' - set smartcase - set ignorecase - ''} - - ${optionalString (cfg.searchCase == "sensitive") '' - set nosmartcase - set noignorecase - ''} - ''; - }; -} diff --git a/modules/core/build/config.nix b/modules/core/build/config.nix new file mode 100644 index 0000000..068319e --- /dev/null +++ b/modules/core/build/config.nix @@ -0,0 +1,322 @@ +{ + config, + lib, + ... +}: let + inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter; + inherit (lib.options) mkOption; + inherit (lib.attrsets) filterAttrs getAttrs; + inherit (lib.strings) optionalString; + inherit (lib.misc) mapAttrsFlatten; + inherit (lib.trivial) showWarnings; + inherit (lib.types) bool str oneOf attrsOf nullOr attrs submodule lines; + inherit (lib.nvim.types) dagOf; + inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.vim) valToVim; + + cfg = config.vim; + + wrapLuaConfig = luaConfig: '' + lua << EOF + ${optionalString cfg.enableLuaLoader '' + vim.loader.enable() + ''} + ${luaConfig} + EOF + ''; + + mkBool = value: description: + mkOption { + type = bool; + default = value; + inherit description; + }; + + # 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