bytesnake / vim-graphical-preview

Small plugin for Vim to display graphics with SIXEL characters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Display graphics in (N)Vim with SIXEL characters

Adds the ability to display graphics to (N)Vim. This is developed for my digital notebook and is still in infancy. Expect weird behaviour and crashes.

The picture's content is streamed via the SIXEL character set (see 1, 2, 3 for more information)

Features

  • Render LaTex equations within math fences
  • Display pictures in standalone image links
  • Support GnuPlot, arbitrary LaTex, fetch source from other files
  • Fix weird artifacts of SIXEL

Examples

Graphic and LaTex math support

sample-sources.mp4

Support folding

sample-folding.mp4

Stream SIXEL characters via any text medium

sample-remote.mp4

Installation

The installation is a bit more involved. You have to make sure that your terminal is able to render SIXEL characters. The plugin is written in Rust for performance reasons, and interfaced to Vimscript with libcallex-vim. For this you also need to install toolchains for Rust and C. Imagemagick is also required to convert between different graphic formats and SIXEL.

First use a terminal supporting SIXEL characters

You have to install imagemagick to render graphics to SIXEL format:

Before installing the vim plugin, make sure that toolchains for Rust and C are installed:

  • for C install make and gcc
  • for Rust install a stable toolchain, for example with rustup

Finally add the following section to your vim configuration

Plug 'mattn/libcallex-vim', { 'do': 'make -C autoload' }
Plug 'bytesnake/vim-graphical-preview', { 'do': 'cargo build --release' }

and install with source %|PlugInstall.

The plugin is currently not mapped to a file format, but can be manually enabled by setting the filetype variable to graphical-preview or add the follow preamble to your file:

vim: set filetype=markdown.graphics :

FAQ

The graphic is overlapping with the command and status line

This is a limitation of SIXEL as it always scrolls after a line and would do that as well for the last one. Otherwise we could overlap and delete with a raster sequence. There is special mode, disabling this behaviour, but then your image is fixed at the upper, left corner (see here).

TODO

Kudos to

About

Small plugin for Vim to display graphics with SIXEL characters

License:MIT License


Languages

Language:Rust 92.7%Language:Vim Script 7.3%