goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.73k stars 101 forks source link

feature request: image support #15

Open shaunsingh opened 2 years ago

shaunsingh commented 2 years ago

Hi, would it be possible to implement image support? https://github.com/edluffy/hologram.nvim can help with displaying the images

goolord commented 2 years ago

jeez, so many kitty features simultaneously impress me and turn me off of kitty.

you should be able to whipup a rather hacky solution with the current set of features. the ui building api should already be extendable, but since hologram.nvim seemingly doesn't have a way of returning how many rows and columns an image takes up calculating how much space to allocate seems like it would be difficult/impossible. i might try to figure something out if i have spare time

shaunsingh commented 2 years ago

Yeah, the previous dashboard plugin (dashboard.nvim) kindof has image support. You could use a floating window running a terminal in place of the dashboard text, and then use something like uzerbeg to display the images. It was really hacky and barely worked though

siduck commented 2 years ago

using ueberzug ( for linux ) would be nice since it works on every terminal :D

goolord commented 2 years ago

dashboard-nvim (which this plugin is not a successor to, btw!) presumably did the terminal previewer for exactly this reason. there are simply too many competing standards.

my approach to designing this api was such that functionality could be added by another plugin, i think i will write 1 such plugin and any further implementations can be contributed :)

goolord commented 2 years ago

i can't seem to get hologram to work at all, let alone with alpha :/

siduck commented 2 years ago

i can't seem to get hologram to work at all, let alone with alpha :/

try using ueberzug to display stuff ._.

siduck commented 2 years ago

image

A lil script taking from telescope-media repo

goolord commented 2 years ago

unfortunately ueberzug also doesn't seem to work for me i read that maybe it doesn't support wayland but since they have seemingly closed their issue tracker there's no way for me to know

siduck commented 2 years ago

unfortunately ueberzug also doesn't seem to work for me i read that maybe it doesn't support wayland but since they have seemingly closed their issue tracker there's no way for me to know

which distro?

shaunsingh commented 2 years ago

according to the repo info section:

...display images in combination with X11 I'm assuming that means no wayland support

The only cross-platform ways I can think of are

I think the best solution would be to create a successor to hologram.nvim, but sounds like quite a bit of work and would end up being extremely complicated if we were to support multiple image protocols.

The easiest (but hackiest) way is to just open a floating neovim terminal window and run uberzug/sixel/kitty-image. Since the dashboard doesn't scroll, maybe you/we could consider an option to replace the dashboard ASCII with a terminal instead, where the user could run anything?

siduck commented 2 years ago

sixel and kitty stuff are very terminal specific , not all terminals support sixel graphics which is upsetting :(

goolord commented 2 years ago

sixel and kitty stuff are very terminal specific , not all terminals support sixel graphics which is upsetting :(

there is not a good cross platform way of displaying images in a terminal. there are simply too many competing standards and none of them are very complete, which is why dashboard does the floating terminal window thing

siduck commented 2 years ago

sixel and kitty stuff are very terminal specific , not all terminals support sixel graphics which is upsetting :(

there is not a good cross platform way of displaying images in a terminal. there are simply too many competing standards and none of them are very complete, which is why dashboard does the floating terminal window thing

yes , but ueberzug works on all terminals on linux ( but not wayland )

shaunsingh commented 2 years ago

honestly maybe chafa is the way to go? You don't get a proper image, its made up of unicode blocks. Benefit being that every single terminal will work, the drawback is a much lower resolution image

goolord commented 2 years ago

this seems promising https://github.com/bytesnake/vim-graphical-preview

siduck commented 2 years ago

this seems promising https://github.com/bytesnake/vim-graphical-preview

ig only a few terminals have sixel graphics support

goolord commented 2 years ago

the upshot being that it actually works : )

EpsilonKu commented 1 year ago

What about to steal dashboard code?

goolord commented 1 year ago

it's already in alpha https://github.com/goolord/alpha-nvim/pull/124 @EpsilonKu

EpsilonKu commented 1 year ago

No, I mean ready ueberzug script.

goolord commented 1 year ago

does dashboard integreate ueberzug now?

EpsilonKu commented 1 year ago

https://github.com/glepnir/dashboard-nvim/commit/0c3fb6e7a430859b8c1b605fa9fdcf38df0dc079 . Kinda yeah

goolord commented 1 year ago

well, ueberzug doesn't work on my machine, so I have no way to test it. but if someone submits a PR I'll happily approve it. the terminal PR should be a good example of how to extend the alpha api.

siduck commented 1 year ago

well, ueberzug doesn't work on my machine, so I have no way to test it. but if someone submits a PR I'll happily approve it. the terminal PR should be a good example of how to extend the alpha api.

how did you test it?

OpenWaygate commented 1 year ago

How about use Chafa to convert an image into graphics formats or ANSI/Unicode character art? It can display in terminal. There are also some discussion about this in dashboard-nvim

image

goolord commented 1 year ago

if that's what you want to do you can use the terminal element https://github.com/goolord/alpha-nvim/blob/main/doc/alpha.txt#L137-L159

justchokingaround commented 1 year ago

this program supports Kitty, Sixel, iTerm and Unicode blocks with truecolor/ansi256 support otherwise. that's pretty much all the terminal picture protocols: https://github.com/emsquid/pic not sure if it is helpful, but thought i would share it here anw

constantitus commented 2 months ago

Is this feature still in consideration ?

calculating how much space to allocate seems like it would be difficult/impossible

Allowing the user to specify the size of the image could be a good solution, even if it's a bit hacky. How often is the user going to change the image anyway ?

I was looking into image.nvim, it supports both kitty and ueberzug. I've been able to get it to draw the image, but it gets wiped after a few miliseconds.

config ```lua local width = vim.api.nvim_win_get_width(0) local buffer = vim.api.nvim_buf_get_name(0) local image = require("image").from_file( "/path/to/image/NeovimLogo.png", { id = "neovim_logo", -- with_virtual_padding = true, -- this should bind the image to alpha's buffer buffer = buffer, -- optional, binds image to a buffer (paired with window binding) -- or just call image:clear() when exiting alpha ? inline = true, -- hacky aproximation of the center x = math.floor(width / 2 - 15), height = 8, } ) require("alpha").setup({ layout = { { type = "terminal", command = function() image:render() -- this is obviously not what I should be using... -- I just need it to call the render function, not execute shell commands return "" end, width = 100, height = 8, opts = { redraw = true, window_config = {}, position = "center", }, }, { type = "button", val = "test button", on_press = function() end, opts = { position = "center", shortcut = "e", cursor = 3, width = 50, align_shortcut = "right", hl_shortcut = "Keyword", }, } }, opts = { margin = 5, }, }) require("alpha.term") ```
goolord commented 2 months ago

until any terminal graphics protocol reaches widespread adoption i am apprehensive to merge anything, especially a neovim library which wraps such an api, into this plugin. since i wrote this plugin i've seen dozens and dozens of these "image in terminal" plugins pop up and die because maintaining them isn't worth the hassle.

i would just use the terminal element and run a shell command that displays an image in that terminal window