Unlock Visuals in Neovim: Viewing Images Made Easy
I’m a mobile engineer, and every day I work with image assets. It’s such a hassle to constantly open files just to check images before using them. The lack of image rendering inside Neovim was really bugging me. But finally, we have our savior: Image.nvim!
image.nvim is a plugin that allows you to display images in Neovim. It supports a variety of image formats, including PNG, GIF and even SVG.
You will need to use the kitty terminal emulator to display the images or install ueberzug++ if you’d like to use a different terminal.
Before adding any configurations, we’ll need to install a few dependencies:
First up, you’ll need to install ImageMagick, a powerful software suite for editing and manipulating digital images.
Ubuntu/Debian
sudo apt install imagemagick-dev
MacOS
brew install imagemagick
NOTE: If you are using MacOS you may need to add the following to your `~/.zshrc` or `~/.bashrc` file(only add it if default config doesn’t work for you):
export DYLD_LIBRARY_PATH="$(brew - prefix)/lib:$DYLD_LIBRARY_PATH"
If you’re using any terminal other than kitty you need to use use the ueberzug++ you can install it with the following command:
MacOS
brew install jstkdng/programs/ueberzugpp
If you’re on Linux you can install ueberzug++ from here.
Install the magick rock
Before we can start using image.nvim we need to install the magick rock.
Here is a lazy specification for the plugin:
{
"vhyrro/luarocks.nvim",
priority = 1001, -- this plugin needs to run before anything else
opts = {
rocks = { "magick" },
},
}
Configure image.nvim
Now that we have the magick rock installed we can install the image.nvim plugin.
{
"3rd/image.nvim",
dependencies = { "luarocks.nvim" },
config = function()
require("image").setup({
backend = "kitty", - or "ueberzug"
max_height_window_percentage = 50,
hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp", "*.svg" },
})
end
}
If you find any issues while doing the configuration please comment here or look it up on the readme.
That’s it, now you should be able to see the images from your terminal.
If you want to setup Neovim for flutter with debugger, check out my article about it here: