├── README.md ├── circom.png ├── ftdetect └── circom.vim └── syntax └── circom.vim /README.md: -------------------------------------------------------------------------------- 1 | # Circom syntax highlighting for vim 2 | 3 | This is a [circom](https://github.com/iden3/circom) syntax highlighting file 4 | for vim, based on the vim 8.1 javascript syntax highlighting file. 5 | 6 | ## Screenshot 7 | 8 | ![](circom.png) 9 | 10 | ## Installation in vim/nvim 11 | 12 | - Using [Plug](https://github.com/junegunn/vim-plug) (recommended), add this line to your `.vimrc`: 13 | ``` 14 | Plug 'iden3/vim-circom-syntax' 15 | ``` 16 | 17 | - Using [Vundle](https://github.com/gmarik/vundle), add this line to your `.vimrc`: 18 | ``` 19 | Plugin 'iden3/vim-circom-syntax' 20 | ``` 21 | 22 | - Using [NeoBundle](https://github.com/Shougo/neobundle.vim), add this line to your `.vimrc`: 23 | ``` 24 | NeoBundleLazy 'iden3/vim-circom-syntax', {'autoload':{'filetypes':['circom']}} 25 | ``` 26 | -------------------------------------------------------------------------------- /circom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iden3/vim-circom-syntax/da7bb12643086c6907c334c5d049dad58a230ae2/circom.png -------------------------------------------------------------------------------- /ftdetect/circom.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.circom set filetype=circom 2 | -------------------------------------------------------------------------------- /syntax/circom.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Based on vim8.1 javascript syntax file http://www.fleiner.com/vim/syntax/javascript.vim 3 | " Language: Circom 4 | " Original: Claudio Fleiner 5 | " Maintainer: Eduard Sanou 6 | " URL: http://www.fleiner.com/vim/syntax/javascript.vim 7 | 8 | if !exists("main_syntax") 9 | " quit when a syntax file was already loaded 10 | if exists("b:current_syntax") 11 | finish 12 | endif 13 | let main_syntax = 'circom' 14 | elseif exists("b:current_syntax") && b:current_syntax == "circom" 15 | finish 16 | endif 17 | 18 | let s:cpo_save = &cpo 19 | set cpo&vim 20 | 21 | 22 | syn keyword circomCommentTodo TODO FIXME XXX TBD contained 23 | syn match circomLineComment "\/\/.*" contains=@Spell,circomCommentTodo 24 | syn match circomCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" 25 | syn region circomComment start="/\*" end="\*/" contains=@Spell,circomCommentTodo 26 | syn match circomSpecial "\\\d\d\d\|\\." 27 | syn region circomStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=circomSpecial,@htmlPreproc 28 | syn region circomStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=circomSpecial,@htmlPreproc 29 | syn region circomStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=circomSpecial,circomEmbed,@htmlPreproc 30 | 31 | syn region circomEmbed start=+${+ end=+}+ contains=@circomEmbededExpr 32 | 33 | syn match circomSpecialCharacter "'\\.'" 34 | syn match circomNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>" 35 | syn region circomRegexpString start=+[,(=+]\s*/[^/*]+ms=e-1,me=e-1 skip=+\\\\\|\\/+ end=+/[gimuys]\{0,2\}\s*$+ end=+/[gimuys]\{0,2\}\s*[+;.,)\]}]+me=e-1 end=+/[gimuys]\{0,2\}\s\+\/+me=e-1 contains=@htmlPreproc,circomComment oneline 36 | 37 | syn keyword circomConditional if else 38 | syn keyword circomRepeat while for do 39 | syn match circomOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-=" 40 | " syn keyword circomType signal 41 | syn keyword circomStatement return with 42 | syn keyword circomBoolean true false 43 | syn keyword circomNull null undefined 44 | syn keyword circomIdentifier arguments this var let 45 | syn keyword circomLabel case default 46 | syn keyword circomMessage alert confirm prompt status 47 | syn keyword circomGlobal self window top parent 48 | syn keyword circomMember document event location 49 | syn keyword circomReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile input output component signal 50 | syn keyword circomInput input nextgroup=circomInputName skipwhite 51 | syn keyword circomOutput output nextgroup=circomInputName skipwhite 52 | syn match circomInputName '\i\+' contained 53 | 54 | syn cluster circomEmbededExpr contains=circomBoolean,circomNull,circomIdentifier,circomStringD,circomStringS,circomStringT 55 | 56 | syn keyword circomFunction function 57 | syn keyword circomTemplate template 58 | syn match circomFuncCall /\<\K\k*\ze\s*(/ 59 | 60 | syn match circomBraces "[{}\[\]]" 61 | syn match circomParens "[()]" 62 | 63 | syn sync fromstart 64 | syn sync maxlines=100 65 | 66 | if main_syntax == "circom" 67 | syn sync ccomment circomComment 68 | endif 69 | 70 | " Define the default highlighting. 71 | " Only when an item doesn't have highlighting yet 72 | hi def link circomComment Comment 73 | hi def link circomLineComment Comment 74 | hi def link circomCommentTodo Todo 75 | hi def link circomSpecial Special 76 | hi def link circomStringS String 77 | hi def link circomStringD String 78 | hi def link circomStringT String 79 | hi def link circomCharacter Character 80 | hi def link circomSpecialCharacter circomSpecial 81 | hi def link circomNumber Number 82 | hi def link circomConditional Conditional 83 | hi def link circomRepeat Repeat 84 | hi def link circomOpSymbols Operator 85 | hi def link circomType Type 86 | hi def link circomStatement Statement 87 | hi def link circomFuncCall Function 88 | hi def link circomFunction Identifier 89 | hi def link circomTemplate Identifier 90 | hi def link circomBraces Function 91 | hi def link circomError Error 92 | hi def link javaScrParenError circomError 93 | hi def link circomNull Keyword 94 | hi def link circomBoolean Boolean 95 | hi def link circomRegexpString String 96 | hi def link circomInput Keyword 97 | hi def link circomOutput Keyword 98 | hi def link circomInputName Special 99 | 100 | hi def link circomIdentifier Identifier 101 | hi def link circomLabel Label 102 | hi def link circomMessage Keyword 103 | hi def link circomGlobal Keyword 104 | hi def link circomMember Keyword 105 | hi def link circomReserved Keyword 106 | hi def link circomDebug Debug 107 | hi def link circomConstant Label 108 | hi def link circomEmbed Special 109 | 110 | let b:current_syntax = "circom" 111 | if main_syntax == 'circom' 112 | unlet main_syntax 113 | endif 114 | let &cpo = s:cpo_save 115 | unlet s:cpo_save 116 | 117 | " vim: ts=8 118 | --------------------------------------------------------------------------------