You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I recently started working with worktrees but when opening LazyVim inside of nvim and go to the worktree section, there is no way to change the current nvim work directory to the one selected. You can press o to open the editor, but then you have a vim instance inside of the lazygit window.
Describe the solution you'd like
When switching to a worktree, it would be nice if the nvim instance would switch to the worktree folder. I do not know in how far this would be possible though and it's not a big issue, it could just save time being able to do it directly inside of lazygit.
The text was updated successfully, but these errors were encountered:
Would love this feature!
For reference, here's how you can do this with the standalone tool.
It works when selecting a repo as well as when changing worktrees.
diff --git a/lua/lazygit.lua b/lua/lazygit.lua
index 770e042..3a1760c 100644
--- a/lua/lazygit.lua+++ b/lua/lazygit.lua@@ -37,2 +37,19 @@ local function on_exit(job_id, code, event)
end
++ local dir_file = os.getenv("LAZYGIT_NEW_DIR_FILE")++ if dir_file then+ local file = io.open(dir_file, "r")++ if file then+ local content = file:read("*all")+ file:close()++ vim.fn.chdir(content)+ else+ print("Failed to open file: " .. file)+ end++ vim.env.LAZYGIT_NEW_DIR_FILE = nil+ end
end
@@ -41,2 +58,4 @@ end
local function exec_lazygit_command(cmd)
+ vim.env.LAZYGIT_NEW_DIR_FILE = vim.fn.expand("~/.lazygit/newdir")+
if LAZYGIT_LOADED == false then
Is your feature request related to a problem? Please describe.
I recently started working with worktrees but when opening LazyVim inside of nvim and go to the worktree section, there is no way to change the current nvim work directory to the one selected. You can press o to open the editor, but then you have a vim instance inside of the lazygit window.
Describe the solution you'd like
When switching to a worktree, it would be nice if the nvim instance would switch to the worktree folder. I do not know in how far this would be possible though and it's not a big issue, it could just save time being able to do it directly inside of lazygit.
The text was updated successfully, but these errors were encountered: