We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
xdg-open
I'm seeking to use Neovim as my Git UI.
In the log view, gf opens the file in Neovim. But I'd like to have another keybind to open files that aren't supported by Neovim, say image files.
gf
I copied some code from
diffview.nvim/lua/diffview/actions.lua
Line 37 in 3dc498c
In the following I use go to open a file with xdg-open. However as you can see there's a lot of copy paste:
go
local function goto_file_open() local lazy = require('diffview.lazy') local lib = lazy.require('diffview.lib') local utils = lazy.require('diffview.utils') local DiffView = lazy.access('diffview.scene.views.diff.diff_view', 'DiffView') local FileHistoryView = lazy.access('diffview.scene.views.file_history.file_history_view', 'FileHistoryView') local pl = lazy.access(utils, 'path') local view = lib.get_current_view() if view and not (view:instanceof(DiffView.__get()) or view:instanceof(FileHistoryView.__get())) then return end local file = view:infer_cur_file() if file then -- Ensure file exists if not pl:readable(file.absolute_path) then utils.err(string.format("File does not exist on disk: '%s'", pl:relative(file.absolute_path, '.'))) return end vim.fn.jobstart({ 'xdg-open', file.absolute_path }) end end return { 'sindrets/diffview.nvim', event = 'VeryLazy', opts = { enhanced_diff_hl = true, keymaps = { view = { { 'n', 'go', goto_file_open }, }, file_panel = { { 'n', 'go', goto_file_open }, }, file_history_panel = { { 'n', 'go', goto_file_open }, }, }, }, ... }
Could you expose prepare_goto_file()? And add this too if this seems good.
prepare_goto_file()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm seeking to use Neovim as my Git UI.
In the log view,
gf
opens the file in Neovim. But I'd like to have another keybind to open files that aren't supported by Neovim, say image files.I copied some code from
diffview.nvim/lua/diffview/actions.lua
Line 37 in 3dc498c
In the following I use
go
to open a file withxdg-open
. However as you can see there's a lot of copy paste:Could you expose
prepare_goto_file()
? And add this too if this seems good.The text was updated successfully, but these errors were encountered: