mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
cudatext: add module
This commit is contained in:
parent
a88781a35c
commit
10d30c9185
11 changed files with 344 additions and 0 deletions
163
modules/programs/cudatext.nix
Normal file
163
modules/programs/cudatext.nix
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkIf
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
nameValuePair
|
||||
mapAttrs'
|
||||
;
|
||||
|
||||
cfg = config.programs.cudatext;
|
||||
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
options.programs.cudatext = {
|
||||
enable = mkEnableOption "cudatext";
|
||||
package = mkPackageOption pkgs "cudatext" { nullable = true; };
|
||||
hotkeys = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
"2823" = {
|
||||
name = "code tree: clear filter";
|
||||
s1 = [ "Home" ];
|
||||
};
|
||||
|
||||
"153" = {
|
||||
name = "delete char right (delete)";
|
||||
s1 = [ "End" ];
|
||||
};
|
||||
|
||||
"655465" = {
|
||||
name = "caret to line end";
|
||||
s1 = [ ];
|
||||
};
|
||||
|
||||
"116" = {
|
||||
name = "column select: page up";
|
||||
s1 = [ ];
|
||||
};
|
||||
|
||||
"655464" = {
|
||||
name = "caret to line begin";
|
||||
s1 = [ ];
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Hotkeys for Cudatext. To see the available options, change
|
||||
the settings in the dialog "Help | Command palette" and
|
||||
look at the changes in `settings/keys.json`.
|
||||
'';
|
||||
};
|
||||
|
||||
userSettings = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
numbers_style = 2;
|
||||
numbers_center = false;
|
||||
numbers_for_carets = true;
|
||||
};
|
||||
description = ''
|
||||
User configuration for Cudatext.
|
||||
'';
|
||||
};
|
||||
|
||||
lexerSettings = mkOption {
|
||||
type = types.attrsOf jsonFormat.type;
|
||||
default = { };
|
||||
example = {
|
||||
C = {
|
||||
numbers_style = 2;
|
||||
};
|
||||
Python = {
|
||||
numbers_style = 1;
|
||||
numbers_center = false;
|
||||
};
|
||||
Rust = {
|
||||
numbers_style = 2;
|
||||
numbers_center = false;
|
||||
numbers_for_carets = true;
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
User configuration settings specific to each lexer.
|
||||
'';
|
||||
};
|
||||
|
||||
lexerHotkeys = mkOption {
|
||||
type = types.attrsOf jsonFormat.type;
|
||||
default = { };
|
||||
example = {
|
||||
C = {
|
||||
"153" = {
|
||||
name = "delete char right (delete)";
|
||||
s1 = [ "End" ];
|
||||
};
|
||||
|
||||
"655465" = {
|
||||
name = "caret to line end";
|
||||
s1 = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
Python = {
|
||||
"2823" = {
|
||||
name = "code tree: clear filter";
|
||||
s1 = [ "Home" ];
|
||||
};
|
||||
|
||||
"655464" = {
|
||||
name = "caret to line begin";
|
||||
s1 = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Hotkeys settings specific to each lexer.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
settingsPath =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
"Library/Application Support/CudaText/settings"
|
||||
else
|
||||
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/cudatext/settings";
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
home.file = {
|
||||
"${settingsPath}/keys.json" = mkIf (cfg.hotkeys != { }) {
|
||||
source = jsonFormat.generate "cudatext-keys.json" cfg.hotkeys;
|
||||
};
|
||||
"${settingsPath}/user.json" = mkIf (cfg.userSettings != { }) {
|
||||
source = jsonFormat.generate "cudatext-user.json" cfg.userSettings;
|
||||
};
|
||||
}
|
||||
// (mapAttrs' (
|
||||
k: v:
|
||||
nameValuePair "${settingsPath}/lexer ${k}.json" {
|
||||
source = jsonFormat.generate "cudatext-lexer-${k}" v;
|
||||
}
|
||||
) cfg.lexerSettings)
|
||||
// (mapAttrs' (
|
||||
k: v:
|
||||
nameValuePair "${settingsPath}/keys lexer ${k}.json" {
|
||||
source = jsonFormat.generate "cudatext-lexer-keys-${k}" v;
|
||||
}
|
||||
) cfg.lexerHotkeys);
|
||||
};
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ let
|
|||
"cmus"
|
||||
"codex"
|
||||
"comodoro"
|
||||
"cudatext"
|
||||
"darcs"
|
||||
"delta"
|
||||
"dircolors"
|
||||
|
|
|
|||
1
tests/modules/programs/cudatext/default.nix
Normal file
1
tests/modules/programs/cudatext/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ cudatext-example-config = ./example-config.nix; }
|
||||
112
tests/modules/programs/cudatext/example-config.nix
Normal file
112
tests/modules/programs/cudatext/example-config.nix
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.cudatext = {
|
||||
enable = true;
|
||||
userSettings = {
|
||||
numbers_style = 2;
|
||||
numbers_center = false;
|
||||
numbers_for_carets = true;
|
||||
};
|
||||
|
||||
hotkeys = {
|
||||
"2823" = {
|
||||
name = "code tree: clear filter";
|
||||
s1 = [ "Home" ];
|
||||
};
|
||||
|
||||
"153" = {
|
||||
name = "delete char right (delete)";
|
||||
s1 = [ "End" ];
|
||||
};
|
||||
|
||||
"655465" = {
|
||||
name = "caret to line end";
|
||||
s1 = [ ];
|
||||
};
|
||||
|
||||
"116" = {
|
||||
name = "column select: page up";
|
||||
s1 = [ ];
|
||||
};
|
||||
|
||||
"655464" = {
|
||||
name = "caret to line begin";
|
||||
s1 = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
lexerSettings = {
|
||||
C = {
|
||||
numbers_style = 2;
|
||||
};
|
||||
Python = {
|
||||
numbers_style = 1;
|
||||
numbers_center = false;
|
||||
};
|
||||
Rust = {
|
||||
numbers_style = 2;
|
||||
numbers_center = false;
|
||||
numbers_for_carets = true;
|
||||
};
|
||||
};
|
||||
|
||||
lexerHotkeys = {
|
||||
C = {
|
||||
"153" = {
|
||||
name = "delete char right (delete)";
|
||||
s1 = [ "End" ];
|
||||
};
|
||||
|
||||
"655465" = {
|
||||
name = "caret to line end";
|
||||
s1 = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
Python = {
|
||||
"2823" = {
|
||||
name = "code tree: clear filter";
|
||||
s1 = [ "Home" ];
|
||||
};
|
||||
|
||||
"655464" = {
|
||||
name = "caret to line begin";
|
||||
s1 = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
settingsPath =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
"home-files/Library/Application Support/CudaText/settings"
|
||||
else
|
||||
"home-files/.config/cudatext/settings";
|
||||
in
|
||||
''
|
||||
assertFileExists "${settingsPath}/user.json"
|
||||
assertFileExists "${settingsPath}/keys.json"
|
||||
|
||||
assertFileExists "${settingsPath}/lexer C.json"
|
||||
assertFileExists "${settingsPath}/lexer Python.json"
|
||||
assertFileExists "${settingsPath}/lexer Rust.json"
|
||||
|
||||
assertFileExists "${settingsPath}/keys lexer C.json"
|
||||
assertFileExists "${settingsPath}/keys lexer Python.json"
|
||||
|
||||
|
||||
|
||||
assertFileContent "${settingsPath}/user.json" ${./user.json}
|
||||
assertFileContent "${settingsPath}/keys.json" ${./keys.json}
|
||||
|
||||
assertFileContent "${settingsPath}/lexer C.json" ${./lexerC.json}
|
||||
assertFileContent "${settingsPath}/lexer Python.json" ${./lexerPython.json}
|
||||
assertFileContent "${settingsPath}/lexer Rust.json" ${./lexerRust.json}
|
||||
|
||||
assertFileContent "${settingsPath}/keys lexer C.json" ${./keysLexerC.json}
|
||||
assertFileContent "${settingsPath}/keys lexer Python.json" ${./keysLexerPython.json}
|
||||
'';
|
||||
}
|
||||
26
tests/modules/programs/cudatext/keys.json
Normal file
26
tests/modules/programs/cudatext/keys.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"116": {
|
||||
"name": "column select: page up",
|
||||
"s1": []
|
||||
},
|
||||
"153": {
|
||||
"name": "delete char right (delete)",
|
||||
"s1": [
|
||||
"End"
|
||||
]
|
||||
},
|
||||
"2823": {
|
||||
"name": "code tree: clear filter",
|
||||
"s1": [
|
||||
"Home"
|
||||
]
|
||||
},
|
||||
"655464": {
|
||||
"name": "caret to line begin",
|
||||
"s1": []
|
||||
},
|
||||
"655465": {
|
||||
"name": "caret to line end",
|
||||
"s1": []
|
||||
}
|
||||
}
|
||||
12
tests/modules/programs/cudatext/keysLexerC.json
Normal file
12
tests/modules/programs/cudatext/keysLexerC.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"153": {
|
||||
"name": "delete char right (delete)",
|
||||
"s1": [
|
||||
"End"
|
||||
]
|
||||
},
|
||||
"655465": {
|
||||
"name": "caret to line end",
|
||||
"s1": []
|
||||
}
|
||||
}
|
||||
12
tests/modules/programs/cudatext/keysLexerPython.json
Normal file
12
tests/modules/programs/cudatext/keysLexerPython.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"2823": {
|
||||
"name": "code tree: clear filter",
|
||||
"s1": [
|
||||
"Home"
|
||||
]
|
||||
},
|
||||
"655464": {
|
||||
"name": "caret to line begin",
|
||||
"s1": []
|
||||
}
|
||||
}
|
||||
3
tests/modules/programs/cudatext/lexerC.json
Normal file
3
tests/modules/programs/cudatext/lexerC.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"numbers_style": 2
|
||||
}
|
||||
4
tests/modules/programs/cudatext/lexerPython.json
Normal file
4
tests/modules/programs/cudatext/lexerPython.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"numbers_center": false,
|
||||
"numbers_style": 1
|
||||
}
|
||||
5
tests/modules/programs/cudatext/lexerRust.json
Normal file
5
tests/modules/programs/cudatext/lexerRust.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"numbers_center": false,
|
||||
"numbers_for_carets": true,
|
||||
"numbers_style": 2
|
||||
}
|
||||
5
tests/modules/programs/cudatext/user.json
Normal file
5
tests/modules/programs/cudatext/user.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"numbers_center": false,
|
||||
"numbers_for_carets": true,
|
||||
"numbers_style": 2
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue