Open Bubbasm opened 2 years ago
I was looking over the Telescope directory when I found this extension and this issue. Based on discussion in https://github.com/nvim-telescope/telescope.nvim/issues/1228, this plugin seems like the best place to implement this kind of functionality.
What makes https://github.com/nvim-telescope/telescope-media-files.nvim/pull/39 nice is that additional actions could be defined, namely, copy to clipboard or insert link/path into the current file.
I use the https://github.com/renerocksai/telekasten.nvim plugin, but parts of this are a fancy overlay to Telescope. If this extension could open files and insert the link to a file, or copy the path to the clipboard as in #16, then much of Telekasten's functionality could be replaced by this plugin, perhaps even reducing the scope of that extension.
For those folks who want this functionality, I (with great difficulty) figured out how to do it by setting a special keymap for telescope environment. For some context: I am not a lua dev, but I got it :laughing:.
So just add the following to your telescope.nvim config and you'll be able to open the currently selected/focused entry in (any?) telescope environment with Shift+Enter through netrw.
defaults = {
mappings = {
i = {
["<S-CR>"] = function()
local entry = require("telescope.actions.state").get_selected_entry()
vim.api.nvim_call_function("netrw#BrowseX", { entry[1], 0 })
end,
},
},
},
In the future with neovim 0.10 release you may replace netrw with builtin function:
defaults = {
mappings = {
i = {
["<S-CR>"] = function()
local entry = require("telescope.actions.state").get_selected_entry()
vim.ui.open(entry[1])
end,
},
},
},
If something doesn't work then you might also need to configure file handler.
For a quick search I sometimes just open nvim to search interactively media files, such as pdfs, images. If a pdf, for instance, has many pages, I would like to open the file with the appropriate application. xdg-open already does this behaviour, so I would only like to call xdg-open instead of actually opening the binary file in nvim when looking through with telescope-media-files. I believe this would not be intrusive, as it would only open when looking for media files, and not regular files.