FlexLM VIM Syntax Highlighting

189 Views Asked by At

I'm trying to make vim a vim syntax file to highlight files for the FlexLM system.

It contains lines with keywords separated by spaces, and I would like to highlight things different colors based on what position they are in.

For example: FEATURE Infinisim infinism 2.4 31-may-2014 1 SUPERSEDE

Each line that starts with the word FEATURE would then have the next word in one color, next in another, etc, separated by spaces.

Is there a way to do this?

Thanks

1

There are 1 best solutions below

0
On

I have a "noddy" vim file as all I want to see are the basics. Put the following in ~/.vim/syntax/flexlm.vim

" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" Syntax is case INsensitive
syn case ignore


" Main statements
"===============================================
syn keyword     flexlmStatement       SERVER DAEMON USE_SERVER

syn keyword     flexlmStatement       FEATURE INCREMENT skipwhite nextgroup=flexlmToken
syn region      flexlmToken start="\S" end="\s" skipwhite nextgroup=flexlmDaemon
syn region      flexlmDaemon start="\S" end="\s" skipwhite nextgroup=flexlmVer
syn region      flexlmVer start="\S" end="\s" skipwhite nextgroup=flexlmDate
syn region      flexlmDate start="\S" end="\s" skipwhite nextgroup=flexlmCount
syn region      flexlmCount start="\S" end="\s" skipwhite nextgroup=flexlmStuff
syn region      flexlmStuff start="\S" end="$"

syn region flexlmComment  start=/#/ end=/$/

syn sync minlines=10

if version >= 508 || !exists("did_flexlm_syntax_inits")
  if version < 508
    let did_flexlm_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink flexlmComment          Comment
  HiLink flexlmStatement        Keyword
  HiLink flexlmToken            Identifier
  HiLink flexlmDaemon           Tag
  HiLink flexlmVer              Label
  HiLink flexlmCount            Macro
  HiLink flexlmStuff            Type

  delcommand HiLink
endif

let b:current_syntax = "flexlm"

You can then set this to be the default syntax highlight with the following in your ~/.vimrc

au BufRead,BufNewFile *.dat set filetype=flexlm

Obviously you can play with the line depending on your file extensions e.g. .lic etc. You can always type the following in vim

:set syntax=flexlm

If you feel like extending the syntax highlighting - please post the results back as it would be nice to include options files etc.