feat(git): Add lazygit configuration and nvim integration
This commit is contained in:
parent
d647d36f10
commit
1006d3fbdc
7
.config/lazygit/config.yml
Normal file
7
.config/lazygit/config.yml
Normal file
@ -0,0 +1,7 @@
|
||||
customCommands:
|
||||
- key: "C"
|
||||
command: "git cz"
|
||||
description: "Commit with commitizen"
|
||||
context: "files"
|
||||
loadingText: "Opening comnmitizen commit tool"
|
||||
subprocess: true
|
@ -34,6 +34,12 @@ map('', '<leader>0', '10gt')
|
||||
-- Open undotree panel
|
||||
map('', '<leader>u', ':UndotreeToggle<CR>')
|
||||
|
||||
-- Run Makefile commands within current repository --
|
||||
vim.keymap.set('', '<leader>r', function() require("makefile-runner").run() end)
|
||||
|
||||
-- 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)
|
||||
|
44
.config/nvim/lua/lazygit_integration.lua
Normal file
44
.config/nvim/lua/lazygit_integration.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user