From 27eedd0db60cccaff8056a6a34feb2ab5c7aafd1 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:05:13 +0300 Subject: [PATCH 01/14] plugins/spellcheck: use the internal `vim.spellChecking` as enable condition --- modules/plugins/spellcheck/vim-dirtytalk/config.nix | 4 ++-- .../plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/plugins/spellcheck/vim-dirtytalk/config.nix b/modules/plugins/spellcheck/vim-dirtytalk/config.nix index 3057ac1..edfe1c7 100644 --- a/modules/plugins/spellcheck/vim-dirtytalk/config.nix +++ b/modules/plugins/spellcheck/vim-dirtytalk/config.nix @@ -5,9 +5,9 @@ }: let inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAfter; - cfg = config.vim.spellcheck; + cfg = config.vim.spellChecking; in { - config = mkIf cfg.vim-dirtytalk.enable { + config = mkIf (cfg.enable && cfg.programmingWordlist.enable) { vim = { startPlugins = ["vim-dirtytalk"]; diff --git a/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix b/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix index b7c59b5..d996fef 100644 --- a/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix +++ b/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix @@ -1,7 +1,7 @@ {lib, ...}: let - inherit (lib.options) mkEnableOption; + inherit (lib.modules) mkAliasOptionModule; in { - options.vim.spellcheck.vim-dirtytalk = { - enable = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words"; - }; + imports = [ + (mkAliasOptionModule ["vim" "spellcheck" "vim-dirtytalk" "enable"] ["vim" "spellChecking" "programmingWordlist" "enable"]) + ]; } From 4c5b33b8275c721cfd840b3d5a9c946e91b4523e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:07:35 +0300 Subject: [PATCH 02/14] wrapper: enable spellchecking for maximal package --- configuration.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configuration.nix b/configuration.nix index 7e55050..e4ac841 100644 --- a/configuration.nix +++ b/configuration.nix @@ -23,11 +23,14 @@ inputs: let vimAlias = true; debugMode = { enable = false; - level = 20; + level = 16; logFile = "/tmp/nvim.log"; }; - spellcheck.vim-dirtytalk.enable = true; + spellChecking = { + enable = isMaximal; + programmingWordlist.enable = isMaximal; + }; lsp = { formatOnSave = true; From 49978655475ee47cc198c619880e4d8a8155dab0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:08:07 +0300 Subject: [PATCH 03/14] types/plugins: inherit `example` in pluginsOpt --- lib/types/plugins.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index e1b8259..f6cdcdb 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -56,10 +56,11 @@ in { pluginsOpt = { description, + example, default ? [], }: mkOption { - inherit description default; + inherit example description default; type = pluginsType; }; From 6eea801cd6a2a6225cb2096785203a66c3c63da5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:09:11 +0300 Subject: [PATCH 04/14] neovim/spellcheck: allow disabling spellchecking for filetypes --- modules/neovim/init/spellcheck.nix | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 modules/neovim/init/spellcheck.nix diff --git a/modules/neovim/init/spellcheck.nix b/modules/neovim/init/spellcheck.nix new file mode 100644 index 0000000..71607ac --- /dev/null +++ b/modules/neovim/init/spellcheck.nix @@ -0,0 +1,66 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; + inherit (lib.types) listOf str; + inherit (lib.nvim.lua) listToLuaTable; + inherit (lib.nvim.dag) entryAfter; + + cfg = config.vim.spellChecking; +in { + options.vim.spellChecking = { + enable = mkEnableOption "neovim's built-in spellchecking"; + languages = mkOption { + type = listOf str; + default = ["en"]; + example = literalExpression ''["en" "de"]''; + description = literalMD '' + A list of languages that should be used for spellchecking. + + To add your own language files, you may place your `spell` + directory in either {path}`~/.config/nvim` or the + [additionalRuntimePaths](#opt-vim.additionalRuntimePaths) + directory provided by neovim-flake. + ''; + }; + + ignoredFiletypes = mkOption { + type = listOf str; + default = ["toggleterm"]; + example = literalExpression ''["markdown" "gitcommit"]''; + description = '' + A list of filetypes for which spellchecking will be disabled. + + You may use `echo &filetype` in neovim to find out the + filetype for a specific buffer. + ''; + }; + + programmingWordlist.enable = mkEnableOption '' + vim-dirtytalk, a wordlist for programmers containing + common programming terms. + + Setting this value as `true` has the same effect + as setting {option}`vim.spellCheck.enable` + ''; + }; + + config = mkIf cfg.enable { + vim.luaConfigRC.spellchecking = entryAfter ["basic"] '' + vim.opt.spell = true + vim.opt.spelllang = ${listToLuaTable cfg.languages} + + -- Disable spellchecking for certain filetypes + -- as configured by `vim.spellChecking.ignoredFiletypes` + vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = ${listToLuaTable cfg.ignoredFiletypes}, + callback = function() + vim.opt_local.spell = false + end, + }) + ''; + }; +} From 43263040a43aaabcd737c3abd174505699aae0cd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:09:39 +0300 Subject: [PATCH 05/14] treewide: restructure modules directory; add comments to modules top-level import --- modules/core/build/options.nix | 87 -------------- modules/modules.nix | 22 ++-- modules/neovim/basic/spellcheck.nix | 34 ------ modules/neovim/config.nix | 5 - modules/neovim/default.nix | 4 +- .../{basic/configrc.nix => init/basic.nix} | 13 +-- modules/neovim/init/debug.nix | 50 +++++++++ modules/neovim/{basic => init}/default.nix | 3 +- modules/neovim/mappings/default.nix | 58 +++++----- modules/{core => wrapper}/build/config.nix | 17 +-- modules/{core => wrapper}/build/default.nix | 0 modules/wrapper/build/options.nix | 106 ++++++++++++++++++ modules/{core => wrapper}/default.nix | 0 .../{core => wrapper}/warnings/default.nix | 0 14 files changed, 218 insertions(+), 181 deletions(-) delete mode 100644 modules/core/build/options.nix delete mode 100644 modules/neovim/basic/spellcheck.nix delete mode 100644 modules/neovim/config.nix rename modules/neovim/{basic/configrc.nix => init/basic.nix} (97%) create mode 100644 modules/neovim/init/debug.nix rename modules/neovim/{basic => init}/default.nix (57%) rename modules/{core => wrapper}/build/config.nix (96%) rename modules/{core => wrapper}/build/default.nix (100%) create mode 100644 modules/wrapper/build/options.nix rename modules/{core => wrapper}/default.nix (100%) rename modules/{core => wrapper}/warnings/default.nix (100%) diff --git a/modules/core/build/options.nix b/modules/core/build/options.nix deleted file mode 100644 index 11f3ff9..0000000 --- a/modules/core/build/options.nix +++ /dev/null @@ -1,87 +0,0 @@ -{ - pkgs, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption literalExpression; - inherit (lib.types) path int package bool str listOf attrsOf; - inherit (lib.nvim.types) pluginsOpt extraPluginType; -in { - options.vim = { - package = mkOption { - type = package; - default = pkgs.neovim-unwrapped; - description = '' - The neovim package to use. - - You will need to use an unwrapped package for this option to work as intended. - ''; - }; - - debugMode = { - enable = mkEnableOption "debug mode"; - level = mkOption { - type = int; - default = 20; - description = "Set the debug level"; - }; - - logFile = mkOption { - type = path; - default = "/tmp/nvim.log"; - description = "Set the log file"; - }; - }; - - viAlias = mkOption { - description = "Enable vi alias"; - type = bool; - default = true; - }; - - vimAlias = mkOption { - description = "Enable vim alias"; - type = bool; - default = true; - }; - - startPlugins = pluginsOpt { - default = []; - description = "List of plugins to startup."; - }; - - optPlugins = pluginsOpt { - default = []; - description = "List of plugins to optionally load"; - }; - - extraPlugins = mkOption { - type = attrsOf extraPluginType; - default = {}; - description = '' - List of plugins and related config. - Note that these are setup after builtin plugins. - ''; - example = literalExpression '' - with pkgs.vimPlugins; { - aerial = { - package = aerial-nvim; - setup = "require('aerial').setup {}"; - }; - harpoon = { - package = harpoon; - setup = "require('harpoon').setup {}"; - after = ["aerial"]; - }; - }''; - }; - - luaPackages = mkOption { - type = listOf str; - default = []; - description = '' - List of lua packages to install. - ''; - }; - }; -} diff --git a/modules/modules.nix b/modules/modules.nix index 8c34046..77a35ea 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -6,16 +6,17 @@ inherit (lib.modules) mkDefault; inherit (lib.lists) concatLists; - core = map (p: ./core + "/${p}") [ - "build" - "warnings" - ]; - + # The core neovim modules. + # Contains configuration for core neovim features + # such as spellchecking, mappings, and the init script (init.vim). neovim = map (p: ./neovim + "/${p}") [ - "basic" + "init" "mappings" ]; + # Individual plugin modules, separated by the type of plugin. + # While adding a new type, you must make sure your type is + # included in the list below. plugins = map (p: ./plugins + "/${p}") [ "assistant" "autopairs" @@ -44,7 +45,14 @@ "visuals" ]; - allModules = concatLists [core neovim plugins]; + # The neovim wrapper, used to build a wrapped neovim package + # using the configuration passed in `neovim` and `plugins` modules. + wrapper = map (p: ./wrapper + "/${p}") [ + "build" + "warnings" + ]; + + allModules = concatLists [neovim plugins wrapper]; pkgsModule = {config, ...}: { config = { diff --git a/modules/neovim/basic/spellcheck.nix b/modules/neovim/basic/spellcheck.nix deleted file mode 100644 index c0644d6..0000000 --- a/modules/neovim/basic/spellcheck.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - inherit (lib.options) mkEnableOption literalExpression mkOption; - inherit (lib.strings) concatStringsSep; - inherit (lib.lists) optionals; - inherit (lib.types) listOf str; - inherit (lib.nvim.dag) entryAfter; - - cfg = config.vim.spellChecking; -in { - options.vim.spellChecking = { - enable = mkEnableOption "neovim's built-in spellchecking"; - languages = mkOption { - type = listOf str; - default = ["en"]; - example = literalExpression ''["en" "de"]''; - description = "The languages to be used for spellchecking"; - }; - }; - - config = mkIf cfg.enable { - vim = { - configRC.spellchecking = entryAfter ["basic"] '' - " Spellchecking - set spell - set spelllang=${concatStringsSep "," cfg.languages} - ''; - }; - }; -} diff --git a/modules/neovim/config.nix b/modules/neovim/config.nix deleted file mode 100644 index 7c0e502..0000000 --- a/modules/neovim/config.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - config = { - vim.startPlugins = ["plenary-nvim"]; - }; -} diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index fc69155..2342bef 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -1,8 +1,6 @@ { imports = [ - ./basic + ./init ./mappings - - ./config.nix ]; } diff --git a/modules/neovim/basic/configrc.nix b/modules/neovim/init/basic.nix similarity index 97% rename from modules/neovim/basic/configrc.nix rename to modules/neovim/init/basic.nix index 8f7fed0..e3af1e7 100644 --- a/modules/neovim/basic/configrc.nix +++ b/modules/neovim/init/basic.nix @@ -145,6 +145,7 @@ in { default = true; description = "New splits will open to the right"; }; + enableEditorconfig = mkOption { type = bool; default = true; @@ -167,25 +168,19 @@ in { config.vim.configRC.basic = entryAfter ["globalsScript"] '' " Settings that are set for everything set encoding=utf-8 + set hidden + set shortmess+=c + set expandtab 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 ''} diff --git a/modules/neovim/init/debug.nix b/modules/neovim/init/debug.nix new file mode 100644 index 0000000..7b801c8 --- /dev/null +++ b/modules/neovim/init/debug.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.strings) optionalString; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) path enum nullOr; + inherit (lib.nvim.dag) entryAfter; + + cfg = config.vim.debugMode; +in { + options.vim = { + debugMode = { + enable = mkEnableOption "debug mode"; + level = mkOption { + type = enum [2 3 4 5 8 9 11 12 13 14 15 16]; + default = 16; + description = '' + Set verbosity level of Neovim while debug mode is enabled. + + Value must be be one of the levels expected by Neovim's + [`verbose` option](https://neovim.io/doc/user/options.html#'verbose') + ''; + }; + + logFile = mkOption { + type = nullOr path; + default = null; + description = '' + Set the log file that will be used to store verbose messages + set by the `verbose` option. + ''; + }; + }; + }; + + config.vim = mkIf cfg.enable { + luaConfigRC.debug-mode = entryAfter ["basic"] '' + -- Debug mode settings + vim.o.verbose = ${toString cfg.level}, + + ${optionalString (cfg.logFile != null) '' + -- Set verbose log file + vim.o.verbosefile = ${cfg.logFile}, + ''} + ''; + }; +} diff --git a/modules/neovim/basic/default.nix b/modules/neovim/init/default.nix similarity index 57% rename from modules/neovim/basic/default.nix rename to modules/neovim/init/default.nix index b744d48..11d9cf5 100644 --- a/modules/neovim/basic/default.nix +++ b/modules/neovim/init/default.nix @@ -1,6 +1,7 @@ { imports = [ - ./configrc.nix + ./basic.nix + ./debug.nix ./spellcheck.nix ]; } diff --git a/modules/neovim/mappings/default.nix b/modules/neovim/mappings/default.nix index 77438a7..8bc58af 100644 --- a/modules/neovim/mappings/default.nix +++ b/modules/neovim/mappings/default.nix @@ -7,17 +7,42 @@ cfg = config.vim; in { - vim.maps = { - normal = - mkIf cfg.disableArrows { + config = { + vim.maps = { + normal = + mkIf cfg.disableArrows { + "" = { + action = ""; + + noremap = false; + }; + "" = { + action = ""; + + noremap = false; + }; + "" = { + action = ""; + noremap = false; + }; + "" = { + action = ""; + noremap = false; + }; + } + // mkIf cfg.mapLeaderSpace { + "" = { + action = ""; + }; + }; + + insert = mkIf cfg.disableArrows { "" = { action = ""; - noremap = false; }; "" = { action = ""; - noremap = false; }; "" = { @@ -28,29 +53,6 @@ in { action = ""; noremap = false; }; - } - // mkIf cfg.mapLeaderSpace { - "" = { - action = ""; - }; - }; - - insert = mkIf cfg.disableArrows { - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; }; }; }; diff --git a/modules/core/build/config.nix b/modules/wrapper/build/config.nix similarity index 96% rename from modules/core/build/config.nix rename to modules/wrapper/build/config.nix index 1ece2d2..17c3695 100644 --- a/modules/core/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -13,7 +13,7 @@ inherit (lib.generators) mkLuaInline; inherit (lib.nvim.types) dagOf; inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort mkLuarcSection mkVimrcSection; - inherit (lib.nvim.lua) toLuaObject wrapLuaConfig; + inherit (lib.nvim.lua) toLuaObject wrapLuaConfig listToLuaTable; inherit (lib.nvim.vim) valToVim; inherit (lib.nvim.config) mkBool; @@ -207,12 +207,15 @@ in { luaConfigPre = mkOption { type = str; - default = let - additionalRuntimePaths = concatStringsSep "," cfg.additionalRuntimePaths; - in '' + default = '' ${optionalString (cfg.additionalRuntimePaths != []) '' - if not vim.o.runtimepath:find('${additionalRuntimePaths}', 1, true) then - vim.o.runtimepath = vim.o.runtimepath .. ',' .. '${additionalRuntimePaths}' + -- The following list is generated from `vim.additionalRuntimePaths` + -- and is used to append additional runtime paths to the + -- `runtimepath` option. + local additionalRuntimePaths = ${listToLuaTable cfg.additionalRuntimePaths}; + + for _, path in ipairs(additionalRuntimePaths) do + vim.opt.runtimepath:append(path) end ''} @@ -226,7 +229,7 @@ in { if [vim.enableLuaLoader](#opt-vim.enableLuaLoader) is set to true. ''; - description = '' + description = literalMD '' Verbatim lua code that will be inserted **before** the result of `luaConfigRc` DAG has been resolved. diff --git a/modules/core/build/default.nix b/modules/wrapper/build/default.nix similarity index 100% rename from modules/core/build/default.nix rename to modules/wrapper/build/default.nix diff --git a/modules/wrapper/build/options.nix b/modules/wrapper/build/options.nix new file mode 100644 index 0000000..09bcf1f --- /dev/null +++ b/modules/wrapper/build/options.nix @@ -0,0 +1,106 @@ +{ + pkgs, + lib, + ... +}: let + inherit (lib.options) mkOption literalExpression; + inherit (lib.types) package bool str listOf attrsOf; + inherit (lib.nvim.types) pluginsOpt extraPluginType; +in { + options.vim = { + package = mkOption { + type = package; + default = pkgs.neovim-unwrapped; + description = '' + The neovim package to use. + + ::: {.warning} + You will need to use an unwrapped package for this + option to work as intended. + ::: + ''; + }; + + viAlias = mkOption { + type = bool; + default = true; + description = "Enable the `vi` alias for `nvim`"; + }; + + vimAlias = mkOption { + type = bool; + default = true; + description = "Enable the `vim` alias for `nvim`"; + }; + + startPlugins = pluginsOpt { + default = ["plenary-nvim"]; + example = literalExpression '' + [pkgs.vimPlugins.telescope-nvim] + ''; + + description = '' + List of plugins to load on startup. This is used + internally to add plugins to Neovim's runtime. + + To add additional plugins to your configuration, consider + using the [{option}`vim.extraPlugins`](#opt-vim.optPlugins) + option. + ''; + }; + + optPlugins = pluginsOpt { + default = []; + example = literalExpression '' + [pkgs.vimPlugins.vim-ghost] + ''; + description = '' + List of plugins to optionally load on startup. + + This option has the same type definition as {option}`vim.startPlugins` + and plugins in this list are appended to {option}`vim.startPlugins` by + the wrapper during the build process. + + To avoid overriding packages and dependencies provided by startPlugins, you + are recommended to use this option or {option}`vim.extraPlugins` option. + ''; + }; + + extraPlugins = mkOption { + type = attrsOf extraPluginType; + default = {}; + description = '' + A list of plugins and their configurations that will be + set up after builtin plugins. + + This option takes a special type that allows you to order + your custom plugins using neovim-flake's modified DAG + library. + ''; + + example = literalExpression '' + with pkgs.vimPlugins; { + aerial = { + package = aerial-nvim; + setup = "require('aerial').setup {}"; + }; + + harpoon = { + package = harpoon; + setup = "require('harpoon').setup {}"; + after = ["aerial"]; # place harpoon configuration after aerial + }; + } + ''; + }; + + luaPackages = mkOption { + type = listOf str; + default = []; + example = literalExpression ''["magick" "serpent"]''; + description = '' + List of lua packages to install. + ''; + }; + }; +} diff --git a/modules/core/default.nix b/modules/wrapper/default.nix similarity index 100% rename from modules/core/default.nix rename to modules/wrapper/default.nix diff --git a/modules/core/warnings/default.nix b/modules/wrapper/warnings/default.nix similarity index 100% rename from modules/core/warnings/default.nix rename to modules/wrapper/warnings/default.nix From 738f6709ff6002f698c4ffed0e54d06456b74232 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:19:21 +0300 Subject: [PATCH 06/14] docs: update v0.6 release notes --- docs/release-notes/rl-0.6.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index f75c54a..26e567f 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -59,6 +59,10 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = - Added rose-pine theme +[jacekpoz](https://github.com/jacekpoz): + +- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated. + [horriblename](https://github.com/horriblename): - Fixed empty winbar when breadcrumbs are disabled @@ -122,7 +126,8 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = - Changed the tree structure to distinguish between core options and plugin options. - Added plugin auto-discovery from plugin inputs. This is mostly from - [JordanIsaac's neovim-flake](https://github.com/jordanisaacs/neovim-flake) + [JordanIsaac's neovim-flake](https://github.com/jordanisaacs/neovim-flake). Allows contributors to add plugin inputs + with the `plugin-` prefix to have them automatically discovered for the `plugin` type in `lib/types`. - Moved internal `wrapLuaConfig` to the extended library, structured its arguments to take `luaBefore`, `luaConfig` and `luaAfter` as strings, which are then concatted inside a lua block. @@ -131,6 +136,7 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = for inserting verbatim Lua configuration before and after the resolved Lua DAG respectively. Both of those options take strings as the type, so you may read the contents of a Lua file from a given path. -[jacekpoz](https://github.com/jacekpoz): - -- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated. +- Added [`vim.spellChecking.ignoredFiletypes`](vim.spellChecking.ignoredFiletypes) + and [`vim.spellChecking.programmingWordlist.enable`](vim.spellChecking.programmingWordlist.enable) for ignoring certain filetypes + in spellchecking and enabling `vim-dirtytalk` respectively. The previously used `vim.spellcheck.vim-dirtytalk` aliases to the latter + option. From 5c7fd22c1d29738b1dfa0b45827700a1dbe8e321 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 18:59:55 +0300 Subject: [PATCH 07/14] flake: update inputs --- flake.lock | 120 ++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/flake.lock b/flake.lock index af5c550..bbc3dab 100644 --- a/flake.lock +++ b/flake.lock @@ -131,11 +131,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712791164, - "narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=", + "lastModified": 1713537308, + "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1042fd8b148a9105f3c0aca3a6177fd1d9360ba5", + "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", "type": "github" }, "original": { @@ -262,11 +262,11 @@ "plugin-catppuccin": { "flake": false, "locked": { - "lastModified": 1713033163, - "narHash": "sha256-hmWp/+qFEJ0zZBjR6kz+EuyHswI0T+DhmUneSPZVhkM=", + "lastModified": 1713105352, + "narHash": "sha256-yTVou/WArEWygBBs2NFPI9Dm9iSGfwVftKFbOAGl8tk=", "owner": "catppuccin", "repo": "nvim", - "rev": "fc98570d85ae772e56dc42cf8d7d6a497a909bdb", + "rev": "a1439ad7c584efb3d0ce14ccb835967f030450fe", "type": "github" }, "original": { @@ -502,11 +502,11 @@ "plugin-dashboard-nvim": { "flake": false, "locked": { - "lastModified": 1712210522, - "narHash": "sha256-i/kKj69yeij/aUP3RpIL1opN5tUiy6C1vehSSLYHbgw=", + "lastModified": 1713420371, + "narHash": "sha256-zcWBgDM409n6rmb06FqVXbC+HU9HJN0+ADoTJDWHvbA=", "owner": "glepnir", "repo": "dashboard-nvim", - "rev": "681300934baf36f6184ca41f0b26aed22056d4ee", + "rev": "6d06924b562de6f0bb136edf1bf549afbf6b7d00", "type": "github" }, "original": { @@ -566,11 +566,11 @@ "plugin-elixir-ls": { "flake": false, "locked": { - "lastModified": 1711286188, - "narHash": "sha256-OIB5f+FBOPsTWKGWyoU+/NQDMsJXBdj1v7UclbTP5ZY=", + "lastModified": 1713432893, + "narHash": "sha256-4xIX5j920uKYHvwH+Ftid4UixMa274a/37CZIw6dg6M=", "owner": "elixir-lsp", "repo": "elixir-ls", - "rev": "3e71900e0d0891f9f95e35d9a52b16c6a773a259", + "rev": "df03608f11700ece5c8f8202ccd4d7f296df54df", "type": "github" }, "original": { @@ -582,11 +582,11 @@ "plugin-elixir-tools": { "flake": false, "locked": { - "lastModified": 1710172806, - "narHash": "sha256-pVDeS9oCFzA9t9J/JfYG/RfdMoSmaaERd5nUgL9KHyM=", + "lastModified": 1713617654, + "narHash": "sha256-pJgtW51FLs+Yr+tlQckRmGkRnSUQNI3fEROn3D51mMs=", "owner": "elixir-tools", "repo": "elixir-tools.nvim", - "rev": "4d003f4b41ab9b4f8b569104fa7818f048ed4e25", + "rev": "3c4f8344a341818417b3d75c04eb96d894cb4640", "type": "github" }, "original": { @@ -614,11 +614,11 @@ "plugin-flutter-tools": { "flake": false, "locked": { - "lastModified": 1711622317, - "narHash": "sha256-TQRz2MHg6qnzZGUDVFUoaZJiTBwQ3Hjqvc8AAeVS93Y=", + "lastModified": 1713525182, + "narHash": "sha256-krcaaDPJsftkrcEov1QdKQUQBH6+PgjNwFamWpmNFkU=", "owner": "akinsho", "repo": "flutter-tools.nvim", - "rev": "4f18033c3b78aa5450e538d81dfbbb3e67aeadec", + "rev": "f04131d6b2c82c2a7624a8843642d6269b50b437", "type": "github" }, "original": { @@ -646,11 +646,11 @@ "plugin-gitsigns-nvim": { "flake": false, "locked": { - "lastModified": 1712937200, - "narHash": "sha256-8pAy6mICiXpUO36ctWXbmRVB7cDSSDIArh9Nq59az9I=", + "lastModified": 1713620636, + "narHash": "sha256-UK3DyvrQ0kLm9wrMQ6tLDoDunoThbY/Yfjn+eCZpuMw=", "owner": "lewis6991", "repo": "gitsigns.nvim", - "rev": "d96ef3bbff0bdbc3916a220f5c74a04c4db033f2", + "rev": "035da036e68e509ed158414416c827d022d914bd", "type": "github" }, "original": { @@ -742,11 +742,11 @@ "plugin-image-nvim": { "flake": false, "locked": { - "lastModified": 1712327429, - "narHash": "sha256-usDtW+WnaeTdxx1ALCiZu/gnx2so7QneOjWoEXiChoQ=", + "lastModified": 1713467683, + "narHash": "sha256-qSGtiBl94RJMffoxXEV74fNcmrYcKtfPc3Aw65tzuDM=", "owner": "3rd", "repo": "image.nvim", - "rev": "9be5ede323756d7ee2bbef2bc157767b3972cce6", + "rev": "301de7919b2c0378cb7a782663f67abbcb198b17", "type": "github" }, "original": { @@ -1015,11 +1015,11 @@ "plugin-nvim-bufferline-lua": { "flake": false, "locked": { - "lastModified": 1709805539, - "narHash": "sha256-drvgwupiyRAoShL2enXEYUumkYJnG+QtIkBIVqVZK+U=", + "lastModified": 1713525468, + "narHash": "sha256-28ZkN2o6xumhvXGbxRl3/eODhMOgJfOig/+svi/uAZk=", "owner": "akinsho", "repo": "nvim-bufferline.lua", - "rev": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef", + "rev": "f6f00d9ac1a51483ac78418f9e63126119a70709", "type": "github" }, "original": { @@ -1095,11 +1095,11 @@ "plugin-nvim-dap": { "flake": false, "locked": { - "lastModified": 1711382674, - "narHash": "sha256-HoLnYeA18TpHM1SJ3NOY53ZAyBo2y2EoUbAIr7TqtQI=", + "lastModified": 1713432622, + "narHash": "sha256-kEn2INrNMQSLHY3gpSVV+cTx9f1nFeUCM6by9WGn5Sg=", "owner": "mfussenegger", "repo": "nvim-dap", - "rev": "405df1dcc2e395ab5173a9c3d00e03942c023074", + "rev": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb", "type": "github" }, "original": { @@ -1159,11 +1159,11 @@ "plugin-nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1713075103, - "narHash": "sha256-3GS1udfgzbghho1xtwZ5N1MZgWXWrJnW36Gnl/SAzIQ=", + "lastModified": 1713507075, + "narHash": "sha256-/SqLT0PG2RUWyknYpcXlcU/aUyKWZMBs35s1sPRkEmc=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "76b1bbaecbe7215498983356d50a16b46c20d6b0", + "rev": "ed8b8a15acc441aec669f97d75f2c1f2ac8c8aa5", "type": "github" }, "original": { @@ -1303,11 +1303,11 @@ "plugin-nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1713029046, - "narHash": "sha256-9r8UjGPAbLFHR3eYReLOR7SmBI+H6l6BeUrzaocq3YU=", + "lastModified": 1713520917, + "narHash": "sha256-AT49dDlwPaV41O+rcUCzzdra8moIg4iDAIhZJb6j0zE=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "ba05c6b753130d96b284d3e8ba8f54c28c0fb6d1", + "rev": "ba4289ad345ececd335a9cdd7b9616fd0bb6be92", "type": "github" }, "original": { @@ -1335,11 +1335,11 @@ "plugin-nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1712684166, - "narHash": "sha256-v+dhVbAN2OKLdS5YbSLmZsLijO4meSUBG26R+Ivm/BM=", + "lastModified": 1713596748, + "narHash": "sha256-yxsKBCP0ICMiH23tcLoTfZJ3VqNMhgkjOzynjPSRb8Q=", "owner": "nvim-tree", "repo": "nvim-web-devicons", - "rev": "6e355632387a085f15a66ad68cf681c1d7374a04", + "rev": "31ba3c489e56a7f20881cee013cea1269b6b2f2d", "type": "github" }, "original": { @@ -1351,11 +1351,11 @@ "plugin-obsidian-nvim": { "flake": false, "locked": { - "lastModified": 1712778222, - "narHash": "sha256-jjsDXGdFMgdalgkw8HSY3+EfiTkYotsNA6txk1/09VY=", + "lastModified": 1713538455, + "narHash": "sha256-nIAaQa0DBYBQyfTEJi3Lzqs7QJqyw0Cemq6Hm704K60=", "owner": "epwalsh", "repo": "obsidian.nvim", - "rev": "1265a1fbfca5979f629ecedb2552f743c70f458f", + "rev": "ec0f44e1921d2701bd99a542031d280f1e3930b5", "type": "github" }, "original": { @@ -1383,11 +1383,11 @@ "plugin-orgmode-nvim": { "flake": false, "locked": { - "lastModified": 1712982802, - "narHash": "sha256-zfw3eHBnJPPhsNr8aG8kn3pAchxklvk5aiFm2rys7PQ=", + "lastModified": 1713539113, + "narHash": "sha256-0Ayu2kVpnsxu/ER0nx+t7nyU9oNN8URLrGQtAKKb7Ls=", "owner": "nvim-orgmode", "repo": "orgmode", - "rev": "5875037fa9c7c8e0abf29cd69510150355d248a0", + "rev": "389e91f6f935aa845bc0cd13dd80f75431c34751", "type": "github" }, "original": { @@ -1464,11 +1464,11 @@ "plugin-rose-pine": { "flake": false, "locked": { - "lastModified": 1712685632, - "narHash": "sha256-A9C5BJiOdT/F6JzWxJw/La77nxCoX3/bND15DM9st6k=", + "lastModified": 1713451685, + "narHash": "sha256-AdPSz5+nCOnLWexBasHuxRxEKbL4WVg+uV78//W5nLs=", "owner": "rose-pine", "repo": "neovim", - "rev": "9cd7d8aad3606a95d733a45d16275eb7a5a836a3", + "rev": "17b466e79479758b332a3cac12544a3ad2be6241", "type": "github" }, "original": { @@ -1560,11 +1560,11 @@ "plugin-telescope": { "flake": false, "locked": { - "lastModified": 1713022073, - "narHash": "sha256-ZktFx77Ukuk1/Qhmf1wUEe0+wODM7f2H+PlXsDDTjcA=", + "lastModified": 1713586895, + "narHash": "sha256-3mrcol36HmY31pMAadirDdZqJtD0f+m8V0Lz8FnBx0M=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "4d4ade7f2b8f403e8816ca50c05ed16e259b21fb", + "rev": "a4432dfb9b0b960c4cbc8765a42dc4fe2e029e8f", "type": "github" }, "original": { @@ -1592,11 +1592,11 @@ "plugin-toggleterm-nvim": { "flake": false, "locked": { - "lastModified": 1707733615, - "narHash": "sha256-FJyDxQm2vs9R4WkqAbh6ryCvEABfrLSKRrAGo/qI5jM=", + "lastModified": 1713526392, + "narHash": "sha256-liy+AE8a+jll1fhROBKpJaTE9YZHQvYosOW4euGZNYc=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "193786e0371e3286d3bc9aa0079da1cd41beaa62", + "rev": "dca1c80fb8ec41c97e7c3ef308719d8143fbbb05", "type": "github" }, "original": { @@ -1672,11 +1672,11 @@ "plugin-vim-illuminate": { "flake": false, "locked": { - "lastModified": 1707016059, - "narHash": "sha256-KNIu4cNyZddZSRS8KZ0U0T8uSSLJu8iqNLQN8e+Bv94=", + "lastModified": 1713467568, + "narHash": "sha256-o0D1edrsHkaljrzBFZXjdxiK/5ziCGJxM/kYNJgBI1E=", "owner": "RRethy", "repo": "vim-illuminate", - "rev": "305bf07b919ac526deb5193280379e2f8b599926", + "rev": "e522e0dd742a83506db0a72e1ced68c9c130f185", "type": "github" }, "original": { @@ -2095,11 +2095,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1713070736, - "narHash": "sha256-FatD7AHSoZGfn2JCOkDt9v04YkJG3PLfC7U7pU6r+bM=", + "lastModified": 1713572548, + "narHash": "sha256-bYNsY9HwrV8+eJGRYvfLEP6/Sgf2Kr9qNbnB91OYMMM=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "1c04fe593ef5124fd84e3d8726d481cba8b527b8", + "rev": "76bccd85db6a182dfcbf8a5f4b540953f029a12c", "type": "github" }, "original": { From 4d8dcc7e49c084c17d824ae3a7008f00eb296afc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 19:00:20 +0300 Subject: [PATCH 08/14] modules/neovim: rename `vim.spellChecking` to `vim.spellcheck` more consistent this way --- modules/neovim/init/spellcheck.nix | 20 +++++++++++-------- .../spellcheck/vim-dirtytalk/config.nix | 2 +- .../vim-dirtytalk/vim-dirtytalk.nix | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/neovim/init/spellcheck.nix b/modules/neovim/init/spellcheck.nix index 71607ac..1995532 100644 --- a/modules/neovim/init/spellcheck.nix +++ b/modules/neovim/init/spellcheck.nix @@ -3,25 +3,29 @@ lib, ... }: let - inherit (lib.modules) mkIf; - inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; + inherit (lib.modules) mkIf mkRenamedOptionModule; + inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) listOf str; inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.dag) entryAfter; - cfg = config.vim.spellChecking; + cfg = config.vim.spellcheck; in { - options.vim.spellChecking = { + imports = [ + (mkRenamedOptionModule ["vim" "spellChecking"] ["vim" "spellcheck"]) + ]; + + options.vim.spellcheck = { enable = mkEnableOption "neovim's built-in spellchecking"; languages = mkOption { type = listOf str; default = ["en"]; example = literalExpression ''["en" "de"]''; - description = literalMD '' + description = '' A list of languages that should be used for spellchecking. To add your own language files, you may place your `spell` - directory in either {path}`~/.config/nvim` or the + directory in either `~/.config/nvim` or the [additionalRuntimePaths](#opt-vim.additionalRuntimePaths) directory provided by neovim-flake. ''; @@ -49,12 +53,12 @@ in { }; config = mkIf cfg.enable { - vim.luaConfigRC.spellchecking = entryAfter ["basic"] '' + vim.luaConfigRC.spellcheck = entryAfter ["basic"] '' vim.opt.spell = true vim.opt.spelllang = ${listToLuaTable cfg.languages} -- Disable spellchecking for certain filetypes - -- as configured by `vim.spellChecking.ignoredFiletypes` + -- as configured by `vim.spellcheck.ignoredFiletypes` vim.api.nvim_create_autocmd({ "FileType" }, { pattern = ${listToLuaTable cfg.ignoredFiletypes}, callback = function() diff --git a/modules/plugins/spellcheck/vim-dirtytalk/config.nix b/modules/plugins/spellcheck/vim-dirtytalk/config.nix index edfe1c7..bef92e5 100644 --- a/modules/plugins/spellcheck/vim-dirtytalk/config.nix +++ b/modules/plugins/spellcheck/vim-dirtytalk/config.nix @@ -5,7 +5,7 @@ }: let inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAfter; - cfg = config.vim.spellChecking; + cfg = config.vim.spellcheck; in { config = mkIf (cfg.enable && cfg.programmingWordlist.enable) { vim = { diff --git a/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix b/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix index d996fef..d20bd62 100644 --- a/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix +++ b/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix @@ -2,6 +2,6 @@ inherit (lib.modules) mkAliasOptionModule; in { imports = [ - (mkAliasOptionModule ["vim" "spellcheck" "vim-dirtytalk" "enable"] ["vim" "spellChecking" "programmingWordlist" "enable"]) + (mkAliasOptionModule ["vim" "spellcheck" "vim-dirtytalk" "enable"] ["vim" "spellcheck" "programmingWordlist" "enable"]) ]; } From 6d681c2c080d4de822ebb6317b99de6f3b3c3df5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 19:00:58 +0300 Subject: [PATCH 09/14] flake/modules: add options to set default editor to nixos and home-manager modules --- flake/modules/home-manager.nix | 39 ++++++++++++++++++++++++++------ flake/modules/nixos.nix | 41 +++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index 28e2b0f..677a39e 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -6,9 +6,10 @@ packages: inputs: { ... }: let inherit (lib) maintainers; - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) optionals; inherit (lib.options) mkOption mkEnableOption literalExpression; - inherit (lib.types) attrsOf anything; + inherit (lib.types) attrsOf anything bool; cfg = config.programs.neovim-flake; inherit (import ../../configuration.nix inputs) neovimConfiguration; @@ -21,7 +22,24 @@ in { meta.maintainers = with maintainers; [NotAShelf]; options.programs.neovim-flake = { - enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper"; + enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper"; + + enableManpages = mkOption { + type = bool; + default = false; + description = "Whether to enable manpages for neovim-flake."; + }; + + defaultEditor = mkOption { + type = bool; + default = false; + description = '' + Whether to set `neovim-flake` as the default editor. + + This will set the `EDITOR` environment variable as `nvim` + if set to true. + ''; + }; finalPackage = mkOption { type = anything; @@ -56,9 +74,16 @@ in { }; }; - config = mkIf cfg.enable { - home.packages = [cfg.finalPackage]; + config = mkIf cfg.enable mkMerge [ + { + programs.neovim-flake.finalPackage = neovimConfigured.neovim; - programs.neovim-flake.finalPackage = neovimConfigured.neovim; - }; + home = { + sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); + packages = + [cfg.finalPackage] + ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; + }; + } + ]; } diff --git a/flake/modules/nixos.nix b/flake/modules/nixos.nix index 29e97cc..a41e3b6 100644 --- a/flake/modules/nixos.nix +++ b/flake/modules/nixos.nix @@ -1,4 +1,4 @@ -# Home Manager module +# NixOS module packages: inputs: { config, pkgs, @@ -6,9 +6,10 @@ packages: inputs: { ... }: let inherit (lib) maintainers; - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) optionals; inherit (lib.options) mkOption mkEnableOption literalExpression; - inherit (lib.types) attrsOf anything; + inherit (lib.types) attrsOf anything bool; cfg = config.programs.neovim-flake; inherit (import ../../configuration.nix inputs) neovimConfiguration; @@ -21,7 +22,24 @@ in { meta.maintainers = with maintainers; [NotAShelf]; options.programs.neovim-flake = { - enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper"; + enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper"; + + enableManpages = mkOption { + type = bool; + default = false; + description = "Whether to enable manpages for neovim-flake."; + }; + + defaultEditor = mkOption { + type = bool; + default = false; + description = '' + Whether to set `neovim-flake` as the default editor. + + This will set the `EDITOR` environment variable as `nvim` + if set to true. + ''; + }; finalPackage = mkOption { type = anything; @@ -56,9 +74,16 @@ in { }; }; - config = mkIf cfg.enable { - environment.systemPackages = [cfg.finalPackage]; + config = mkIf cfg.enable mkMerge [ + { + programs.neovim-flake.finalPackage = neovimConfigured.neovim; - programs.neovim-flake.finalPackage = neovimConfigured.neovim; - }; + environment = { + variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); + systemPackages = + [cfg.finalPackage] + ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; + }; + } + ]; } From f17cf118a6dec2b3a1965923e8dd01e7e09bb41e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 19:01:33 +0300 Subject: [PATCH 10/14] wrapper: rename `spellChecking` to `spellcheck` --- configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index e4ac841..b0d1331 100644 --- a/configuration.nix +++ b/configuration.nix @@ -27,7 +27,7 @@ inputs: let logFile = "/tmp/nvim.log"; }; - spellChecking = { + spellcheck = { enable = isMaximal; programmingWordlist.enable = isMaximal; }; From 03888986482b1a3079acfbe41e6580d059c27be7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 19:01:54 +0300 Subject: [PATCH 11/14] docs: fix build failures due to `literalMD` --- modules/wrapper/build/config.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 17c3695..9cd7183 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -229,7 +229,9 @@ in { if [vim.enableLuaLoader](#opt-vim.enableLuaLoader) is set to true. ''; - description = literalMD '' + example = literalExpression ''"$${builtins.readFile ./my-lua-config-pre.lua}"''; + + description = '' Verbatim lua code that will be inserted **before** the result of `luaConfigRc` DAG has been resolved. @@ -238,9 +240,11 @@ in { of lua configs after the DAG result. ::: {.warning} - You do not want to override this option. It is used - internally to set certain options as early as possible - and should be avoided unless you know what you're doing. + You do not want to override this option with mkForce + It is used internally to set certain options as early + as possible and should be avoided unless you know what + you're doing. Passing a string to this option will + merge it with the default contents. ::: ''; }; @@ -269,8 +273,9 @@ in { luaConfigPost = mkOption { type = str; default = ""; + example = literalExpression ''"$${builtins.readFile ./my-lua-config-post.lua}"''; description = '' - Verbatim lua code that will be inserted after + Verbatim lua code that will be inserted **after** the result of the `luaConfigRc` DAG has been resolved This option **does not** take a DAG set, but a string From e982955540f0ab091f5eaf9ae5caf92dbed46eb0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 23:42:48 +0300 Subject: [PATCH 12/14] modules: add documentation comments to internal variables --- configuration.nix | 4 ++- flake/modules/home-manager.nix | 20 ++++++------ flake/modules/nixos.nix | 20 ++++++------ modules/default.nix | 59 ++++++++++++++++++++++++---------- 4 files changed, 63 insertions(+), 40 deletions(-) diff --git a/configuration.nix b/configuration.nix index b0d1331..b0e7baa 100644 --- a/configuration.nix +++ b/configuration.nix @@ -7,9 +7,11 @@ inputs: let lib ? pkgs.lib, check ? true, extraSpecialArgs ? {}, + extraModules ? [], + ... }: modulesWithInputs { - inherit pkgs lib check extraSpecialArgs; + inherit pkgs lib check extraSpecialArgs extraModules; configuration.imports = modules; }; diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index 677a39e..e879223 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -74,16 +74,14 @@ in { }; }; - config = mkIf cfg.enable mkMerge [ - { - programs.neovim-flake.finalPackage = neovimConfigured.neovim; + config = mkIf cfg.enable { + programs.neovim-flake.finalPackage = neovimConfigured.neovim-wrapped; - home = { - sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); - packages = - [cfg.finalPackage] - ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; - }; - } - ]; + home = { + sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); + packages = + [cfg.finalPackage] + ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; + }; + }; } diff --git a/flake/modules/nixos.nix b/flake/modules/nixos.nix index a41e3b6..226175f 100644 --- a/flake/modules/nixos.nix +++ b/flake/modules/nixos.nix @@ -74,16 +74,14 @@ in { }; }; - config = mkIf cfg.enable mkMerge [ - { - programs.neovim-flake.finalPackage = neovimConfigured.neovim; + config = mkIf cfg.enable { + programs.neovim-flake.finalPackage = neovimConfigured.neovim-wrapped; - environment = { - variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); - systemPackages = - [cfg.finalPackage] - ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; - }; - } - ]; + environment = { + variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); + systemPackages = + [cfg.finalPackage] + ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; + }; + }; } diff --git a/modules/default.nix b/modules/default.nix index 17e8ba1..ee3f1fa 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,30 +4,43 @@ inputs: { lib ? pkgs.lib, check ? true, extraSpecialArgs ? {}, + extraModules ? [], }: let inherit (builtins) map filter isString toString getAttr; inherit (pkgs) wrapNeovimUnstable vimPlugins; inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.neovimUtils) makeNeovimConfig; + inherit (lib.lists) concatLists; inherit (lib.attrsets) recursiveUpdate; inherit (lib.asserts) assertMsg; + # call the extedended library with `lib` and `inputs` as arguments + # lib is used to provide the standard library functions to the extended library + # but it can be overridden while this file is being called + # inputs is used to pass inputs to the plugin autodiscovery function extendedLib = import ../lib/stdlib-extended.nix lib inputs; + # import modules.nix with `check`, `pkgs` and `lib` as arguments + # check can be disabled while calling this file is called + # to avoid checking in all modules nvimModules = import ./modules.nix { inherit check pkgs; lib = extendedLib; }; + # evaluate the extended library with the modules + # optionally with any additional modules passed by the user module = extendedLib.evalModules { - modules = [configuration] ++ nvimModules; specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs; + modules = concatLists [[configuration] nvimModules extraModules]; }; + # alias to the internal configuration vimOptions = module.config.vim; - extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; - + # build a vim plugin with the given name and arguments + # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug + # instead buildPlug = {pname, ...} @ args: assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter."; buildVimPlugin (args @@ -60,24 +73,36 @@ inputs: { (f: f != null) plugins); - plugins = - (buildConfigPlugins vimOptions.startPlugins) - ++ (map (package: { - plugin = package; - optional = false; - }) - (buildConfigPlugins - vimOptions.optPlugins)); + # built (or "normalized") plugins that are modified + builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; + builtOptPlugins = map (package: { + plugin = package; + optional = false; + }) (buildConfigPlugins vimOptions.optPlugins); - neovim = wrapNeovimUnstable vimOptions.package (makeNeovimConfig { - inherit (vimOptions) viAlias; - inherit (vimOptions) vimAlias; - inherit extraLuaPackages; - inherit plugins; + plugins = builtStartPlugins ++ builtOptPlugins; + + extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; + + # wrap user's desired neovim package using the neovim wrapper from nixpkgs + # the wrapper takes the following arguments: + # - withPython (bool) + # - extraPython3Packages (lambda) + # - withNodeJs (bool) + # - withRuby (bool) + # - extraLuaPackages (lambda) + # - plugins (list) + # - customRC (string) + # and returns the wrapped package + neovim-wrapped = wrapNeovimUnstable vimOptions.package (makeNeovimConfig { + inherit (vimOptions) viAlias vimAlias; + inherit plugins extraLuaPackages; customRC = vimOptions.builtConfigRC; }); in { inherit (module) options config; inherit (module._module.args) pkgs; - inherit neovim; + + # expose wrapped neovim-package + neovim = neovim-wrapped; } From 8ca0760b011e400ad24bee46588ff0586fe1aeea Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Apr 2024 23:48:15 +0300 Subject: [PATCH 13/14] flake/modules: remove redundant lib calls --- flake/modules/home-manager.nix | 6 +++--- flake/modules/nixos.nix | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index e879223..7b80984 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -6,7 +6,7 @@ packages: inputs: { ... }: let inherit (lib) maintainers; - inherit (lib.modules) mkIf mkMerge; + inherit (lib.modules) mkIf; inherit (lib.lists) optionals; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) attrsOf anything bool; @@ -75,10 +75,10 @@ in { }; config = mkIf cfg.enable { - programs.neovim-flake.finalPackage = neovimConfigured.neovim-wrapped; + programs.neovim-flake.finalPackage = neovimConfigured.neovim; home = { - sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); + sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";}; packages = [cfg.finalPackage] ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; diff --git a/flake/modules/nixos.nix b/flake/modules/nixos.nix index 226175f..57f99d9 100644 --- a/flake/modules/nixos.nix +++ b/flake/modules/nixos.nix @@ -6,7 +6,7 @@ packages: inputs: { ... }: let inherit (lib) maintainers; - inherit (lib.modules) mkIf mkMerge; + inherit (lib.modules) mkIf mkOverride; inherit (lib.lists) optionals; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) attrsOf anything bool; @@ -75,10 +75,10 @@ in { }; config = mkIf cfg.enable { - programs.neovim-flake.finalPackage = neovimConfigured.neovim-wrapped; + programs.neovim-flake.finalPackage = neovimConfigured.neovim; environment = { - variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim"); + variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); systemPackages = [cfg.finalPackage] ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; From 25dc887a8ecb7b3ac6134f5d2c9e3971cc9aa672 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 21 Apr 2024 00:10:00 +0300 Subject: [PATCH 14/14] flake/modules: return manpage package as a singleton --- flake/modules/home-manager.nix | 4 ++-- flake/modules/nixos.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index 7b80984..bcefcf1 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -7,7 +7,7 @@ packages: inputs: { }: let inherit (lib) maintainers; inherit (lib.modules) mkIf; - inherit (lib.lists) optionals; + inherit (lib.lists) optional; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) attrsOf anything bool; @@ -81,7 +81,7 @@ in { sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";}; packages = [cfg.finalPackage] - ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; + ++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; }; }; } diff --git a/flake/modules/nixos.nix b/flake/modules/nixos.nix index 57f99d9..de234c7 100644 --- a/flake/modules/nixos.nix +++ b/flake/modules/nixos.nix @@ -7,7 +7,7 @@ packages: inputs: { }: let inherit (lib) maintainers; inherit (lib.modules) mkIf mkOverride; - inherit (lib.lists) optionals; + inherit (lib.lists) optional; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) attrsOf anything bool; @@ -81,7 +81,7 @@ in { variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); systemPackages = [cfg.finalPackage] - ++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; + ++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; }; }; }