neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
9.98k stars 2.04k forks source link

Arduino Language Server does not attach #3209

Closed mike-lloyd03 closed 2 weeks ago

mike-lloyd03 commented 2 weeks ago

Description

I have followed all of the instructions for setting up arduino-language-server. But when I open an arduino file in nvim, the client does not attach.

LspInfo:

 Press q or <Esc> to close this window. Press <Tab> to view server doc.

 Language client log: /home/mike/.local/state/nvim/lsp.log
 Detected filetype:   arduino

 0 client(s) attached to this buffer: 

 Other clients that match the filetype: arduino

 Config: arduino_language_server
    filetypes:         arduino
    root directory:    /home/mike/repos/hoverboard-firmware
    cmd:               /usr/bin/arduino-language-server
    cmd is executable: true
    autostart:         true
    custom handlers:   

 Configured servers list: arduino_language_server, typst_lsp, nil_ls, kotlin_language_server, ccls, jsonls, eslint, tsserver, pyright, gopls, bashls, ansiblels, lua_ls, svelte

The client is recognized but it will not attach to the file. LspStart does nothing.

LspLog

[START][2024-06-19 15:06:51] LSP logging initiated
[ERROR][2024-06-19 15:06:51] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/bin/arduino-language-server"  "stderr"    "15:06:51.296123 ArduinoCLI config file found at /home/mike/.arduino15/arduino-cli.yaml\n15:06:51.296203 arduino-cli found at /usr/bin/arduino-cli\n15:06:51.296240 clangd found at /usr/bin/clangd\n15:06:51.296311 \27[97mLS: : Initial board configuration: \27[0m\n15:06:51.296317 \27[97mLS: : arduino-language-server Version: 0.0.0-git Commit:  Date: \27[0m\n15:06:51.296351 \27[97mLS: : Language server temp directory: /tmp/arduino-language-server3308433109\27[0m\n15:06:51.296357 \27[97mLS: : Language server build path: /tmp/arduino-language-server3308433109/build\27[0m\n15:06:51.296360 \27[97mLS: : Language server build sketch root: /tmp/arduino-language-server3308433109/build/sketch\27[0m\n15:06:51.296362 \27[97mLS: : Language server FULL build path: /tmp/arduino-language-server3308433109/fullbuild\27[0m\n15:06:51.296947 IN Elapsed: 507.876µs\n15:06:51.297085 \27[92mIDE --> LS REQU initialize 1\27[0m\n"

It looks like the language server outputs text on stderr. Is it possible that nvim is interpreting output on stderr as an error?

Relevant config:

require("lspconfig").arduino_language_server.setup({})

It appears that the LSP is running:

$ procs arduino 

 PID:▲  User │ TTY CPU MEM CPU Time │ Command
             │     [%] [%]          │
 290410 mike │     0.0 0.0 00:00:00 │ /usr/bin/arduino-language-server
fspv commented 2 weeks ago

Same here. Literally debugging the same problem right now. Everything seems to be working, but the buffer doesn't attach. I assume that arduino might require certain files, but not sure what else does it need apart from

./sketch.yaml
./test.ino
~/.arduino15/arduino-cli.yaml
fspv commented 2 weeks ago

Found this https://github.com/arduino/arduino-language-server/issues/187

Somebody says it is something broken in nvim 0.10, and 0.9.5 works well. Haven't tried this myself

fspv commented 2 weeks ago

Described the bug here https://github.com/arduino/arduino-language-server/issues/187#issuecomment-2179619062

It is not related to the nvim, but rather caused by the outdated library, which doesn't support new LSP capabilities added in nvim 0.10

mike-lloyd03 commented 2 weeks ago

You are correct. I downgraded to nvim 0.9.5 and the LS is working.

Kinda funny that we were having the same problem at the same time. Thanks for your help!