Apache Camel Language support in CodeMirror

Apache Camel Language support in CodeMirror

In a previous article, I mentioned the growing set of supported IDEs/editors for the Apache Camel language. I’m happy to announce that this set has grown again. It is now possible to use CodeMirror with Apache Camel. CodeMirror is a lightweight, embeddable editor for web browsers.

This repository shows how to use CodeMirror. Based on this repository example, you can watch the features in action in this video:

Everything you need to grow your career.

With your free Red Hat Developer program membership, unlock our library of cheat sheets and ebooks on next-generation application development.


Behind the scenes

With the Language Server Protocol (LSP), communication can be done through standard input/output or a WebSocket. CodeMirror supports only WebSocket connections. The Camel Language Server was supporting only standard input/output. Then, the Camel Language Server needs to support WebSocket connections. This addition was done using the new LSP4J API and the reference implementation of WebSocket in Java, Tyrus. The idea was to keep the implementation as simple and lightweight as possible.

Support for another IDE/editor?

Now that the Camel Language Server supports WebSocket connections, this opens the possibility to integrate Apache Camel into other clients that support only WebSocket, such as the MS Monaco Editor.

Adding support for CodeMirror was surely one of the hardest tasks because it required implementing WebSocket support on the Camel Language Server side, yet it took me only a few days. Consequently, I encourage users of other IDEs/editors to test how it goes with Camel LSP and then share steps for using them. You can find a list of potential clients here (I recommend searching for your beloved IDE, as not all are listed). Some pointers are provided for Vim or Emacs. If there is no specific Git repository for your IDE in the Camel tooling organization, you can make a request or provide feedback on the Camel Language Server Git issue repository.