Skip to content

Instantly share code, notes, and snippets.

@kimsk
Created June 30, 2015 15:56
Show Gist options
  • Save kimsk/358b4ba0c9cde1fcdd0c to your computer and use it in GitHub Desktop.
Save kimsk/358b4ba0c9cde1fcdd0c to your computer and use it in GitHub Desktop.
F# Syntax Highlighting for FishEye
syntaxdef fsharp {
/\s+/m : ;
# inline doc-comment
/\/\/\/(.*)$/m : {
doccomment(${1});
region {
type=comment;
index=prose;
findlinks=true;
}
}
# multiline doc-comment
/\/\*\*(.*?)\*\//s : {
doccomment(${1});
region {
type=comment;
index=prose;
findlinks=true;
}
}
context doccomment {
# find xml tag-like things
/ < \/?
([\p{N}\p{L}:_-]+)
((\s+[\p{N}\p{L}:_-]+((="[^"]*")|(=[^\s>]+))?)*)
\s*
\/? >
/mx : {
region {
type=commentmeta;
}
}
}
# inline comment
/\/\/.*$/m : {
region {
type=comment;
index=prose;
findlinks=true;
}
}
# multiline comment
/(\*(.*?)\*)/s : {
region {
type=comment;
index=prose;
findlinks=true;
}
}
# numeric
/(0x[0-9a-f]+l?)|([0-9]+(\.[0-9]*)?|\.[0-9]+)(e(\+|-)?[0-9]+)?(f|l|d)?/i : {
region {
type=numeric;
}
}
# string literal
/"/ : {
context {
/\\"/: ;
/\\./: ;
/$/m : exit;
"\"" : exit;
}
region ${ALL} {
type=string;
}
}
# verbatim string literal
/@"/ : {
context {
/"{2}/: ;
/\\./: ;
"\"" : exit;
}
region ${ALL} {
type=string;
}
}
# char literal
/'(\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\x[0-9a-fA-F]{1,4}|\\.|.)'/ : {
region {
type=char_literal;
}
region ${1} {
index=word;
}
}
# keywords
/(abstract|and|as|assert|base|begin|class|default|delegate|do|done\
|downcast|downto|elif|else|end|exception|extern|false|finally|for\
|fun|function|if|in|inherit|inline|interface|internal|lazy|let\
|match|member|module|mutable|namespace|new|null|of|open|or\
|override|private|public|rec|return|static|struct|then|to\
|true|try|type|upcast|use|val|void|when|while|with|yield)\b/ : {
region {
type=keyword;
index=word;
}
}
# preprocessing directive
/^[^\r\n]*#[^\r\n]*(def(ault|ine)|e(l(if|se)|nd(if|region)|rror)|if|line|region|undef|warning).*$/m : {
region {
type=preprocessor;
index=prose;
}
}
# identifier
/[\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}_][\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}\p{Nd}\p{Pc}\p{Cf}]*/ : {
region {
type=identifier;
index=word;
}
}
}
@kimsk
Copy link
Author

kimsk commented Jun 30, 2015

Instructions

  1. Put the file fsharp.def in FISHEYE_INST/syntax directory.
  2. Copy the FISHEYE_HOME/filename.map to your FISHEYE_INST/syntax directory and add the lines below to the filename.map file
    "**/*.fs" fsharp.def "F#"
    "**/*.fsx" fsharp.def "F# Script"
    "**/*.fsi" fsharp.def "F# Signature"
  1. Restart FishEye to pick up the change.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment