summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-04-25 22:12:56 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-04-25 22:12:56 +0200
commit24f0581a96e682ef108c5b417b26563f4df022f5 (patch)
treefac5fc5450eecec5558e66d94192372eabcd4c18
parent33c94846710579d685a6b3b55010051045ad108c (diff)
downloadvim-polyglot-24f0581a96e682ef108c5b417b26563f4df022f5.tar.gz
vim-polyglot-24f0581a96e682ef108c5b417b26563f4df022f5.zip
Add rego support, closes #471
-rw-r--r--README.md3
-rwxr-xr-xbuild1
-rw-r--r--ftdetect/polyglot.vim11
-rw-r--r--syntax/rego.vim61
4 files changed, 75 insertions, 1 deletions
diff --git a/README.md b/README.md
index dc9e895d..8497a4c8 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
-- It **installs and updates 120+ times faster** than the <!--Package Count-->147<!--/Package Count--> packages it consists of.
+- It **installs and updates 120+ times faster** than the <!--Package Count-->148<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -150,6 +150,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin)
- [razor](https://github.com/adamclerk/vim-razor) (syntax, indent, ftplugin)
- [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent)
+- [rego](https://github.com/tsandall/vim-rego) (syntax)
- [rspec](https://github.com/keith/rspec.vim) (syntax)
- [rst](https://github.com/marshallward/vim-restructuredtext) (syntax, indent, autoload, ftplugin)
- [ruby](https://github.com/vim-ruby/vim-ruby) (syntax, indent, compiler, autoload, ftplugin)
diff --git a/build b/build
index 6e1f447c..7201f1c7 100755
--- a/build
+++ b/build
@@ -268,6 +268,7 @@ PACKS="
raml:IN3D/vim-raml
razor:adamclerk/vim-razor
reason:reasonml-editor/vim-reason-plus
+ rego:tsandall/vim-rego
rspec:keith/rspec.vim
rst:marshallward/vim-restructuredtext
ruby:vim-ruby/vim-ruby
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 35b7485c..54d71378 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -1221,6 +1221,17 @@ au BufNewFile,BufRead .merlin set ft=merlin
augroup end
endif
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rego') == -1
+ augroup filetypedetect
+ " rego, from rego.vim in tsandall/vim-rego
+autocmd BufRead,BufNewFile *.rego set filetype=rego
+
+" Use # as a comment prefix
+setlocal comments=b:#,fb:-
+setlocal commentstring=#\ %s
+ augroup end
+endif
+
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1
augroup filetypedetect
" ruby, from ruby.vim in vim-ruby/vim-ruby
diff --git a/syntax/rego.vim b/syntax/rego.vim
new file mode 100644
index 00000000..5fa20d1a
--- /dev/null
+++ b/syntax/rego.vim
@@ -0,0 +1,61 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rego') == -1
+
+" Vim syntax file
+" Language: Rego (http://github.com/open-policy-agent/opa)
+" Maintainers: Torin Sandall <torinsandall@gmail.com>
+
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+syn case match
+
+" language keywords
+syn keyword regoKeyword package import as not with default else some
+
+" comments
+syn match regoComment "#.*$" contains=regoTodo,@Spell
+syn keyword regoTodo FIXME XXX TODO contained
+
+" data types
+syn keyword regoNull null
+syn keyword regoBoolean true false
+syn match regoNumber "\<\(0[0-7]*\|0[xx]\x\+\|\d\+\)[ll]\=\>"
+syn match regoNumber "\(\<\d\+\.\d*\|\.\d\+\)\([ee][-+]\=\d\+\)\=[ffdd]\="
+syn match regoNumber "\<\d\+[ee][-+]\=\d\+[ffdd]\=\>"
+syn match regoNumber "\<\d\+\([ee][-+]\=\d\+\)\=[ffdd]\>"
+syn region regoString start="\"" skip="\\\"" end="\"" contains=regoStringEscape
+syn match regoStringEscape "\\u[0-9a-fA-F]\{4}" contained
+syn match regoStringEscape "\\[nrfvb\\\"]" contained
+
+" rules
+syn match regoRuleName "^\(\w\+\)"
+syn region regoBody start="{" end="}" transparent
+
+" operators
+syn match regoEquality "="
+syn match regoInequality "[<>!]"
+syn match regoArith "[+-/*&|]"
+syn match regoBuiltin "\w\+(" nextgroup=regoBuiltinArgs contains=regoBuiltinArgs
+syn region regoBuiltinArgs start="(" end=")" contained contains=regoNull,regoBoolean,regoNumber,regoString
+
+" highlighting
+hi link regoKeyword Keyword
+hi link regoNull Function
+hi link regoBoolean Boolean
+hi link regoNumber Number
+hi link regoString String
+
+hi link regoRuleName Function
+
+hi link regoEquality Keyword
+hi link regoInequality Keyword
+hi link regoArith Keyword
+hi link regoBuiltin Type
+
+hi link regoComment Comment
+hi link regoTodo Todo
+
+endif