Skip to content

Commit bf5b965

Browse files
christogavPaul Sachs
andauthored
Use Buf CLI as an LSP (#392)
Hi team, I've spent the last couple weekends looking at #344 which appears abandoned. This snowballed a bit into a rewrite for mostly maintainability and testability reasons. Apologies for the size of the pull - happy to split it up if you want to take it on, else I'll continue happily running this locally. Changes I've introduced: - Introduce a command pattern for command handling. - Rewrite installation processes via install/update commands (now works cross platform). - Provide flexible method of using buf located in path/storage. - Improve status bar with a command picker. - Support 'buf generate' as a command. - ~~Support module detection for the active file in editor.~~ - ~~Provide a shortcut to opening 'buf.yaml' as a command.~~ --------- Co-authored-by: Paul Sachs <psachs@buf.build>
1 parent 9c419ca commit bf5b965

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5005
-5470
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
.vscode-test/
55
*.vsix
66
.env/
7+
.user-data-dir-test

.vscode/launch.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,32 @@
99
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
12+
"args": [
13+
"--disable-extensions",
14+
"--extensionDevelopmentPath=${workspaceFolder}"
15+
],
1316
"outFiles": ["${workspaceFolder}/out/**/*.js"],
14-
"preLaunchTask": "${defaultBuildTask}"
17+
"preLaunchTask": "npm: watch"
1518
},
1619
{
1720
"name": "Extension Tests",
1821
"type": "extensionHost",
1922
"request": "launch",
23+
"runtimeExecutable": "${execPath}",
2024
"args": [
25+
"--disable-extensions",
26+
"--profile-temp",
2127
"--extensionDevelopmentPath=${workspaceFolder}",
22-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
28+
"--extensionTestsPath=${workspaceFolder}/out/test/unit/index",
29+
"--user-data-dir=${workspaceFolder}/extension/.user-data-dir-test",
30+
"--timeout",
31+
"999999"
2332
],
2433
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
25-
"preLaunchTask": "${defaultBuildTask}"
34+
"sourceMaps": true,
35+
"smartStep": true,
36+
"preLaunchTask": "npm: watch",
37+
"cwd": "${workspaceFolder}/extension"
2638
}
2739
]
2840
}

.vscode/tasks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7+
"label": "npm: watch",
78
"type": "npm",
89
"script": "watch",
910
"problemMatcher": "$tsc-watch",

README.md

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,98 @@
11
# Buf for Visual Studio Code
22

3-
## Installation
3+
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.
44

5-
Install via the Visual Studio Code extension browser or see
6-
[the extension page](https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf)
7-
for detailed installation instructions.
8-
9-
## Features
5+
## Requirements
106

11-
- Lints your protobuf files using `buf lint`. It checks your currently opened file
12-
whenever you save it.
7+
* Visual Studio Code
8+
* A [Buf](https://buf.build/) configuration environment.
139

14-
![Lint errors](./lint_errors.png)
10+
## Getting Started
1511

16-
- Formats your protobuf files using `buf format`.
12+
The Buf CLI is the ultimate tool for modern, fast, and efficient Protobuf API management. Getting started is simple!
1713

18-
- Provides syntax highlighting for `.proto` files.
14+
1. Install the [VS Code Buf extension](https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf).
15+
2. Create a [buf.yaml](https://buf.build/docs/cli/#default-configuration) in the root of your workspace.
16+
3. Open any Protobuf file to automatically activate the extension. A Buf status bar appears in the bottom right corner of the window.
17+
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.
1918

20-
## Requirements
19+
## Features
2120

22-
- [buf](https://docs.buf.build/installation)
21+
- **Code navigation** - Jump to or peek at a symbol's declaration.
22+
- **Syntax highlighting** - Protobuf specific color and styling of code.
23+
- **Code editing** - Support for formatting and linting.
24+
- **Buf command support** - Execution of Buf CLI commands e.g. [Buf Generate](https://buf.build/docs/generate/tutorial/).
2325

2426
## Extension Settings
2527

2628
This extension contributes the following settings:
2729

28-
- `buf.binaryPath`: configure the path to your buf binary. By default it uses `buf` in your `$PATH`.
30+
### buf.commandLine.path
31+
32+
Default: `null`
33+
34+
The path to a specific install of Buf to use. Relative paths are supported and are relative to the workspace root.
35+
36+
> 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.
37+
38+
### buf.commandLine.version
39+
40+
Default: `null`
41+
42+
Specific version (git tag e.g. 'v1.53.0') of Buf release to download and install.
43+
44+
### buf.restartAfterCrash
45+
46+
Default: `true`
47+
48+
Automatically restart Buf (up to 4 times) if it crashes.
49+
50+
### buf.checkUpdates
51+
52+
Default: `true`
53+
54+
Check for language server updates on startup.
55+
56+
### buf.enableHover
57+
58+
Default: `true`
59+
60+
Enable hover features provided by the language server.
61+
62+
### buf.enable
63+
64+
Default: `true`
65+
66+
Enable Buf language server features.
67+
68+
### buf.debug
69+
70+
Default: `false`
71+
72+
Enable debug mode.
73+
74+
### buf.log-format
75+
76+
Default: `text`
77+
78+
Buf language server log format.
79+
80+
### buf.checks.breaking.againstStrategy
81+
82+
Default: `git`
83+
84+
The strategy to use when checking breaking changes against a specific reference.
85+
86+
### buf.checks.breaking.againstGitRef
87+
88+
Default: `refs/remotes/origin/HEAD`
89+
90+
The Git reference to check breaking changes against.
2991

3092
## Changelog
3193

94+
- v0.8.0
95+
- Improve overall editor functionality, using Buf Language Server.
3296
- v0.7.2
3397
- Fix issue with `buf` commands returning an unexpected error on exec.
3498
- v0.7.1

0 commit comments

Comments
 (0)