mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 07:09:11 +08:00
feat(layer): add lang#yang
layer
This commit is contained in:
parent
a7db14e865
commit
d4bf364cbe
26
autoload/SpaceVim/layers/lang/yang.vim
Normal file
26
autoload/SpaceVim/layers/lang/yang.vim
Normal file
@ -0,0 +1,26 @@
|
||||
"=============================================================================
|
||||
" yang.vim --- yang support for vim
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
""
|
||||
" @section lang#yang, layers-lang-yang
|
||||
" @parentsection layers
|
||||
" This layer adds syntax highlighting for the YANG data file.
|
||||
" It is disabled by default, to enable this layer, add following snippet to your
|
||||
" SpaceVim configuration file.
|
||||
" >
|
||||
" [[layers]]
|
||||
" name = 'lang#yang'
|
||||
" <
|
||||
"
|
||||
|
||||
function! SpaceVim#layers#lang#yang#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/yang.vim', {'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
20
bundle/yang.vim/README.md
Normal file
20
bundle/yang.vim/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
yang.vim
|
||||
========
|
||||
|
||||
YANG syntax highlighting and other niceties for VIM. Use with [Vundle](https://github.com/VundleVim/Vundle.vim) via:
|
||||
|
||||
```vim
|
||||
Plugin 'nathanalderson/yang.vim'
|
||||
```
|
||||
|
||||
Don't forget to run `:PluginInstall`.
|
||||
|
||||
Credit
|
||||
======
|
||||
|
||||
I didn't actually write any of the syntax highlighting. It was originally downloaded from
|
||||
http://www.yang-central.org/twiki/pub/Main/YangTools/yang.vim.
|
||||
|
||||
Thanks to all the contributors who have continued to expand and improve this plugin.
|
||||
|
||||
If you notice a new version or have a change, let me know.
|
1
bundle/yang.vim/ftdetect/yang.vim
Normal file
1
bundle/yang.vim/ftdetect/yang.vim
Normal file
@ -0,0 +1 @@
|
||||
au BufRead,BufNewFile *.yang set filetype=yang
|
18
bundle/yang.vim/ftplugin/yang.vim
Normal file
18
bundle/yang.vim/ftplugin/yang.vim
Normal file
@ -0,0 +1,18 @@
|
||||
" Only do this when not done yet for this buffer
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal commentstring=//%s
|
||||
setlocal include=^\\s*import
|
||||
setlocal suffixesadd=.yang
|
||||
|
||||
" j is a fairly recent addition - silence warnings if it can't be set.
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
silent! setlocal formatoptions+=j
|
||||
|
||||
let b:undo_ftplugin = 'setlocal commentstring< formatoptions< include< suffixesadd<'
|
||||
|
||||
setlocal iskeyword+=-
|
||||
let b:undo_ftplugin .= ' iskeyword<'
|
10
bundle/yang.vim/indent/yang.vim
Normal file
10
bundle/yang.vim/indent/yang.vim
Normal file
@ -0,0 +1,10 @@
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
" Not perfect, but mostly good enough...
|
||||
setlocal autoindent nocindent cinwords= smartindent
|
||||
|
||||
let b:undo_indent = 'setlocal autoindent< cindent< cinwords< smartindent<'
|
112
bundle/yang.vim/syntax/yang.vim
Normal file
112
bundle/yang.vim/syntax/yang.vim
Normal file
@ -0,0 +1,112 @@
|
||||
" Vim syntax file
|
||||
" Language: YANG
|
||||
" Remark: RFC 7950 http://tools.ietf.org/html/rfc7950
|
||||
" Author: Matt Parker <mparker@computer.org>
|
||||
"------------------------------------------------------------------
|
||||
|
||||
if v:version < 600
|
||||
syntax clear
|
||||
elseif exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
" Enable block folding
|
||||
syntax region yangBlock start="{" end="}" fold transparent
|
||||
|
||||
" YANG identifiers are made up of alphanumeric characters, underscores,
|
||||
" hyphens, and dots.
|
||||
if has('patch-7.4.1142')
|
||||
syntax iskeyword a-z,A-Z,48-57,_,-,.
|
||||
endif
|
||||
|
||||
" An identifier looks like [prefix:]identifier
|
||||
syntax match yangIdentifier /\<\(\h\k*:\)\?\h\k*\>/
|
||||
|
||||
" keywords are case-sensitive
|
||||
syntax case match
|
||||
|
||||
" built-in types (section 4.2.4)
|
||||
syntax keyword yangType binary bits boolean decimal64 empty enumeration identityref
|
||||
syntax keyword yangType instance-identifier int8 int16 int32 int64 leafref string
|
||||
syntax keyword yangType uint8 uint16 uint32 uint64 union
|
||||
|
||||
" statement keywords
|
||||
syntax keyword yangStatement augment config deviate deviation fraction-digits input
|
||||
syntax keyword yangStatement length mandatory max-elements min-elements modifier
|
||||
syntax keyword yangStatement must namespace ordered-by output pattern position range
|
||||
syntax keyword yangStatement refine require-instance revision revision-date status
|
||||
syntax keyword yangStatement unique units value when yang-version yin-element
|
||||
|
||||
syntax keyword yangStatement action anydata anyxml argument base nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement belongs-to bit case choice contact nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement container default description enum nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement error-app-tag error-message extension nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement feature grouping identity import include nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement key leaf leaf-list list module nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement notification organization path prefix nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement presence reference rpc submodule typedef nextgroup=yangIdentifier skipwhite
|
||||
syntax keyword yangStatement uses nextgroup=yangIdentifier skipwhite
|
||||
|
||||
syntax keyword yangStatement type nextgroup=yangType,yangIdentifier skipwhite
|
||||
|
||||
" other keywords
|
||||
syntax keyword yangKeyword add current delete deprecated invert-match max min not-supported
|
||||
syntax keyword yangKeyword obsolete replace system unbounded user
|
||||
|
||||
" boolean constants (separated from the 'other keywords' for vim syntax purposes)
|
||||
syntax keyword yangBoolean true false
|
||||
|
||||
" operators (separated from the 'other keywords' for vim syntax purposes)
|
||||
syntax keyword yangOperator and or not
|
||||
|
||||
" if-feature (separated from 'statement keywords' for vim syntax purposes)
|
||||
syntax keyword yangConditional if-feature
|
||||
|
||||
" comments
|
||||
syntax region yangComment start="/\*" end="\*/" contains=@Spell
|
||||
syntax region yangComment start="//" end="$" contains=@Spell
|
||||
|
||||
" strings
|
||||
syntax region yangString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
|
||||
syntax region yangString start=+'+ end=+'+ contains=@Spell
|
||||
|
||||
" dates
|
||||
syntax match yangDateArg /"\=\<\d\{4}-\d\{2}-\d\{2}\>"\=/
|
||||
|
||||
" length-arg TODO: this needs to also include the pipe and individual numbers (i.e. fixed length)
|
||||
syntax match yangLengthArg /"\(\d\+\|min\)\s*\.\.\s*\(\d\+\|max\)"/
|
||||
|
||||
" numbers
|
||||
syntax match yangNumber /\<[+-]\=\d\+\>/
|
||||
syntax match yangNumber "\<0x\x\+\>"
|
||||
|
||||
|
||||
"-------------------------------------
|
||||
" and now for the highlighting
|
||||
|
||||
" things with one-to-one mapping
|
||||
highlight def link yangBoolean Boolean
|
||||
highlight def link yangComment Comment
|
||||
highlight def link yangConditional Conditional
|
||||
highlight def link yangIdentifier Identifier
|
||||
highlight def link yangKeyword Keyword
|
||||
highlight def link yangNumber Number
|
||||
highlight def link yangOperator Operator
|
||||
highlight def link yangStatement Statement
|
||||
highlight def link yangString String
|
||||
highlight def link yangType Type
|
||||
|
||||
" arbitrary mappings
|
||||
highlight def link yangDateArg Special
|
||||
highlight def link yangLengthArg Special
|
||||
|
||||
" synchronize
|
||||
syntax sync match yangSync grouphere NONE '}$'
|
||||
|
||||
let b:current_syntax = 'yang'
|
||||
|
||||
let &cpoptions = s:cpo_save
|
||||
unlet s:cpo_save
|
@ -215,21 +215,22 @@ CONTENTS *SpaceVim-contents*
|
||||
120. lang#wolfram.........................|SpaceVim-layers-lang-wolfram|
|
||||
121. lang#xml.................................|SpaceVim-layers-lang-xml|
|
||||
122. lang#xquery...........................|SpaceVim-layers-lang-xquery|
|
||||
123. lang#zig.................................|SpaceVim-layers-lang-zig|
|
||||
124. language server protocol......................|SpaceVim-layers-lsp|
|
||||
125. leaderf...................................|SpaceVim-layers-leaderf|
|
||||
126. mail.........................................|SpaceVim-layers-mail|
|
||||
127. operator.................................|SpaceVim-layers-operator|
|
||||
128. shell.......................................|SpaceVim-layers-shell|
|
||||
129. ssh...........................................|SpaceVim-layers-ssh|
|
||||
130. test.........................................|SpaceVim-layers-test|
|
||||
131. tmux.........................................|SpaceVim-layers-tmux|
|
||||
132. tools#dash.............................|SpaceVim-layers-tools-dash|
|
||||
133. tools#mpv...............................|SpaceVim-layers-tools-mpv|
|
||||
134. tools#zeal.............................|SpaceVim-layers-tools-zeal|
|
||||
135. treesitter.............................|SpaceVim-layers-treesitter|
|
||||
136. ui.............................................|SpaceVim-layers-ui|
|
||||
137. unite.......................................|SpaceVim-layers-unite|
|
||||
123. lang#yang...............................|SpaceVim-layers-lang-yang|
|
||||
124. lang#zig.................................|SpaceVim-layers-lang-zig|
|
||||
125. language server protocol......................|SpaceVim-layers-lsp|
|
||||
126. leaderf...................................|SpaceVim-layers-leaderf|
|
||||
127. mail.........................................|SpaceVim-layers-mail|
|
||||
128. operator.................................|SpaceVim-layers-operator|
|
||||
129. shell.......................................|SpaceVim-layers-shell|
|
||||
130. ssh...........................................|SpaceVim-layers-ssh|
|
||||
131. test.........................................|SpaceVim-layers-test|
|
||||
132. tmux.........................................|SpaceVim-layers-tmux|
|
||||
133. tools#dash.............................|SpaceVim-layers-tools-dash|
|
||||
134. tools#mpv...............................|SpaceVim-layers-tools-mpv|
|
||||
135. tools#zeal.............................|SpaceVim-layers-tools-zeal|
|
||||
136. treesitter.............................|SpaceVim-layers-treesitter|
|
||||
137. ui.............................................|SpaceVim-layers-ui|
|
||||
138. unite.......................................|SpaceVim-layers-unite|
|
||||
7. Usage....................................................|SpaceVim-usage|
|
||||
1. alternate file........................|SpaceVim-usage-alternate-file|
|
||||
2. buffers-and-files..................|SpaceVim-usage-buffers-and-files|
|
||||
@ -5250,6 +5251,18 @@ disabled by default, to enable this layer, add following snippet to your
|
||||
name = 'lang#xquery'
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
LANG#YANG *SpaceVim-layers-lang-yang*
|
||||
|
||||
This layer adds syntax highlighting for the YANG data file. It is disabled by
|
||||
default, to enable this layer, add following snippet to your SpaceVim
|
||||
configuration file.
|
||||
>
|
||||
[[layers]]
|
||||
name = 'lang#yang'
|
||||
<
|
||||
|
||||
|
||||
==============================================================================
|
||||
LANG#ZIG *SpaceVim-layers-lang-zig*
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user