aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-12-24 15:48:50 -0600
committerToby Vincent <tobyv13@gmail.com>2022-12-24 15:48:50 -0600
commitd40d801053f2f4a50514739969578a788c6fe48b (patch)
tree23fc3eff7e8a57332bcf760673de430b7cbe5b81
parent713eb7fc00826eee285396227bbf49423baccc56 (diff)
feat(nvim,neogit): manually impl pr until it is merged
Refs: #415
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua71
1 files changed, 64 insertions, 7 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua b/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua
index 68d1457..008d920 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua
@@ -1,13 +1,6 @@
local M = {
"TimUntersberger/neogit",
dependencies = { "sindrets/diffview.nvim" },
- config = {
- disable_commit_confirmation = true,
- disable_signs = true,
- integrations = {
- diffview = true,
- },
- },
}
function M.init()
@@ -16,4 +9,68 @@ function M.init()
end, { desc = "neogit" })
end
+function M.config()
+ -- TODO: revert once pr is merged
+ --
+ -- Refs: #415
+ local Buffer = require("neogit.lib.buffer")
+ local config = require("neogit.config")
+ local input = require("neogit.lib.input")
+
+ local CommitEditor = require("neogit.buffers.commit_editor")
+ function CommitEditor:open()
+ local written = false
+ self.buffer = Buffer.create({
+ name = self.filename,
+ filetype = "gitcommit",
+ buftype = "",
+ kind = config.values.commit_popup.kind,
+ modifiable = true,
+ readonly = false,
+ autocmds = {
+ ["BufWritePost"] = function()
+ written = true
+ end,
+ ["BufUnload"] = function()
+ if written then
+ if
+ config.values.disable_commit_confirmation
+ or input.get_confirmation("Are you sure you want to commit?")
+ then
+ vim.cmd("silent g/^#/d | silent w!")
+ end
+ end
+ if self.on_unload then
+ self.on_unload(written)
+ end
+ require("neogit.process").defer_show_preview_buffers()
+ end,
+ },
+ mappings = {
+ n = {
+ ["q"] = function(buffer)
+ buffer:close(true)
+ end,
+ },
+ },
+ initialize = function(buffer)
+ buffer:set_lines(0, -1, false, self.content)
+ if not config.values.disable_insert_on_commit then
+ vim.cmd(":startinsert")
+ end
+ -- NOTE: This avoids the user having to force to save the contents of the buffer.
+ vim.cmd("silent w!")
+ end,
+ })
+ end
+
+ require("neogit").setup({
+ disable_commit_confirmation = true,
+ disable_signs = true,
+ integrations = {
+ diffview = true,
+ },
+ })
+end
+
return M