dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.4k stars 1.42k forks source link

Support Rego #2531

Open pbnj opened 5 years ago

pbnj commented 5 years ago

Name: Rego URL: https://www.openpolicyagent.org/docs/latest/how-do-i-write-policies/

Rego is a declarative language, inspired by Datalog, used in Open-Policy-Agent Kubernetes project.

The vim syntax is provided via vim-rego. The opa CLI itself provides a fmt command for formatting Rego source files

redbmk commented 1 year ago

Looks like there's support for rego now with opa check and opa fmt. Although I'm seeing an issue where if if I run opa check . there are no issues but checking an individual file shows issues (e.g. a variable defined in another file).

Seems like ALE would need to check a file in the context of surrounding files somehow?

e.g. instead of opa check % --format json it could open check . --format json and then only report errors that match that filename. or better than . might be to somehow find the root

redbmk commented 1 year ago

I made a quick fix to use ., which is working for me. afaict ALE sets the cwd to that of the buffer before running the command.

I'm not super familiar with rego, so this may still not be ideal if rego supports referencing things defined in parent directories.