Most of the engineering staff at Oso uses Language Server Protocol (LSP) implementations in their editors––Rust, TypeScript, and others all have fantastic LSP implementations that make the hard work of building software a bit easier. If you're not familiar, the Language Server Protocol is a specification that lets people write rich developer tooling in an editor-agnostic way.
We knew that building our own LSP implementation for Polar policy files would go a long way to making Oso the absolute easiest way to write your authorization logic––and today we're pleased to announce it's shipped and widely available.
While the Polar LSP includes the general features you expect like syntax validation, we also have two additional, powerful, Polar-specific features:
Shorthand expansion
When writing Polar policies, users can write ergonomic “shorthand rules,” which greatly simplifies common types of rules tying together your roles, permissions, and inter-resource relations.
Behind the scenes, we convert these shorthand rules into “longhand.” This process has been a bit mysterious (though it is explained in detail in our docs).
To make this process more clear, when using the Polar LSP, we’ll show you the longhand version of the rule when hovering over the shorthand.
![screenshot of a hovering over a shorthand rule in Polar and a window displaying the longhand version of the rule](https://cdn.prod.website-files.com/5f1483105c9a72fd0a3b662a/6685a6625bdcaf03bfbcc021_AD_4nXfqNHFZmUhDuW1gxOqSBwY74Y2WE9p6UcnAH-S9ZLVxn4WkpHPmZKOEelkFECLv2nwbWT-IbwUO_79UVBf95akTgr89fJCme4dCwA5fHIqj1eCBNkt8sJ2Ml1Ua6o5QSjWJCpuC45AqjtounSKdQ69PEk5g.png)
Unit test integration
Polar policies include built-in unit tests, which let you set up a small set of facts and assert that rules produce certain outcomes based on those facts.
To help you run and manage those unit tests, the LSP now lets your unit tests directly from your editor. If any of your tests fail, the LSP will suggest facts that you can introduce to get the tests passing.
![screenshot of a failed Polar unit test being hovered over suggesting Quick Fixes to make the test pass](https://cdn.prod.website-files.com/5f1483105c9a72fd0a3b662a/6685a6a775b39c55f483e35f_AD_4nXdFcXLCtdifVs6LKnQKS2Grj7dIr00YJUJDh1S6MLzT4Z9bENg7raMmCwp-QATWPZbe1IoeaTy4nVGffxcI8bbLicJ8sqfwhrg3ze_QU4D4r6sVyuRjcdnJ1_Kmqo9Wx8kmVrn91eeKPfKaT-Fd1s5J6kY.png)
Using the LSP
One of the most ingenious features of the Language Server Protocol is that it’s editor-agnostic. How to get the LSP working for you depends on your environment:
VSCode
As of version 0.39.0, the Oso VSCode extension is powered by the Polar language server. You can install it through the Extensions panel of VSCode.
Vim, Emacs, etc.
If you use editors other than VSCode, you can run the LSP through the oso-cloud binary, using:
oso-cloud lsp
On the web
Oso Cloud’s policy editor in code mode leverages the Polar LSP by default. It’ll be available as soon as you log in.
What would help you most?
This is just the beginning. We hope to keep adding features (such as refactoring support) to the Polar language server. Is there a feature you're particularly interested in? Let us know!
If you haven’t checked out Oso Cloud yet, you can sign up for a free developer account here.