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

[feature] Macos support. #17

Open
singlexyz opened this issue Sep 26, 2021 · 20 comments
Open

[feature] Macos support. #17

singlexyz opened this issue Sep 26, 2021 · 20 comments

Comments

@singlexyz
Copy link

Überzug doesn't support MacOs,
Then I found a Plugin:
https://github.com/edluffy/hologram.nvim
Maybe use its method to achieve image preview in Telescope.

115054101-c0848680-9ed7-11eb-9980-a3bc2d691fc2

@protiumx
Copy link

Any updates on this?
I'd love to get this working on mac

@cpuccino
Copy link

Any updates on this?

@AGou-ops
Copy link

AGou-ops commented Jan 4, 2022

Macos support +1.

@joehannes
Copy link

Hey guys! FYI, if anyone is looking for how to install ueberzug on macOS ...
I found:
creating or adding

[build_ext]
include_dirs=/opt/X11/include
library_dirs=/opt/X11/lib

to ~/.pydistutils.cfg as per this article, plus addtionally
installing xquartz as downloadable on their website ...
I finally am able to successfully install uberzug on my macOS Monterey v12.1 ...
via pip3 install --user ueberzug

I'm not sure yet if that makes it work alltogether, I've only just successfully installed ueberzug ...

joehannes added a commit to joehannes-os/telescope-media-files.nvim that referenced this issue Jan 30, 2022
Since I got myself ueberzug installed as described in [this telescope-media-files.nvim-issue](nvim-telescope#17 (comment)) ... I deleted the unconditional process abortion for macOS ... and give it a shot
@joehannes
Copy link

Hey guys! FYI, if anyone is looking for how to install ueberzug on macOS ... I found: creating or adding

[build_ext]
include_dirs=/opt/X11/include
library_dirs=/opt/X11/lib

to ~/.pydistutils.cfg as per this article, plus addtionally installing xquartz as downloadable on their website ... I finally am able to successfully install uberzug on my macOS Monterey v12.1 ... via pip3 install --user ueberzug

I'm not sure yet if that makes it work alltogether, I've only just successfully installed ueberzug ...

so, after adapting this very plugin - which initially forcefully bails out on darwin/macOS (just deleting this portion of the plugin script) - and installing my fork in my nvim-cfg ... I found I didn't get the simple bailout msg ... but some error msg ...

image

If anyone has some knowledge of ueberzug and its usage, or if the author or somebody could have a look if this is fixable with reasonable efforts ... I'd love to use this plugin on my mac :-)

BTW, I'm using zsh and I found this to be a bash-script or so ... maybe the syntax error is to be overcome in a very few simple steps, but I lack knowledge and am out of time/energy ...

@howarddo2208
Copy link

please support macos

@brodia10
Copy link

brodia10 commented Jul 20, 2022

Does anyone have a high-level idea of what a solution for MacOS would look like? What are the current blockers?

Happy to collaborate and take a stab at it.

@jswent
Copy link

jswent commented Jul 22, 2022

Would also be happy to lend a hand if people so desire, at this point I feel it might be easier to build a new Telescope extension from the ground up specifically for macos.

@jugarpeupv
Copy link

What about using imgcat? we can display images in iterm2

@brodia10
Copy link

I feel like this is probably the best option. @jswent you want to start collaborating on this? I can start a slack channel or discord or something

@brodia10
Copy link

What about using imgcat? we can display images in iterm2

imgcat looks awesome thanks. Probably a good starting point. I was able to get it working no problem on macOS with Alacritty terminal.

@howarddo2208
Copy link

howarddo2208 commented Aug 29, 2022

I found a way to use viu with this plugin. Here is the config I found

require("telescope").setup({
	defaults = {
		preview = {
			mime_hook = function(filepath, bufnr, opts)
				local is_image = function(filepath)
					local image_extensions = { "png", "jpg", "jpeg", "gif" } -- Supported image formats
					local split_path = vim.split(filepath:lower(), ".", { plain = true })
					local extension = split_path[#split_path]
					return vim.tbl_contains(image_extensions, extension)
				end
				if is_image(filepath) then
					local term = vim.api.nvim_open_term(bufnr, {})
					local function send_output(_, data, _)
						for _, d in ipairs(data) do
							vim.api.nvim_chan_send(term, d .. "\r\n")
						end
					end
					vim.fn.jobstart({
						"viu",
						filepath,
					}, {
						on_stdout = send_output,
						stdout_buffered = true,
					})
				else
					require("telescope.previewers.utils").set_preview_message(
						bufnr,
						opts.winid,
						"Binary cannot be previewed"
					)
				end
			end,
		},
	},
})
require("telescope").load_extension("media_files")

I use Alacritty and the image quality is pretty shit but at least I got a peek of what the images look like, maybe iterm2 and kitty would be better.

@joehannes
Copy link

hey guys!
Just saw this interesting option in the last comment by @howarddo2208 :-)
It didn't work for me, as the media_files plugin didn't seem to pick up that hook and I didn't know where to go from there ...

So anyway, I found a way that might be of interest to other guys on MacOS or on any platform that supports the viu cli image viewer :-) And this time it's really easy ...

All one has to do, is tinker a bit with a fork of this repo and replace the line in the plugin where it calls the ueberzug script with a simple string viu ... that's it.

Basically like that:

M.media_preview = defaulter(function(opts)
  return previewers.new_termopen_previewer {
    get_command = function(entry)
      local tmp_table = vim.split(entry.value, "\t");
      local preview = opts.get_preview_window()
      opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd()
      if vim.tbl_isempty(tmp_table) then
        return { "echo", "" }
      end
      return {
        'viu',
        string.format([[%s/%s]], opts.cwd, tmp_table[1]),
        preview.col,
        preview.line + 1,
        preview.width,
        preview.height
      }
    end
  }
end, {})

Also, I did fork that already, so, if you just wanna give it a shot if it works for you, you might want to temporarily try my unmaintained fork here: github.com/joehannes-os/telescope-media-files.nvim ...

Cheers 🥳

@joehannes
Copy link

ohh, and an example of what that looks like, also including my unfinished cleanup ...
img

@howarddo2208
Copy link

@joehannes nice job, but you're a monster, use dark theme right now!

@Conni2461
Copy link
Member

There is also a PR that replaces Ueberzug with viu #35

which looked pretty good, i only had one nit otherwise it would have been merged already

@HendrikPetertje
Copy link
Contributor

jep been working on this for a while. sad that I didn't see this comment before, Pull request has its kinks fixed now. should be good to merge.

Feel free to use it as a base-point for hologram or other better non pixelated solutions. My next stop after getting this merged is going to be svg preview

@quadruple-output
Copy link

quadruple-output commented Aug 2, 2023

I would love to see this feature merged. Wondering whether this issue could receive more attention if the title would be changed to me less generic. (@singlexyz)

@HendrikPetertje
Copy link
Contributor

that pull request i mentioned was actually merged in. it switched out ueberzeug with "Chafa", which uses text symbols to draw pictures with extreme ascii art
#35

@MDSADABWASIM
Copy link

Any update on macos support?

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

No branches or pull requests