diff options
author | Adam Hovorka <[email protected]> | 2019-10-12 22:17:27 -0600 |
---|---|---|
committer | Adam Hovorka <[email protected]> | 2019-10-12 22:17:27 -0600 |
commit | f0d8a2304e75c8c4c30afb18da5803e2ceddb122 (patch) | |
tree | eb67abe060d42219417a1e4b0d8b7ef4b4bc88a2 /base/vim | |
parent | 7ebb6f05eecb2369dbc43e499cd4277f13e5c5c5 (diff) |
Sync misc changes 20191012
Diffstat (limited to 'base/vim')
-rw-r--r-- | base/vim/ftdetect/toml.vim | 2 | ||||
-rw-r--r-- | base/vim/ftplugin/toml.vim | 21 | ||||
-rw-r--r-- | base/vim/syntax/toml.vim | 72 |
3 files changed, 95 insertions, 0 deletions
diff --git a/base/vim/ftdetect/toml.vim b/base/vim/ftdetect/toml.vim new file mode 100644 index 0000000..568dd82 --- /dev/null +++ b/base/vim/ftdetect/toml.vim @@ -0,0 +1,2 @@ +" Go dep and Rust use several TOML config files that are not named with .toml. +autocmd BufNewFile,BufRead *.toml,Gopkg.lock,Cargo.lock,*/.cargo/config,*/.cargo/credentials,Pipfile setf toml diff --git a/base/vim/ftplugin/toml.vim b/base/vim/ftplugin/toml.vim new file mode 100644 index 0000000..9075e88 --- /dev/null +++ b/base/vim/ftplugin/toml.vim @@ -0,0 +1,21 @@ +" File: ftplugin/toml.vim +" Author: Kevin Ballard <[email protected]> +" Description: FileType Plugin for Toml +" Last Change: Feb 12, 2019 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo&vim +let b:undo_ftplugin = 'setlocal commentstring< comments<' + +setlocal commentstring=#\ %s +setlocal comments=:# + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sw=4 ts=4: diff --git a/base/vim/syntax/toml.vim b/base/vim/syntax/toml.vim new file mode 100644 index 0000000..86f6b6f --- /dev/null +++ b/base/vim/syntax/toml.vim @@ -0,0 +1,72 @@ +" Language: TOML +" Maintainer: Caleb Spare <[email protected]> +" URL: https://github.com/cespare/vim-toml +" LICENSE: MIT + +if exists("b:current_syntax") + finish +endif + +syn match tomlEscape /\\[btnfr"/\\]/ display contained +syn match tomlEscape /\\u\x\{4}/ contained +syn match tomlEscape /\\U\x\{8}/ contained +hi def link tomlEscape SpecialChar + +syn match tomlLineEscape /\\$/ contained +hi def link tomlLineEscape SpecialChar + +" Basic strings +syn region tomlString oneline start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=tomlEscape +" Multi-line basic strings +syn region tomlString start=/"""/ end=/"""/ contains=tomlEscape,tomlLineEscape +" Literal strings +syn region tomlString oneline start=/'/ end=/'/ +" Multi-line literal strings +syn region tomlString start=/'''/ end=/'''/ +hi def link tomlString String + +syn match tomlInteger /[+-]\=\<[1-9]\(_\=\d\)*\>/ display +syn match tomlInteger /[+-]\=\<0\>/ display +syn match tomlInteger /[+-]\=\<0x[[:xdigit:]]\(_\=[[:xdigit:]]\)*\>/ display +syn match tomlInteger /[+-]\=\<0o[0-7]\(_\=[0-7]\)*\>/ display +syn match tomlInteger /[+-]\=\<0b[01]\(_\=[01]\)*\>/ display +syn match tomlInteger /[+-]\=\<\(inf\|nan\)\>/ display +hi def link tomlInteger Number + +syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\.\d\+\>/ display +syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\(\.\d\(_\=\d\)*\)\=[eE][+-]\=\d\(_\=\d\)*\>/ display +hi def link tomlFloat Float + +syn match tomlBoolean /\<\%(true\|false\)\>/ display +hi def link tomlBoolean Boolean + +" https://tools.ietf.org/html/rfc3339 +syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}/ display +syn match tomlDate /\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?/ display +syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}[T ]\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)\?/ display +hi def link tomlDate Constant + +syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ display +hi def link tomlKey Identifier + +syn region tomlKeyDq oneline start=/\v(^|[{,])\s*\zs"/ end=/"\ze\s*=/ contains=tomlEscape +hi def link tomlKeyDq Identifier + +syn region tomlKeySq oneline start=/\v(^|[{,])\s*\zs'/ end=/'\ze\s*=/ +hi def link tomlKeySq Identifier + +syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq +hi def link tomlTable Title + +syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq +hi def link tomlTableArray Title + +syn keyword tomlTodo TODO FIXME XXX BUG contained +hi def link tomlTodo Todo + +syn match tomlComment /#.*/ contains=@Spell,tomlTodo +hi def link tomlComment Comment + +syn sync minlines=500 + +let b:current_syntax = "toml" |