mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
kitty: allow not setting shell_integration
This allows better support for using kitty's built-in shell integration method by setting `shellIntegration.mode' to `null', which makes it not be set at all in the config file and disables modification to shell initialization scripts by default. If this is used, the user should set `settings.shell_integration' instead (if shell integration is desired), which receives no special handling.
This commit is contained in:
parent
d57112db87
commit
8f3d8dec26
4 changed files with 41 additions and 9 deletions
|
@ -49,10 +49,11 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
shellIntegrationDefaultOpt = {
|
||||
default = !(elem "disabled" (splitString " " cfg.shellIntegration.mode));
|
||||
shellIntegrationDefaultOpt = let mode = cfg.shellIntegration.mode;
|
||||
in {
|
||||
default = (mode != null) && !(elem "disabled" (splitString " " mode));
|
||||
defaultText = literalExpression ''
|
||||
!(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode))
|
||||
(mode != null) && !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode))
|
||||
'';
|
||||
};
|
||||
in {
|
||||
|
@ -162,18 +163,18 @@ in {
|
|||
|
||||
shellIntegration = {
|
||||
mode = mkOption {
|
||||
type = types.str;
|
||||
type = types.nullOr types.str;
|
||||
default = "no-rc";
|
||||
example = "no-cursor";
|
||||
apply = o:
|
||||
apply = mapNullable (o:
|
||||
let
|
||||
modes = splitString " " o;
|
||||
filtered = filter (m: m != "no-rc") modes;
|
||||
in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]);
|
||||
in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]));
|
||||
description = ''
|
||||
Set the mode of the shell integration. This accepts the same options
|
||||
as the `shell_integration` option of Kitty. Note that
|
||||
`no-rc` is always implied. See
|
||||
`no-rc` is always implied, unless this set to `null`. See
|
||||
<https://sw.kovidgoyal.net/kitty/shell-integration>
|
||||
for more details.
|
||||
'';
|
||||
|
@ -213,10 +214,10 @@ in {
|
|||
(optionalString (cfg.themeFile != null) ''
|
||||
include ${pkgs.kitty-themes}/share/kitty-themes/themes/${cfg.themeFile}.conf
|
||||
'')
|
||||
''
|
||||
(optionalString (cfg.shellIntegration.mode != null) ''
|
||||
# Shell integration is sourced and configured manually
|
||||
shell_integration ${cfg.shellIntegration.mode}
|
||||
''
|
||||
'')
|
||||
(toKittyConfig cfg.settings)
|
||||
(toKittyKeybindings cfg.keybindings)
|
||||
(toKittyEnv cfg.environment)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
kitty-example-settings = ./example-settings.nix;
|
||||
kitty-theme-to-themeFile = ./theme-to-themeFile.nix;
|
||||
kitty-null-shellIntegration = ./null-shellIntegration.nix;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# Generated by Home Manager.
|
||||
# See https://sw.kovidgoyal.net/kitty/conf.html
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
22
tests/modules/programs/kitty/null-shellIntegration.nix
Normal file
22
tests/modules/programs/kitty/null-shellIntegration.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.kitty = {
|
||||
enable = true;
|
||||
|
||||
shellIntegration.mode = null;
|
||||
};
|
||||
|
||||
test.stubs.kitty = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/kitty/kitty.conf
|
||||
assertFileContent \
|
||||
home-files/.config/kitty/kitty.conf \
|
||||
${./null-shellIntegration-expected.conf}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue