diff --git a/modules/apps/default.nix b/modules/apps/default.nix new file mode 100644 index 00000000..bea99deb --- /dev/null +++ b/modules/apps/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./kate.nix + ]; +} diff --git a/modules/apps/kate.nix b/modules/apps/kate.nix new file mode 100644 index 00000000..3649ee5f --- /dev/null +++ b/modules/apps/kate.nix @@ -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; + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index bdd4393c..c872ce76 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -11,6 +11,7 @@ ./kwin.nix ./startup.nix ./panels.nix + ./apps ]; options.programs.plasma.enable = lib.mkEnableOption ''