Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

thumb

thumb-demo

Popup images under the cursor and render LaTeX selections directly in Vim.

Requires Vim 9.2+, Python 3, Pillow, and matplotlib.

Installation

Using vim-plug

Plug 'JosefAlbers/thumb'

Then run:

:PlugInstall

Install the Python dependencies:

python3 -m pip install Pillow matplotlib

Alternatively

You can just clone the repository directly into Vim's package directory, e.g.,:

git clone https://github.com/JosefAlbers/thumb ~/.vim/pack/thumb/start/thumb

If you use a different Vim configuration directory, use the corresponding pack/*/start/ directory instead.

Usage

Images

Put the cursor on an image filename:

![example](images/example.png)

Then run:

:Thumb

The image is rendered as a popup anchored below the cursor.

Relative paths are resolved relative to the current file.

LaTeX

Select a LaTeX expression in Visual mode:

\begin{eqnarray*}
\mathcal{F} &=& \int f\left( \phi, c \right) dV, \\
\frac{ \partial \phi } { \partial t } &=& -M_{ \phi }
\frac{ \delta \mathcal{F} } { \delta \phi }
\end{eqnarray*}

Then run:

:'<,'>Thumb

Or simply:

:Thumb

while the selection is active.

The selection is rendered as a popup anchored below the selected text.

Closing a popup

Press t while the popup has focus.

Configuration

Python executable:

let g:thumb_python = 'python3'

Image popup height, in terminal cells:

let g:thumb_height = 8

LaTeX popup height, in terminal cells:

let g:thumb_math_height = 4

By default, text.usetex is enabled. To disable it to use matplotlib's built-in mathtext renderer:

let g:thumb_latex_usetex = 0

text.usetex requires LaTeX installation

For example:

let g:thumb_python = '/opt/homebrew/bin/python3'
let g:thumb_height = 10
let g:thumb_math_height = 5
let g:thumb_latex_usetex = 0

Optional mapping

thumb does not install any mappings. Add your own if desired:

nnoremap <leader>t <Cmd>Thumb<CR>
xnoremap <leader>t :Thumb<CR>

Requirements

  • Vim 9.2+
  • Python 3
  • Pillow
  • matplotlib

Vim must have popup image support (+popupwin and +terminal/image support as appropriate for your build).

License

MIT

Releases

Packages

Contributors

Languages