Closed nabaco closed 1 year ago
Hey. I'm very sorry for the incredible long delay.
First of all, I would like to ask you to just return nil
for this case and do not work on the tags yourself. It is just not necessary as NeoVim will do it itself when nil
gets returned. Atm it doesn't work as you expect because it returns an empty list.
Second I'm thinking if this can be tweaked/configured. I'm not 100% sure if this is always the intended behavior. Especially because it will always trigger an actual tag search when the language server(s) provide no location (which can be correct). So I wonder if it would be more precise to check if the necessary location providers are available. If it does and the response is empty, accept that. If not, go ahead and use tags. Do you think this would help here? In worst case you could explicitly setup your language client so it disabled certain location provider you know of that they don't work properly.
If that should not be possible, I would at least add a configuration variable to enable the fallback to tags. So the current behavior remains as it for all users and everyone like you can configure it the way you need it.
Looking forward to your feedback.
Fixed the return value, it indeed works as expected that way. I'm not sure what you mean by "check the location provider" - can you elaborate on that please? I will look into adding an option for opting into this behaviour.
Added a global option for my change. Did some further testing and I noticed that when I don't have compile_commands.json clangd returns incorrect locations for tags instead of an empty list, so my change doesn't really help here. But when I turn off the LSP client (:LspStop) then my change kicks in and works perfectly.
Though maybe in such cases we need to check if there are any LSP Clients attached to the buffer, and if not return nil
? Is that what you meant by "check the location provider"?
Hey, sorry that I haven't responded. 🙈 I like the current state. Do you think we can merge it right now or would you like to add more due to your recent problem?
I'm fine with merging now. If I'll have further fixes, I'll raise another PR.
At times I'm working on C projects where I don't have a compile_commands.json, and thus the LSP doesn't fully work on the file. But I do have
tags
file present, and I wantCtrl-]
to work with them too. So I've added logic to use the tags file if LSP didn't return any symbol.