From 22bea90404c5ff6457913a03c1a54a3caa5b1c57 Mon Sep 17 00:00:00 2001 From: magnouvean <85435692+magnouvean@users.noreply.github.com> Date: Fri, 9 Aug 2024 21:39:39 +0200 Subject: [PATCH] Add escapeValue option and fix brackets.characters option for kate (#307) --- lib/types.nix | 9 +++++++++ modules/apps/kate/default.nix | 22 ++++++++++++---------- script/write_config.py | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/types.nix b/lib/types.nix index f06e0eb0..b806be51 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -35,6 +35,15 @@ let plasma-manager will leave it unchanged after activation. ''; }; + escapeValue = lib.mkOption { + type = bool; + default = true; + description = '' + Whether to escape the value according to kde's escape-format. See: + https://github.com/KDE/kconfig/blob/44f98ff5cb9008436ba5ba385cae03bbd0ab33e6/src/core/kconfigini.cpp#L882 + for info about this format. + ''; + }; }; }); coercedSettingsType = with lib.types; diff --git a/modules/apps/kate/default.nix b/modules/apps/kate/default.nix index 4c0133b0..75a0903c 100644 --- a/modules/apps/kate/default.nix +++ b/modules/apps/kate/default.nix @@ -306,15 +306,17 @@ in type = lib.types.bool; }; - inputMode = let - enumVals = [ "normal" "vi" ]; - in lib.mkOption { - type = lib.types.enum enumVals; - description = "The input mode for the editor."; - default = "normal"; - example = "vi"; - apply = getIndexFromEnum enumVals; - }; + inputMode = + let + enumVals = [ "normal" "vi" ]; + in + lib.mkOption { + type = lib.types.enum enumVals; + description = "The input mode for the editor."; + default = "normal"; + example = "vi"; + apply = getIndexFromEnum enumVals; + }; font = lib.mkOption { type = fontType; @@ -476,7 +478,7 @@ in }; "KTextEditor View" = { - "Chars To Enclose Selection" = cfg.editor.brackets.characters; + "Chars To Enclose Selection" = { value = cfg.editor.brackets.characters; escapeValue = false; }; "Bracket Match Preview" = cfg.editor.brackets.highlightMatching; "Auto Brackets" = cfg.editor.brackets.automaticallyAddClosing; "Input Mode" = cfg.editor.inputMode; diff --git a/script/write_config.py b/script/write_config.py index e52153d1..5b23013c 100644 --- a/script/write_config.py +++ b/script/write_config.py @@ -109,7 +109,7 @@ def from_json(cls, value: dict) -> Self: else str(value["value"]).lower() ) return cls( - value=escape(key_value), + value=escape(key_value) if value["escapeValue"] else key_value, immutable=value["immutable"], shellExpand=value["shellExpand"], )