The Intellij plugin provides a way to embed the Portal UI directly into your IDE.
You can download the IntelliJ plugin from the Jet Brains Marketplace. "Portal" button will appear on the right-hand bar. The window area will be blank until portal is launched from the REPL.
Add a dependency on Portal to your deps.edn
or project.clj
, start a Clojure
REPL and inside that evaluate:
(do
(def user/portal ((requiring-resolve 'portal.api/open) {:launcher :intellij}))
(add-tap (requiring-resolve 'portal.api/submit)))
You can now tap>
data and they will appear in the Portal tool window.
The main benefits of using this plugin are:
- Automatic font / theme discovery.
- No window management.
- Editor specific commands. See: goto-definition in the command palette.
If after running portal.api/open
at the REPL, the Portal UI does not open, it
is most likely due to having a multi-module project. When the plugin is started,
it writes a .portal/intellij.edn
file, which the REPL process will try to
find. If the REPL process is started outside of the root project, it will not be
able to use the Intellij plugin.
A quick hack to get around this problem is to symlink the .portal
directory to
the directory where the REPL process is started.
Similarly, if you get the following error message, simply remove the .portal
directory, and try calling (p/open {:launcher :intellij}
again.
(This might be caused by the portal intellij extension not being initialized after upgrading, but you have an existing .portal/intellij.edn -- the clj runtime is trying to connect to a server that is no longer running.)
Execution error (ConnectException) at sun.nio.ch.Net/pollConnect (Net.java:-2).
Connection refused