Skip to content

Instantly share code, notes, and snippets.

@mrryanjohnston
Last active August 9, 2024 15:14
Show Gist options
  • Save mrryanjohnston/527d42f460abab01dd0c2d09a67a8deb to your computer and use it in GitHub Desktop.
Save mrryanjohnston/527d42f460abab01dd0c2d09a67a8deb to your computer and use it in GitHub Desktop.
Better syntax highlighting for CLIPS in vim in Ubuntu

Slightly better syntax highlighting for CLIPS in vim (in Ubuntu)

Problem

Syntax highlighting is so-so for .clp files. vim, my favorite code editor, detects these filetypes as jess, an unmaintained Rules Engine with a similar syntax to CLIPS.

Adding the jess.vim file to ~/.vim/after/syntax/ and the default.vim file to ~/.vim/colors in your Ubuntu system will provide slightly better highlighting when editing CLIPS files for the following:

  1. expand$ variables in LHS
  2. & (and) and | (or) symbols in LHS
  3. - and + as characters in variable names
  4. escape characters in double quoted strings
  5. TRUE and FALSE are bolded and have a slightly brighter color
hi Boolean guifg=#ffffff gui=bold ctermfg=255 cterm=bold
syn region jessString start=+"+ end=+"+ skip=+\\.+
syn region jessVar start="$?\|?" end="[^a-zA-Z0-9+-]"me=e-1
syn match jessBarSymbol "|" contained
syn match jessAmpersandSymbol "&" contained
syn match jessTildeSymbol "\~" contained
syn match jessBooleanSymbol /\<\(TRUE\|FALSE\)\>/
syn region jessList matchgroup=Delimiter start="(" skip="|.\{-}|" matchgroup=Delimiter end=")" contains=jessAtom,jessBQList,jessConcat,jessDeclaration,jessList,jessNumber,jessSymbol,jessSpecial,jessFunc,jessKey,jessAtomMark,jessString,jessComment,jessBarSymbol,jessAtomBarSymbol,jessVar,jessAmpersandSymbol,jessTildeSymbol,jessBooleanSymbol
syn region jessBQList matchgroup=PreProc start="`(" skip="|.\{-}|" matchgroup=PreProc end=")" contains=jessAtom,jessBQList,jessConcat,jessDeclaration,jessList,jessNumber,jessSpecial,jessSymbol,jessFunc,jessKey,jessVar,jessAtomMark,jessString,jessComment,jessBarSymbol,jessAtomBarSymbol,jessTildeSymbol,jessBooleanSymbol
hi def link jessAmpersandSymbol Special
hi def link jessTildeSymbol Special
hi def link jessBooleanSymbol Boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment