bufbuild / buf

The best way of working with Protocol Buffers.
https://buf.build
Apache License 2.0
9.01k stars 272 forks source link

`buf beta lsp` local go-to-definition issue #3359

Closed stefanvanburen closed 1 week ago

stefanvanburen commented 2 weeks ago

GitHub repository with your minimal reproducible example (do not fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)

https://github.com/bufbuild/registry-proto

Commands

nvim buf/registry/module/v1/module_service.proto
# Go to line 60, column 12 (cursor on `ModuleRef`)
# Invoke LSP go-to-definition

Output

Nothing — the definition is not opened.

The logs are very noisy (from :LspLog); here's the first couple lines:

[START][2024-10-01 10:11:35] LSP logging initiated
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[34mINFO\27[0m\tnew file version: file:///Users/stefanvanburen/src/registry-proto/buf/registry/module/v1/module_service.proto, 0 -> 0\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/src/registry-proto/buf/registry/module/v1/module_service.proto, 0\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    "\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/src/registry-proto/buf/registry/module/v1/module.proto, -1\n"
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    "\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/src/registry-proto/buf/registry/owner/v1/owner.proto, -1\n"
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    "\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/.cache/buf/v3/modules/b5/buf.build/bufbuild/protovalidate/b983156c5e994cc9892e0ce3e64e17e0/files/buf/validate/validate.proto, -1\n"
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    "\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/.cache/buf/v3/wellknowntypes/27.0/google/protobuf/descriptor.proto, -1\n"
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tcould not find URI for import "buf/validate/expression.proto"\n\27[33mWARN\27[0m\tcould not find URI for import "buf/validate/priv/private.proto"\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/.cache/buf/v3/wellknowntypes/27.0/google/protobuf/duration.proto, -1\n\27[34mINFO\27[0m\tparsing AST for file:///Users/stefanvanburen/.cache/buf/v3/wellknowntypes/27.0/google/protobuf/timestamp.proto, -1\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tcould not find image for "file:///Users/stefanvanburen/.cache/buf/v3/modules/b5/buf.build/bufbuild/protovalidate/b983156c5e994cc9892e0ce3e64e17e0/files/buf/validate/validate.proto"\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'
[ERROR][2024-10-01 10:11:35] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/homebrew/bin/buf" "stderr"    '\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n\27[33mWARN\27[0m\tcould not find image for "file:///Users/stefanvanburen/.cache/buf/v3/modules/b5/buf.build/bufbuild/protovalidate/b983156c5e994cc9892e0ce3e64e17e0/files/buf/validate/validate.proto"\n\27[33mWARN\27[0m\tnotify returned\t{"method": "$/progress"}\n'

It then seems to continuously try to find the image for bufbuild/protovalidate/b9831... and fail over and over.

Expected Output

I expected to go to the definition of ModuleRef (within the same package at ./module.proto:103:9).

Anything else?

I haven't used the LSP enough to know for sure, but this seems like an issue only with same-package symbols - go-to-definition works with e.g. buf.registry.owner.v1.OwnerRef on line 92 in the same file, and all of the buf.validate extensions, for example.

jpaju commented 1 week ago

I have the same issue. Maybe it could be because of the could not find URI for import ... in the logs? If you try go-to-definition with some well-known type like google.protobuf.Timestamp it works correctly. Also the logs have this sort of line: parsing AST for file://<user-home>.cache/buf/v3/wellknowntypes/27.0/google/protobuf/empty.proto, -1\n