Skip to main content

Editor Integration

Buf produces file:line:column:message error output by default for build, lint, and breaking change errors. It can also output errors in JSON. As such, it is easy to write editor integrations that provide real-time feedback to developers.

Right now, we only provide Vim and Visual Stuio Code integration, however we expect to cover Emacs and potentially Intellij in the near future. Please contact us if you are interested in any of these.

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 the following 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

This will result in individual files being linted on save via buf lint --path. Note that some lint rules are dependent on checking multiple files at once, for example the lint rules in the PACKAGE_AFFINITY category, so we still recommend your CI setup runs buf lint.

Buf will be executed in your current directory, which results in your configuration being read from your current directory.

Visual Studio Code#

The Visual Studio Code extension can be downloaded from the in-editor extension browser under the name "Buf", or manually via the extension page.

It requires Buf to be installed.

The extension runs buf lint --path on save and as a result, it will not catch all potential lint errors. We recommend that your CI setup runs buf lint.

Buf will be executed in the root of your workspace, which results in your configuration being read from the root of your workspace.