sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.85k stars 105 forks source link

How can I open Diffview in a floating window via lua? #306

Closed kagbodji closed 1 year ago

kagbodji commented 1 year ago

Hi, awesome plugin!

I am trying to open diffview of an arbitrary file in a floating window in lua. Ideally, I'd like to open the file in the the diff2_horizontal view (without the file tree) in a floating window. Is this possible? I understand I can use configuration to setup the floating window and setup the view; I however can't figure out how to set that config dynamically and pass the file to require("diffview").open()

Help is greatly appreciated!

sindrets commented 1 year ago

There's no way to open a view in a floating window layout. Views open in their own tab pages.

I am trying to open diffview of an arbitrary file

If you only want to diff a single file just pass its path as an argument to :DiffviewOpen after the end-of-options token:

:DiffviewOpen -- /some/path/here

If you want to diff an entire changeset, and only want one of the containing files to be initially selected, you can use --selected-file={path}:

:DiffviewOpen --selected-file=/some/path/here
kagbodji commented 1 year ago

Oh I see, thanks. I think I may have misunderstood this. Does this only apply to the file panel?

sindrets commented 1 year ago

It refers to everything in the config that accepts a win_config table. Which is currently the various different UI panels.