brisvag / starfile.vim

VIM syntax for STAR/CIF files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

starfile.vim

A syntax file for vim for the STAR (Self-defining Text Archive and Retrieval) format (the underlying format behind the PDBx/mmCIF/CIF molecular structure files from the PDB, the .star files used by RELION, and a few others).

It highlights each column and header differently, in a way that makes easier to match specific columns to their headers in the otherwise inscrutable sea of characters. This is especially useful with many headers wrapping over multiple lines or continuing off the screen where it's hard to count columns.

vim screenshot

The colorscheme used above is gruvbox-dark, but it should work well with the builtin colorschemes; try for example :colorscheme slate.

How-to

For syntax highlighting to work, your vim needs to have the following settings active (in your ~/.vimrc for persistence):

filetype plugin indent on
syntax on

Then, create or edit your filetype.vim file (likely inside ~/.vim/) so it contains something like this:

if exists("did_load_filetypes")
  finish
endif

augroup filetypedetect
  au! BufRead,BufNewFile *.star,*.cif setfiletype starfile
augroup END

This will automatically detect the file extension and load the correct syntax file whenever you open a .star file.

Finally, put the starfile.vim provided here inside the syntax vim runtime directory (likely ~/.vim/syntax/) and everything should work.

Neovim

If you're on nvim, the aforementioned paths should all be inside .config/nvim/.

Known issues

  • if there's a newline between columns that belongs to the same line in a _loop construct (which is weird, but alas allowed in STAR), colors will be mismatched. This is unfortunately common in mmCIF files. (This is because with the limited vim syntax we can't distinguish between a new line of columns or just the next column on a new line.)

License is GPLv3; feel free to contribute and fork!

About

VIM syntax for STAR/CIF files.

License:GNU General Public License v3.0


Languages

Language:Vim Script 100.0%