summaryrefslogtreecommitdiffstats
path: root/modules/plugins/lsp/nvim-docs-view/nvim-docs-view.nix
blob: bd96ced78d36531d21f4b66f419f3e593173c1ae (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
  config,
  lib,
  ...
}: let
  inherit (lib.options) mkEnableOption mkOption;
  inherit (lib.nvim.types) mkPluginSetupOption;
  inherit (lib.types) enum int;
  inherit (lib.modules) mkRenamedOptionModule;
  inherit (config.vim.lib) mkMappingOption;
in {
  imports = let
    renamedSetupOption = oldPath: newPath:
      mkRenamedOptionModule
      (["vim" "lsp" "nvim-docs-view"] ++ oldPath)
      (["vim" "lsp" "nvim-docs-view" "setupOpts"] ++ newPath);
  in [
    (renamedSetupOption ["position"] ["position"])
    (renamedSetupOption ["width"] ["width"])
    (renamedSetupOption ["height"] ["height"])
    (renamedSetupOption ["updateMode"] ["update_mode"])
  ];

  options.vim.lsp.nvim-docs-view = {
    enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel.";

    setupOpts = mkPluginSetupOption "nvim-docs-view" {
      position = mkOption {
        type = enum ["left" "right" "top" "bottom"];
        default = "right";
        description = ''
          Where to open the docs view panel
        '';
      };

      height = mkOption {
        type = int;
        default = 10;
        description = ''
          Height of the docs view panel if the position is set to either top or bottom
        '';
      };

      width = mkOption {
        type = int;
        default = 60;
        description = ''
          Width of the docs view panel if the position is set to either left or right
        '';
      };

      update_mode = mkOption {
        type = enum ["auto" "manual"];
        default = "auto";
        description = ''
          Determines the mechanism used to update the docs view panel content.
          - If auto, the content will update upon cursor move.
          - If manual, the content will only update once :DocsViewUpdate is called
        '';
      };
    };

    mappings = {
      viewToggle = mkMappingOption "Open or close the docs view panel" "<leader>lvt";
      viewUpdate = mkMappingOption "Manually update the docs view panel" "<leader>lvu";
    };
  };
}