Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"--profile-temp",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/integration",
"${workspaceFolder}/test/workspaces/multi/mult.code-workspace"
"${workspaceFolder}/test/workspaces/multi/multi.code-workspace"
],
"preLaunchTask": "npm: pretest",
"outFiles": ["${workspaceFolder}/out/test/integration/**/*.js"],
Expand Down
1 change: 0 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.vscode-test/**
.github/**
.gitignore
.prettierignore
.yarnrc
.envrc
.env
Expand Down
79 changes: 79 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Changelog

## Unreleased

This release reworks Buf for Visual Studio Code. It integrates the Buf Language Server,
available in [beta on the `buf` CLI][buf-lsp], introducing new [language server enabled features](README.md#features).

Thanks to [@christogav](https://github.com/christogav) for their contributions on integrating
the Buf Language Server with VS Code on this release.

## v0.7.2

- Fix issue with `buf` commands returning an unexpected error on exec.

## v0.7.1

- Fix "undefined" error when running `buf` on the extension.

## v0.7.0

- Output errors to "Buf" channel in the VS Code output console.

## v0.6.2

- Reintroduce relative binary path support.

## v0.6.1

- Revert relative binary path support.

## v0.6.0

- Support relative binary path.

## v0.5.3

- Add syntax highlighting for `.proto` files.

## v0.5.2

- Fix lint highlighting issue outside of the current file.

## v0.5.1

- Fix an issue with setting `buf format` as the default formatter for proto3 files.

## v0.5.0

- Add formatting using `buf format`. Defaults to format on save.

## v0.4.0

- Use single file reference to resolve lint file from any path

## v0.3.1

- Accept v1.0.0-rc1 in version parser

## v0.3.0

- Change `--version` to read from both `stdout` and `stderr`

## v0.2.0

- Update minimum required version to v0.34.0

## v0.1.3

- Update logo

## v0.1.0

- Add version check and download link

## v0.0.3

- Fix missing generation command

[buf-lsp]: https://buf.build/docs/reference/cli/buf/beta/lsp/)
32 changes: 17 additions & 15 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# VS Code Buf extension development guide

## Running the extension
## Setup

To get started, run `npm install` to install all the packages.

## Running the extension with VS Code Debugger

To start a new instance of VS Code with the extension loaded and running, open this project,
`vscode-buf` in VS Code.
`vscode-buf` in VS Code. Then, navigate to "Run and Debug" in the Activity Bar and select
`Run Extension` or press F5.

## Running the extension by building from source and installing

To run a new instance of VS Code with the extension loaded, navigate to "Run and Debug" in
the Activity Bar and select `Run Extension` or press F5.
To build the extension, run `make`. This produces a `*.vsix` file, which can be manually
installed to an instance of VS Code by running:

```sh
$ code --install-extension <name>.vsix
```

[vscode-docs-test-cli]: https://code.visualstudio.com/api/working-with-extensions/testing-extension#quick-setup-the-test-cli

## Tests

Expand All @@ -28,14 +41,3 @@ These tests are runnable from VS Code in the "Run and Debug" tab using the dropd

We use Playwright to orchestrate end-to-end tests with user actions and conditions, e.g. running
commands from the Command Palette.

## Building the extension

To build the extension, run `make`. This produces a `*.vsix` file, which
can be manually installed to an instance of VS Code by running:

```sh
$ code --install-extension <name>.vsix
```

[vscode-docs-test-cli]: https://code.visualstudio.com/api/working-with-extensions/testing-extension#quick-setup-the-test-cli
161 changes: 83 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,134 @@
# Buf for Visual Studio Code

The [VS Code Buf extension](https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf) provides rich support for [Protocol Buffers](https://protobuf.dev/) using the [Buf](https://buf.build/) development environment.
The [VS Code Buf extension][vs-code-marketplace] helps you work with [Protocol Buffers][protobuf]
files in a much more intuitive way, adding smart syntax highlighting, navigation, formatting,
documentation and diagnostic hovers, and integrations with [Buf][buf] commands.

## Requirements
## Features

- **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][command-palette].

- Visual Studio Code
- A [Buf](https://buf.build/) configuration environment.
![Preview features](./preview.gif)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a general note above, but just to add here - this Gif is really hard to see. I'm happy to redo it for you if I can get up an running over here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, would happily take this offer once we get the development environment stuff sorted out!


## Getting Started

The Buf CLI is the ultimate tool for modern, fast, and efficient Protobuf API management. Getting started is simple!

1. Install the [VS Code Buf extension](https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf).
2. Create a [buf.yaml](https://buf.build/docs/cli/#default-configuration) in the root of your workspace.
3. Open any Protobuf file to automatically activate the extension. A Buf status bar appears in the bottom right corner of the window.
4. The extension depends on the [Buf CLI](https://buf.build/docs/cli/). If a Buf binary is not found in your path, the extension will attempt to install the latest release from Github.
[Install the latest version via the VS Code marketplace][vs-code-marketplace].

## Features
By default, the extension will use your locally-installed version of `buf` on your system
`$PATH`. However, you don't have to install `buf` - the extension can manage and install it
for you based on the [buf.commandLine.path](#buf.commandline.path) and [buf.commandLine.version](#buf.commandline.version)
configurations:

- **Code navigation** - Jump to or peek at a symbol's declaration.
- **Syntax highlighting** - Protobuf specific color and styling of code.
- **Code editing** - Support for formatting and linting.
- **Buf command support** - Execution of Buf CLI commands e.g. [Buf Generate](https://buf.build/docs/generate/tutorial/).
| | <pre>buf.commandLine.path</pre> | <pre>buf.commandLine.version</pre> |
| --- | --- | --- |
| Default: Use `buf` from the system `$PATH`. | {empty} | {empty} |
| Use the latest released version of `buf` and check for updates on extension activation. | {empty} | `latest` |
| Use `buf` at specified path. | User specified path | {empty} |
| Install and use the specified version of `buf`. | {empty} | User specified semver version |
| Use `buf` at specified path and display an error message. | User specified path | User specified semver version |

## Extension Settings

This extension contributes the following settings:
This extension contributes the following configuration settings.

### buf.commandLine.path

Default: `null`

The path to a specific install of Buf to use. Relative paths are supported and are relative to the workspace root.

> If not set and `buf.commandLine.version` is also not set, the extension will attempt to find a os-specific Buf binary on the path.
The path to a specific install of Buf to use. Relative paths are supported and are relative to the VS Code workspace root.

### buf.commandLine.version

Default: `null`

Specific version (git tag e.g. 'v1.53.0') of Buf release to download and install.
Specific version (e.g. 'v1.53.0') of Buf release to download and install.

### buf.restartAfterCrash

Default: `true`

Automatically restart Buf (up to 4 times) if it crashes.

### buf.checkUpdates

Default: `true`

Check for language server updates on startup.
Automatically restart the Buf Language Server (up to 4 times) if it crashes.

### buf.enableHover

Default: `true`

Enable hover features provided by the language server.

### buf.enable

Default: `true`

Enable Buf language server features.
Enable Buf Language Server features.

### buf.debug

Default: `false`

Enable debug mode.
Enable debug logs in output channels.

### buf.log-format

Default: `text`

Buf language server log format.
Buf Language Server log format.

### buf.checks.breaking.againstStrategy

Default: `git`

The strategy to use when checking breaking changes against a specific reference.

### buf.checks.breaking.againstGitRef

Default: `refs/remotes/origin/HEAD`
The Git reference to check breaking changes against. This is only compatible when `buf.checks.breaking.againstStrategy`
is set to `git`, otherwise it is ignored.

## Commands

This extension contributes the following commands to the [Command Palette][command-palette].

### Setup

- Install CLI: installs the `buf` CLI based on `buf.commandLine.path` and `buf.commandLine.version`
configurations and then attempts to start the language server.
- Update CLI: updates the `buf` CLI based on `buf.commandLine.path` and `buf.commandLine.version`
configurations and then attempts to start the language server.

### Language Server

- Start Buf Language Server: starts the Buf Language Server. If the Buf Language Server is
already running, it will stop and then start it.
- Stop Buf Language Server: stops the Buf Language Server. If the Buf Language Server is not
currently running, then it is a no-op.

### Buf

- Build: runs `buf build` with an optional user input for the build output.
- Init: runs `buf config init` at the root of each VS Code workspace. This creates a `buf.yaml` file
to help users get started with Buf modules and workspaces.
- List available breaking change detection rules: lists the breaking change detection rules
that are available.
- List available lint rules: lists the lint rules that are available.
- Prune module dependencies: prunes unused dependencies from the `buf.lock` at the root of
each VS Code workspace.
- Update module dependencies: updates the dependencies in `buf.lock` at the root of each
VS Code workspace.
- Generate: runs `buf generate` at the root of each VS Code workspace.
- List module files: lists the Protobuf definition files for the Buf module/workspace at the
root of each VS Code workspace.
- Price of BSR paid plans: provides the pricing information for Buf Schema Registry (BSR)
for each VS Code workspace.
- Module stats: provides Buf module/workspace stats at the root of each VS Code workspace.

### Extension

- Show Buf Output: shows the extension output channel

## Legal

Offered under the [Apache 2 license][license].

The Git reference to check breaking changes against.

## Changelog

- v0.8.0
- Improve overall editor functionality, using Buf Language Server.
- v0.7.2
- Fix issue with `buf` commands returning an unexpected error on exec.
- v0.7.1
- Fix "undefined" error when running `buf` on the extension.
- v0.7.0
- Output errors to "Buf" channel in the VSCode output console.
- v0.6.2
- Reintroduce relative binary path support.
- v0.6.1
- Revert relative binary path support.
- v0.6.0
- Support relative binary path.
- v0.5.3
- Add syntax highlighting for `.proto` files.
- v0.5.2
- Fix lint highlighting issue outside of the current file.
- v0.5.1
- Fix an issue with setting buf format as the default formatter for proto3 files.
- v0.5.0
- Add formatting through using buf format. Defaults to format on save.
- v0.4.0
- Use single file reference to resolve lint file from any path
- v0.3.1
- Accept v1.0.0-rc1 in version parser
- v0.3.0
- Change `--version` to read from both `stdout` and `stderr`
- v0.2.0
- Update minimum required version to v0.34.0
- v0.1.3
- Update logo
- v0.1.0
- Add version check and download link
- v0.0.3
- Fix missing generation command
[command-palette]: https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette
[vs-code-marketplace]: https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf
[protobuf]: https://protobuf.dev/
[buf]: https://buf.build/
[license]: https://github.com/bufbuild/vscode-buf/blob/main/LICENSE
Binary file removed lint_errors.png
Binary file not shown.
15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"Linters"
],
"keywords": [
"proto",
"proto3",
"protobuf",
"protocol buffers",
"buf",
"bufbuild",
"format",
"lint",
"format"
"proto",
"proto3",
"protobuf",
"protocol buffers"
],
"activationEvents": [
"workspaceContains:**/*.proto",
Expand Down Expand Up @@ -171,11 +171,6 @@
"default": true,
"description": "Automatically restart Buf (up to 4 times) if it crashes."
},
"buf.checkUpdates": {
"type": "boolean",
"default": true,
"description": "Check for language server updates on startup."
},
"buf.enableHover": {
"type": "boolean",
"default": true,
Expand Down
Binary file added preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading