diff --git a/.config/lazygit/config.yml b/.config/lazygit/config.yml new file mode 100644 index 0000000..9fc8eb4 --- /dev/null +++ b/.config/lazygit/config.yml @@ -0,0 +1,7 @@ +customCommands: + - key: "C" + command: "git cz" + description: "Commit with commitizen" + context: "files" + loadingText: "Opening comnmitizen commit tool" + subprocess: true diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua index 638d710..8b1b836 100644 --- a/.config/nvim/lua/keybindings.lua +++ b/.config/nvim/lua/keybindings.lua @@ -34,6 +34,9 @@ map('', '0', '10gt') -- Open undotree panel map('', 'u', ':UndotreeToggle') +-- Open lazygit in floating window for current repository -- +vim.keymap.set('', 'G', function() require("lazygit_integration").run() end) + --- Telescope --- -- List project files vim.keymap.set('', '', function() require("plugins/telescope/custom").project_files() end) diff --git a/.config/nvim/lua/lazygit_integration.lua b/.config/nvim/lua/lazygit_integration.lua new file mode 100644 index 0000000..7fa8333 --- /dev/null +++ b/.config/nvim/lua/lazygit_integration.lua @@ -0,0 +1,44 @@ +local M = {} + +M.run = function() + vim.api.nvim_create_autocmd({"TermClose"}, { + pattern= { "term://*lazygit" }, + callback = function() + vim.api.nvim_input("") + 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