mirror of
https://github.com/nix-community/plasma-manager.git
synced 2024-11-30 11:52:44 +03:00
Add module for configuration of kate (#88)
This commit is contained in:
parent
dda62b1901
commit
8a032af55e
12
flake.lock
12
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": {
|
||||
|
7
modules/apps/default.nix
Normal file
7
modules/apps/default.nix
Normal file
@ -0,0 +1,7 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./kate.nix
|
||||
];
|
||||
}
|
101
modules/apps/kate.nix
Normal file
101
modules/apps/kate.nix
Normal file
@ -0,0 +1,101 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
|
||||
|
||||
let
|
||||
cfg = config.programs.kate;
|
||||
# compute kate's magic TabHandlingMode
|
||||
# 0 is not tab & not undoByShiftTab
|
||||
# 1 is tab & undoByShiftTab
|
||||
# 2 is not tab & undoByShiftTab
|
||||
tabHandlingMode = indentSettings:
|
||||
if (!indentSettings.undoByShiftTab && !indentSettings.tabFromEverywhere) then 0 else
|
||||
(
|
||||
if (indentSettings.undoByShiftTab && indentSettings.tabFromEverywhere) then 1 else
|
||||
2
|
||||
);
|
||||
in
|
||||
{
|
||||
options.programs.kate = {
|
||||
enable = lib.mkEnableOption ''
|
||||
Enable configuration management for 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 = cfg.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 = cfg.editor.indent.undoByShiftTab || (!cfg.editor.indent.tabFromEverywhere);
|
||||
message = "Kate does not support both 'undoByShiftTab' to be disabled and 'tabFromEverywhere' to be enabled at the same time.";
|
||||
}
|
||||
];
|
||||
|
||||
config.programs.plasma.configFile."katerc" = lib.mkIf cfg.enable {
|
||||
"KTextEditor Document" = {
|
||||
"Auto Detect Indent" = cfg.editor.indent.autodetect;
|
||||
"Indentation Width" = cfg.editor.indent.width;
|
||||
"Tab Handling" = (tabHandlingMode cfg.editor.indent);
|
||||
"Tab Width" = cfg.editor.tabWidth;
|
||||
"Keep Extra Spaces" = cfg.editor.indent.keepExtraSpaces;
|
||||
"ReplaceTabsDyn" = cfg.editor.indent.replaceWithSpaces;
|
||||
};
|
||||
|
||||
"KTextEditor Renderer" = {
|
||||
"Show Indentation Lines" = cfg.editor.indent.showLines;
|
||||
};
|
||||
};
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
./kwin.nix
|
||||
./startup.nix
|
||||
./panels.nix
|
||||
./apps
|
||||
];
|
||||
|
||||
options.programs.plasma.enable = lib.mkEnableOption ''
|
||||
|
@ -56,6 +56,7 @@ let
|
||||
"dolphinrc"
|
||||
"ffmpegthumbsrc"
|
||||
"kactivitymanagerdrc"
|
||||
"katerc"
|
||||
"kcminputrc"
|
||||
"kded5rc"
|
||||
"kdeglobals"
|
||||
|
Loading…
Reference in New Issue
Block a user