├── LICENSE ├── README.md ├── ftdetect └── p4.vim ├── install.sh └── syntax └── p4.vim /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Yi Tseng 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | P4 syntax highlighting for vim 2 | ==== 3 | 4 | ## About P4: 5 | P4 is a declarative language for expressing how packets are processed by the pipeline of a network forwarding element such as a switch, NIC, router or network function appliance. (P4 spec) 6 | 7 | For more information, please see [p4.org](http://p4.org) 8 | 9 | ## How to install: 10 | 11 | ```bash 12 | $ curl -o- -L https://raw.githubusercontent.com/TakeshiTseng/vim-language-p4/master/install.sh | bash 13 | ``` 14 | 15 | ## License 16 | 17 | MIT 18 | -------------------------------------------------------------------------------- /ftdetect/p4.vim: -------------------------------------------------------------------------------- 1 | autocmd BufRead,BufNewFile *.p4 set filetype=p4 2 | autocmd BufRead,BufNewFile *.P4 set filetype=p4 3 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ~/.vim/syntax 4 | mkdir -p ~/.vim/ftdetect 5 | 6 | curl -o- -L https://raw.githubusercontent.com/TakeshiTseng/vim-language-p4/master/ftdetect/p4.vim > ~/.vim/ftdetect/p4.vim 7 | curl -o- -L https://raw.githubusercontent.com/TakeshiTseng/vim-language-p4/master/syntax/p4.vim > ~/.vim/syntax/p4.vim 8 | 9 | -------------------------------------------------------------------------------- /syntax/p4.vim: -------------------------------------------------------------------------------- 1 | syntax match Number /^\d\+/ 2 | syntax match Number /^0\(b\|B\)[01]\+/ 3 | syntax match Number /^0\(x\|X\)\x\+/ 4 | syntax match Number /^\(+\|-\)\=\d\+'\d\+/ 5 | syntax match Function /\(^\|\s\)\(apply\|valid\|select\|current\|extract\|add_header\|copy_header\|remove_header\|modify_field\|add_to_field\|add\|set_field_to_hash_index\|truncate\|drop\|no_op\|push\|pop\|count\|meter\|generate_digest\|resubmit\|recirculate\|clone_ingress_pkt_to_ingress\|clone_egress_pkt_to_ingress\|clone_ingress_pkt_to_egress\|clone_egress_pkt_to_egress\|register_write\|register_read\)/ 6 | syntax match PreProc /^#include/ 7 | syntax match Type /\(^\|\s\)\(length\|fields\|max_length\)\s/ 8 | syntax match Type /\(^\|\s\)\(width\|layout\|attributes\|type\|static\|result\|direct\|instance_count\|min_width\|saturating\)\s/ 9 | syntax match Special /\(bytes\|packets\)\s/ 10 | syntax match Special /\(^\|\s\)\(control\|action\|table\|counter\|header_type\|header\|register\|parser\|metadata\|primitive_action\|meter\|parse_error\|default\)\s/ 11 | syntax match Title /\(^\|\s\)\(reads\|actions\|min_size\|max_size\|size\|support_timeout\|action_profile\)/ 12 | syntax match Type /\(exact\|ternary\|lpm\|range\|valid\|mask\)\s/ 13 | syntax match Keyword /\(^\|\s\)\(if\|else if\|else\)/ 14 | syntax match Comment /\/\/.*\n/ 15 | syntax match String /"[^"]*"/ 16 | --------------------------------------------------------------------------------