2

I've created a local syntax file def.vim and saved in ~/.vim/syntax.

First it's working, but just after I closed gvim and several other windows, it stops working.

First I checked :scriptnames. Local def.vim is loaded.
enter image description here

Also checked syntax list. enter image description here

Just don't understand why suddenly it stops working.

Below is local def.vim.

" Vim syntax file
" Language:     DEF 

" def register definition
if exists("b:current_syntax")
  finish
endif

" let s:cpo_save ="  &cpo
" set cpo&vim

" case is not significant
syn case ignore

" def keywords
syn keyword defStatement endf endg endr 
syn keyword defStatement field
syn keyword defStatement group
syn keyword defStatement register
syn keyword defStatement version

" syn match   defStatement "\<\(field\|endf\)\>"
" syn match   defStatement "\<\(register\|endr\)\>"
" syn match   defStatement "\<\(group\|endg\)\>"

" " Predefined VHDL types
" syn keyword defType desc title default split readonly

" syn match  defVector "0B[01_]\+"
" syn match  defVector "0O[0-7_]\+"
syn match  defVector "0X[0-9a-f_]\+"
syn match  defVector "\[[0-9]\+ \.\. [0-9]\+\]"
" syn match  defCharacter "'.'"
" syn region defString start=+"+  end=+"+ contains=@Spell

" syn match defComment "--.*$" contains=@Spell
" syn match defComment "{.*}" contains=@Spell

let b:current_syntax = "def"

" let &cpo = s:cpo_save
" unlet s:cpo_save
  • For future reference, the :syntax command you're using to confirm the syntax items exists also show you how the matches will be highlighted: the xxx item near the start of the line shows that no highlighting has yet been applied. – Rich Jan 30 '18 at 13:09
1

Found the reason, need to add below highlight links.

HiLink cDefine      PreProc      
HiLink defSpecial   Special
HiLink defStatement Statement
HiLink defCharacter String
HiLink defString    String
HiLink defVector    String
HiLink defBoolean   String
HiLink defComment   Comment
HiLink defNumber    String
HiLink defTime      String
HiLink defType      Type
HiLink defOperator  Type
HiLink defGlobal    Error
HiLink defAttribute Type
  • select your own answer so it shows as completed – jecxjo May 22 '18 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.