feat(docs-view): custom setup

This commit is contained in:
Ching Pei Yang 2024-02-17 16:10:45 +01:00
parent 379231b43d
commit 62b0791b75
2 changed files with 47 additions and 40 deletions

View file

@ -3,10 +3,10 @@
lib,
...
}: let
inherit (builtins) toString;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp.nvim-docs-view;
self = import ./nvim-docs-view.nix {inherit lib;};
@ -20,12 +20,7 @@ in {
startPlugins = ["nvim-docs-view"];
luaConfigRC.nvim-docs-view = entryAnywhere ''
require("docs-view").setup {
position = "${cfg.position}",
width = ${toString cfg.width},
height = ${toString cfg.height},
update_mode = "${cfg.updateMode}",
}
require("docs-view").setup ${toLuaObject cfg.setupOpts}
'';
maps.normal = mkMerge [

View file

@ -1,13 +1,26 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum int;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib) types mkRenamedOptionModule;
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 = lib.nvim.types.mkPluginSetupOption "nvim-docs-view" {
position = mkOption {
type = enum ["left" "right" "top" "bottom"];
type = types.enum ["left" "right" "top" "bottom"];
default = "right";
description = ''
Where to open the docs view panel
@ -15,7 +28,7 @@ in {
};
height = mkOption {
type = int;
type = types.int;
default = 10;
description = ''
Height of the docs view panel if the position is set to either top or bottom
@ -23,24 +36,23 @@ in {
};
width = mkOption {
type = int;
type = types.int;
default = 60;
description = ''
Width of the docs view panel if the position is set to either left or right
'';
};
updateMode = mkOption {
type = enum ["auto" "manual"];
update_mode = mkOption {
type = types.enum ["auto" "manual"];
default = "auto";
description = ''
Determines the mechanism used to update the docs view panel content
Possible values:
- auto: the content will update upon cursor move.
- manual: the content will only update once :DocsViewUpdate is called
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" "lvt";