diff --git a/configuration.nix b/configuration.nix index de778d5..c3431af 100644 --- a/configuration.nix +++ b/configuration.nix @@ -29,6 +29,8 @@ inputs: let }; }; + vim.spellcheck.vim-dirtytalk.enable = true; + vim.lsp = { formatOnSave = true; lspkind.enable = false; diff --git a/modules/modules.nix b/modules/modules.nix index b9704d3..8c34046 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -33,6 +33,7 @@ "rich-presence" "session" "snippets" + "spellcheck" "statusline" "tabline" "terminal" diff --git a/modules/neovim/basic/spellcheck.nix b/modules/neovim/basic/spellcheck.nix index d6e9b92..c0644d6 100644 --- a/modules/neovim/basic/spellcheck.nix +++ b/modules/neovim/basic/spellcheck.nix @@ -5,17 +5,15 @@ }: let inherit (lib.modules) mkIf; inherit (lib.options) mkEnableOption literalExpression mkOption; - inherit (lib.strings) concatStringsSep optionalString; + inherit (lib.strings) concatStringsSep; inherit (lib.lists) optionals; inherit (lib.types) listOf str; inherit (lib.nvim.dag) entryAfter; cfg = config.vim.spellChecking; - languages = cfg.languages ++ optionals cfg.enableProgrammingWordList ["programming"]; in { options.vim.spellChecking = { enable = mkEnableOption "neovim's built-in spellchecking"; - enableProgrammingWordList = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words"; languages = mkOption { type = listOf str; default = ["en"]; @@ -26,12 +24,10 @@ in { config = mkIf cfg.enable { vim = { - startPlugins = optionals cfg.spellChecking.enableProgrammingWordList ["vim-dirtytalk"]; configRC.spellchecking = entryAfter ["basic"] '' - ${optionalString cfg.enable '' - set spell - set spelllang=${concatStringsSep "," languages} - ''} + " Spellchecking + set spell + set spelllang=${concatStringsSep "," cfg.languages} ''; }; }; diff --git a/modules/plugins/spellcheck/default.nix b/modules/plugins/spellcheck/default.nix new file mode 100644 index 0000000..8c7bf24 --- /dev/null +++ b/modules/plugins/spellcheck/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./vim-dirtytalk + ]; +} diff --git a/modules/plugins/spellcheck/vim-dirtytalk/config.nix b/modules/plugins/spellcheck/vim-dirtytalk/config.nix new file mode 100644 index 0000000..3057ac1 --- /dev/null +++ b/modules/plugins/spellcheck/vim-dirtytalk/config.nix @@ -0,0 +1,23 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAfter; + cfg = config.vim.spellcheck; +in { + config = mkIf cfg.vim-dirtytalk.enable { + vim = { + startPlugins = ["vim-dirtytalk"]; + + # vim-dirtytalk doesn't have any setup + # but we would like to append programming to spelllang + # as soon as possible while the plugin is enabled + luaConfigRC.vim-dirtytalk = entryAfter ["basic"] '' + -- append programming to spelllang + vim.opt.spelllang:append("programming") + ''; + }; + }; +} diff --git a/modules/plugins/spellcheck/vim-dirtytalk/default.nix b/modules/plugins/spellcheck/vim-dirtytalk/default.nix new file mode 100644 index 0000000..300c477 --- /dev/null +++ b/modules/plugins/spellcheck/vim-dirtytalk/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./vim-dirtytalk.nix + ]; +} diff --git a/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix b/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix new file mode 100644 index 0000000..b7c59b5 --- /dev/null +++ b/modules/plugins/spellcheck/vim-dirtytalk/vim-dirtytalk.nix @@ -0,0 +1,7 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; +in { + options.vim.spellcheck.vim-dirtytalk = { + enable = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words"; + }; +}