From 32d83e44ce16a46678fde45dd433f5c14d028b8e Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Mon, 27 Feb 2023 20:09:48 +0100
Subject: [PATCH] Fixed neogit fold issues

---
 dotfiles/neovim/lua/my/plugins/init.lua   | 17 --------------
 dotfiles/neovim/lua/my/plugins/neogit.lua | 28 +++++++++++++++++++++++
 2 files changed, 28 insertions(+), 17 deletions(-)
 create mode 100644 dotfiles/neovim/lua/my/plugins/neogit.lua

diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua
index af4ec91..5e6e27d 100644
--- a/dotfiles/neovim/lua/my/plugins/init.lua
+++ b/dotfiles/neovim/lua/my/plugins/init.lua
@@ -200,23 +200,6 @@ return {
     keys = "<leader>yg",
   },
 
-  {
-    -- magit clone
-    "TimUntersberger/neogit",
-    -- dependencies = { "plenary.nvim" },
-    cmd = "Neogit",
-    enabled = env.firenvim.not_active() and env.vscode.not_active(),
-    init = function()
-      vim.keymap.set(
-        "n",
-        "<C-g>",
-        "<cmd>Neogit<cr>",
-        { desc = "Open neo[g]it" }
-      )
-    end,
-    config = true,
-  },
-
   {
     -- discord rich presence
     "andweeb/presence.nvim",
diff --git a/dotfiles/neovim/lua/my/plugins/neogit.lua b/dotfiles/neovim/lua/my/plugins/neogit.lua
new file mode 100644
index 0000000..40e5374
--- /dev/null
+++ b/dotfiles/neovim/lua/my/plugins/neogit.lua
@@ -0,0 +1,28 @@
+local env = require("my.helpers.env")
+
+local M = {
+  "TimUntersberger/neogit",
+
+  -- dependencies = { "plenary.nvim" },
+
+  cmd = "Neogit",
+  enabled = env.firenvim.not_active() and env.vscode.not_active(),
+  init = function()
+    vim.keymap.set("n", "<C-g>", "<cmd>Neogit<cr>", { desc = "Open neo[g]it" })
+  end,
+  config = function()
+    require("neogit").setup()
+
+    -- {{{ Disable folds inside neogit
+    vim.api.nvim_create_autocmd("FileType", {
+      pattern = { "NeogitStatus" },
+      group = vim.api.nvim_create_augroup("NeogitStatusOptions", {}),
+      callback = function()
+        vim.opt.foldenable = false
+      end,
+    })
+    -- }}}
+  end,
+}
+
+return M