From 40ddf334c9428ff7d88b7ca12912a9a1ea80dbab Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 27 Sep 2017 20:19:38 +0200 Subject: Add F# support, closes #219 --- syntax/fsharp.vim | 269 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 syntax/fsharp.vim (limited to 'syntax') diff --git a/syntax/fsharp.vim b/syntax/fsharp.vim new file mode 100644 index 00000000..f66daa01 --- /dev/null +++ b/syntax/fsharp.vim @@ -0,0 +1,269 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fsharp') == -1 + +" Vim syntax file +" Language: F# +" Last Change: Sun 19 Oct 2014 11:11:44 PM CEST +" Maintainer: Gregor Uhlenheuer +" +" Note: This syntax file is a complete rewrite of the original version +" of fs.vim from Choy Rim and a slight +" modified version from Thomas Schank + +if version < 600 + syntax clear +elseif exists('b:current_syntax') + finish +endif + +" F# is case sensitive. +syn case match + +" reset 'iskeyword' setting +setl isk&vim + +" Scripting/preprocessor directives +syn match fsharpSScript "^\s*#\S\+" transparent contains=fsharpScript,fsharpRegion,fsharpPreCondit + +syn match fsharpScript contained "#" +syn keyword fsharpScript contained quitlabels warnings directory cd load use +syn keyword fsharpScript contained install_printer remove_printer requirethread +syn keyword fsharpScript contained trace untrace untrace_all print_depth +syn keyword fsharpScript contained print_length define undef if elif else endif +syn keyword fsharpScript contained line error warning light nowarn + + +" comments +syn match fsharpSingleLineComment "//.*$" contains=fsharpTodo,@Spell +syn region fsharpDocComment start="///" end="$" contains=fsharpTodo,fsharpXml,@Spell keepend oneline +syn region fsharpXml matchgroup=fsharpXmlDoc start="<[^>]\+>" end="]\+>" contained contains=fsharpXml + +" Double-backtick identifiers +syn region fsharpDoubleBacktick start="``" end="``" keepend oneline + + +" symbol names +syn match fsharpSymbol "\%(let\|use\|mutable\|rec\|and\|private\)\@<=!\=\s\+\zs\w\+\ze\s*[^=:]*[=:]" +syn match fsharpSymbol "\%(member\)\@<=\s\+\w\+\.\zs\w\+" + + +" types +syn match fsharpTypeName "\%(\" +syn match fsharpRefAssign ":=" +syn match fsharpTopStop ";;" +syn match fsharpOperator "\^" +syn match fsharpOperator "::" + +syn match fsharpLabel "\<_\>" + +syn match fsharpOperator "&&" +syn match fsharpOperator "<" +syn match fsharpOperator ">" +syn match fsharpOperator "|>" +syn match fsharpOperator ":>" +syn match fsharpOperator ":?>" +syn match fsharpOperator "&&&" +syn match fsharpOperator "|||" +syn match fsharpOperator "\.\." + +syn match fsharpKeyChar "|[^\]]"me=e-1 +syn match fsharpKeyChar ";" +syn match fsharpKeyChar "\~" +syn match fsharpKeyChar "?" +syn match fsharpKeyChar "\*" +syn match fsharpKeyChar "+" +syn match fsharpKeyChar "=" +syn match fsharpKeyChar "|" +syn match fsharpKeyChar "(\*)" + +syn match fsharpOperator "<-" + +syn match fsharpNumber "\<\d\+" +syn match fsharpNumber "\<-\=\d\(_\|\d\)*\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpNumber "\<-\=0[x|X]\(\x\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpNumber "\<-\=0[o|O]\(\o\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpNumber "\<-\=0[b|B]\([01]\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpFloat "\<-\=\d\(_\|\d\)*\.\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>" +syn match fsharpFloat "\<-\=\d\(_\|\d\)*\.\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>" +syn match fsharpFloat "\<\d\+\.\d*" + +" modules +syn match fsharpModule "\%(\= 508 || !exists("did_fs_syntax_inits") + if version < 508 + let did_fs_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink fsharpBraceErr Error + HiLink fsharpBrackErr Error + HiLink fsharpParenErr Error + HiLink fsharpArrErr Error + HiLink fsharpCommentErr Error + + HiLink fsharpSingleLineComment Comment + HiLink fsharpMultiLineComment Comment + HiLink fsharpDocComment Comment + HiLink fsharpXml Comment + HiLink fsharpDoubleBacktick String + + HiLink fsharpOpen Include + HiLink fsharpModPath Include + HiLink fsharpScript Include + HiLink fsharpPreCondit Include + + HiLink fsharpKeyword Keyword + HiLink fsharpCoreMethod Keyword + + HiLink fsharpOCaml Statement + HiLink fsharpLinq Statement + + HiLink fsharpSymbol Function + + HiLink fsharpFunDef Operator + HiLink fsharpRefAssign Operator + HiLink fsharpTopStop Operator + HiLink fsharpKeyChar Operator + HiLink fsharpOperator Operator + + HiLink fsharpBoolean Boolean + HiLink fsharpConstant Constant + HiLink fsharpCharacter Character + HiLink fsharpNumber Number + HiLink fsharpFloat Float + + HiLink fsharpString String + HiLink fsharpFormat Special + + HiLink fsharpModifier StorageClass + + HiLink fsharpException Exception + + HiLink fsharpLabel Identifier + HiLink fsharpOption Identifier + HiLink fsharpTypeName Identifier + HiLink fsharpModule Identifier + + HiLink fsharpType Type + + HiLink fsharpCoreClass Typedef + HiLink fsharpAttrib Typedef + HiLink fsharpXmlDoc Typedef + + HiLink fsharpTodo Todo + + HiLink fsharpEncl Delimiter + HiLink fsharpAttribute Delimiter + + delcommand HiLink +endif + +let b:current_syntax = 'fsharp' + +" vim: sw=4 et sts=4 + +endif -- cgit v1.2.3