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, lib,
... ...
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) nullOr enum bool package either int; inherit (lib.types) nullOr enum package either int;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
@ -29,15 +29,10 @@ in {
description = "Direction of the terminal"; description = "Direction of the terminal";
}; };
enable_winbar = mkOption { enable_winbar = mkEnableOption "winbar";
type = bool;
default = false;
description = "Enable winbar";
};
size = mkOption { size = mkOption {
type = either luaInline int; type = either luaInline int;
description = "Number or lua function which is passed to the current terminal";
default = mkLuaInline '' default = mkLuaInline ''
function(term) function(term)
if term.direction == "horizontal" then if term.direction == "horizontal" then
@ -47,17 +42,38 @@ in {
end end
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 = { winbar = {
enabled = mkEnableOption "winbar in terminal" // {default = true;}; enabled = mkEnableOption "winbar in terminal" // {default = true;};
name_formatter = mkOption { name_formatter = mkOption {
type = luaInline; type = luaInline;
description = "Winbar formatter function.";
default = mkLuaInline '' default = mkLuaInline ''
function(term) function(term)
return term.name return term.name
end end
''; '';
defaultText =
literalExpression
mkLuaInline '' '
function(term)
return term.name
end
'''
'';
description = "Winbar formatter function.";
}; };
}; };
}; };
@ -73,7 +89,14 @@ in {
package = mkOption { package = mkOption {
type = nullOr package; type = nullOr package;
default = pkgs.lazygit; 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 = { mappings = {