• This repository has been archived on 07/Jan/2024
  • Stars
    star
    166
  • Rank 226,657 (Top 5 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 2 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ–ผ๏ธ Image Viewer as ASCII Art for Neovim written in Lua

image.nvim

Image Viewer as ASCII Art for Neovim, written in Lua

Issues Repository's starts License Latest commit

animated

Features

  • Supports many file formats (.png, .jpg, .jpeg, .bmp, .webp, ...)
  • Colored images
  • Almost no code runs on startup
  • Rendering with a dither method makes images more visible than traditional ascii art
  • Images are centered and have labels!

How does it work?

When you open an image file (e.g. portrait.png), the open buffer becomes non-editable and non-saveable to ensure the file contents won't be overwritten. Then the buffer is filled with the ascii art generated by ascii-image-converter. I found out that a plugin similiar to this was already implemented for vim in vimscript: image.vim, so you can consider this a modern, lua version.

Prerequisites

Install

With packer

use {
  'samodostal/image.nvim',
  requires = {
    'nvim-lua/plenary.nvim'
  },
},

With vim.plug

Plug 'samodostal/image.nvim'
Plug 'nvim-lua/plenary.nvim'

Setup

-- Require and call setup function somewhere in your init.lua
require('image').setup {
  render = {
    min_padding = 5,
    show_label = true,
    use_dither = true,
    foreground_color = false,
    background_color = false
  },
  events = {
    update_on_nvim_resize = true,
  },
}

Colors support:

Colors are turned off by default.

  • The reason for colors not being on by default is a significant delay when opening images + an additional dependency: plugin baleia.nvim (no need to call setup, only install)
  • Enable optionsrender.foreground_color and render.background_color
  • render.background_color setting is a nice addition that enables colors not only for characters, but also for the space behind them.