improve notes experience in helix

This commit is contained in:
Noah Masur 2025-03-30 21:24:15 -04:00
parent 0be5c026a7
commit 2c55912abf
No known key found for this signature in database
3 changed files with 55 additions and 5 deletions

View File

@ -22,6 +22,7 @@ in
# Set Neovim as the default app for text editing and manual pages # Set Neovim as the default app for text editing and manual pages
home.sessionVariables = { home.sessionVariables = {
EDITOR = lib.mkForce "${lib.getExe pkgs.helix}"; EDITOR = lib.mkForce "${lib.getExe pkgs.helix}";
MANPAGER = lib.mkForce "${lib.getExe pkgs.helix}";
}; };
# Create quick aliases for launching Helix # Create quick aliases for launching Helix
@ -78,7 +79,7 @@ in
} }
{ {
name = "markdown"; name = "markdown";
auto-format = true; auto-format = false;
language-servers = [ "marksman" ]; language-servers = [ "marksman" ];
formatter = { formatter = {
command = lib.getExe pkgs.mdformat; command = lib.getExe pkgs.mdformat;
@ -124,6 +125,15 @@ in
# Enable and disable inlay hints # Enable and disable inlay hints
space.H = ":toggle lsp.display-inlay-hints"; space.H = ":toggle lsp.display-inlay-hints";
# Toggle floating pane
space.t = ":sh zellij action toggle-floating-panes";
# Today's note
space.n = [
":sh fish -c 'generate-today'"
":vsplit %sh{generate-today}"
];
# Open lazygit # Open lazygit
# Unfortunately, this breaks mouse input and the terminal after quitting Helix # Unfortunately, this breaks mouse input and the terminal after quitting Helix
space.l = [ space.l = [
@ -133,6 +143,8 @@ in
":buffer-close!" ":buffer-close!"
":redraw" ":redraw"
":reload-all" ":reload-all"
":set mouse false"
":set mouse true"
]; ];
# Open yazi # Open yazi

View File

@ -44,7 +44,7 @@ in
programs.fish.functions = { programs.fish.functions = {
syncnotes = { syncnotes = {
description = "Full git commit on notes"; description = "Full git commit on notes";
body = builtins.readFile lib.getExe ( body = lib.getExe (
pkgs.writers.writeFishBin "syncnotes" { pkgs.writers.writeFishBin "syncnotes" {
makeWrapperArgs = [ makeWrapperArgs = [
"--prefix" "--prefix"
@ -52,13 +52,13 @@ in
":" ":"
"${lib.makeBinPath [ pkgs.git ]}" "${lib.makeBinPath [ pkgs.git ]}"
]; ];
} builtins.readFile ./syncnotes.fish } (builtins.readFile ./syncnotes.fish)
); );
}; };
note = { note = {
description = "Edit or create a note"; description = "Edit or create a note";
argumentNames = "filename"; argumentNames = "filename";
body = builtins.readFile lib.getExe ( body = lib.getExe (
pkgs.writers.writeFishBin "note" { pkgs.writers.writeFishBin "note" {
makeWrapperArgs = [ makeWrapperArgs = [
"--prefix" "--prefix"
@ -69,7 +69,44 @@ in
pkgs.fzf pkgs.fzf
]}" ]}"
]; ];
} builtins.readFile ./note.fish } (builtins.readFile ./note.fish)
);
};
generate-today = {
description = "Create today's note";
body = # fish
''
set filename $(date +%Y-%m-%d_%a)
set filepath "${cfg.path}/content/journal/$filename.md"
if ! test -e "$filepath"
echo -e "---\ntitle: $(date +"%A, %B %e %Y") - $(curl "https://wttr.in/New+York+City?u&format=1")\ntags: [ journal ]\n---\n\n" > "$filepath"
end
echo "$filepath"
'';
};
today = {
description = "Edit or create today's note";
body = lib.getExe (
pkgs.writers.writeFishBin "today"
{
makeWrapperArgs = [
"--prefix"
"PATH"
":"
"${lib.makeBinPath [
pkgs.curl
pkgs.helix
]}"
];
} # fish
''
set filename $(date +%Y-%m-%d_%a)
set filepath "${cfg.path}/content/journal/$filename.md"
if ! test -e "$filepath"
echo -e "---\ntitle: $(date +"%A, %B %e %Y") - $(curl "https://wttr.in/New+York+City?u&format=1")\ntags: [ journal ]\n---\n\n" > "$filepath"
end
hx "$filepath"
''
); );
}; };
}; };

View File

@ -61,6 +61,7 @@ in
neovim.enable = lib.mkDefault true; neovim.enable = lib.mkDefault true;
nix-index.enable = lib.mkDefault true; nix-index.enable = lib.mkDefault true;
nixpkgs.enable = lib.mkDefault true; nixpkgs.enable = lib.mkDefault true;
notes.enable = lib.mkDefault true;
prettyping.enable = lib.mkDefault true; prettyping.enable = lib.mkDefault true;
ripgrep.enable = lib.mkDefault true; ripgrep.enable = lib.mkDefault true;
weather.enable = lib.mkDefault true; weather.enable = lib.mkDefault true;