Skip to content

Commit

Permalink
initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
xnning committed Mar 18, 2015
0 parents commit 662cf53
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# vim syntax highlight for f2j

Highlight the f2j code in Vim editor.

## Usage

1. Make sure Vim can idenfity the \*.sf file type.

find `$VIMRUNTIME/filetype.vim`

add

```
" f2j
au BufNewFile,BufRead *sf setf f2j
```
For more details, type `:help filetype` in vim.
2. Put `f2j.vim` to `$VIMRUNTIME/syntax/`
77 changes: 77 additions & 0 deletions f2j.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
" Vim syntax file
" Language: f2j
" Maintainer: Ningning Xie <[email protected]>
" Last Change: 2015 Mar 18

" For vim-version 5.x: Clear all syntax items
" For other vim-version : Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif

" (Qualified) identifiers (no default highlighting)
syn match ConId "\(\<\u[a-zA-Z0-9_']*\.\)\=\<\u[a-zA-Z0-9_']*\>"
syn match VarId "\(\<\u[a-zA-Z0-9_']*\.\)\=\<\l[a-zA-Z0-9_']*\>"

" Keywords
syn keyword f2jBoolean True False
syn keyword f2jConditional if then else
syn keyword f2jStatement case of \| let and rec
syn keyword f2jModule module
syn keyword f2jStructure data
syn keyword f2jTypedef type
syn keyword f2jType Int String Bool Char Float Double

" Infix operation
syn match f2jVarSym "\(\<\u[a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~:.][-!#$%&\*\+/<=>\?@\\^|~:.]*"

" Strings and Constants
syn match f2jInteger "\<-\=\d\+\>"
syn match f2jReal "\<-\=\d\+\.\d*\([eE][-+]\=\d\+\)\=\>"
syn match f2jCharacter "'[^']'"
syn match f2jCharacter "'\\''"
syn match f2jCharacter "'[^\\]'"
syn region f2jString start=+"+ skip=+\\\\\|\\"+ end=+"+

syn match f2jDelimiter "(\|)\|\[\|\]\|,\|;\|{\|}"

" Comments
syn region f2jComment start="--" end="$" contains=f2jTodo
syn keyword f2jTodo contained TODO FIXME XXX


" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_f2j_syntax_inits")
if version < 508
let did_f2j_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif

HiLink f2jModule f2jStructure
HiLink f2jVarSym f2jOperator

HiLink f2jConditional Conditional
HiLink f2jStatement Statement
HiLink f2jInteger Number
HiLink f2jReal Float
HiLink f2jCharacter Character
HiLink f2jBoolean Boolean
HiLink f2jType Type
HiLink f2jString String
HiLink f2jComment Comment
HiLink f2jTodo Todo
HiLink f2jStructure Structure
HiLink f2jOperator Operator
HiLink f2jTypedef Typedef
HiLink f2jDelimiter Delimiter

delcommand HiLink
endif

let b:current_syntax = "f2j"

0 comments on commit 662cf53

Please sign in to comment.