commit 7155f902e2a447163af57e9f7584417da30aba5b Author: Buddy Sandidge Date: Mon Jun 20 17:33:23 2016 -0700 Squashed 'vim/bundle/toml/' content from commit f6f79f3cc git-subtree-dir: vim/bundle/toml git-subtree-split: f6f79f3cc6740dfacca73a195857cbc45e778912 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d04c502 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013 Caleb Spare + +MIT License + +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: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3dffa41 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# vim-toml + +Vim syntax for [TOML](https://github.com/toml-lang/toml). + +## Installation + +### Pathogen + +Set up [Pathogen](https://github.com/tpope/vim-pathogen) then clone/submodule this repo into `~/.vim/bundle/toml`, or wherever you've pointed your Pathogen. + +### Vundle + +Set up [Vundle](https://github.com/gmarik/Vundle.vim) then add `Bundle 'cespare/vim-toml'` to your vimrc and run `:BundleInstall` from a fresh vim. + +## Contributing + +Contributions are very welcome! Just open a PR. diff --git a/ftdetect/toml.vim b/ftdetect/toml.vim new file mode 100644 index 0000000..b47cc60 --- /dev/null +++ b/ftdetect/toml.vim @@ -0,0 +1,4 @@ +autocmd BufNewFile,BufRead *.toml set filetype=toml + +" Rust uses Cargo.toml and Cargo.lock (both are toml files). +autocmd BufNewFile,BufRead Cargo.lock set filetype=toml diff --git a/ftplugin/toml.vim b/ftplugin/toml.vim new file mode 100644 index 0000000..6e205c2 --- /dev/null +++ b/ftplugin/toml.vim @@ -0,0 +1,37 @@ +" File: ftplugin/toml.vim +" Author: Kevin Ballard +" Description: FileType Plugin for Toml +" Last Change: Dec 09, 2014 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo&vim + +setlocal commentstring=#\ %s + +" Add NERDCommenter delimiters + +let s:delims = { 'left': '#' } +if exists('g:NERDDelimiterMap') + if !has_key(g:NERDDelimiterMap, 'toml') + let g:NERDDelimiterMap.toml = s:delims + endif +elseif exists('g:NERDCustomDelimiters') + if !has_key(g:NERDCustomDelimiters, 'toml') + let g:NERDCustomDelimiters.toml = s:delims + endif +else + let g:NERDCustomDelimiters = { 'toml': s:delims } +endif +unlet s:delims + +let b:undo_ftplugin = "" + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sw=4 ts=4: diff --git a/syntax/toml.vim b/syntax/toml.vim new file mode 100644 index 0000000..1025053 --- /dev/null +++ b/syntax/toml.vim @@ -0,0 +1,54 @@ +" Language: TOML +" Maintainer: Caleb Spare +" 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 /\<[+-]\=[0-9]\(_\=\d\)*\>/ display +hi def link tomlInteger Number + +syn match tomlFloat /\<[+-]\=[0-9]\(_\=\d\)*\.\d\+\>/ display +syn match tomlFloat /\<[+-]\=[0-9]\(_\=\d\)*\(\.[0-9]\(_\=\d\)*\)\=[eE][+-]\=[0-9]\(_\=\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\}T\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)/ display +hi def link tomlDate Constant + +syn match tomlTable /^\s*\[[^#\[\]]\+\]\s*\(#.*\)\?$/ contains=tomlComment +hi def link tomlTable Identifier + +syn match tomlTableArray /^\s*\[\[[^#\[\]]\+\]\]\s*\(#.*\)\?$/ contains=tomlComment +hi def link tomlTableArray Identifier + +syn keyword tomlTodo TODO FIXME XXX BUG contained +hi def link tomlTodo Todo + +syn match tomlComment /#.*/ contains=@Spell,tomlTodo +hi def link tomlComment Comment + +let b:current_syntax = "toml"