...as of e8824368.
Possibly related to #1786.
cc @dimbleby
Possibly related to #1786.
Sounds plausible, thanks. (Though I have long since switched to a different client, for this and other reasons)
Looks like there's a function ale#lsp#message#Initialized(), but so far as I can see it never gets called...
Okay, finally this makes sense. The are _two_ messages in the protocol, one is initialize, which ALE does send, and the other is initialized, which is a separate message that is easy to confuse with the first one, which ALE doesn't currently send. Almost all servers don't follow the protocol and don't require you to send the initialized message, which is why this problem was only found with the yang-lsp server, which does follow the protocol.
I can fix this over the next few days.
Exactly. Found using rust-analyzer.
What's annoying is that this bug was hard to catch, because most servers don't follow the spec and work even if you don't send initialized.
Okay, I should have fixed this now. Try it out.
I can't confirm that it works.
Cool, thank you for reporting the issue. It helped me finally figure out what was wrong.
Umm, it still doesn't work for me, but I don't have an easy way to sniff the server-client communication to be certain.
Oh, you "can't confirm." Sorry, I read that as "I can confirm."
Which language server are you testing this with? I can confirm that the initialized message is sent before any other messages now. If you can run ALE in Vim, use :call ch_logfile(expand('~/channel.log'), 'w') and look at the messages going back and forth.
E117: Unknown function: ch_logfile
I've tested it with rust-analyzer:
let g:ale_rust_rls_executable = 'ra_lsp_server'
let g:ale_rust_rls_toolchain = ''
The function isn't defined in NeoVim, you'll have to test this with Vim instead.
See this NeoVim issue where I requested that they implement something similar: https://github.com/neovim/neovim/issues/9010 The only way to log channel messages at the moment in NeoVim is to compile NeoVim differently.
I think they plan on implementing a similar function eventually.
I could try, but it might take a while until I find time to set up Vim.
Cool, let me know how it goes.
If you want to try that language server, use env RUST_LOG=1 RA_INTERNAL_MODE=1 and look into a log subdirectory.
==== start log session ====
6.260437 : Starting job: /usr/bin/zsh -c 'ra_lsp_server'
6.260577 on 0: Created channel
6.263415 SEND on 0(in): 'Content-Length: 196^M
^M
{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"initializationOptions":{},"rootUri":"file:///home/grayshade/hello","capabilities":{},"rootPath":"/home/grayshade/hello","processId":12501}}'
6.265667 : looking for messages on channels
6.279038 RECV on 0(err): 'INFO [ra_lsp_server] lifecycle: server started
'
6.279054 on 0: Dropping message 'INFO [ra_lsp_server] lifecycle: server started
'
6.279458 RECV on 0(err): 'INFO [gen_lsp_server] lsp server initializes
'
6.279466 : looking for messages on channels
6.279503 on 0: Dropping message 'INFO [gen_lsp_server] lsp server initializes
'
6.280426 RECV on 0(out): 'Content-Length: 739^M
^M
{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"codeActionProvider":true,"codeLensProvider":{"resolveProvider":true},"completionProvider":{"triggerCharacters":[":","."]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":["."]},"documentSymbolProvider":true,"executeCommandProvider":{"commands":["apply_code_action"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"signatureHelpProvider":{"triggerCharacters":["(",",",")"]},"textDocumentSync":{"change":1,"openClose":true},"workspaceSymbolProvider":true}}}'
6.280445 : looking for messages on channels
6.280575 on 0: Invoking channel callback <SNR>44_VimOutputCallback
6.282211 SEND on 0(in): 'Content-Length: 40^M
^M
{"method":"initialized","jsonrpc":"2.0"}'
6.283433 SEND on 0(in): 'Content-Length: 218^M
^M
{"method":"textDocument/didOpen","jsonrpc":"2.0","params":{"textDocument":{"uri":"file:///home/grayshade/hello/src/main.rs","version":1,"languageId":"rust","text":"fn main() {\n println!(\"Hello, world!\");\n}\n"}}}'
6.283661 RECV on 0(err): 'INFO [ra_lsp_server] lifecycle: terminating process with Err(ErrorMessage { msg: "expected initialized notification" }
'
6.284513 on 0: Dropping message 'INFO [ra_lsp_server] lifecycle: terminating process with Err(ErrorMessage { msg: "expected initialized notification" }
That's very strange. The message is sent, and then the server says it isn't. I bet it's expecting an empty object to be sent in params.
Okay, git pull again and give that a try. Now an empty object will be sent as the params, which the spec does say is required.
Yeah, that works, thanks.
Nice! Thank you for your help with testing this.