diff options
author | CodingCellist <teh6@st-andrews.ac.uk> | 2020-09-05 21:37:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 21:37:11 +0200 |
commit | 3baafd5c336d18d87898ae87f16df7cd76bc8d65 (patch) | |
tree | 3bd6787bde3c5713fd5cfc7c962d60ac4b3dac50 /syntax | |
parent | b0124dc88082f5ed8c96faa16d3b334d38f5949f (diff) | |
download | vim-polyglot-3baafd5c336d18d87898ae87f16df7cd76bc8d65.tar.gz vim-polyglot-3baafd5c336d18d87898ae87f16df7cd76bc8d65.zip |
Add support for Idris2, closes #534 (#535)
Diffstat (limited to 'syntax')
-rw-r--r-- | syntax/idris2.vim | 85 | ||||
-rw-r--r-- | syntax/lidris2.vim | 26 | ||||
-rw-r--r-- | syntax/rust.vim | 3 |
3 files changed, 113 insertions, 1 deletions
diff --git a/syntax/idris2.vim b/syntax/idris2.vim new file mode 100644 index 00000000..6bd18c58 --- /dev/null +++ b/syntax/idris2.vim @@ -0,0 +1,85 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +" syntax highlighting for Idris 2 (idris-lang.org) +" +" Heavily modified version of the haskell syntax +" highlighter to support Idris 2. +" +" author: raichoo (raichoo@googlemail.com) + +if exists("b:current_syntax") + finish +endif + +syn match idrisTypeDecl "[a-zA-Z][a-zA-z0-9_']*\s\+:\s\+" + \ contains=idrisIdentifier,idrisOperators +syn region idrisParens matchgroup=idrisDelimiter start="(" end=")" contains=TOP,idrisTypeDecl +syn region idrisBrackets matchgroup=idrisDelimiter start="\[" end="]" contains=TOP,idrisTypeDecl +syn region idrisBlock matchgroup=idrisDelimiter start="{" end="}" contains=TOP,idrisTypeDecl +syn keyword idrisModule module namespace +syn keyword idrisImport import +syn keyword idrisStructure data record interface implementation +syn keyword idrisWhere where +syn keyword idrisVisibility public abstract private export +syn keyword idrisBlock parameters mutual using +syn keyword idrisTotality total partial covering +syn keyword idrisAnnotation auto impossible default constructor +syn keyword idrisStatement do case of rewrite with +syn keyword idrisLet let in +syn keyword idrisForall forall +syn keyword idrisDataOpt noHints uniqueSearch search external noNewtype containedin=idrisBrackets +syn match idrisSyntax "\(pattern \+\|term \+\)\?syntax" +syn keyword idrisConditional if then else +syn match idrisNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>" +syn match idrisFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>" +syn match idrisDelimiter "[,;]" +syn keyword idrisInfix prefix infix infixl infixr +syn match idrisOperators "\([-!#$%&\*\+./<=>\?@\\^|~:]\|\<_\>\)" +syn match idrisType "\<[A-Z][a-zA-Z0-9_']*\>" +syn keyword idrisTodo TODO FIXME XXX HACK contained +syn match idrisLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=idrisTodo,@Spell +syn match idrisDocComment "|||\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=idrisTodo,@Spell +syn match idrisMetaVar "?[a-z][A-Za-z0-9_']*" +syn match idrisPragma "%\(hide\|logging\|auto_lazy\|unbound_implicits\|undotted_record_projections\|amibguity_depth\|pair\|rewrite\|integerLit\|stringLit\|charLit\|name\|start\|allow_overloads\|language\|default\|transform\|hint\|global_hint\|defaulthint\|inline\|extern\|macro\|spec\|foreign\|runElab\|tcinline\)" +syn match idrisChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'" +syn match idrisBacktick "`[A-Za-z][A-Za-z0-9_']*`" +syn region idrisString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell +syn region idrisBlockComment start="{-" end="-}" contains=idrisBlockComment,idrisTodo,@Spell +syn match idrisIdentifier "[a-zA-Z][a-zA-z0-9_']*" contained + +highlight def link idrisDeprecated Error +highlight def link idrisIdentifier Identifier +highlight def link idrisImport Structure +highlight def link idrisModule Structure +highlight def link idrisStructure Structure +highlight def link idrisStatement Statement +highlight def link idrisForall Structure +highlight def link idrisDataOpt Statement +highlight def link idrisDSL Statement +highlight def link idrisBlock Statement +highlight def link idrisAnnotation Statement +highlight def link idrisWhere Structure +highlight def link idrisLet Structure +highlight def link idrisTotality Statement +highlight def link idrisSyntax Statement +highlight def link idrisVisibility Statement +highlight def link idrisConditional Conditional +highlight def link idrisPragma Statement +highlight def link idrisNumber Number +highlight def link idrisFloat Float +highlight def link idrisDelimiter Delimiter +highlight def link idrisInfix PreProc +highlight def link idrisOperators Operator +highlight def link idrisType Include +highlight def link idrisDocComment Comment +highlight def link idrisLineComment Comment +highlight def link idrisBlockComment Comment +highlight def link idrisTodo Todo +highlight def link idrisMetaVar Macro +highlight def link idrisString String +highlight def link idrisChar String +highlight def link idrisBacktick Operator + +let b:current_syntax = "idris2" + +endif diff --git a/syntax/lidris2.vim b/syntax/lidris2.vim new file mode 100644 index 00000000..a4757205 --- /dev/null +++ b/syntax/lidris2.vim @@ -0,0 +1,26 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +" Vim syntax file +" Language: Literate Idris 2 +" Maintainer: Idris Hackers (https://github.com/edwinb/idris2-vim) +" Last Change: 2020 May 19 +" Version: 0.1 +" +" This is just a minimal adaption of the Literate Haskell syntax file. + + +" Read Idris highlighting. +if version < 600 + syntax include @idrisTop <sfile>:p:h/idris2.vim +else + syntax include @idrisTop syntax/idris2.vim +endif + +" Recognize blocks of Bird tracks, highlight as Idris. +syntax region lidrisBirdTrackBlock start="^>" end="\%(^[^>]\)\@=" contains=@idrisTop,lidrisBirdTrack +syntax match lidrisBirdTrack "^>" contained +hi def link lidrisBirdTrack Comment + +let b:current_syntax = "lidris2" + +endif diff --git a/syntax/rust.vim b/syntax/rust.vim index d1e9d8d4..2ad37ed8 100644 --- a/syntax/rust.vim +++ b/syntax/rust.vim @@ -67,10 +67,11 @@ syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifie syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained +syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP syn match rustMacroVariable "$\w\+" +syn match rustRawIdent "\<r#\h\w*" contains=NONE " Reserved (but not yet used) keywords {{{2 syn keyword rustReservedKeyword become do priv typeof unsized abstract virtual final override |