Skip to content

Use Buf CLI as an LSP#392

Merged
doriable merged 27 commits intobufbuild:mainfrom
christogav:christogav/lsp
May 21, 2025
Merged

Use Buf CLI as an LSP#392
doriable merged 27 commits intobufbuild:mainfrom
christogav:christogav/lsp

Conversation

@christogav
Copy link
Contributor

@christogav christogav commented Apr 1, 2025

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.

  - Introduce a command pattern for command handling.
  - Rewrite installation processes via install/update commands.
  - 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.
@doriable doriable self-requested a review April 2, 2025 18:04
@doriable doriable requested a review from paul-sachs April 7, 2025 20:18
@christogav
Copy link
Contributor Author

Resync'd with #393 - run lint+format and resolve issues.

Copy link
Member

@doriable doriable left a comment

Choose a reason for hiding this comment

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

Thank you so much for putting up this PR, we really appreciate this contribution, and apologies for the delayed response/review. I think this is very much in-line with what we are looking for in the LSP integration and in-line with @mcy's first PR.

Our intention is to get these changes checked in. For full transparency, we are currently working on some improvements and changes to our LSP, and do not want to make a release of the VSCode extension backed by the LSP until we are ready, so we may not follow-up with a release immediately. Additionally, this is a pretty big change that would take some time to get merged. @paul-sachs and I will be reviewing this and working with you on this, so don't hesitate to reach out if needed :)

  * Remove current buf module concept - update basic statusbar tooltips.
  * Remove open `buf.yaml` command
  * Allow user to provide `buf.commandLine.path` and also `buf.commandLine.version` for specific version pinning.
  * When `buf.commandLine.path` set, do not show `COMMAND_SETUP` commands on the palette.
  * Move `Log` to its own file.
  * Remove extra params that we don't want to expose on the extension until we understand more.
  1. Change the way findBuf works to align better to PR feedback.
  3. If buf not installed, change command on status bar to install buf.
  2. Add a `buf.remove` command.
  3. Fix fetching github release by version.
@paul-sachs paul-sachs changed the title Use Buf CLI as an LSP (v2). Use Buf CLI as an LSP Apr 14, 2025
@christogav
Copy link
Contributor Author

@doriable @paul-sachs Tidied command descriptions and removed an unnecessary activation event in packages.json - they were hurting my OCD when using the editor. Any issues with the late commit, happy to revert.

@paul-sachs paul-sachs mentioned this pull request Apr 17, 2025
@christogav
Copy link
Contributor Author

Hi team - anymore feedback to address? 🙏

Copy link
Member

@doriable doriable left a comment

Choose a reason for hiding this comment

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

Sorry it took so long for me to get back to this! Left a quick comment, there needs to be a small adjustment to the find/install process, but it's looking good!

Comment on lines 127 to 131
if (version === "latest") {
found = files
.filter((f) => f.startsWith("v"))
.sort()
.at(-1);
Copy link
Member

Choose a reason for hiding this comment

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

This behaviour doesn't seem correct -- if the user has anything installed in their global storage, it would be used as latest, even if it is not actually the latest version of the CLI... so in the case where the user has formerly installed v1.40.0 for example, and then changes the value to latest, no update would actually happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the handling per @paul-sachs's approach slightly modified.

@doriable
Copy link
Member

Thank you so much for the contribution, I know we put you through a pretty long code review process, so I really appreciate you sticking with us on this! I'm going to merge this PR now 🙏🏼

In the upcoming few weeks, I'm going to figure out some housekeeping around the repository, which may include changing up the README, changelogs, etc. I'll include you/this work in the credits in any changes I make!

Thank you again!

@doriable doriable merged commit bf5b965 into bufbuild:main May 21, 2025
2 checks passed
paul-sachs added a commit that referenced this pull request May 21, 2025
Fix formatting and missing package-lock file update accidentally merged
in with #392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants