From d2fdaf9611ada47fb12bf8e26a0e0fbbbeb33080 Mon Sep 17 00:00:00 2001
From: Gabe Venberg <gabevenberg@gmail.com>
Date: Mon, 24 Feb 2025 18:52:46 +0100
Subject: [PATCH] added the zk note taking assistant.

---
 configs/home-manager/zellij/default.nix |  5 +--
 configs/home-manager/zk.nix             | 50 +++++++++++++++++++++++++
 modules/home-manager/nvim/default.nix   |  1 +
 modules/home-manager/nvim/zk.nix        | 12 ++++++
 roles/home-manager/terminal.nix         |  1 +
 5 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 configs/home-manager/zk.nix
 create mode 100644 modules/home-manager/nvim/zk.nix

diff --git a/configs/home-manager/zellij/default.nix b/configs/home-manager/zellij/default.nix
index 665c25d..a32dfab 100644
--- a/configs/home-manager/zellij/default.nix
+++ b/configs/home-manager/zellij/default.nix
@@ -10,7 +10,6 @@
     enableZshIntegration = false;
     enableFishIntegration = false;
   };
-  home.file = {
-    ".config/zellij/config.kdl".source = ./config.kdl;
-  };
+
+  home.file.".config/zellij/config.kdl".source = ./config.kdl;
 }
diff --git a/configs/home-manager/zk.nix b/configs/home-manager/zk.nix
new file mode 100644
index 0000000..b41d19e
--- /dev/null
+++ b/configs/home-manager/zk.nix
@@ -0,0 +1,50 @@
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}: {
+  programs.zk = {
+    enable = true;
+    settings = {
+      notebook.dir = "~/notes";
+
+      note = {
+        language = "en";
+        default-title = "untitled";
+        filename = "{{id}}-{{slug title}}";
+        id-charset = "hex";
+        id-length = 8;
+        id-case = "lower";
+      };
+
+      format.markdown={
+        link-format="wiki";
+        hashtags=true;
+      };
+
+      alias = {
+        bl = ''zk list --link-to $@'';
+        i = ''zk edit --interactive'';
+        unlinked-mentions = ''zk list --mentioned-by $1 --no-linked-by $1'';
+        wc = ''zk list --format '{{word-count}}\t{{title}}' --sort word-count $@'';
+      };
+
+      tool = {
+        fzf-preview = "bat -p --color always {-1}";
+      };
+
+      lsp = {
+        diagnostics = {
+          wiki-title = "hint";
+          dead-link = "error";
+        };
+        completion = {
+          note-label = "{{title-or-path}}";
+          note-filter-text = "{{title}} {{path}}";
+          note-detail = "{{filename}}";
+        };
+      };
+    };
+  };
+}
diff --git a/modules/home-manager/nvim/default.nix b/modules/home-manager/nvim/default.nix
index fed7640..0809cc2 100644
--- a/modules/home-manager/nvim/default.nix
+++ b/modules/home-manager/nvim/default.nix
@@ -41,6 +41,7 @@
     ./gitsigns.nix
     ./which-key.nix
     ./telescope.nix
+    ./zk.nix
     ./treesitter
     ./cmp
     ./lsp
diff --git a/modules/home-manager/nvim/zk.nix b/modules/home-manager/nvim/zk.nix
new file mode 100644
index 0000000..60c04dc
--- /dev/null
+++ b/modules/home-manager/nvim/zk.nix
@@ -0,0 +1,12 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}: {
+  config = lib.mkIf config.user.nvim.enable {
+    programs.nixvim = {
+      plugins.zk.enable = true;
+    };
+  };
+}
diff --git a/roles/home-manager/terminal.nix b/roles/home-manager/terminal.nix
index a8bf44a..739e99a 100644
--- a/roles/home-manager/terminal.nix
+++ b/roles/home-manager/terminal.nix
@@ -8,6 +8,7 @@
     ./minimal-terminal.nix
     ../../configs/home-manager/nushell
     ../../configs/home-manager/starship.nix
+    ../../configs/home-manager/zk.nix
   ];
 
   user = {