From 83802bb7dbb9f1f367dd087e73db781f3f02e116 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 27 Oct 2023 09:30:20 +0300 Subject: [PATCH] lsp/nvim-docs-view: add keybinds --- modules/lsp/nvim-docs-view/config.nix | 11 ++++++++++- modules/lsp/nvim-docs-view/nvim-docs-view.nix | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/lsp/nvim-docs-view/config.nix b/modules/lsp/nvim-docs-view/config.nix index 1cbb37a..d7dc837 100644 --- a/modules/lsp/nvim-docs-view/config.nix +++ b/modules/lsp/nvim-docs-view/config.nix @@ -3,10 +3,14 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib) mkIf nvim addDescriptionsToMappings mkSetBinding mkMerge; inherit (builtins) toString; cfg = config.vim.lsp.nvim-docs-view; + self = import ./nvim-docs-view.nix {inherit lib;}; + + mappingDefinitions = self.options.vim.lsp.nvim-docs-view.mappings; + mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { vim = { @@ -21,6 +25,11 @@ in { update_mode = "${cfg.updateMode}", } ''; + + maps.normal = mkMerge [ + (mkSetBinding mappings.viewToggle "DocsViewToggle") + (mkSetBinding mappings.viewUpdate "DocsViewUpdate") + ]; }; }; } diff --git a/modules/lsp/nvim-docs-view/nvim-docs-view.nix b/modules/lsp/nvim-docs-view/nvim-docs-view.nix index acbc1c4..808613e 100644 --- a/modules/lsp/nvim-docs-view/nvim-docs-view.nix +++ b/modules/lsp/nvim-docs-view/nvim-docs-view.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib) mkEnableOption mkOption types mkMappingOption; in { options.vim.lsp.nvim-docs-view = { enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel."; @@ -37,5 +37,10 @@ in { - If manual, the content will only update once :DocsViewUpdate is called ''; }; + + mappings = { + viewToggle = mkMappingOption "Open or close the docs view panel" "lvt"; + viewUpdate = mkMappingOption "Manually update the docs view panel" "lvu"; + }; }; }