Hi,

On Sun, Apr 17, 2022 at 3:04 PM Prabir Shrestha <[email protected]>
wrote:

> I have tried the PR and it correctly parses the LSP message. Thanks for
> the quick fix!
>

Thanks for verifying the fix.


> Found another bug. Doc says that channel callback will return decoded
> json rpc message as vim dict.
> https://github.com/yegappan/vim/blob/aea71ca1f496c89dbfd127376368bb8c7c693782/runtime/doc/channel.txt#L1415-L1422
>

We should call this a doc bug. Depending on the mode specified for stderr,
the callback
function can be called with either a string or a dict. To handle LSP
messages on stdout and
strings on stderr, it is better to specify separate callback functions for
"out_cb" and
"err_cb" (as you have described below). I will update the help to mention
this.

Regards,
Yegappan


> But from my experience seems like it may return a string if the server
> writes to stderr. I did a quickfix in vim-lsp to always check the type to
> be dict. prabirshrestha/vim-lsp@71efb2d
> <https://github.com/prabirshrestha/vim-lsp/commit/71efb2d265369cae0a7e3c492457289359a542db>.
> I think the better option would be to never call the callback for stderr
> and ask the caller to attach out_err instead.
>
> Here is when a callback response is string.
>
> Sun Apr 17 14:58:54 2022:["s:native_notification_callback","2022/04/17 
> 14:58:54 efm-langserver: reading on stdin, writing on stdout"]
>
> Here is when callback response is a dict
>
> Sun Apr 17 14:59:25 
> 2022:["s:native_notification_callback",{"id":0,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"rustAnalyzer/Fetching"}}]
>
> let l:jobopt = { 'in_mode': 'lsp', 'out_mode': 'lsp', 'noblock': 1, 
> 'callback': function('s:native_notification_callback') }let l:job = 
> job_start(a:opts['cmd'], l:jobopt)
> function! s:native_notification_callback(channel, response) abort
>     call s:log('s:s:native_notification_callback', a:response)
>     if type(a:response) == type({})       " a:response is json decoded lsp 
> message
>     else        " a:respone is string from stderr
>     endifendfunction
>
>
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7k7Pg%3D%3DgHO8yO0DkXMiJMFLm76fLkd3cY_yUP3LEBcRcg%40mail.gmail.com.

Raspunde prin e-mail lui