From 6770e93bdcd2828f75196512e558db50dbaf1434 Mon Sep 17 00:00:00 2001 From: blitter Date: Fri, 22 Mar 2024 21:35:43 +0100 Subject: [PATCH] fix kate's magic tab handling number --- flake.lock | 12 ++++++------ modules/apps/kate.nix | 17 +++++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index af915a56..b9f6d4b6 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1706981411, - "narHash": "sha256-cLbLPTL1CDmETVh4p0nQtvoF+FSEjsnJTFpTxhXywhQ=", + "lastModified": 1710888565, + "narHash": "sha256-s9Hi4RHhc6yut4EcYD50sZWRDKsugBJHSbON8KFwoTw=", "owner": "nix-community", "repo": "home-manager", - "rev": "652fda4ca6dafeb090943422c34ae9145787af37", + "rev": "f33900124c23c4eca5831b9b5eb32ea5894375ce", "type": "github" }, "original": { @@ -23,11 +23,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708294118, - "narHash": "sha256-evZzmLW7qoHXf76VCepvun1esZDxHfVRFUJtumD7L2M=", + "lastModified": 1710951922, + "narHash": "sha256-FOOBJ3DQenLpTNdxMHR2CpGZmYuctb92gF0lpiirZ30=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e0da498ad77ac8909a980f07eff060862417ccf7", + "rev": "f091af045dff8347d66d186a62d42aceff159456", "type": "github" }, "original": { diff --git a/modules/apps/kate.nix b/modules/apps/kate.nix index 7ffe2fb4..4526f9c3 100644 --- a/modules/apps/kate.nix +++ b/modules/apps/kate.nix @@ -1,11 +1,16 @@ { config, lib, ... }: + + let # compute kate's magic TabHandlingMode - boolToInt = b: if b then 1 else 0; - t = boolToInt config.programs.kate.editor.indent.tabFromEverywhere; - s = boolToInt config.programs.kate.editor.indent.undoByShiftTab; - tabHandlingMode = t + 2 * s - 1; + # 0 is not tab & not undoByShiftTab + # 1 is tab & undoByShiftTab + # 2 is not tab & undoByShiftTab + tabHandlingMode = + if (! config.programs.kate.editor.indent.undoByShiftTab) && (! config.programs.kate.editor.indent.tabFromEverywhere) then 0 else ( + if (config.programs.kate.editor.indent.undoByShiftTab && config.programs.kate.editor.indent.tabFromEverywhere) then 1 else + 2); in { options.programs.kate.editor = { @@ -66,8 +71,8 @@ in config.assertions = [ { - assertion = tabHandlingMode >= -1; - message = "Kate does not support both 'undoByShiftTab' and 'tabFromEverywhere' to be disabled at the same time."; + assertion = (!config.programs.kate.editor.indent.undoByShiftTab) && (!config.programs.kate.editor.indent.tabFromEverywhere); + message = "Kate does not support both 'undoByShiftTab' to be disabled and 'tabFromEverywhere' to be enabled at the same time."; } ];