Buf is proud to denote the first fully-featured, production-grade LSP server for Protobuf.
The Language Server Protocol is the modular API for integrating connection support into your favourite IDE aliases matter editor, specified arsenic VSCode, IntelliJ, aliases Neovim. An LSP server provides the smarts that powerfulness spell to definition, codification completion, uncovering references, and semantics-aware syntax highlighting.
Before today, Protobuf lacked the aforesaid LSP support different awesome programming languages enjoy. We don’t want to overstate our ain work, but this is simply a game-changer for Protobuf development: Protobuf now has modern IDE support for the first time, each powered by the Buf CLI.
At Buf, we judge that Protobuf is the champion schema language, acknowledgment to its established ecosystem of libraries and tools. Protobuf shouldn’t conscionable beryllium the smart choice; it should beryllium the easiest prime too. This is why we’re releasing the Buf LSP server, arsenic portion of our family of devices that complete the Protobuf ecosystem, including Protobuf-ES (used successful Chromium!), Protovalidate, ConnectRPC, and the Buf Schema Registry. No matter your task aliases use-case, processing pinch Protobuf should beryllium the easy, obvious choice.
Here’s really you tin effort it out!
Installing the Buf LSP
VSCode is 1 of the astir celebrated graphical editors available, and it has stellar LSP support (LSP originated pinch VSCode). To usage the Buf LSP, conscionable instal the Buf extension. This will automatically usage your installed type of the Buf CLI (which bundles the LSP server), aliases instal 1 if you request it.
Neovim is Buf engineers’ favourite editor, and the Buf LSP useful awesome pinch it, too. All you request to do is instal the Buf CLI, and configure Neovim to usage it arsenic an LSP server.
- Make judge you’ve installed the nvim-lspconfig repository, which provides default LSP config options. Follow the instructions here.
- Add lspconfig.buf_ls.setup {} to your .nvimrc .
Alternatively, you tin adhd the pursuing location successful init.lua (or different config file, if you like):
Then, you tin alteration it pinch vim.lsp.enable('buf-lsp') successful your .nvimrc .
Learn much astir LSP and Neovim here.
If you’re utilizing different editor, first find retired really LSP integration works, and conscionable make judge the buf lsp service bid gets tally to spawn the server.
Buf already maintains a Protobuf compiler frontend (the portion that parses files and calls plugins, for illustration protoc), which we telephone protocompile. Our implementation isn’t conscionable fully-compliant, but it is overmuch faster and much elastic than protoc. Our compiler is truthful bully that moreover Google is utilizing it alongside protoc successful immoderate parts of its monolithic codebase.
To build the Buf LSP, we’ve taken protocompile to the adjacent level. We’ve developed a brand-new, query-driven frontend which enables incremental compilation and overmuch amended diagnostics. For example, dissimilar protoc, we correctly diagnose a copy repeated modifier:
We designed a caller AST and intermediate practice for precisely diagnosing these errors, alternatively of utilizing FileDescriptorProto. Its elasticity makes it easy for america to instrumentality caller connection features arsenic they are added to Protobuf, specified arsenic upcoming features successful Editions 2024. It is besides memory-efficient, truthful it tin grip workspaces that see very ample Buf modules.
Our commitment
Our activity connected the Buf LSP is not done. We are ever improving our diagnostics, and we’re readying to adhd much features to the LSP server, too:
- Adding imports arsenic an automatic fix.
- Tighter integration pinch buf.yaml (such arsenic automatically importing modules).
- Code completion and reference lookup for civilization options.
- Automatic proposal of field/enum numbers.
- Dedicated Protovalidate support, including syntax highlighting for CEL snippets.
At Buf, we will ever push the bound of what you tin execute pinch Protobuf, enabling schema-driven improvement for all!
If you want thief enforcing standards connected your organization’s data, contact us to spot if Buf tin help. If building fantabulous developer tooling excites you, cheque retired our careers page!
English (US) ·
Indonesian (ID) ·