Skip to content

Commit

Permalink
fix(home::espanso): load match files with haumea
Browse files Browse the repository at this point in the history
  • Loading branch information
montchr committed Sep 24, 2024
1 parent be13edf commit 391e2f8
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 160 deletions.
18 changes: 6 additions & 12 deletions home/profiles/espanso/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
flake,
pkgs,
# config,
...
}:
let
# inherit (config.lib.file) mkOutOfStoreSymlink;
# dotfieldDir = config.home.sessionVariables."DOTFIELD_DIR";
inherit (flake.inputs) haumea;

cmx-espanso-list-triggers = pkgs.writeShellApplication {
name = "cmx-espanso-list-triggers";
Expand All @@ -17,15 +16,6 @@ let
};
in
{
imports = [
./matches/base.nix
./matches/time.nix
./matches/urls.nix
./matches/words.nix
./matches/comment.nix
./matches/_accented-words.nix
];

services.espanso = {
enable = true;
configs = {
Expand All @@ -39,6 +29,10 @@ in
# search_shortcut = "ALT+CMD+SPACE";
};
};
matches = haumea.lib.load {
src = ./matches;
loader = haumea.lib.loaders.verbatim;
};
};

home.packages = [ cmx-espanso-list-triggers ];
Expand Down
2 changes: 1 addition & 1 deletion home/profiles/espanso/matches/_accented-words.nix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ services.espanso.matches = null; }
{ matches = null; }
2 changes: 1 addition & 1 deletion home/profiles/espanso/matches/base.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
services.espanso.matches = [
matches = [
{
replace = "⌘";
trigger = ";s;cmd";
Expand Down
170 changes: 84 additions & 86 deletions home/profiles/espanso/matches/comment.nix
Original file line number Diff line number Diff line change
@@ -1,91 +1,89 @@
{
services.espanso = {
global_vars = [
{
name = "clip";
type = "clipboard";
}
];
global_vars = [
{
name = "clip";
type = "clipboard";
}
];

matches = [
{
replace = "# <{{clipped}}>";
trigger = "# <";
vars = [
{
depends_on = [ "clip" ];
name = "clipped";
params = {
cmd = "echo \"$ESPANSO_CLIP\" \\\n| grep '^https://' || [[ $? == 1 ]]\n";
};
type = "shell";
}
];
}
{
replace = ";; <{{clipped}}>";
trigger = ";; <";
vars = [
{
depends_on = [ "clip" ];
name = "clipped";
params = {
cmd = "echo \"$ESPANSO_CLIP\" \\\n| grep '^https://' || [[ $? == 1 ]]\n";
};
type = "shell";
}
];
}
{
replace = "' :: <{{clipped}}>";
trigger = "' :: <";
vars = [
{
depends_on = [ "clip" ];
name = "clipped";
params = {
cmd = "echo \"$ESPANSO_CLIP\" \\\n| grep '^https://' || [[ $? == 1 ]]\n";
};
type = "shell";
}
];
}
{
replace = "# SPDX-FileCopyrightText: {{year}} {{form.author}}\n# SPDX-License-Identifier: {{form.license}}";
trigger = ";#spdx";
vars = [
{
name = "form";
params = {
fields = {
author = {
default = "Chris Montgomery <[email protected]>";
};
license = {
default = "GPL-3.0-or-later";
type = "choice";
values = [
"GPL-3.0-or-later"
"MIT"
"Apache-2.0"
"MPL-2.0"
"BSD-3-Clause"
];
};
matches = [
{
replace = "# <{{clipped}}>";
trigger = "# <";
vars = [
{
depends_on = [ "clip" ];
name = "clipped";
params = {
cmd = "echo \"$ESPANSO_CLIP\" \\\n| grep '^https://' || [[ $? == 1 ]]\n";
};
type = "shell";
}
];
}
{
replace = ";; <{{clipped}}>";
trigger = ";; <";
vars = [
{
depends_on = [ "clip" ];
name = "clipped";
params = {
cmd = "echo \"$ESPANSO_CLIP\" \\\n| grep '^https://' || [[ $? == 1 ]]\n";
};
type = "shell";
}
];
}
{
replace = "' :: <{{clipped}}>";
trigger = "' :: <";
vars = [
{
depends_on = [ "clip" ];
name = "clipped";
params = {
cmd = "echo \"$ESPANSO_CLIP\" \\\n| grep '^https://' || [[ $? == 1 ]]\n";
};
type = "shell";
}
];
}
{
replace = "# SPDX-FileCopyrightText: {{year}} {{form.author}}\n# SPDX-License-Identifier: {{form.license}}";
trigger = ";#spdx";
vars = [
{
name = "form";
params = {
fields = {
author = {
default = "Chris Montgomery <[email protected]>";
};
license = {
default = "GPL-3.0-or-later";
type = "choice";
values = [
"GPL-3.0-or-later"
"MIT"
"Apache-2.0"
"MPL-2.0"
"BSD-3-Clause"
];
};
layout = "author: [[author]]\nlicense: [[license]]\n";
};
type = "form";
}
{
name = "year";
params = {
format = "%Y";
};
type = "date";
}
];
}
];
};
layout = "author: [[author]]\nlicense: [[license]]\n";
};
type = "form";
}
{
name = "year";
params = {
format = "%Y";
};
type = "date";
}
];
}
];
}
115 changes: 57 additions & 58 deletions home/profiles/espanso/matches/time.nix
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
{
services.espanso = {
global_vars = [
{
name = "date";
params = {
format = "%F";
};
type = "date";
}
{
name = "time";
params = {
format = "%T";
};
type = "date";
}
];
matches = [
{
replace = "{{date}}";
trigger = ";d;dd";
}
{
replace = "{{dateFriendly}}";
trigger = ";d.df";
vars = [
{
name = "dateFriendly";
params = {
format = "%B %e, %Y";
};
type = "date";
}
];
}
{
replace = "{{time}}";
trigger = ";d;tt";
}
{
replace = "{{date}} {{time}}";
trigger = ";d.dt";
}
{
replace = "{{id}}";
trigger = ";d;id";
vars = [
{
name = "id";
params = {
format = "%Y%m%d%H%M%S";
};
type = "date";
}
];
}
];
};
global_vars = [
{
name = "date";
params = {
format = "%F";
};
type = "date";
}
{
name = "time";
params = {
format = "%T";
};
type = "date";
}
];

matches = [
{
replace = "{{date}}";
trigger = ";d;dd";
}
{
replace = "{{dateFriendly}}";
trigger = ";d.df";
vars = [
{
name = "dateFriendly";
params = {
format = "%B %e, %Y";
};
type = "date";
}
];
}
{
replace = "{{time}}";
trigger = ";d;tt";
}
{
replace = "{{date}} {{time}}";
trigger = ";d.dt";
}
{
replace = "{{id}}";
trigger = ";d;id";
vars = [
{
name = "id";
params = {
format = "%Y%m%d%H%M%S";
};
type = "date";
}
];
}
];
}
2 changes: 1 addition & 1 deletion home/profiles/espanso/matches/urls.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
services.espanso.matches = [
matches = [
{
replace = "https://github.com/";
trigger = ";@gh";
Expand Down
2 changes: 1 addition & 1 deletion home/profiles/espanso/matches/words.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
services.espanso.matches = [
matches = [
{
propagate_case = true;
replace = "philadelphia";
Expand Down

0 comments on commit 391e2f8

Please sign in to comment.