From bab5f8f4a8c4d6f79ea7c2fd4850cf9eaa0b0af8 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.dev>
Date: Fri, 6 Dec 2024 16:06:33 +0000
Subject: [PATCH] Fix occassional Neovim loading error

---
 flake.nix                                      |  6 ------
 .../home-manager/features/cli/neovim.nix       | 18 ++++++------------
 nvim/init.lua                                  |  1 +
 nvim/lua/opdavies/init.lua                     |  2 --
 4 files changed, 7 insertions(+), 20 deletions(-)
 create mode 100644 nvim/init.lua

diff --git a/flake.nix b/flake.nix
index c2323f6c..51b1c7a7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -41,16 +41,10 @@
       };
 
       inherit (pkgs) mkShell;
-      inherit (pkgs.vimUtils) buildVimPlugin;
     in
     {
       packages.${system} = {
         default = mkShell { buildInputs = with pkgs; [ bashInteractive ]; };
-
-        opdavies-nvim = buildVimPlugin {
-          name = "opdavies-nvim";
-          src = ./nvim;
-        };
       };
 
       formatter.${system} = pkgs.nixfmt-rfc-style;
diff --git a/nix/modules/home-manager/features/cli/neovim.nix b/nix/modules/home-manager/features/cli/neovim.nix
index 90fd61ac..30bb5234 100644
--- a/nix/modules/home-manager/features/cli/neovim.nix
+++ b/nix/modules/home-manager/features/cli/neovim.nix
@@ -1,8 +1,8 @@
 {
   config,
-  inputs,
   lib,
   pkgs,
+  self,
   ...
 }:
 
@@ -141,19 +141,8 @@
 
         # Themes
         catppuccin-nvim
-
-        # Configuration.
-        inputs.self.packages.${pkgs.system}.opdavies-nvim
       ];
 
-      extraLuaConfig = ''
-        if vim.loader then
-          vim.loader.enable()
-        end
-
-        require "opdavies"
-      '';
-
       extraPackages = with pkgs; [
         # Languages
         nodePackages.typescript
@@ -199,6 +188,11 @@
       ];
     };
 
+    xdg.configFile.nvim = {
+      source = "${self}/nvim";
+      recursive = true;
+    };
+
     home.file.".markdownlint.yaml".text = ''
       default: true
 
diff --git a/nvim/init.lua b/nvim/init.lua
new file mode 100644
index 00000000..0437de40
--- /dev/null
+++ b/nvim/init.lua
@@ -0,0 +1 @@
+require "opdavies"
diff --git a/nvim/lua/opdavies/init.lua b/nvim/lua/opdavies/init.lua
index 7e5bc84d..64e71065 100644
--- a/nvim/lua/opdavies/init.lua
+++ b/nvim/lua/opdavies/init.lua
@@ -1,5 +1,3 @@
-pcall("require", impatient)
-
 require "opdavies.globals"
 require "opdavies.keymaps"
 require "opdavies.options"