-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
blitter
committed
Mar 19, 2024
1 parent
26acf8f
commit 11adaa9
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ ... }: | ||
|
||
{ | ||
imports = [ | ||
./kate.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ 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; | ||
in | ||
{ | ||
options.programs.kate.editor = { | ||
tabWidth = lib.mkOption { | ||
description = "The width of a single tab (\\t) sign (in number of spaces)."; | ||
default = 4; | ||
type = lib.types.int; | ||
}; | ||
|
||
indent.showLines = lib.mkOption { | ||
description = "Whether to show the vertical lines that mark each indentation level."; | ||
default = true; | ||
type = lib.types.bool; | ||
}; | ||
|
||
indent.width = lib.mkOption { | ||
description = "The width of each indent level (in number of spaces)."; | ||
default = config.programs.kate.editor.tabWidth; | ||
type = lib.types.int; | ||
}; | ||
|
||
indent.autodetect = lib.mkOption { | ||
description = "Whether kate should try to detect indentation for each given file and not impose default indentation settings."; | ||
default = true; | ||
type = lib.types.bool; | ||
}; | ||
|
||
indent.keepExtraSpaces = lib.mkOption { | ||
description = "Whether additional spaces that do not match the indent should be kept when adding/removing indentation level. If these are kept (option to true) then indenting 1 space further (with a default of 4 spaces) will be set to 5 spaces."; | ||
default = false; | ||
type = lib.types.bool; | ||
}; | ||
|
||
indent.replaceWithSpaces = lib.mkOption { | ||
description = "Whether all indentation should be automatically converted to spaces."; | ||
default = false; | ||
type = lib.types.bool; | ||
}; | ||
|
||
indent.backspaceDecreaseIndent = lib.mkOption { | ||
description = "Whether the backspace key in the indentation should decrease indentation by a full level always."; | ||
default = true; | ||
type = lib.types.bool; | ||
}; | ||
|
||
indent.tabFromEverywhere = lib.mkOption { | ||
description = "Whether the tabulator key increases intendation independent from the current cursor position."; | ||
default = false; | ||
type = lib.types.bool; | ||
}; | ||
|
||
indent.undoByShiftTab = lib.mkOption { | ||
description = "Whether to unindent the current line by one level with the shortcut Shift+Tab"; | ||
default = true; | ||
type = lib.types.bool; | ||
}; | ||
}; | ||
|
||
config.assertions = [ | ||
{ | ||
assertion = tabHandlingMode >= -1; | ||
message = "Either 'undeByShiftTab' or 'tabFromEverywhere' needs to be enabled!"; | ||
# kate does not seem to support disabling both. | ||
} | ||
]; | ||
|
||
config.programs.plasma.configFile."katerc" = { | ||
"KTextEditor Document" = { | ||
"Auto Detect Indent" = config.programs.kate.editor.indent.autodetect; | ||
"Indentation Width" = config.programs.kate.editor.indent.width; | ||
"Tab Handling" = tabHandlingMode; | ||
"Tab Width" = config.programs.kate.editor.tabWidth; | ||
"Keep Extra Spaces" = config.programs.kate.editor.indent.keepExtraSpaces; | ||
"ReplaceTabsDyn" = config.programs.kate.editor.indent.replaceWithSpaces; | ||
}; | ||
|
||
"KTextEditor Renderer" = { | ||
"Show Indentation Lines" = config.programs.kate.editor.indent.showLines; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters