-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Command: LazygitToggle #106
Comments
Thanks for sharing your config @Dimfred! |
That won't resolve path well if you find yourself in a sub-directory, away from the
|
@teocns man this is awesome, very nice idea, didn't now how to do that properly, thanks a lot! |
for some reason i get shown a window with my command and press ENTER to go back to lazygit and adding <CR> at the start of the command fixes it if anyone has the same problem.
|
lazygit now has a native integration with nvim remote: https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#configuring-file-editing In my case I didn't even have to open nvim with the --listen flag, it just worked out of the box. |
Native integration does indeed work great! However (correct me if I'm wrong), there's still no way to "resume lazygit at the same spot" as @Dimfred was asking, right ? |
So I wrote my own "lazygit" function, which allows me to do that. local term = nil
M.toggle = function()
local Terminal = require("toggleterm.terminal").Terminal
local size = 90
local direction = "float"
if not term then
term = Terminal:new({
cmd = "lazygit",
hidden = true,
count = 10,
on_exit = function()
term = nil
end,
})
term:toggle(size, direction)
vim.cmd("set ft=lazygit")
map("nvit", "<C-w>", function()
term:toggle(size, direction)
end, { buffer = true })
else
term:toggle(size, direction)
end
end |
Nice, thanks ! I'll try that Edit: It works pretty well :) Don't forget to change my keymaps if needed: Somewhere in nvim conf: local term = nil
local function lg_toggle()
local Terminal = require("toggleterm.terminal").Terminal
local size = 90
local direction = "float"
if not term then
term = Terminal:new({
cmd = "lazygit",
hidden = true,
on_exit = function()
term = nil
end,
})
if term then
term:toggle(size, direction)
vim.cmd("set ft=lazygit")
vim.keymap.set("t", "<a-q>", function()
term:toggle(size, direction)
end, { buffer = true })
end
else
term:toggle(size, direction)
end
end
vim.api.nvim_create_user_command("LazyGitToggle", lg_toggle, {})
vim.keymap.set("n", "<leader>gg", "<cmd>LazyGitToggle<cr>", {}) lazygit conf: os:
editPreset: 'nvim-remote'
edit: '[ -z "$NVIM" ] && (nvim -- {{filename}}) || (nvim --server "$NVIM" --remote-send "<CMD>LazyGitToggle<CR>" && nvim --server "$NVIM" --remote-tab {{filename}})'
editAtLine: '[ -z "$NVIM" ] && (nvim +{{line}} -- {{filename}}) || (nvim --server "$NVIM" --remote-send "<CMD>LazyGitToggle<CR>" && nvim --server "$NVIM" --remote-tab {{filename}} && nvim --server "$NVIM" --remote-send ":{{line}}<CR>")'
promptToReturnFromSubprocess: false |
Is your feature request related to a problem? Please describe.
In my lazygit config I am using:
This allows me to open the file from lazygit inside my main window and not in lazygit. As you can see for that before opening the file, I am closing lazygit with
q
, what would be nice if I could just toggle then window away. Then way I could resume lazygit at the same spot I closed it.Describe the solution you'd like
A
LazygitToggle
command, which allows to toggle the Lazygit window, so an extension of the currrent command.That would be awesome :) Thx for the plugin btw, appreciate it.
EDIT:
Meanwhile I found how to better make use of
<CMD>
so this is the updated version, I'll leave the old one for reference. Then you also won't get annoying cmd popups n stuff.The text was updated successfully, but these errors were encountered: