feat(git): Add lazygit configuration and nvim integration

This commit is contained in:
Tanguy Herbron 2024-01-31 11:38:34 +01:00
parent d647d36f10
commit 07bfa7ba8c
3 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,7 @@
customCommands:
- key: "C"
command: "git cz"
description: "Commit with commitizen"
context: "files"
loadingText: "Opening comnmitizen commit tool"
subprocess: true

View File

@ -34,6 +34,9 @@ map('', '<leader>0', '10gt')
-- Open undotree panel
map('', '<leader>u', ':UndotreeToggle<CR>')
-- Open lazygit in floating window for current repository --
vim.keymap.set('', '<leader>G', function() require("lazygit_integration").run() end)
--- Telescope ---
-- List project files
vim.keymap.set('', '<C-p>', function() require("plugins/telescope/custom").project_files() end)

View File

@ -0,0 +1,44 @@
local M = {}
M.run = function()
vim.api.nvim_create_autocmd({"TermClose"}, {
pattern= { "term://*lazygit" },
callback = function()
vim.api.nvim_input("<CR>")
end
})
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
local width = vim.api.nvim_get_option("columns")
local height = vim.api.nvim_get_option("lines")
local win_width = math.ceil(width * 0.8)
local win_height = math.ceil(height * 0.8 - 4)
local col = math.ceil((width - win_width) / 2 - 1)
local row = math.ceil((height - win_height) / 2 - 1)
local opts = {
style = "minimal",
relative = "editor",
width = win_width,
height = win_height,
row = row,
col = col,
border = "rounded"
}
local win = vim.api.nvim_open_win(buf, true, opts)
vim.api.nvim_win_set_option(win, "cursorline", true)
vim.api.nvim_buf_set_option(buf, "modifiable", true)
vim.api.nvim_cmd({cmd="terminal", args={"lazygit"}}, {})
vim.cmd('startinsert')
vim.api.nvim_buf_set_option(buf, "modifiable", true)
end
return M