From 62c1fa03b085551a7719495be91b98aaa0c2d232 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sat, 25 Oct 2025 22:52:31 +0200 Subject: [PATCH 1/3] chore: add gopls. --- shell.nix | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/shell.nix b/shell.nix index 41d5401..e2c221b 100644 --- a/shell.nix +++ b/shell.nix @@ -4,22 +4,21 @@ inherit (builtins) fetchTree fromJSON readFile; inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix; in - import (fetchTree nixpkgs.locked) { - overlays = [ - (import "${fetchTree gomod2nix.locked}/overlay.nix") - ]; - } + import (fetchTree nixpkgs.locked) { + overlays = [ + (import "${fetchTree gomod2nix.locked}/overlay.nix") + ]; + } ), mkGoEnv ? pkgs.mkGoEnv, gomod2nix ? pkgs.gomod2nix, -}: - -let - goEnv = mkGoEnv { pwd = ./.; }; +}: let + goEnv = mkGoEnv {pwd = ./.;}; in -pkgs.mkShell { - packages = [ - goEnv - gomod2nix - ]; -} + pkgs.mkShell { + packages = [ + goEnv + gomod2nix + pkgs.gopls + ]; + } From 407614b72e62616c914cfb588a580e419ea85bf3 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sat, 25 Oct 2025 22:52:43 +0200 Subject: [PATCH 2/3] chore: follow shell.nix --- .envrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.envrc b/.envrc index 3550a30..29da48d 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,2 @@ +watch_file shell.nix use flake From dfbd324e0d53a94fa93c7aff7ed7a942cd4e925d Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sat, 25 Oct 2025 22:53:28 +0200 Subject: [PATCH 3/3] feat: list notes, create dailly note using a template. --- main.go | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 59ebd2b..c070018 100644 --- a/main.go +++ b/main.go @@ -1,10 +1,15 @@ package main import ( + "bytes" + "errors" "flag" "fmt" + "log" "os" "os/exec" + "strings" + "time" ) func main() { @@ -14,10 +19,12 @@ func main() { func ParseFlags(sb string) { note := sb + "/notes" - // daily := sb + "/periodic/daily" - // templates := sb + "/templates" + daily := sb + "/periodic/daily" + templates := sb + "/templates" quickPtr := flag.Bool("q", false, "Open quick file for notes") + listPtr := flag.Bool("l", false, "List files in notes directory") + dailyPtr := flag.Bool("d", false, "Create/Edit daily journal entry") flag.Parse() @@ -29,6 +36,41 @@ func ParseFlags(sb string) { os.Exit(0) } + if *listPtr { + files, err := os.ReadDir(note) + if err != nil { + log.Fatal(err) + } + + for _, f := range files { + file := f.Name() + fmt.Println(strings.ReplaceAll(file, ".md", "")) + } + os.Exit(0) + } + + if *dailyPtr { + date := time.Now().Local().Format("2006-01-02") + file := daily + "/" + date + ".md" + dailyTemplate := templates + "/daily.md" + + // If the file doesn't exist, create it + if _, err := os.Stat(file); errors.Is(err, os.ErrNotExist) { + // Read template file + t, _ := os.ReadFile(dailyTemplate) + + // Replace yesterday and tomorrow with specific dates + t = bytes.ReplaceAll(t, []byte("YESTERDAY"), []byte(time.Now().Local().AddDate(0, 0, -1).Format("2006-01-02"))) + t = bytes.ReplaceAll(t, []byte("TOMORROW"), []byte(time.Now().Local().AddDate(0, 0, 1).Format("2006-01-02"))) + + // write the file + os.WriteFile(file, t, 0644) + } + + OpenNvim(file) + os.Exit(0) + } + if len(fileName) == 0 { fmt.Println("You didn't specify a note name") os.Exit(1)