← Back
JetBrains TV November 17, 2026 34m

Building Language Plugins With the Native LSP API

Read full transcript 31 segments
  1. I am Vladimir Logachev, and today I'll talk about what it takes to bring your language to JetBrains IDEs and what price you have to pay to get things working for free. This talk is for you if you have a language or you're considering starting one. No matter how special your language is, the users will want to keep using their own existing IDEs because they will use your language alongside other languages they already use in their projects. So reaching them may be easier than it may seem. But to get things working for free, your compiler has to work not like this, but more like this. I mean, your compiler must provide access to individual stages, both in and out.

  2. I'll cover the details about that a bit later. And now a few words about me. I'm a software engineer for about nine years. I've been writing Haskell, Scala, Elm, and TypeScript. And I love functional programming. We'll take a look at the plugin for my language called Awsum. It's an experimental functional language focused on safety, and it already supports several targets and several operating systems, but it's still in the very early stage of development. Today I won't cover the language itself, but, well, it has some interesting features like safe recursion, memory safety, and stuff like that, and safe arithmetics. So how do you tell if you're doing the right thing with your language?

  3. Well, put yourself in the shoes of someone who has to use it. Not by choice, but at work. Imagine you've been handed a language at your job, and you're seeing it for the first time. You'd probably love to have at least syntax highlighting, type errors, type hints on hover, a formatter, and all that you probably need to have without switching to a different editor. And all of that needs to just work, like always. But if your compiler happens to live on a different planet from your users, they cry. So let's review the example. A compiler of my compiler. There's just a fact that Awesome is written in Haskell on GHC 9.12. This version of Haskell compiler was released in December 2024, and formatters and linter were ready in about a month and a half, and language server support was ready in about 5.5 months, and a full, relatively usable set of packages was ready in about seven months from the date this compiler was released.

  4. And by the way, today, November 10th of 2026, it's still not a recommended version of compiler. But to avoid problems like this, you don't actually need a PhD. All you need is just support every editor. In my case, it's five editors, but this approach works for the remaining editors as well. So it may sound like it's a lot of work to support a lot of editors, but think of it this way. If you have a language, you have a compiler, you already have a parser. To get a formatter, all you need is to pass the output of your parser to a pretty printer, which converts the AST back to the code. And your language server will use your compiler stages and your formatter, and one language server will serve all the editors users will use.

  5. And also, to get a syntax highlighting, you must have other grammars implemented for JetBrains' IDEs and VS Code and its forks. It's TextMate, and for Neovim, Emacs, and Zed, it's Tree-sitter. So maintaining separate grammars may sound like a lot of work, but actually, you can ask AI to write grammars using the existing parser. And you can wire those grammars with property-based and case-based tests to your compiler so that they will be checked automatically every time the compiler is checked against an arbitrary program or a specific program. So you may not trust AI in language development, but think of it this way.

  6. Everything that is responsible for correctness in your user editors will be done by LSP server, which delegates its work to compiler stages. So AI code will not be responsible for correctness in this case, and it will only serve for coloring of the code, like for syntax highlight. And the worst thing that could happen is syntax highlighting will be broken on some obscure programs that even your compiler wasn't tested against. So that sounds to me like an acceptable risk. And so acceptable that you may actually not need to review those generated grammars yourself at all.

  7. And my message is that just don't overthink it. Just be on the same planet where your users are. Now let me demonstrate how my Minimalistic Language plugin actually works. This is a fairly minimal example. And this language plugin can catch type errors, display them in the Problems tab. It can catch some warnings, for example, unused arguments, provide quick fixes for that. And the language plugin doesn't understand anything about the code, or doesn't understand anything except how to connect to a language server. And all of the remaining stuff is implemented inside the compiler itself. So, yeah, it's like that.

  8. And the LSP is performant enough to work with large files. It's relatively quick. And speaking of being on the same planet where your users are, from the product perspective, it makes sense to go this way. So, speaking of IntelliJ Platform and LSP, today, IntelliJ Platform supports about 30 features that could be implemented using LSP, but a Minimalistic Language plugin only uses eight of them. And, oh, I forgot to demonstrate their formatting. So, for example, if I mess things up and... Yeah, I can reformat code like that, and it works instantly.

  9. So, my language plugin uses only eight of the features, and it could be using many more, but these features aren't equally cheap to implement. Some of these features require a pretty advanced machinery on the compiler side. For example, working with an unfinished, partially broken code that is being in the process of writing. So, these features are not equally cheap. And what I did is I didn't actually write an IDE plugin, I just told the IDE where my compiler is. So, all of the work that was needed to support my language in the IDE was made in five files and 77 lines of Kotlin, and I'll show you that.

  10. The first file is telling the IDE to make sure that server is running. Every time the user opens a file with my language that is judged by extension. The second file is responsible for running an executable which is located in path using a specific command, and after that, the language plugin communicates to LSP server using a standard input and standard output. That's it. Another file tells the IDE how to get a TextMate grammar, which is bundled with the plugin, and this file declares dependencies, which is the platform itself, LSP and TextMate plugin. Yeah.

  11. And this override tells the IDE that only a language server should be used to format my files. This is also judged by file extension, and as you can see, it's fairly easy. And, yeah, before I talk about another override, let me explain how versioning works in my minimalistic approach to supporting every editor I expect my users to use. The language is experimental and it changes often, and the tooling for it and language-supporting editors should be always available and compatible with latest release, otherwise it would be difficult to use. And I really believe that everything related to my language should be property tested against the compiler.

  12. So, grammars are property tested against the compiler, formatter is tested, and everything else, and different stages of the compiler. And I don't need to put expectations from the community that someone will develop something for my product. So, if I am responsible for my product, then I do not expect anything from the community. So, my approach is not to support several versions of the compiler in any language plugin, but to just have a single version for everything and release every piece of tooling and ship it to marketplaces with the same version. Today, marketplaces put some restrictions on versions that you can use when you're publishing plugins and extensions. In some marketplaces, you can use only A.B.C versions, so you have to adjust for that.

  13. And I decided that while this is an experimental language, I will support only the latest version, and everything will be shipped on the same day, and everything will work together. And in order for this to work, I need to implement a handshake procedure. So, when the LSP client connects to a server, the client can pass some parameters to a server, and the server can respond to this with some actions from its side. So, what I did is I passed the expected compiler version to a server on the initialization step, and it usually is so that users get a language plugin before they get a new compiler, because the IDE updates plugins itself in most editors. And if there is a version mismatch, the server responds with a message like that, that, well, the expected version is higher than you have, and you can open the language install page and update the plugin, or you can ignore this message if you want to just proceed and you don't care about the incompatibility.

  14. And another extra step that I implemented in my language plugin is a command for restarting the server. Actually, JetBrains IDEs already have a widget with a restart button, but it doesn't have an action ID, and it could not be called with a Find Action menu, and it couldn't be used to have a keyboard shortcut bound to that. So, for convenience, I implemented it roughly the same way as it is implemented in the IDE 2026.3 like that. But this step is unnecessary for probably most users. And, well, let me also tell you how difficult it was to publish the extension. It wasn't at all.

  15. So, every time I publish a new version of extension, I just push a tag and GitHub builds an extension, and I upload it manually on the marketplace, and soon after that it is reviewed and published, and on the first time I published it, it just took a bit longer. That's it. There's nothing complicated about publishing an extension, so if you're worried about things like that, you should not be, and you should go forward and publish your language and your extensions. And what I like about JetBrains Marketplace is that they constantly send me letters like this, that my extensions use some deprecated APIs, and they start sending these messages long before the change is really necessary. So, even if you are a total sloth, you have plenty of time to update your extension. That is a really good thing.

  16. (Sighs) Now, let me talk about why the plugin turned out to be so small. It follows from my language survival strategy, (Sighs) because I wanted everyone to be able to use the language immediately with tooling, and for that I designed the compiler in such a way that every compiler stage could be accessed individually. And it's not like a pipe where you have only one input and one output, you pass in the source code, and you have an executable, and every piece of tooling you or community may need will have to implement the parsers of their own using different languages, and they won't be probably tested against each other using property-based tests or something like that.

  17. And, well, it will drift apart significantly, and users will have to worry about what is compatible with what, and you know that, you've seen examples of that. So, the solution I propose is to allow as much access to your compiler stages as it can technically be done. And, by the way, I did not write the LSP machinery myself, I used the LSP library for Haskell, the same library as Haskell Language Server uses, and everything related to state management and the LSP protocol itself was already implemented for me, so I did not implement it myself, I just used a library and wired it to the output of specific phases of my compiler. Yeah, that's it.

  18. So, my proposal is that you design your compiler not as a pipe, but as a manifold. Let's, for example, see how Scala solves this. Yeah, the Scala 3 is the source of inspiration for me in terms of compiler APIs. They opened many compiler stages, and you can bypass some stages, you can have access to a lot of outputs of the compiler, and in the ecosystem, it's not much that maintainers needed to reimplement themselves. For example, for Scalafmt, there is a separate parser. And for IntelliJ Scala plugin, there is a parser, but compiler errors for Scala 3, as far as I know, they come directly for compiler today.

  19. So, this approach is proven to be working, and with Scala 3, it's easier and easier every day to update the compiler. In the Haskell world, it's somewhat similar. So, GHC already allows to have access to specific, to output of specific stages, but the problem with Haskell tooling is that tooling is maintained separately, have separate release cycles, separate maintainers, and it depends not only on the compiler, but on other libraries too. So, it's not enough to adjust the format or code. It's not enough to adjust LSP for the latest version of compiler.

  20. It requires LSP maintainers to wait for other dependencies to be updated, and that is why allowing access to specific stages is not enough by itself. And the third example I'd like to review is the Elm programming language. This is a counter-example. It's really a pipe when you pass the sources and you get error reports in the JSON form or the output JavaScript code or docs. And that's all you can have from the compiler. And in the ecosystem, there is a formatter, linter, language server, IntelliJ plugin, and another language server implemented in Rust. And all of these pieces of tooling requires their maintainers to maintain their own parsers and other compiler stages.

  21. In fact, they have to maintain separate versions of the compiler themselves, but without the backend. And Elm's solution to this problem is to not change the language for years. Yeah, and apparently that works too. And for me, the first step to this approach of reusing compiler stages was testing the parser. Actually, I wanted to have property tests for my parser, and one of the easiest property tests that I can come up with is a round-trip test when I pass random abstract syntax, syntactic trees to a... I render arbitrary ASTs and parse them back and have the same result.

  22. And when I implemented that, there was no reason to delay implementing a formatter, because a formatter is just... You parse the user's code and you render it back, and that's it. Well, it's more complex than that, because you have to maintain additional information about the user's code. But in general, it's very close to that. So, yeah, that was the first step for me. And the second step is, once I get the QuickCheck generator, it's a piece for property-based tests, which generate arbitrary abstract syntactic trees. I and I have a printer. I can use this machinery to test grammars, and then I can ask grammars using, for example, Tree-sitter queries to make sure that the grammar is working fine and nothing has broken on every program that is being tested.

  23. Yeah, that's how it worked for me. And LSP can't solve everything that users may need in your editor. LSP can't be used for features that require a syntactic tree inside the IDE, not inside the server. So, complex use cases like language injection, when one language is used inside a file with another language, or complex refactorings, or references from different programming languages between each other. These require a different approach. They require a full-blown IntelliJ platform plugin, and it's a different scale of work, I would say.

  24. So, my today's talk is not about that, but it must be said that LSP is somewhat limited, but it can do a lot for your users. The source code of my language and the plugin for it is published on the GitHub, and if you are interested in knowing more about that, you can invite me in your conferences, podcasts, and meetups, and I will gladly tell something interesting. And a documentation about IntelliJ LSP support can be found there. I would be glad to answer your questions. Thank you. Okay, thank you very much. I got an answer.

  25. So, I don't see any questions on our YouTube comments, but I got a question. So, you were talking about basically how you split up your parser so that it emits all the different stages that can be used for work, right? So, that leaves out one of the most important things, right? That no matter how many stages you emit, your parser needs to read incomplete files all the time. Files that are basically incorrect because users are just typing up. And if we just look historically, parsers will immediately stop, usually, when they find an error. So, could you tell a bit about how you solve that problem, basically, that you have to emit useful information while still being able to read and parse through incomplete or incorrect files? I decided to not solve this problem in the early days of compiler.

  26. So, the compiler stops at the first error it sees. And in my experience, it's way better than, for example, it's done in Scala. In Scala, if there is a compiler error, you get a lot of compiler errors. And once you solve one of them, a lot of other compiler errors may go away. This is far from ideal user experience because if I'm a beginner user, I'm freaked out by having 200 errors. So, my message is that maintainers of a programming language should be on the same planet with their users. And they must have enough tooling, enough developer experience for users to survive. And that means sometimes users have to go with their compiler errors one by one. And that's fine. Can I ask a really practical follow-up question?

  27. So, when you basically stop at an error and you have a large file, how does it look practically in the editor right now? So, let's say you have an error at the top. Are you getting not any type information below that or no highlighting, no advanced highlighting? How does it look? It has no advanced highlighting. The highlight, like the colors in the editor's simple syntactic highlight works using TextMate and tree-sitter grammars. And they are not responsible for any type information for correctness. They are used only for syntax highlight. So, the highlighting doesn't break, but the other compiler information is not provided to the user until the user resolves a specific question, a specific problem. And the type error contains enough information about type mismatch, for example. So, yes, it breaks, but breaking that in the editor is way more useful than to just not implement a language plugin at all, or to let users see the output in the terminal in the compiler.

  28. So, if you are typing something that compiler doesn't like, you have a red underline immediately and that works. A lot could be done with that. Okay. Maybe let me bring up one more question. Oh, sorry, I hit it again. So, here. So, Al Bryan asked, "If I start a plugin with LSP, how hard is it to migrate to a full PSI implementation later?" Do you want to answer that? Yes, I have my own answer and this answer would not be enough professional because I'm not an experienced IntelliJ platform developer or Kotlin developer at all. And that would be a lot of work because a lot will be different. But you have to... Well, if you feel like you have to implement a PSI plugin, you probably should do that rather than not doing that because in 2026, when there are LLMs and there are a lot of known techniques on testing and verifying software, it's better to implement something using AI and verify that it's correct enough and make your users happy than to just not implement it.

  29. But I believe it would be very complex. Yeah. That's something, Patrick, you've done with Wolfram recently. No, no, no, no. So, I always had a basically a handwritten parser. So, let's say how hard it is to migrate. The migration is probably not trivial, right? On the other hand, you have already experienced writing a parser or working, right? What an AST is and so on. And what you need to do then is basically bring it into the PSI and IntelliJ framework. And of course, the big thing there is your parser must not stop. Your lexer and your parser must not stop at errors. Basically, error messages get just injected into the AST tree. And then you need to ensure that all your features still do something useful even when you're under errors, right? So, that is one of the trickiest parts to give the best user experience even when the code is incomplete that the user writes and still contains errors.

  30. So, sorry, Jacob. Go ahead. No, no, that's fine. That's fine. Okay. So, we basically still can use AI for writing PSI stuff, I believe. Patrick covered your Wolfram plugin recently with more tests. Yeah, I did basically kind of the same thing that Vladimir did, right? So, I used a ground truth parser and used test cases. And then I compared basically what my parser delivers as an AST with the original parser. And then I fixed my thing. And since this was really small steps and really small fixes, it could do really a lot of changes and a lot of non-trivial fixing there in a short amount of time. Yeah. Okay.

  31. So, I mean, I can just continue, Jacob. If you want to say something. No, I'm good. I'm good. I'm really good. Yeah. So, we got told to go directly to break. But first, Vladimir, thanks a lot for your presentation. It was quite insightful. You're muted, by the way, not by me. Thank you for having me. Yeah. That was really great. Thanks for being here.

Summary

Vladimir Logachev discusses how to bring a custom programming language to JetBrains IDEs and other editors by designing a compiler that provides modular access to individual stages and integrates with the Language Server Protocol. The talk references his experimental functional language, Awsum, and details using AI to generate syntax grammars while relying on the compiler for correctness. The practical takeaway is that language creators can efficiently support multiple user editors with minimal code by making their compiler modular and leveraging the Language Server Protocol rather than building complex, editor-specific plugins from scratch.

View original episode ↗