Closed dsych closed 1 year ago
Just found require("diffview.lib").get_current_view():infer_cur_file().path
, which is probably the answer. But do let me know if there is a better way
Thank you for taking an interest in the project.
Just found
require("diffview.lib").get_current_view():infer_cur_file()
.path, which is probably the answer. But do let me know if there is a better way
Not quite. infer_cur_file()
is contextual, and will infer the file according to the rules described under :h diffview-file-inference
.
What you want is probably:
require("diffview.lib").get_current_view().cur_entry.absolute_path
Hey! diffview is awesome at what it does and I would like to leverage it as part of a plugin I am writing instead of re-inventing the wheel. What I am looking for is some way to hook into diffview to be able to enhance the current layout with additional keymaps, signs virtual lines etc.
I tried creating an autocmd for
diffview://
file name, but it proved insufficient for me, since the path contains references to.git
repo and other git related stuff, which I don't really want to parse out. I need to file name because of the way I designed the data structure containing additional information i.e. there is a mapping from file path to some arbitrary data, so that every time a new file diff is loaded, i could efficiently look up the related data and use it to enhance the view.Here is how I see it playing out:
BufEnter
View
object that contains the system file path to the file current displayed in the view.I found https://github.com/sindrets/diffview.nvim/issues/329, which talks about
require("diffview.lib").get_current_view()
that looks like what I need. However, I wasn't able to figure out how to get the fs filepath out of it.Any pointers are appreciated.