Skip to content

Editor integration#

The Buf CLI produces structured machine readable error output for build, lint, and breaking change errors which integrate with IDEs, scripts, and other tools.

We currently provide integration with Vim, Visual Studio Code, and JetBrains IDEs, and we may support other editors in the future. Contact us if you're interested in any of these, or others not already listed here.

Vim#

Vim integration for linting is available using the ALE lint engine via the vim-buf plugin.

To use Vim integration buf must be installed. Using vim-plug, add this to your .vimrc:

Plug 'dense-analysis/ale'
Plug 'bufbuild/vim-buf'
let g:ale_linters = {
\   'proto': ['buf-lint',],
\}
let g:ale_lint_on_text_changed = 'never'
let g:ale_linters_explicit = 1

The extension runs buf lint --path on save and reveals errors on a per-file basis. To detect package-level problems, be sure to run a workspace-wide buf lint as part of your CI process.

Visual Studio Code#

The VS Code Buf extension helps you work with Protocol Buffers files in a much more intuitive way, adding smart syntax highlighting, navigation, formatting, documentation and diagnostic hovers, and integrations with Buf commands.

Install it via the in-editor extension browser under the name "Buf" or manually via the extension page. If you have other plugins installed for .proto files, like vscode-proto, we recommend disabling or removing them first. See the extension page for more detailed installation instructions.

Its features include:

  • Code navigation - Go-to definition and documentation insets for .proto symbols.
  • Syntax highlighting - Protobuf-specific color and styling of code.
  • Code editing - Formatting via buf format and annotations and hovers based on buf lint and buf breaking.
  • Documentation hovers - Documentation for definitions when hovering a reference.
  • Buf command support - Execution of buf CLI commands via the Command Palette.

JetBrains IDEs#

The plugin for all IntelliJ-based IDEs is available on the JetBrains Plugin Marketplace.

You can install it from the settings window of your IDE. The plugin supports linting and formatting for your .proto files, as well as navigation, syntax highlighting, and more.

EditorConfig suggestions#

If you use EditorConfig files to enforce consistent styles in your code, we recommend these settings for your .proto files:

[*.proto]
indent_size = 2
indent_style = space
insert_final_newline = true

These settings aren't semantically meaningful in Protobuf but are commonly used throughout the ecosystem.

Formatting options#

The Buf CLI supports these formatting options (passed using the --error-format flag) to support other integrations:

path/to/file.proto:1:10:syntax value must be "proto2" or "proto3"
path/to/file.proto(1,10) : error COMPILE : syntax value must be "proto2" or "proto3"`
{"path":"path/to/file.proto","start_line":1,"start_column":10,"end_line":1,"end_column":10,"type":"COMPILE","message":"syntax value must be \"proto2\" or \"proto3\""}