From 0ca98d02104f7f0a703787a7a080a570b7f1bedd Mon Sep 17 00:00:00 2001 From: Zain Kergaye Date: Mon, 30 Sep 2024 12:22:35 -0600 Subject: [PATCH] plugins/wrapping: Add more options --- plugins/by-name/wrapping/default.nix | 66 +++++++++++++++++-- .../plugins/by-name/wrapping/default.nix | 7 +- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/plugins/by-name/wrapping/default.nix b/plugins/by-name/wrapping/default.nix index 0b93ba33..4950b875 100644 --- a/plugins/by-name/wrapping/default.nix +++ b/plugins/by-name/wrapping/default.nix @@ -1,8 +1,4 @@ -{ - pkgs, - lib, - ... -}: +{ lib, ... }: let inherit (lib.nixvim) defaultNullOpts; in @@ -18,9 +14,69 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { By default, wrapping.nvim will output a message to the command line when the hard or soft mode is set. ''; + + create_commands = defaultNullOpts.mkBool true '' + If true, the plugin will create the following + commands to set/override a wrapping mode in case + it is not autodetected correctly: + + * 'HardWrapMode' + + * 'SoftWrapMode' + + * 'ToggleWrapMode' + ''; + + create_keymaps = defaultNullOpts.mkBool true '' + If true, it will create the following normal-mode keymappings: + + * '[ow' (soft wrap mode) + + * ']ow' (hard wrap mode) + + * 'yow' (toggle wrap mode) + ''; + + auto_set_mode_filetype_allowlist = defaultNullOpts.mkListOf lib.types.str [ + "asciidoc" + "gitcommit" + "help" + "latex" + "mail" + "markdown" + "rst" + "tex" + "text" + "typst" + ] "Filetypes for automatic heuristic mode triggers."; + + auto_set_mode_filetype_denylist = + defaultNullOpts.mkListOf lib.types.str [ ] + "Auto set mode filetype deny list"; + + auto_set_mode_heuristically = defaultNullOpts.mkBool true '' + If true, the plugin will set the hard or soft mode automatically when any file loads. + + For a specific set of file types, use `plugins.wrapping.settings.auto_set_mode_filetype_allowlist`. + + It uses the `BufWinEnter` event in an autocmd with a variety of undocumented heuristics. + Refer to the [plugin documentation] for more details on this evolving behavior. + + [plugin documentation] https://github.com/andrewferrier/wrapping.nvim?tab=readme-ov-file#automatic-heuristic-mode''; + + set_nvim_opt_default = defaultNullOpts.mkBool true '' + If true, wrapping.nvim will tweak some NeoVim defaults + (linebreak and wrap) to make it operate more smoothly. + ''; }; settingsExample = { notify_on_switch = false; + create_commands = false; + create_keymaps = false; + auto_set_mode_filetype_allowlist = [ + "file" + "filetwo" + ]; }; } diff --git a/tests/test-sources/plugins/by-name/wrapping/default.nix b/tests/test-sources/plugins/by-name/wrapping/default.nix index bbb0770c..3cfa8185 100644 --- a/tests/test-sources/plugins/by-name/wrapping/default.nix +++ b/tests/test-sources/plugins/by-name/wrapping/default.nix @@ -6,7 +6,12 @@ defaults = { plugins.wrapping = { enable = true; - settings.notify_on_switch = true; + settings = { + notify_on_switch = true; + create_commands = true; + create_keymaps = false; + set_nvim_opt_default = true; + }; }; }; }