Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Add Jinja Syntax Highlighting To Neovim

I'm using the Minijinja^mj^^ Rust crate to make the templates for Neopolitan^neo^^. It's a solid format but it's a bit hard to look at. Especially without syntax highlighting which doesn't appear to be available by default in Neovim^g:nvim^^.

I tried a plugin^plug^^ to add the highlights but caused a bunch of errors every time I started up.

This is the process I ended up going with:

Code

au Syntax jinja   runtime! syntax/htmljinja.vim
au BufNewFile,BufRead *.jinja,*.j2  setf jinja

That got syntax highlighting working for me. It doesn't do automatic indention. That would be nice but if I had to choose one or the other I'd choose syntax highlighting over the indention.

I've forked the other repo so can take a look at it as well.

Footnotes

  • (id:mj)

    "a powerful template engine for Rust with minimal dependencies"

  • (id:neo)

    My plain-text format for websites

  • (id:nvim)

    The "hyperextensible Vim-based text editor" that's my daily driver. (Though I'm not picky, I use VSCode, Sublime Text, and Emacs too)

  • (id:plug)

    This is the plugin I tried that kinda worked but threw a bunch of errors.

References