Skip to content

Commit

Permalink
Merge pull request #150 from marrink-lab/syntax
Browse files Browse the repository at this point in the history
Add vim highlighting to the repo
  • Loading branch information
pckroon committed Oct 6, 2018
2 parents 850acbf + 2bc15cb commit 4b037ac
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions maintainers/vim/syntax/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
VIM syntax highlighting for vermouth file formats
=================================================

This directory contains syntax highlighting rules for VIM to handle vermouth
files. Install them by copying the content of this directory in
`~/.vim/syntax/`. To activate the highlighting, you should copy the following
lines in `~/.vimrc`:

```
" Highlighting for vermouth force field files
au BufNewFile,BufRead *.ff set syntax=ff
```
48 changes: 48 additions & 0 deletions maintainers/vim/syntax/ff.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
if exists("b:current_syntax")
finish
endif

syn match ffComment ";.*$"
syn match ffSuperComment ";;.*$"
syn match ffMeta "^#\w\+"
syn match ffMacro "\$\w\+"

syn match ffMetaError "^#meta\s\+\([^{]\+\)$"

"syn region ffSection start='\[' end='\]' contains=ffSectionName,ffSectionSpecial
syn match ffSectionName "\[\s*\([A-Za-z0-9_-]\|\s\|\.\)\+\s*\]"
syn match ffSectionRemove "\[\s*\(![A-Za-z0-9_-]\+\)\+\s*\]"
syn match ffSectionSpecial "\[\s*\(edges\|non-edges\|patterns\|molmeta\|features\)\s*\]"

syn match ffMolType "^\s*\[\s*\(moleculetype\)\s*\]"
syn match ffLink "^\s*\[\s*\(link\)\s*\]"
syn match ffVariables "^\s*\[\s*\(variables\)\s*\]"
syn match ffMacroSectionName "^\s*\[\s*\(macros\)\s*\]"

syn region ffMacroSection start='^\s*\[\s*macros\s*\]' end='^\s*\['me=e-1 transparent contains=ALL keepend
syn match ffMacroDef "^\(\w\+\)" contained containedin=ffMacroSection

syn region ffMolecules start='^\s*\[\s*moleculetype\s*\]' end='^\s*\['me=e-1 transparent contains=ALL keepend
syn match ffBlockNameError "^\([A-Za-z0-9_-]\|+\)\+" contained containedin=ffMolecules
syn match ffBlockName "^\([A-Za-z0-9_-]\|+\)\+" contained containedin=ffMolecules nextgroup=ffMolNumber skipwhite
syn match ffMolNumber "\d\+\s*$" contained containedin=ffMolecules


hi def link ffComment Comment
hi def link ffSuperComment VimCommentTitle
hi def link ffMeta PreProc
hi def link ffMacro Constant
hi def link ffSectionName Identifier
hi def link ffSectionRemove Structure
hi def link ffSectionSpecial Type
hi def link ffMolNumber level14c
hi def link ffMolType Exception
hi def link ffLink Exception
hi def link ffVariables Exception
hi def link ffMacroSectionName Exception
hi def link ffMacroDef Constant
hi def link ffBlockName String
hi def link ffMetaError Error


let b:current_syntax = "ff"

0 comments on commit 4b037ac

Please sign in to comment.