Skip to content

Commit

Permalink
fix kate's magic tab handling number
Browse files Browse the repository at this point in the history
  • Loading branch information
blitter committed Mar 22, 2024
1 parent be4c22d commit 6770e93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions modules/apps/kate.nix
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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.";
}
];

Expand Down

0 comments on commit 6770e93

Please sign in to comment.