Vim and Neovim
Set up Vim with VimTeX and Zathura for LaTeX on macOS, and add the Neo-tree file explorer to Neovim.
3 min readUpdated
Two setups on macOS with Homebrew: Vim (MacVim) as a LaTeX editor with VimTeX and the Zathura PDF viewer, and Neovim with the Neo-tree file explorer, installed with packer.nvim, vim-plug or lazy.nvim.
Write LaTeX with VimTeX and Zathura
Install MacVim, Zathura and MacTeX
Install MacVim, then Zathura and its Poppler PDF plugin from the Zathura tap:
brew install macvimbrew tap homebrew-zathura/zathurabrew install zathura --with-synctexbrew install zathura-pdf-poppler--with-synctex builds Zathura with SyncTeX support, which lets VimTeX jump between a line in the source and the matching place in the PDF. The tap was formerly zegervdv/zathura.
Zathura only finds the PDF plugin if it is linked into Zathura’s plugin directory. The tap’s README gives this command; run it again after installing new plugins:
d=$(brew --prefix zathura)/lib/zathura ; mkdir -p $d ; for n in cb djvu pdf-mupdf pdf-poppler ps ; do p=$(brew --prefix zathura-$n)/lib$n.dylib ; [[ -f $p ]] && ln -s $p $d ; doneInstall a TeX distribution without the GUI applications:
brew install --cask mactex-no-guiInstall VimTeX with vim-plug
Install vim-plug as described in its README, then add VimTeX between the call plug#begin('~/.vim/plugged') and call plug#end() lines of your .vimrc:
" https://github.com/junegunn/vim-plug" Specify a directory for pluginscall plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex' let g:tex_flavor='latex' let g:vimtex_view_method='zathura' let g:vimtex_quickfix_mode=0 " these two lines are for a separate plugin: https://github.com/KeitaNakamura/tex-conceal.vim set conceallevel=1 let g:tex_conceal='abdmg'
" Initialize plugin systemcall plug#end()g:tex_flavor='latex'makes Vim treat.texfiles as LaTeX rather than plain TeX.g:vimtex_view_method='zathura'opens the compiled PDF in Zathura.g:vimtex_quickfix_mode=0stops the quickfix window from opening on every compiler warning.conceallevelandg:tex_concealdisplay LaTeX commands such as\alphaas the symbol they produce. They work together with tex-conceal.vim.
Reload .vimrc and install the plugins from inside Vim:
:PlugInstallAdd Neo-tree to Neovim
Install Neovim:
brew install neovimNeo-tree needs three other plugins: plenary.nvim and nui.nvim are required, nvim-web-devicons is optional and adds file icons. The v3.x branch is the current stable release line. Pick one of the plugin managers below.
With packer.nvim
Note: packer.nvim has been unmaintained since August 2023, and its README recommends lazy.nvim instead. The steps still work for existing setups.
Clone packer into Neovim’s package directory:
git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvimDeclare Neo-tree in your Lua config, usually ~/.config/nvim/init.lua:
require('packer').startup(function() use { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", requires = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", -- optional, for file icons "MunifTanjim/nui.nvim", } }end)Install the plugins from inside Neovim:
:PackerSyncWith vim-plug
Install vim-plug for Neovim:
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vimDeclare Neo-tree in your config, ~/.config/nvim/init.vim for Vimscript:
call plug#begin('~/.local/share/nvim/plugged')Plug 'nvim-neo-tree/neo-tree.nvim', { 'branch': 'v3.x' }Plug 'nvim-lua/plenary.nvim'Plug 'nvim-tree/nvim-web-devicons' " optional, for file iconsPlug 'MunifTanjim/nui.nvim'call plug#end()Install the plugins from inside Neovim:
:PlugInstallWith lazy.nvim
If you use lazy.nvim, add this plugin spec (taken from the Neo-tree README):
return { { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", dependencies = { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", -- optional, but recommended }, lazy = false, -- neo-tree will lazily load itself }}Configure and open Neo-tree
Call setup in your Lua config to change the defaults; with no options it uses the defaults:
require("neo-tree").setup({ -- your configuration here})Show or hide the file tree:
:Neotree toggle