├── LICENSE ├── README.md ├── ftdetect └── vyper.vim ├── install.sh └── syntax └── vyper.vim /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 chgue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-viper 2 | Vim syntax highlighting for the experimental programming language [Vyper](https://github.com/ethereum/vyper). 3 | 4 | Work in progess. 5 | 6 | Currently uses *.vy. 7 | 8 | ### Quick Install 9 | ``` 10 | curl https://raw.githubusercontent.com/jacqueswww/vim-vyper/master/install.sh | sh 11 | ``` 12 | ### Installation 13 | 14 | Drop the appropriate files into: 15 | 16 | ``` 17 | ~/.vim/syntax/ 18 | ~/.vim/ftdetect/ 19 | ``` 20 | 21 | Note: Folders might have to be created. 22 | 23 | -------------------------------------------------------------------------------- /ftdetect/vyper.vim: -------------------------------------------------------------------------------- 1 | 2 | au BufRead,BufNewFile *.vy set filetype=vyper 3 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | 3 | mkdir -p ~/.vim/syntax/ 4 | mkdir -p ~/.vim/ftdetect/ 5 | 6 | curl -L "https://github.com/jacqueswww/vim-vyper/raw/master/syntax/vyper.vim" -o ~/.vim/syntax/vyper.vim 7 | curl -L "https://github.com/jacqueswww/vim-vyper/raw/master/ftdetect/vyper.vim" -o ~/.vim/ftdetect/vyper.vim 8 | 9 | -------------------------------------------------------------------------------- /syntax/vyper.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Vyper (https://github.com/ethereum/vyper) 3 | " Author: chgue (https://github.com/chgue) 4 | " URL: https://github.com/chgue/vim-viper 5 | " Last Change: 2019-06-06 6 | " Filenames: *.vy 7 | 8 | if exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | "Keywords 13 | syn keyword vyperStatement return 14 | syn keyword vyperStatement assert @version 15 | syn keyword vyperStatement struct 16 | syn keyword vyperStatement contract def nextgroup=vyperFunction skipwhite 17 | syn keyword vyperRepeat for while 18 | syn keyword vyperConditional if else 19 | syn keyword vyperOperator and in not or 20 | syn keyword vyperBoolean True False 21 | syn keyword vyperStatement return public private nonreentrant 22 | syn keyword vyperTypes address bool decimal num bytes32 int128 uint256 bytes string 23 | syn keyword vyperTypes wei_value timestamp timedelta 24 | syn keyword vyperBuiltin as_unitless_number as_wei_value bitwise_and bitwise_not bitwise_or bitwise_xor blockhash ceil concat 25 | syn keyword vyperBuiltin convert create_with_code_of ecadd ecmul ecrecover extract32 floor keccak256 len max method_id min raw_call 26 | syn keyword vyperBuiltin RLPList sha3 shift slice uint256_addmod uint256_mulmod 27 | syn keyword vyperBuiltin map event 28 | syn keyword vyperTodo TODO FIXME NOTE contained 29 | 30 | "Functions 31 | syn match vyperFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained 32 | 33 | "Operators 34 | syn match vyperOperator "\(=\|+\|-\|*\|\/\|%\|!\|<\|>\)" 35 | 36 | "Decorators 37 | syn match vyperDecorator "@" display nextgroup=vyperDecoratorName skipwhite 38 | syn match vyperDecoratorName "\(payable\|constant\|internal\|public\)$" display contained 39 | 40 | "Comments 41 | syn match vyperComment "#.*$" contains=vyperTodo 42 | 43 | "Literals 44 | syn match vyperNumber "\<\d\>" display 45 | syn match vyperNumber "\<[1-9]\d\+\>" display 46 | syn match vyperNumberError "\<0\d\+\>" display 47 | syn match vyperAddress "\<0x\x\{40}\>" display 48 | syn match vyperAddressError "\<0x\x\{0,39}\>" display 49 | syn match vyperAddressError "\<0x\x\{41,}\>" display 50 | syn match vyperAddressError "\<0x\x*\X\+.\+\>" display 51 | syn match vyperDecimal "\<\d*\.\d\+\>" display 52 | "String (String inside a string doesn't work properly!) 53 | syn match vyperString +".\{-}"+ display 54 | syn match vyperString +'.\{-}'+ display 55 | "Docstrings 56 | syn region vyperString start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend 57 | 58 | syn match vyperStringError +".\{-}'+ display 59 | syn match vyperStringError +'.\{-}"+ display 60 | 61 | "We need to sync at each def so that docstrings don't spill into other methods 62 | syn sync match vyperSync grouphere NONE "^\%(def\)\s\+\h\w*\s*[(:]" 63 | 64 | "Highlighting 65 | hi link vyperStatement Statement 66 | hi link vyperConditional Conditional 67 | hi link vyperRepeat Repeat 68 | hi link vyperOperator Operator 69 | hi link vyperBoolean Boolean 70 | hi link vyperDecorator Define 71 | hi link vyperDecoratorName Function 72 | hi link vyperComment Comment 73 | hi link vyperTypes Type 74 | hi link vyperNumber Number 75 | hi link vyperAddress Number 76 | hi link vyperAddressError Error 77 | hi link vyperDecimal Float 78 | hi link vyperFunction Function 79 | hi link vyperBuiltin Function 80 | hi link vyperStringError Error 81 | hi link vyperString String 82 | hi link vyperTodo todo 83 | --------------------------------------------------------------------------------