summaryrefslogtreecommitdiffstats
path: root/modules/plugins/lsp/nvim-docs-view/config.nix
blob: 911bff5d6c98461df127dbcc4217717bca016870 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  config,
  lib,
  options,
  ...
}: let
  inherit (lib.modules) mkIf;
  inherit (lib.nvim.binds) mkKeymap;
  inherit (lib.nvim.dag) entryAnywhere;
  inherit (lib.nvim.lua) toLuaObject;

  cfg = config.vim.lsp.nvim-docs-view;

  inherit (options.vim.lsp.nvim-docs-view) mappings;
in {
  config = mkIf cfg.enable {
    vim = {
      lsp.enable = true;
      startPlugins = ["nvim-docs-view"];

      pluginRC.nvim-docs-view = entryAnywhere ''
        require("docs-view").setup ${toLuaObject cfg.setupOpts}
      '';

      keymaps = [
        (mkKeymap "n" cfg.mappings.viewToggle "<cmd>DocsViewToggle<CR>" {desc = mappings.viewToggle.description;})
        (mkKeymap "n" cfg.mappings.viewUpdate "<cmd>DocsViewUpdate<CR>" {desc = mappings.viewUpdate.description;})
      ];
    };
  };
}