about summary refs log tree commit diff stats
path: root/modules/by-name/nv/nvim
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-23 13:19:39 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-23 13:22:08 +0100
commit77e62827b1b37b2000d07c0826e3b2b8917972f1 (patch)
tree56f25ba299f78adb8c8532a2e37a12f47239fe36 /modules/by-name/nv/nvim
parentrefactor(modules/nvim/files): Move to their respective plugin (diff)
downloadnixos-config-77e62827b1b37b2000d07c0826e3b2b8917972f1.tar.gz
nixos-config-77e62827b1b37b2000d07c0826e3b2b8917972f1.zip
fix(modules/nvim/plgs/neorg): Move keybind setup to separate ftplugin
Diffstat (limited to '')
-rw-r--r--modules/by-name/nv/nvim/plgs/neorg/default.nix94
-rw-r--r--modules/by-name/nv/nvim/plgs/neorg/key_mappings.lua30
2 files changed, 76 insertions, 48 deletions
diff --git a/modules/by-name/nv/nvim/plgs/neorg/default.nix b/modules/by-name/nv/nvim/plgs/neorg/default.nix
index 995f9601..67c18cc6 100644
--- a/modules/by-name/nv/nvim/plgs/neorg/default.nix
+++ b/modules/by-name/nv/nvim/plgs/neorg/default.nix
@@ -5,60 +5,58 @@
 }: let
   cfg = config.soispha.programs.nvim;
 in {
-  home-manager.users.soispha.programs.nixvim.plugins = lib.mkIf cfg.enable {
-    cmp.settings.sources = [
-      {name = "neorg";}
-    ];
+  home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable {
+    extraFiles = {
+      "ftplugin/neorg.lua".text = ''
+        ${lib.strings.fileContents ./key_mappings.lua}
+      '';
+    };
 
-    neorg = {
-      enable = true;
-      lazyLoading = true;
+    plugins = {
+      cmp.settings.sources = [
+        {name = "neorg";}
+      ];
 
-      modules = {
-        "core.defaults" = {
-          __empty = null;
-        };
-        "core.esupports.metagen".config = {
-          type = "auto";
-        };
-        "core.journal".config = {
-          workspace = "journal";
-        };
-        "core.keybinds".config = {
-          hook = {
-            __raw = ''
-              function(keybinds)
-                  -- remap the looking glas to the same key, femaco is also mapped to.
-                  keybinds.remap_event("norg", "n", "<space>cc", "core.looking-glass.magnify-code-block")
+      neorg = {
+        enable = true;
+        lazyLoading = true;
 
-                  keybinds.remap_event("norg", "n", "<C-s>", "core.integrations.telescope.find_linkable")
-                  keybinds.remap_event("norg", "i", "<C-i>", "core.integrations.telescope.insert_link")
-              end,
-            '';
+        modules = {
+          "core.defaults" = {
+            __empty = null;
           };
-        };
-        "core.completion".config = {
-          engine = "nvim-cmp";
-        };
-        "core.concealer".config = {
-          __empty = null;
-        };
-        "core.dirman".config = {
-          workspaces = {
-            general = "~/repos/notes/general";
-            journal = "~/repos/notes/journal";
-            projects = "~/repos/notes/projects";
+          "core.esupports.metagen".config = {
+            type = "auto";
+          };
+          "core.journal".config = {
+            workspace = "journal";
+          };
+          "core.keybinds".config = {
+            __empty = null;
+          };
+          "core.completion".config = {
+            engine = "nvim-cmp";
+          };
+          "core.concealer".config = {
+            __empty = null;
+          };
+          "core.dirman".config = {
+            workspaces = {
+              general = "~/repos/notes/general";
+              journal = "~/repos/notes/journal";
+              projects = "~/repos/notes/projects";
+            };
+          };
+          "core.export".config = {
+            __empty = null;
+          };
+          "core.integrations.telescope".config = {
+            __empty = null;
           };
-        };
-        "core.export".config = {
-          __empty = null;
-        };
-        "core.integrations.telescope".config = {
-          __empty = null;
-        };
 
-        "core.ui.calendar".config = {
-          __empty = null;
+          "core.ui.calendar".config = {
+            __empty = null;
+          };
         };
       };
     };
diff --git a/modules/by-name/nv/nvim/plgs/neorg/key_mappings.lua b/modules/by-name/nv/nvim/plgs/neorg/key_mappings.lua
new file mode 100644
index 00000000..e2ebb653
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/neorg/key_mappings.lua
@@ -0,0 +1,30 @@
+-- Override some of my default key mappings to better integrate into neorg.
+-- They still to the same conceptual thing.
+
+-- Femaco does the same outside of neorg, so map looking-glass the same key.
+vim.keymap.set(
+  "n",
+  "<Leader>cc",
+  "<Plug>(neorg.looking-glass.magnify-code-block)",
+  { noremap = true, silent = true, desc = "Edit code block" }
+)
+vim.keymap.set(
+  "n",
+  "<Enter>",
+  "<Plug>(neorg.esupports.hop.hop-link)",
+  { noremap = true, silent = true, desc = "Follow link" }
+)
+vim.keymap.set(
+  "n",
+  "<C-s>",
+  "<Plug>(core.integrations.telescope.find_linkable)",
+  { noremap = true, silent = true, desc = "Find possible links" }
+)
+vim.keymap.set(
+  "i",
+  "<C-i>",
+  "<Plug>(core.integrations.telescope.insert_link)",
+  { noremap = true, silent = true, desc = "Insert a link" }
+)
+
+-- action = "gf", key = "<Enter>", mode = { "n" }, options = { desc = "open file/url under cursor" } },