Hi, On Fri, Aug 25, 2023 at 4:26 PM Magnus Groß <[email protected]> wrote:
> @yegappan <https://github.com/yegappan> Is there any reason why the > Content-Type header is set in the first place? It causes problems with > some LSP servers such as haskell-language-server > <https://github.com/haskell/haskell-language-server>, which doesn't > support that header and crashes with the following error when it receives > that header (when using your vim9 LSP client > <https://github.com/yegappan/lsp>): > I originally set it to follow the LSP specification. But as we learned over a period of time, some of the LSP servers are not able to properly handle/ignore this header. > Error | Failed to parse message header: > : string > > Obviously we could fix that particular server, but I think there is > incentive to not send that header at all, because: > > - it is an optional header > - the value that we set (Content-Type: application/vscode-jsonrpc; > charset=utf-8) is already the default value > > <https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#headerPart> > - other popular LSP clients also omit this header > > I have tested the following LSP clients and not a single one of them sets > the Content-Type header, only the Content-Length header is set for all of > them: > > - coc.nvim > - Neovim LSP > > <https://github.com/neovim/neovim/blob/5d8ab32f3871b0232972cac1116ac7cba98389e5/runtime/lua/vim/lsp/rpc.lua#L22> > - VSCode > - Ale > > <https://github.com/dense-analysis/ale/blob/115ad17ace047cab20ccc67f79c943aaf3f0f291/autoload/ale/lsp.vim#L149> > - YouCompleteMe > > Therefore in order to improve compatibility with slightly misbehaving LSP > clients, I propose to drop this header: > > diff --git a/src/json.c b/src/json.c > index acf7ac57c..e2a011309 100644--- a/src/json.c+++ b/src/json.c@@ -105,8 > +105,7 @@ json_encode_lsp_msg(typval_T *val) > ga_init2(&lspga, 1, 4000); > // Header according to LSP specification. > vim_snprintf((char *)IObuff, IOSIZE,- "Content-Length: %u\r\n"- > "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n\r\n",+ > "Content-Length: %u\r\n\r\n", > ga.ga_len - 1); > ga_concat(&lspga, IObuff); > ga_concat_len(&lspga, ga.ga_data, ga.ga_len); > > I don't see a problem in removing the Content-Type header. Can you create a PR with this change? Thanks, Yegappan -- -- 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/CAAW7x7mTetOb-8FtN66pvJMwa1rKj-8FnmTjQMknJajw_Zmf7g%40mail.gmail.com.
