Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsandall/vim-rego
Vim plugin for Rego: www.openpolicyagent.org
https://github.com/tsandall/vim-rego
Last synced: 17 days ago
JSON representation
Vim plugin for Rego: www.openpolicyagent.org
- Host: GitHub
- URL: https://github.com/tsandall/vim-rego
- Owner: tsandall
- Created: 2016-03-28T23:51:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T02:59:06.000Z (11 months ago)
- Last Synced: 2024-10-14T15:58:36.406Z (about 2 months ago)
- Language: Vim script
- Homepage:
- Size: 9.77 KB
- Stars: 45
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-opa - Vim - Vim plugin for the Rego language, with support for syntax highlighting (IDE and Editor Integrations / Datasource Integrations Blogs and Articles)
README
# vim-rego
A Vim plugin for the Rego language that includes support for syntax highlighting.
## Installation
The rego-vim plugin can be installed the old fashion way, by copying the files here into your `~/.vim` directory, or
using any of the plugin managers (Vundle, etc).### Vundle Installation
In your `.vimrc` file add the line `Plugin 'tsandall/vim-rego'`, like so:
```viml
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" ... other plugins here ...Plugin 'tsandall/vim-rego'
" ... more plugins ...
" All of your Plugins must be added before the following line
call vundle#end() " required
```## Formatting
### vim-autoformat
You can configure Vim to automatically format your Rego policies using `opa
fmt`. Install the [vim-autoformat](https://github.com/Chiel92/vim-autoformat)
plugin then put this in your `.vimrc`:```viml
let g:formatdef_rego = '"opa fmt"'
let g:formatters_rego = ['rego']
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
au BufWritePre *.rego Autoformat
```If you want to see parse errors that occurred during formatting put this in your
`.vimrc` as well:```viml
let g:autoformat_verbosemode = 1
```### Neoformat
If you are using [`neoformat`](https://github.com/sbdchd/neoformat) plugin, then put this in your `.vimrc`:
```viml
let g:neoformat_rego_opa = {
\ 'exe': 'opa',
\ 'args': ['fmt'],
\ 'stdin': 1,
\ }let g:neoformat_enabled_rego = ['opa']
```Now, `:Neoformat` command will use `opa` to format rego files.
To make Neoformat auto-format on save, put this in your `.vimrc`:
```viml
augroup fmt
autocmd!
autocmd BufWritePre * undojoin | Neoformat
augroup END
```