Fix: move "Navbuddy" user command to the global scope, so invoking it without LSP attached results in proper error #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey,
Since user command
Navbuddy
exists only when LSP is attached, it does not appear in the completion all the time, and invoking it without LSP does not produce any meaningfull error.The only thing that appears in this case is
E492: Not an editor command: Navbuddy
which is super confusing, if you don't know/remember how the plugin works.Creating
Navbuddy
only when LSP attaches doesn't make much sense, because said cmd does not have any logic on it's own, it calls a wraper and the actual function which already has a branch for dealing with this exact case:nvim-navbuddy/lua/nvim-navbuddy/init.lua
Lines 209 to 210 in f22bac9
So I just turned
Navbuddy
into global user command, by moving it toM.setup()
. This fixes the mentioned issues without introducing any new code.Although, I wonder why it was implemented like this in the first place?
Maybe, I'm missing something here? Some edge case?
Ideally, the best possible behavior would be forcing LSP to start and then, if it won't start, printing the error, but this would be way more risky to implement and harder to maintain.
Cheers!