prabirshrestha / vim-lsp

async language server protocol plugin for vim and neovim
MIT License
3.13k stars 305 forks source link

tagfunc with clangd in reverse order #1448

Closed jlevon closed 1 year ago

jlevon commented 1 year ago

LSP's tagfunc uses workspace/symbol. Given "mystruct_t", then clang returns, for example:

Fri 17 Mar 2023 14:58:10 UTC:["--->",1,"clangd",{"method":"workspace/symbol","on_notification":"---funcref---","params":{"query":"mystruct_t"}}]
Fri 17 Mar 2023 14:58:10 UTC:["<---",1,"clangd",{"response":{"id":27,"jsonrpc":"2.0","result":
  [
{"score":0.55,"location":{"uri":"a.c","range":{"end":{"character":12,"line":26},"start":   {"character":2,"line":26}}},"name":"mystruct_t","kind":5,"containerName":""},

{"score":0.55,"location":
{"uri":"a.c","range":{"end":{"character":19,"line":30},"start": "character":0,"line":30}}},"name":"get_mystruct_to_eat","kind":12,"containerName":""}]},

"request":{"id":27,"jsonrpc":"2.0","method":"workspace/symbol","params":{"query":"mystruct_t"}}}]

The default ordering of s:compare_tags means that "get_mystruct_to_eat" is the top result, and we go there. But the first result - the highest score, and an exact match, is where we should be going.

I've fixed this locally by inverting the order of s:compare_tags - but surely it's not just me seeing this?

$ clangd  --version
clangd version 16.0.0 (https://github.com/llvm/llvm-project.git 3ab00cfca9cf76840d178b7ab80631837886c176)
Features: linux
Platform: x86_64-unknown-linux-gnu
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.