vim-lsp
                                
                                 vim-lsp copied to clipboard
                                
                                    vim-lsp copied to clipboard
                            
                            
                            
                        [question]How to know if LspDefinition fail or success in vim script
I can see "No definition found" message if LspDefinition can find any definiton, but how to know this in vim script?
I have tried following, but neither of it working
redir => l:msg
:LspDefinition
redir END
if l:msg == "No definition found"
let l:ret = 1
endif
try
:LspDefinition
catch
 let l:ret = 1
endtry
I try to use cscope or ctags if lsp not working, that's why I need to know if Lsp command fail or success.
Have you found a way around this? I'm having the same issue.
Vim-lsp does not throw exceptions, that is why your second approach didn't work. The solution I found:
diff --git a/autoload/lsp/utils.vim b/autoload/lsp/utils.vim
index 5bcdb7b..a8292c3 100644
--- a/autoload/lsp/utils.vim
+++ b/autoload/lsp/utils.vim
@@ -271,6 +271,7 @@ function! lsp#utils#error(msg) abort
     echohl ErrorMsg
     echom a:msg
     echohl NONE
+    throw "LspError"
 endfunction
 
 function! lsp#utils#echo_with_truncation(msg) abort
In my .vimrc:
function! Gototo()
    try
        :LspDefinition
    catch
        :tag
    endtry
endfunction
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.