Syntax Files

From radmind

Revision as of 12:41, 31 August 2007 by Portman@goshen.edu (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

[edit] Vim

To get a bit of highlighting using the Vim text editor you will need the following three files (or edit existing files you may have). This has been tested only with Vim 7+, and no claims exist to the quality of these files (please improve them :).

In order to get Vim to recognize the Radmind config and transcript files, you need to tell it to associate those files with certain highlighting scripts. These commands need to be saved in a file called ~/.vim/filetype.vim

augroup filetypedetect
au BufRead,BufNewFile /var/radmind/config set filetype=radmind
au BufRead,BufNewFile /var/radmind/command/*.K set filetype=radmind
au BufRead,BufNewFile /var/radmind/transcript/*.T set filetype=radmind_transcript
augroup END
au syntax radmind source $VIMRUNTIME/radmind.vim
au syntax radmind_transcript source $VIMRUNTIME/radmind_transcipt.vim

This is the actual syntax definition for config and command files. This should be saved in ~/.vim/syntax/radmind.vim

if version < 600
    syntax clear
elseif exists("b:current_syntax")
    finish
endif

syn match radmindComment /\s*#.*/
syn match radmindCommand /\S*\.K\s/
syn match radmindCommand /\S*\.K$/
syn match radmindKType /\<k\>/
syn match radmindPType /\<p\>/
syn match radmindNType /\<n\>/
syn match radmindSType /\<s\>/
syn match radmindOpr /^[+-]\s/

" Link up our terms with the actual terms
command -nargs=+ HiLink hi def link <args>

HiLink radmindComment           Comment
HiLink radmindCommand           Include
HiLink radmindOpr               Operator
HiLink radmindKType  Include
HiLink radmindPType  StorageClass
HiLink radmindNType  Debug
HiLink radmindSType  Exception

delcommand HiLink

let b:current_syntax = "radmind"

This is the syntax definition for transcript files. This should be saved in ~/.vim/syntax/radmind_transcript.vim

if version < 600
    syntax clear
elseif exists("b:current_syntax")
    finish
endif

syn match radmindTranscriptComment "\s*#.*"
syn match radmindTranscriptOpr "^[+-]\s" nextgroup=radmindTranscriptType skipwhite
syn match radmindTranscriptTypeFile "\<[hlfa]\>"
syn match radmindTranscriptTypeOther "\<[dcbpsD]\>"

" Link up our terms with the actual terms
command -nargs=+ HiLink hi def link <args>

HiLink radmindTranscriptComment         Comment
HiLink radmindTranscriptOpr             Special
HiLink radmindTranscriptTypeFile  Include
HiLink radmindTranscriptTypeOther  Statement

delcommand HiLink

let b:current_syntax = "radmind"
Personal tools