From f01e404b2ec332d2d8b806379fd3a562e0f0da6f Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 21:56:33 +0000 Subject: [PATCH 1/8] languages/elixir.nix: fix elixir-tools setup (#401) --- modules/plugins/languages/elixir.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/plugins/languages/elixir.nix b/modules/plugins/languages/elixir.nix index 1a57d78..145746a 100644 --- a/modules/plugins/languages/elixir.nix +++ b/modules/plugins/languages/elixir.nix @@ -114,12 +114,12 @@ in { (mkIf cfg.elixir-tools.enable { vim.startPlugins = ["elixir-tools"]; vim.pluginRC.elixir-tools = entryAnywhere '' - local elixir-tools = require("elixir") - local elixirls = require("elixir-tools.elixirls") + local elixir = require("elixir") + local elixirls = require("elixir.elixirls") -- disable imperative insstallations of various -- elixir related tools installed by elixir-tools - elixir-tools.setup { + elixir.setup { nextls = { enable = false -- defaults to false }, From 379d2a9f1647d9bb0111d5e33b57921af470234e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 01:16:18 +0300 Subject: [PATCH 2/8] meta: improve github pull request template --- .github/pull_request_template.md | 69 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ca65c8b..5f1e4b6 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,39 +1,44 @@ -# Description + -## Type of change +## Sanity Checking -Please delete any options that are not relevant. + -- Bug fix (non-breaking change which fixes an issue) -- New feature (non-breaking change which adds functionality) -- Breaking change (fix or feature that would cause existing functionality to not work as expected) -- Translation/Language update -- Docs -- Other +[editorconfig]: https://editorconfig.org -## Checklist +- Style and consistency + - [ ] I ran **Alejandra** to format my code (`nix fmt`). + - [ ] My code conforms to the [editorconfig] configuration of the project. + - [ ] My changes are consistent with the rest of the codebase. +- If new changes are particularly complex: + - [ ] My code includes comments in particularly complex areas + - [ ] I have added a section in the manual. + - [ ] _(For breaking changes)_ I have included a migration guide. +- Package(s) built: + - [ ] `.#nix` (default package) + - [ ] `.#maximal` + - [ ] `.#docs-html` +- Tested on platform(s) + - [ ] `x86_64-linux` + - [ ] `aarch64-linux` + - [ ] `x86_64-darwin` + - [ ] `aarch64-darwin` -Please try to check at least a majority of the checklist before opening your pull request. Exceptions to this will be reviewed on a case by case basis. - -- [ ] My code follows the style and contributing guidelines of this project. -- [ ] I ran Alejandra to format my code (`nix fmt`). -- [ ] I have performed a self-review of my own code and tested it. -- [ ] I have commented my code, particularly in hard-to-understand areas. -- [ ] My changes generate no new warnings. -- [ ] This change requires a documentation update. -- [ ] I have updated the documentation accordingly. - -## Screenshots & Logs - -You are kindly requested to attach screenshots of your changes in actions and preferably your build/run logs for all available packages. If you are not sure how to do this, you can refer to the [documentation](https://notashelf.github.io/neovim-flake/). - -**Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.** - -```console -# Paste your logs here -``` + From fdd0642c7d83bf43eb2b69c7a7ef3955223342ce Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 01:18:04 +0300 Subject: [PATCH 3/8] docs: update 0.7 release notes --- docs/release-notes/rl-0.7.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 0be6ef3..7023371 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -89,7 +89,8 @@ everyone. - Add [new-file-template.nvim] to automatically fill new file contents using templates -- Make [neo-tree.nvim] display file icons properly by enabling `visuals.nvimWebDevicons` +- Make [neo-tree.nvim] display file icons properly by enabling + `visuals.nvimWebDevicons` [diniamo](https://github.com/diniamo): @@ -206,8 +207,12 @@ everyone. - Fixed `project-nvim` command and keybinding - Added default ikeybind/command for `Telescope resume` (`fr`) -[Soliprem](https://github.com/Soliprem) +[Soliprem](https://github.com/Soliprem): - Add LSP and Treesitter support for R under `vim.languages.R`. - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with ccc + +[Bloxx12](https://github.com/Bloxx12): + +- Fix internal breakage in `elixir-tools` setup. From 614ad33a60da7ce7dc61f09fad6afc45664a7cfd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 01:46:59 +0300 Subject: [PATCH 4/8] meta: add changelog reminder to the pull request template --- .github/pull_request_template.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5f1e4b6..7768d36 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,10 +15,16 @@ this comment. Please check all that apply. As before, this section is not a hard requirement but checklists with more checked items are likely to be merged faster. You may save some time in maintainer review by performing self-reviews here before submitting your pull request. + +If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include +it above in your description. --> [editorconfig]: https://editorconfig.org +[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes +- [ ] I have updated the [changelog] as per my changes. +- [ ] I have tested, and self-reviewed my code. - Style and consistency - [ ] I ran **Alejandra** to format my code (`nix fmt`). - [ ] My code conforms to the [editorconfig] configuration of the project. @@ -42,3 +48,10 @@ If your changes touch upon a portion of the codebase that you do not understand the maintainers on your changes. In most cases, making an issue before creating your PR will help you avoid duplicate efforts in the long run. --> + +--- + +Add a :+1: [reaction] to [pull requests you find important]. + +[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/ +[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc From 649f5513f942da45bdf66c8a46458992465a5b8c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 02:41:05 +0300 Subject: [PATCH 5/8] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'plugin-catppuccin': 'github:catppuccin/nvim/5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe' (2024-05-26) → 'github:catppuccin/nvim/7be452ee067978cdc8b2c5f3411f0c71ffa612b9' (2024-10-05) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index bc0859d..3e26731 100644 --- a/flake.lock +++ b/flake.lock @@ -207,11 +207,11 @@ "plugin-catppuccin": { "flake": false, "locked": { - "lastModified": 1716704960, - "narHash": "sha256-UDPS+1o8FQGkfqiG4GX4DNUI2pU5hIvagmfnWTKDb44=", + "lastModified": 1728131011, + "narHash": "sha256-j6F078taxuGzr3jngrc+Pc5I1kDdxTLMETgq6Xn4w/4=", "owner": "catppuccin", "repo": "nvim", - "rev": "5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe", + "rev": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9", "type": "github" }, "original": { From b637f921d591118b4b60bdc2370b45a6daf0824b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 6 Oct 2024 11:23:01 +0200 Subject: [PATCH 6/8] maps: allow same key on multiple mode (#360) * mappings: add new keymap option * mappings: impl keymap option * doc: update release notes * map: fix misinformation * map: remove redundant variable * fixup! mappings: impl keymap option --- docs/release-notes/rl-0.7.md | 17 +++--- modules/neovim/mappings/config.nix | 89 +++++++++++++++++++++-------- modules/neovim/mappings/options.nix | 72 ++++++++++++----------- modules/wrapper/rc/config.nix | 39 ++----------- 4 files changed, 120 insertions(+), 97 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 060efba..2ec691b 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -28,10 +28,10 @@ configuration formats. ### `vim.maps` rewrite {#sec-vim-maps-rewrite} -Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new -`mode` option has mode has been introduced. It can be either a string, or a list -of strings, where a string represents the short-name of the map mode(s), that -the mapping should be set for. See `:help map-modes` for more information. +Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new `vim.keymaps` +submodule with support for a `mode` option has been introduced. It can be either a string, or a +list of strings, where a string represents the short-name of the map mode(s), that the mapping +should be set for. See `:help map-modes` for more information. For example: @@ -42,10 +42,13 @@ vim.maps.normal."m" = { ... }; has to be replaced by ```nix -vim.maps."m" = { - mode = "n"; +vim.keymaps = [ + { + key = "m"; + mode = "n"; + } ... -}; +]; ``` ### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation} diff --git a/modules/neovim/mappings/config.nix b/modules/neovim/mappings/config.nix index 365e124..4d7f241 100644 --- a/modules/neovim/mappings/config.nix +++ b/modules/neovim/mappings/config.nix @@ -3,32 +3,75 @@ lib, ... }: let - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.trivial) pipe; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.lists) flatten; + + legacyMapModes = { + normal = ["n"]; + insert = ["i"]; + select = ["s"]; + visual = ["v"]; + terminal = ["t"]; + normalVisualOp = ["n" "v" "o"]; + visualOnly = ["n" "x"]; + operator = ["o"]; + insertCommand = ["i" "c"]; + lang = ["l"]; + command = ["c"]; + }; cfg = config.vim; in { config = { - vim.maps = mkIf cfg.disableArrows { - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - }; + vim.keymaps = mkMerge [ + ( + mkIf cfg.disableArrows [ + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + ] + ) + ( + pipe cfg.maps + [ + (mapAttrsToList ( + oldMode: keybinds: + mapAttrsToList ( + key: bind: + bind + // { + inherit key; + mode = legacyMapModes.${oldMode}; + } + ) + keybinds + )) + flatten + ] + ) + ]; }; } diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index f422991..f05de21 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,6 +1,6 @@ {lib, ...}: let inherit (lib.options) mkOption; - inherit (lib.types) either str listOf attrsOf nullOr submodule bool; + inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; mapConfigOptions = { @@ -31,6 +31,10 @@ options = mapConfigOptions // { + key = mkOption { + type = str; + description = "The key that triggers this keybind."; + }; mode = mkOption { type = either str (listOf str); description = '' @@ -38,52 +42,56 @@ See `:help map-modes` for a list of modes. ''; + example = ''`["n" "v" "c"]` for normal, visual and command mode''; }; }; }; - # legacy stuff - mapOption = submodule { - options = mapConfigOptions; - }; - - mapOptions = mode: + legacyMapOption = mode: mkOption { description = "Mappings for ${mode} mode"; - type = attrsOf mapOption; + type = attrsOf (submodule { + options = mapConfigOptions; + }); default = {}; }; in { options.vim = { - maps = mkOption { - type = submodule { - freeformType = attrsOf mapType; - 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 = {}; + keymaps = mkOption { + type = listOf mapType; description = "Custom keybindings."; example = '' - maps = { - "m" = { + vim.keymaps = [ + { + key = "m"; mode = "n"; silent = true; - action = "make"; - }; # Same as nnoremap m make - }; + action = ":make"; + } + { + key = "l"; + mode = ["n" "x"]; + silent = true; + action = "cnext"; + } + ]; ''; + default = {}; + }; + + maps = { + normal = legacyMapOption "normal"; + insert = legacyMapOption "insert"; + select = legacyMapOption "select"; + visual = legacyMapOption "visual and select"; + terminal = legacyMapOption "terminal"; + normalVisualOp = legacyMapOption "normal, visual, select and operator-pending (same as plain 'map')"; + + visualOnly = legacyMapOption "visual only"; + operator = legacyMapOption "operator-pending"; + insertCommand = legacyMapOption "insert and command-line"; + lang = legacyMapOption "insert, command-line and lang-arg"; + command = legacyMapOption "command-line"; }; }; } diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index 6c1936e..6f9ed1c 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -3,8 +3,8 @@ lib, ... }: let - inherit (builtins) map mapAttrs filter removeAttrs attrNames; - inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList; + inherit (builtins) map mapAttrs filter; + inherit (lib.attrsets) mapAttrsToList filterAttrs; inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.trivial) showWarnings; inherit (lib.generators) mkLuaInline; @@ -41,40 +41,9 @@ in { inherit (keymap) desc silent nowait script expr unique noremap; }; - toLuaKeymap = { - name, - value, - }: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})"; + toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})"; - namedModes = { - "normal" = ["n"]; - "insert" = ["i"]; - "select" = ["s"]; - "visual" = ["v"]; - "terminal" = ["t"]; - "normalVisualOp" = ["n" "v" "o"]; - "visualOnly" = ["n" "x"]; - "operator" = ["o"]; - "insertCommand" = ["i" "c"]; - "lang" = ["l"]; - "command" = ["c"]; - }; - - maps = - removeAttrs cfg.maps (attrNames namedModes) - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normal;}) cfg.maps.normal - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insert;}) cfg.maps.insert - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.select;}) cfg.maps.select - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visual;}) cfg.maps.visual - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.terminal;}) cfg.maps.terminal - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normalVisualOp;}) cfg.maps.normalVisualOp - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visualOnly;}) cfg.maps.visualOnly - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.operator;}) cfg.maps.operator - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insertCommand;}) cfg.maps.insertCommand - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.lang;}) cfg.maps.lang - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.command;}) cfg.maps.command; - - keymaps = concatLines (map toLuaKeymap (attrsToList (filterAttrs (_: value: value != null) maps))); + keymaps = concatLines (map toLuaKeymap cfg.keymaps); in { vim = { luaConfigRC = { From 7a8b95cf7c65e204ac9986ccf19a7594d737888f Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:35:07 +0200 Subject: [PATCH 7/8] Surround setupopts (#402) * surround: fix keymaps * surround: make description multi-line --- docs/release-notes/rl-0.7.md | 2 + modules/plugins/utility/surround/config.nix | 45 ++++------ modules/plugins/utility/surround/surround.nix | 86 +++---------------- 3 files changed, 28 insertions(+), 105 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 2ec691b..bb9f3d3 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -150,6 +150,8 @@ everyone. - Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the breaking changes section above for more details +- Add a `setupOpts` option to nvim-surround, which allows modifying options that aren't defined in nvf. Move the alternate nvim-surround keybinds to use `setupOpts`. + [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() - Make Neovim's configuration file entirely Lua based. This comes with a few diff --git a/modules/plugins/utility/surround/config.nix b/modules/plugins/utility/surround/config.nix index 824b8c9..4c98c86 100644 --- a/modules/plugins/utility/surround/config.nix +++ b/modules/plugins/utility/surround/config.nix @@ -3,42 +3,29 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; + inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.utility.surround; - self = import ./surround.nix {inherit lib config;}; - mappingDefinitions = self.options.vim.utility.surround.mappings; - mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { vim = { - startPlugins = [ - "nvim-surround" - ]; + startPlugins = ["nvim-surround"]; + pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; - pluginRC.surround = entryAnywhere '' - require('nvim-surround').setup() - ''; - - maps = { - insert = mkMerge [ - (mkIf (mappings.insert != null) (mkSetBinding mappings.insert "(nvim-surround-insert)")) - (mkIf (mappings.insertLine != null) (mkSetBinding mappings.insertLine "(nvim-surround-insert-line)")) - ]; - normal = mkMerge [ - (mkIf (mappings.normal != null) (mkSetBinding mappings.normal "(nvim-surround-normal)")) - (mkIf (mappings.normalCur != null) (mkSetBinding mappings.normalCur "(nvim-surround-normal-cur)")) - (mkIf (mappings.normalLine != null) (mkSetBinding mappings.normalLine "(nvim-surround-normal-line)")) - (mkIf (mappings.normalCurLine != null) (mkSetBinding mappings.normalCurLine "(nvim-surround-normal-cur-line)")) - (mkIf (mappings.delete != null) (mkSetBinding mappings.delete "(nvim-surround-delete)")) - (mkIf (mappings.change != null) (mkSetBinding mappings.change "(nvim-surround-change)")) - ]; - visualOnly = mkMerge [ - (mkIf (mappings.visual != null) (mkSetBinding mappings.visual "(nvim-surround-visual)")) - (mkIf (mappings.visualLine != null) (mkSetBinding mappings.visualLine "(nvim-surround-visual-line)")) - ]; + utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings { + insert = "z"; + insert_line = "Z"; + normal = "gz"; + normal_cur = "gZ"; + normal_line = "gzz"; + normal_cur_line = "gZZ"; + visual = "gz"; + visual_line = "gZ"; + delete = "gzd"; + change = "gzr"; + change_line = "gZR"; }; }; }; diff --git a/modules/plugins/utility/surround/surround.nix b/modules/plugins/utility/surround/surround.nix index 8024c9b..7d00638 100644 --- a/modules/plugins/utility/surround/surround.nix +++ b/modules/plugins/utility/surround/surround.nix @@ -1,90 +1,24 @@ -{ - lib, - config, - ... -}: let - inherit (lib.modules) mkIf mkDefault; +{lib, ...}: let inherit (lib.options) mkOption; - inherit (lib.types) bool nullOr str; + inherit (lib.types) bool; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.utility.surround = { enable = mkOption { type = bool; default = false; - description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap."; + description = '' + nvim-surround: add/change/delete surrounding delimiter pairs with ease. + Note that the default mappings deviate from upstreeam to avoid conflicts + with nvim-leap. + ''; }; + setupOpts = mkPluginSetupOption "nvim-surround" {}; + useVendoredKeybindings = mkOption { type = bool; default = true; description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap"; }; - mappings = { - insert = mkOption { - type = nullOr str; - default = "z"; - description = "Add surround character around the cursor"; - }; - insertLine = mkOption { - type = nullOr str; - default = "Z"; - description = "Add surround character around the cursor on new lines"; - }; - normal = mkOption { - type = nullOr str; - default = "gz"; - description = "Surround motion with character"; - }; - normalCur = mkOption { - type = nullOr str; - default = "gZ"; - description = "Surround motion with character on new lines"; - }; - normalLine = mkOption { - type = nullOr str; - default = "gzz"; - description = "Surround line with character"; - }; - normalCurLine = mkOption { - type = nullOr str; - default = "gZZ"; - description = "Surround line with character on new lines"; - }; - visual = mkOption { - type = nullOr str; - default = "gz"; - description = "Surround selection with character"; - }; - visualLine = mkOption { - type = nullOr str; - default = "gZ"; - description = "Surround selection with character on new lines"; - }; - delete = mkOption { - type = nullOr str; - default = "gzd"; - description = "Delete surrounding character"; - }; - change = mkOption { - type = nullOr str; - default = "gzr"; - description = "Change surrounding character"; - }; - }; - }; - config.vim.utility.surround = let - cfg = config.vim.utility.surround; - in { - mappings = mkIf (! cfg.useVendoredKeybindings) (mkDefault { - insert = null; - insertLine = null; - normal = null; - normalCur = null; - normalLine = null; - normalCurLine = null; - visual = null; - visualLine = null; - delete = null; - change = null; - }); }; } From b39b84490ff21003358afd78ed5bce1cb83b4722 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:03:21 +0200 Subject: [PATCH 8/8] Docs/map rewrite (#403) * doc: fix formatting * docs: update keymaps section --- docs/manual/hacking/keybinds.md | 27 ++++++++------------------- modules/neovim/mappings/options.nix | 4 ++-- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/docs/manual/hacking/keybinds.md b/docs/manual/hacking/keybinds.md index f4a5149..63a05d6 100644 --- a/docs/manual/hacking/keybinds.md +++ b/docs/manual/hacking/keybinds.md @@ -7,37 +7,26 @@ section contains a general overview to how you may utilize said functions. ## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings} -To set a mapping, you should define it in `vim.maps.<>`. -The available modes are: - -- normal -- insert -- select -- visual -- terminal -- normalVisualOp -- visualOnly -- operator -- insertCommand -- lang -- command +To set a mapping, you should define it in `vim.keymaps`. An example, simple keybinding, can look like this: ```nix { - vim.maps.normal = { - "wq" = { + vim.keymaps = [ + { + key = "wq"; + mode = ["n"]; action = ":wq"; silent = true; desc = "Save file and quit"; - }; - }; + } + ]; } ``` There are many settings available in the options. Please refer to the -[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action) +[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps) to see a list of them. **nvf** provides a list of helper commands, so that you don't have to write the diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index f05de21..8f0e8eb 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.options) mkOption; + inherit (lib.options) mkOption literalMD; inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; @@ -42,7 +42,7 @@ See `:help map-modes` for a list of modes. ''; - example = ''`["n" "v" "c"]` for normal, visual and command mode''; + example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode''; }; }; };