Skip to content

clangd startup failed with Neovim 0.11.4 #215

@bmrips

Description

@bmrips

Describe the problem

The language server fails to start up clangd.

To reproduce

In Neovim (version 0.11.4), setup the language server as follows:

vim.lsp.config("arduino_language_server", {
	capabilities = {
		textDocument = {
			semanticTokens = vim.NIL,
		},
		workspace = {
			semanticTokens = vim.NIL,
		},
	},
	cmd = {
		"arduino-language-server",
		"-cli-config",
		vim.fn.expand("~/.arduino15/arduino-cli.yaml"),
		"-fqbn",
		"esp8266:esp8266:d1_mini",
		"-cli",
		"arduino-cli",
		"-clangd",
		"clangd",
	},

	filetypes = { "arduino" },

	root_dir = function(_, on_dir)
		on_dir(vim.fn.expand("%:p:h"))
	end,
})

Set up the working directory such that:

❯ tree ..
..
└── HelloWorld
    ├── HelloWorld.ino
    └── sketch.yaml

❯ cat sketch.yaml
default_fqbn: esp8266:esp8266:d1_mini
default_port: /dev/ttyUSB0

When opening HelloWorld.ino with neovim, you get notified that the Client arduino_language_server quit with exit code 2 and signal 0. The log (as found in ~/.local/state/nvim/lsp.log, in a sanitized form) says:

ArduinoCLI config file found at /home/bmr/.arduino15/arduino-cli.yaml
08:54:56.229151 arduino-cli found at /home/bmr/.local/state/nix/profile/bin/arduino-cli
08:54:56.229391 clangd found at /home/bmr/.local/state/nix/profile/bin/clangd
08:54:56.229513 LS: : Initial board configuration:
08:54:56.229521 LS: : arduino-language-server Version: 0.7.7 Commit: unknown Date:
08:54:56.229530 LS: : Language server temp directory: /tmp/arduino-language-server2023951873
08:54:56.229541 LS: : Language server build path: /tmp/arduino-language-server2023951873/build
08:54:56.229545 LS: : Language server build sketch root: /tmp/arduino-language-server2023951873/build/sketch
08:54:56.229548 LS: : Language server FULL build path: /tmp/arduino-language-server2023951873/fullbuild
08:54:56.229779 IN Elapsed: 98.196µs
08:54:56.229971 IDE --> LS REQU initialize 1
08:54:56.230815                 initialize 1: write-locked
08:54:56.230850                 initialize 1: write-unlocked
08:54:56.231111 INIT --- : initializing workbench: file:///home/bmr/Arduino/HelloWorld
08:54:56.231165 INIT --- : read-locked
08:54:56.231180 INIT --- : read-unlocked
08:54:56.231347                 initialize 1: initialization parameters: {\"capabilities\":{\"textDocumentSync\":{\"openClose\":true,\"change\":2,\"save\":{\"includeText\":true}},\"completionProvider\":{\"triggerCharacters\":[\".\",\"\\u003c\",\"\\u003e\",\":\",\"\\\"\",\"/\"],\"allCommitCharacters\":[\" \",\"\\t\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"\\u003c\",\"\\u003e\",\":\",\";\",\",\",\"+\",\"-\",\"/\",\"*\",\"%\",\"^\",\"\\u0026\",\"#\",\"?\",\".\",\"=\",\"\\\"\",\"'\",\"|\"],\"completionItem\":{}},\"hoverProvider\":{},\"signatureHelpProvider\":{\"triggerCharacters\":[\"(\",\",\"]},\"definitionProvider\":{},\"documentHighlightProvider\":{},\"documentSymbolProvider\":{},\"codeActionProvider\":{\"codeActionKinds\":[\"quickfix\",\"refactor\",\"info\"]},\"documentFormattingProvider\":{},\"documentRangeFormattingProvider\":{},\"documentOnTypeFormattingProvider\":{\"firstTriggerCharacter\":\"\ \"},\"renameProvider\":{},\"executeCommandProvider\":{\"commands\":[\"clangd.applyFix\",\"clangd.applyTweak\"]},\"workspaceSymbolProvider\":{}},\"serverInfo\":{\"name\":\"arduino-language-server\",\"version\":\"0.7.7\"}}
08:54:56.231354 INIT --- : running: --config-file /home/bmr/.arduino15/arduino-cli.yaml compile --fqbn  --only-compilation-database --source-override /tmp/1882621206 --build-path /tmp/arduino-language-server2023951873/fullbuild --format json /home/bmr/Arduino/HelloWorld
08:54:56.231366 IDE <-- LS RESP initialize 1
08:54:56.231430 OUT Elapsed: 6.767µs

IN Elapsed: 67.3711ms
08:54:56.298874 IDE --> LS NOTIF initialized
08:54:56.298878                  initialized: Notification is not propagated to clangd
08:54:56.298887 IN Elapsed: 7.003µs
08:54:56.298897 IDE --> LS NOTIF textDocument/didOpen
08:54:56.298922                  textDocument/didOpen: write-locked
08:54:56.298924                  textDocument/didOpen: (throttled: waiting for clangd)
08:54:56.298925                  textDocument/didOpen: unlocked (waiting clangd)

INIT --- : error starting clang: running --config-file /home/bmr/.arduino15/arduino-cli.yaml compile --fqbn  --only-compilation-database --source-override /tmp/1882621206 --build-path /tmp/arduino-language-server2023951873/fullbuild --format json /home/bmr/Arduino/HelloWorld: exit status 1
08:54:56.655562                  textDocument/didOpen: locked (waiting clangd)
08:54:56.655567                  textDocument/didOpen: clangd startup failed: quitting Language server

Expected behavior

The language server starts up successfully.

Arduino Language Server version

0.7.7

Arduino CLI version

1.3.1

Operating system

Linux

Operating system version

NixOS 25.11.20250924.e643668 (Xantusia); Linux 6.16.8

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest version
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions