mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 23:16:46 +00:00
feat(docs-view): custom setup
This commit is contained in:
parent
379231b43d
commit
62b0791b75
2 changed files with 47 additions and 40 deletions
|
@ -3,10 +3,10 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toString;
|
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
|
||||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.lsp.nvim-docs-view;
|
cfg = config.vim.lsp.nvim-docs-view;
|
||||||
self = import ./nvim-docs-view.nix {inherit lib;};
|
self = import ./nvim-docs-view.nix {inherit lib;};
|
||||||
|
@ -20,12 +20,7 @@ in {
|
||||||
startPlugins = ["nvim-docs-view"];
|
startPlugins = ["nvim-docs-view"];
|
||||||
|
|
||||||
luaConfigRC.nvim-docs-view = entryAnywhere ''
|
luaConfigRC.nvim-docs-view = entryAnywhere ''
|
||||||
require("docs-view").setup {
|
require("docs-view").setup ${toLuaObject cfg.setupOpts}
|
||||||
position = "${cfg.position}",
|
|
||||||
width = ${toString cfg.width},
|
|
||||||
height = ${toString cfg.height},
|
|
||||||
update_mode = "${cfg.updateMode}",
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
maps.normal = mkMerge [
|
maps.normal = mkMerge [
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.types) enum int;
|
|
||||||
inherit (lib.nvim.binds) mkMappingOption;
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
|
inherit (lib) types mkRenamedOptionModule;
|
||||||
in {
|
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 = {
|
options.vim.lsp.nvim-docs-view = {
|
||||||
enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel.";
|
enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel.";
|
||||||
|
|
||||||
|
setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-docs-view" {
|
||||||
position = mkOption {
|
position = mkOption {
|
||||||
type = enum ["left" "right" "top" "bottom"];
|
type = types.enum ["left" "right" "top" "bottom"];
|
||||||
default = "right";
|
default = "right";
|
||||||
description = ''
|
description = ''
|
||||||
Where to open the docs view panel
|
Where to open the docs view panel
|
||||||
|
@ -15,7 +28,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
height = mkOption {
|
height = mkOption {
|
||||||
type = int;
|
type = types.int;
|
||||||
default = 10;
|
default = 10;
|
||||||
description = ''
|
description = ''
|
||||||
Height of the docs view panel if the position is set to either top or bottom
|
Height of the docs view panel if the position is set to either top or bottom
|
||||||
|
@ -23,24 +36,23 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
width = mkOption {
|
width = mkOption {
|
||||||
type = int;
|
type = types.int;
|
||||||
default = 60;
|
default = 60;
|
||||||
description = ''
|
description = ''
|
||||||
Width of the docs view panel if the position is set to either left or right
|
Width of the docs view panel if the position is set to either left or right
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
updateMode = mkOption {
|
update_mode = mkOption {
|
||||||
type = enum ["auto" "manual"];
|
type = types.enum ["auto" "manual"];
|
||||||
default = "auto";
|
default = "auto";
|
||||||
description = ''
|
description = ''
|
||||||
Determines the mechanism used to update the docs view panel content
|
Determines the mechanism used to update the docs view panel content.
|
||||||
|
- If auto, the content will update upon cursor move.
|
||||||
Possible values:
|
- If manual, the content will only update once :DocsViewUpdate is called
|
||||||
- auto: the content will update upon cursor move.
|
|
||||||
- manual: the content will only update once :DocsViewUpdate is called
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
mappings = {
|
mappings = {
|
||||||
viewToggle = mkMappingOption "Open or close the docs view panel" "lvt";
|
viewToggle = mkMappingOption "Open or close the docs view panel" "lvt";
|
||||||
|
|
Loading…
Reference in a new issue