terminal/toggleterm: fix documentation rendering for literals; use mkEnableOption

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I1e58edf910815db0241e8d780cac489b6a6a6964
This commit is contained in:
raf 2026-04-22 00:31:18 +03:00
commit 2a35be20e5
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -4,8 +4,8 @@
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) nullOr enum bool package either int;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) nullOr enum package either int;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline;
@ -29,15 +29,10 @@ in {
description = "Direction of the terminal";
};
enable_winbar = mkOption {
type = bool;
default = false;
description = "Enable winbar";
};
enable_winbar = mkEnableOption "winbar";
size = mkOption {
type = either luaInline int;
description = "Number or lua function which is passed to the current terminal";
default = mkLuaInline ''
function(term)
if term.direction == "horizontal" then
@ -47,17 +42,38 @@ in {
end
end
'';
defaultText = literalExpression ''
mkLuaInline '''
function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end
'''
'';
description = "Integer or Lua function which is passed to the current terminal";
};
winbar = {
enabled = mkEnableOption "winbar in terminal" // {default = true;};
name_formatter = mkOption {
type = luaInline;
description = "Winbar formatter function.";
default = mkLuaInline ''
function(term)
return term.name
end
'';
defaultText =
literalExpression
mkLuaInline '' '
function(term)
return term.name
end
'''
'';
description = "Winbar formatter function.";
};
};
};
@ -73,7 +89,14 @@ in {
package = mkOption {
type = nullOr package;
default = pkgs.lazygit;
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
defaultText = literalExpression "pkgs.lazygit";
description = ''
The package that should be used for lazygit.
Setting this option to `null` will instead attemp to use `lazygit`
from your {env}`PATH`
'';
};
mappings = {