Buf Language Server
bufls
is a prototype for the beginnings of a Protobuf language server compatible with Buf modules and workspaces. This currently only supports go-to-definition.
This is a proof-of-concept that we wanted to share with the community. We do not actively maintain this, and there are no guarantees in terms of stability, but we want to hear your feedback!
For details on where we could go with this, please refer to future work.
Usage
Regardless of the LSP-compatible editor you use, you'll need to install bufls
so that it's available on your $PATH
.
go install github.com/bufbuild/buf-language-server/cmd/bufls@latest
Vim
With vim-lsp, the only configuration you need is the following:
Plug 'prabirshrestha/vim-lsp'
augroup LspBuf
au!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'bufls',
\ 'cmd': {server_info->['bufls', 'serve']},
\ 'whitelist': ['proto'],
\ })
autocmd FileType proto nmap <buffer> gd <plug>(lsp-definition)
augroup END
Supported features
Buf's language server behaves similarly to the rest of the buf
CLI. If the user has a buf.work.yaml
defined, the modules defined in the workspace will take precedence over the modules specified in the buf.lock
(i.e. the modules found in the module cache). The language server requires that inputs are of the protofile type.
Go to definition
Go to definition resolves the definition location of a symbol at a given text document position (i.e. textDocument/definition).
This feature is currently only implemented on the textDocument/definition
endpoint. It may make sense to move this to textDocument/typeDefinition
and/or textDocument/typeImplementation
. The Protobuf grammar is far more limited than a programming language grammar, so not all of the semantics for each LSP endpoint apply here.
Today, this feature is only supported for messages and enums. The well-known types (WKT), and [custom] options are not yet supported.
Implementation
Protobuf compilation is fast, so the implementation is currently naive. Every editor command will compile the input file (e.g. file://proto/pet/v1/pet.proto
) from scratch (there isn't any caching). Simple caching is fairly straightforward, but the cache would need to be cleared whenever a file is edited during the same language server session, which would require a file watcher. For now, performance is fine as-is (even for workspaces and large modules), but we might need to revisit this later as build graphs continue to grow.
Future work
More LSP features
This is just the tip of the iceberg - there's way more that a fully-featured Protobuf language server can do for the Protobuf community. For starters, the following set of endpoints are next in line:
- textDocument/completion
- textDocument/codeLens
- textDocument/foldingRange
- textDocument/formatting
- textDocument/hover
Go to definition
A couple features remain for full go to definition support:
- Add go to definition support for [custom] options.
- Add go to definition support for the well-known types (i.e. synthesize the WKT in the module cache).
Bump go.uber.org/zap from 1.23.0 to 1.24.0
Bumps go.uber.org/zap from 1.23.0 to 1.24.0.
Release notes
Sourced from go.uber.org/zap's releases.
Changelog
Sourced from go.uber.org/zap's changelog.
Commits
a55bdc3
Release v1.24.0 (#1208)ed5598a
Use ReplaceAll instead of Replace with -1 pos arg (#1195)da406e3
Chore: Fix deprecation docs and links (#1193)9b86a50
SugaredLogger: Turn error into zap.Error (#1185)9137e0e
go.mod: Bump go directive to 1.19 (#1181)7cabba7
Open absolute paths as files, limited Windows support (#1159)7681a0a
Export objectMarshalerPtr (#1171)9abd14b
chore: remove duplicate word in comments (#1169)eae3743
Logger, SugaredLogger: Add Level method (#1148)0d6a75b
tests: assert.Error/Contains => assert.ErrorContains (#1158)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)Bump go.uber.org/zap from 1.22.0 to 1.23.0
Bumps go.uber.org/zap from 1.22.0 to 1.23.0.
Release notes
Sourced from go.uber.org/zap's releases.
Changelog
Sourced from go.uber.org/zap's changelog.
Commits
1ae5819
Release v1.23.0 (#1157)23d6cc7
Add Stringers field constructor for slices of Stringer-compatible objects (#1...1e46f5e
Issue Templates: Show a "Discussions" link for questions (#1152)92dded6
Add issue template for questions (#1151)4a895a2
zapcore: Add LevelOf(LevelEnabler), UnknownLevel (#1147)19a5d8a
Open: expose error cause, test for fs.ErrNotExist (#1149)bdd673d
Replace os.TempDir usage with t.TempDir (#1146)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)Bump github.com/spf13/cobra from 1.5.0 to 1.6.1
Bumps github.com/spf13/cobra from 1.5.0 to 1.6.1.
Release notes
Sourced from github.com/spf13/cobra's releases.
... (truncated)
Commits
b43be99
Check for group presence after full initialization (#1839) (#1841)8607918
feat: make InitDefaultCompletionCmd public (#1467)2169adb
Add groups for commands in help (#1003)212ea40
Include --help and --version flag in completion (#1813)d4040ad
Allow user to add completion for powershell alias (#1621)23fc5e0
ci: add minimum GitHub token permissions for workflows (#1792)93d1913
Add OnFinalize method (#1788)07034fe
build(deps): bump actions/stale from 5 to 6 (#1815)3dc9761
Add allero to list of projects using cobra (#1819)7039e1f
Add '--version' flag to Help output (#1707)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)Add `@latest` to installation instructions
Just a minor tweak to avoid
Bump github.com/bufbuild/buf from 1.10.0 to 1.11.0
Bumps github.com/bufbuild/buf from 1.10.0 to 1.11.0.
Release notes
Sourced from github.com/bufbuild/buf's releases.
Changelog
Sourced from github.com/bufbuild/buf's changelog.
Commits
b6d1820
Release v1.11.0 (#1686)c28dda4
Bump bufbuild/buf-push-action from 1.0.1 to 1.1.1 (#1682)108da9b
Bump peter-evans/create-pull-request from 4.2.2 to 4.2.3 (#1643)04e5243
Bump go.uber.org/multierr from 1.8.0 to 1.9.0 (#1684)bc1fb94
image filtering: don't include entire enclosing message/service (#1659)2991585
Add UpstreamClient UserAgent to dockerclient (#1678)e85a0a6
add user type filter for ListUsers and include user type in User (#1660)8985c1b
optimize checking for current digest (#1665)fae35f6
fix regression in plugin generation (#1675)5d29981
update connect-go and latest go deps (#1674)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)Bump go.uber.org/multierr from 1.8.0 to 1.9.0
Bumps go.uber.org/multierr from 1.8.0 to 1.9.0.
Release notes
Sourced from go.uber.org/multierr's releases.
Changelog
Sourced from go.uber.org/multierr's changelog.
Commits
39ca40c
Prepare release v1.9.0 (#68)4459990
Add a shorthand for AppendInvoke (#65)80b07a7
Document named return constraint for defer (#63)492b792
Test and lint against Go 1.19 (#62)aa8f15f
Upgrade to yaml.v3 3.0.1 (#60)f46d400
Use append instead of copy to clone slices (#58)6fede5c
CI: Test against Go 1.17/1.18 (#57)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)goto definition being very slow?
I've been giving
buf-language-server
a try.I added it to my
~/.config/helix/languages.toml
:I typed
gd
on a symbol. For some reason, it takes 3-5 seconds for it to jump, even if the symbol is in the same file?Would linting also be a potential candidate?
I love the idea of a proper buf ls! I was wondering if it also would include diagnostics and formatting? It would make https://github.com/bufbuild/buf/issues/1035 probably obsolete.
EDIT: I just saw https://github.com/bufbuild/buf/pull/1345 which fixes the mentioned issue. So oh well, not that relevant for the beginning then. If it gets merged then it should be possible to run the bufcli and bufls in parallel.