├── LICENSE ├── README.rst ├── docs ├── vim_conf_syntax.png └── vim_junos_syntax.png ├── ftdetect └── junos.vim └── syntax └── junos.vim /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Clockwork Active Media Systems 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | vim-junos-syntax 2 | ================ 3 | 4 | Vim syntax for Junos configuration files 5 | 6 | +--------------------------+--------------------------+ 7 | | conf syntax example | |conf_syntax_png| | 8 | +--------------------------+--------------------------+ 9 | | junos syntax example | |junos_syntax_png| | 10 | | | | 11 | | | color scheme is molokai_ | 12 | +--------------------------+--------------------------+ 13 | 14 | .. |conf_syntax_png| image:: docs/vim_conf_syntax.png 15 | :alt: conf syntax example 16 | .. |junos_syntax_png| image:: docs/vim_junos_syntax.png 17 | :alt: junos syntax example 18 | .. _molokai: https://github.com/tomasr/molokai 19 | 20 | 21 | Install 22 | ======= 23 | 24 | Copy or soft link the respective ``junos.vim`` files into your 25 | ``~/.vim/syntax`` and ``~/.vim/ftdetect`` directories. 26 | 27 | 28 | Related 29 | ======= 30 | 31 | Scott Ware maintains vim-slax_: syntax coloring of slax, xslt-style language, 32 | which is used for automation in Juniper Junos devices. 33 | 34 | .. _vim-slax: https://github.com/scottdware/vim-slax 35 | 36 | 37 | License 38 | ======= 39 | 40 | - LICENSE_ (`MIT License`_) 41 | 42 | .. _LICENSE: LICENSE 43 | .. _`MIT License`: http://www.opensource.org/licenses/MIT 44 | -------------------------------------------------------------------------------- /docs/vim_conf_syntax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClockworkNet/vim-junos-syntax/6f394dc1d386c8967efdd2b1ce550d4a5e87ff78/docs/vim_conf_syntax.png -------------------------------------------------------------------------------- /docs/vim_junos_syntax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClockworkNet/vim-junos-syntax/6f394dc1d386c8967efdd2b1ce550d4a5e87ff78/docs/vim_junos_syntax.png -------------------------------------------------------------------------------- /ftdetect/junos.vim: -------------------------------------------------------------------------------- 1 | " Junos configuration 2 | autocmd BufNewFile,BufReadPost *.junos set filetype=junos 3 | -------------------------------------------------------------------------------- /syntax/junos.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Junos Configuration 3 | " Maintainer: Tim Zehta 4 | " Last Change: 2013-01-26 5 | " Version: 3 6 | " URL: https://github.com/ClockworkNet/vim-junos-syntax 7 | " Credits: ... 8 | 9 | 10 | " Quit when a syntax file was already loaded 11 | if exists("b:current_syntax") 12 | finish 13 | endif 14 | 15 | 16 | setlocal iskeyword+=- 17 | 18 | 19 | " Comments 20 | syn region junosComment start=#\V/*# end=#\V*/# oneline contains=junosURL 21 | syn match junosComment /^\s*##.*$/ contains=junosURL 22 | 23 | 24 | " Constants 25 | " console type 26 | syn match junosConstant /\v(console type\s)@<=[a-z-]+(;)@=/ 27 | " class 28 | syn match junosConstant /\v(class\s)@<=[a-z-]+(;)@=/ 29 | " default applications 30 | syn match junosConstant /\vjunos-[a-z-]+/ 31 | " family 32 | syn match junosConstant /\v(family\s)@<=[a-z-]+6?(\s\{)@=/ 33 | " file 34 | syn match junosConstant /\v(file\s)@<=[a-z-]+(\s\{)@=/ 35 | " log levels (also matches policy constant 'any') 36 | syn match junosConstant /\valert|any|critical|emergency|error|info|none|notice|warning(;)@=/ 37 | " protocol 38 | syn match junosConstant /\v(protocol\s)@<=[a-z-]+(;)@=/ 39 | " static-nat 40 | syn match junosConstant /\v(static-nat\s)@<=[a-z-]+(;)@=/ 41 | " syn-flood-protection-mode 42 | syn match junosConstant /\v(syn-flood-protection-mode\s)@<=[a-z-]+(;)@=/ 43 | 44 | 45 | " Debug 46 | syn match junosHeader /\v(version\s)@<=[0-9R.]+(;)@=/ 47 | 48 | 49 | " Errors 50 | syn match junosError /## SECRET-DATA.*/ 51 | 52 | 53 | " Functions 54 | syn match junosNumber /\v( \d+[ ;]| \d+\a[ ;])/ contained contains=junosSymbol 55 | " bare functions 56 | syn match junosFunction /\v^\s*[a-z-]{3,}(;)@=/ 57 | " function with a single value 58 | syn match junosFunction /\v^\s*[a-z-]{2,} (.+;)@=/ contains=junosFunction 59 | " multi word functions containing IPs or numbers 60 | syn match junosFunction /\v^\s*([0-9a-z./-]+ ){3,}([0-9a-z./-]+)(;)@=/ contains=junosIP,junosNumber 61 | " static-nat subfunction 62 | syn match junosFunction /\v(static-nat\s)@<=[a-z-]+(\s[0-9./:]+;)@=/ 63 | " edge cases 64 | syn match junosFunction /console type/ 65 | syn match junosFunction /from zone/ 66 | syn match junosFunction /then accept/ 67 | syn match junosFunction /to zone/ 68 | syn match junosFunction /description/ 69 | 70 | 71 | " IPs 72 | syn match JunosIpSep #/\|\.# contained 73 | syn match junosIP /\v(\d{1,3}\.){3}\d{1,3}(\/\d{1,2})?/ contains=JunosIpSep 74 | 75 | " IPv6 76 | syn match junosIP /\v(\x{1,4}:){1,7}:*(\x{1,4})?(\/\d+)?/ contains=JunosIpSep 77 | 78 | 79 | " Interfaces 80 | syn match junosInterface /\v(ge|xe)\-(\d+\/){2,3}\d+/ 81 | 82 | " Statements 83 | syn match junosStatement /\v^\s*[a-z-]+( \{$)@=/ 84 | syn match junosStatement /\v^\s*[a-z-]+ (.+\{$)@=/ 85 | syn keyword junosStatement to-zone 86 | 87 | 88 | " Strings 89 | syn region junosString start=#"# end=#"# skip=#\\\\\|\\"# oneline contains=junosVariable 90 | syn region junosString start=#'# end=#'# skip=#\\\\\|\\'# oneline contains=junosVariable 91 | 92 | 93 | " Symbols 94 | syn match junosSymbol /[{}]/ 95 | syn match junosSymbol /\v\[|\]|;$/ 96 | 97 | 98 | " URLs 99 | syn match junosURL #\vhttps?://[[:graph:]]+# contains=junosSymbol 100 | 101 | 102 | " Variables 103 | syn match junosVariable /\V<*>/ 104 | syn match junosVariable /[$]{[^}]\+}/ 105 | syn match junosVariable /\V*/ 106 | 107 | 108 | " Highlight 109 | hi link junosComment Comment 110 | hi link junosConstant Constant 111 | hi link junosError Error 112 | hi link junosFunction Function 113 | hi link junosHeader Debug 114 | hi link junosIP Label 115 | hi link junosIpSep Delimiter 116 | hi link junosNumber Normal 117 | hi link junosStatement Statement 118 | hi link junosString String 119 | hi link junosSymbol Delimiter 120 | hi link junosURL Underlined 121 | hi link junosVariable Identifier 122 | hi link junosInterface Label 123 | 124 | 125 | let b:current_syntax = "junos" 126 | --------------------------------------------------------------------------------