Skip to content
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

Document new lazygit edit command config #101

Open
jesseduffield opened this issue Aug 3, 2023 · 6 comments
Open

Document new lazygit edit command config #101

jesseduffield opened this issue Aug 3, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@jesseduffield
Copy link

(First off sorry but I've lost the issue template and can't get it back upon reload)

Lazygit maintainer here: thanks for making this plugin, lots of people find it really valuable.

Lazygit has a new config structure for specifying how file are edited like so:

os:
  edit: 'myeditor {{filename}}'
  editAtLine: 'myeditor --line={{line}} {{filename}}'
  editAtLineAndWait: 'myeditor --block --line={{line}} {{filename}}'
  editInTerminal: true
  openDirInEditor: 'myeditor {{dir}}'

I'm not sure how this fits onto neovim (I've been intending to get into neovim but haven't found the time) but it would be good to document what the corresponding values should be when using this plugin.

@jesseduffield jesseduffield added the enhancement New feature or request label Aug 3, 2023
@jesseduffield
Copy link
Author

Also, side-note: if you ever have ideas for how to improve the integration between neovim and lazygit that require a change on the lazygit side, let me know!

@kdheepak
Copy link
Owner

kdheepak commented Aug 3, 2023

Thanks for writing and maintaining lazygit! It is a game changing git workflow!

I’ll let you know if I think of any good ideas for a better integration.

For reference and content, right now in this plugin lazygit is essentially just executed in a floating terminal window inside neovim. There’s nothing special that this plugin does, all the terminal capabilities are handled by neovim.

So if people are finding this plugin useful, it is because of lazygit :)

@jesseduffield
Copy link
Author

Thanks :)

Sounds good

@TylerBarnes
Copy link

Been trying to make this work but I haven't been having much luck. Anyone know how to make it work? Following the new syntax I tried to do this:

alias n="nvim --listen /tmp/$cwd/nvim-server.pipe"
os:
  edit: 'nvim --server /tmp/{{dir}}/nvim-server.pipe --remote-tab "{{filename}}"'
  editInTerminal: true

but it only seems to work if I don't have the file open in nvim already. When I remove the $cwd and {{dir}} it doesn't open the file at all 🤔

@mikavilpas
Copy link

Hello @TylerBarnes, I'd like to share my setup that I think does what you asked about:

  • the first part is to setup neovim using https://github.com/willothy/flatten.nvim. This makes it possible, when operating in a subprocess of neovim (such as lazygit), to tell the parent neovim process to open a file
    • note: I think it may be capable of more features but I haven't set those up myself
  • the lazygit config I use is this
os:
  # I usually use lazygit embedded in nvim. For this, I use
  # https://github.com/willothy/flatten.nvim to simplify the setup without the
  # need for external applications.
  #
  edit: "nvim {{filename}}"
  editAtLine: "nvim +{{line}} {{filename}}"
  editAtLineAndWait: "nvim +{{line}} {{filename}}"

Note 1: I don't use this plugin, but I think the idea is the same regardless.

Note 2: I made a performance optimization to skip loading all unnecessary plugins if I only want to send the send instruction to the parent neovim here https://github.com/mikavilpas/dotfiles/blob/fe3ac5480bc80f558b3e3330d89b2bb2abcd7db6/.config/nvim/lua/config/lazy.lua?plain=1#L35

My config:

https://github.com/mikavilpas/dotfiles/blob/fe3ac5480bc80f558b3e3330d89b2bb2abcd7db6/.config/nvim/lua/fast-plugins/terminal-integration.lua?plain=1#L5

https://github.com/mikavilpas/dotfiles/blob/fe3ac5480bc80f558b3e3330d89b2bb2abcd7db6/.config/lazygit/config.yml?plain=1#L79

Let me know if you have any questions; I can explain this further if needed

@TylerBarnes
Copy link

Thanks @mikavilpas ! Just tried your setup and it works. I think I discovered why I was having trouble with this before. When I edit a file I first see "ATTENTION found a swap file". Once I choose "open read only" or "edit anyway" it opens it in the parent nvim as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants