arduino_language_server

URL: https://github.com/arduino/arduino-language-server

plugins.lsp.servers.arduino_language_server.enable

Whether to enable https://github.com/arduino/arduino-language-server

Language server for Arduino

The arduino-language-server can be installed by running:

go install github.com/arduino/arduino-language-server@latest

The arduino-cli tool must also be installed. Follow these installation instructions for your platform.

After installing arduino-cli, follow these instructions for generating a configuration file if you haven’t done so already, and make sure you install any relevant platforms libraries.

The language server also requires clangd to be installed. Follow these installation instructions for your platform.

If you don’t have a sketch yet create one.

$ arduino-cli sketch new test
$ cd test

You will need a sketch.yaml file in order for the language server to understand your project. It will also save you passing options to arduino-cli each time you compile or upload a file. You can generate the file by using the following commands.

First gather some information about your board. Make sure your board is connected and run the following:

$ arduino-cli board list
Port         Protocol Type              Board Name  FQBN            Core
/dev/ttyACM0 serial   Serial Port (USB) Arduino Uno arduino:avr:uno arduino:avr

Then generate the file:

arduino-cli board attach -p /dev/ttyACM0 -b arduino:avr:uno test.ino

The resulting file should look like this:

default_fqbn: arduino:avr:uno
default_port: /dev/ttyACM0

Your folder structure should look like this:

.
├── test.ino
└── sketch.yaml

For further instructions about configuration options, run arduino-language-server --help.

Note that an upstream bug makes keywords in some cases become undefined by the language server. Ref: https://github.com/arduino/arduino-ide/issues/159 .

Type: boolean

Default: false

Example: true

Declared by:

plugins.lsp.servers.arduino_language_server.package

The arduino_language_server package to use.

Type: null or package

Default: pkgs.arduino-language-server

Declared by:

plugins.lsp.servers.arduino_language_server.autostart

Controls if the FileType autocommand that launches a language server is created. If false, allows for deferring language servers until manually launched with :LspStart (|lspconfig-commands|).

Type: null or boolean or raw lua code

Default: null

Plugin default: true

Declared by:

plugins.lsp.servers.arduino_language_server.cmd

A list where each entry corresponds to the blankspace delimited part of the command that launches the server.

The first entry is the binary used to run the language server. Additional entries are passed as arguments.

Type: null or (list of string)

Default: null

Declared by:

plugins.lsp.servers.arduino_language_server.extraOptions

Extra options for the arduino_language_server language server.

Type: attribute set of anything

Default: { }

Declared by:

plugins.lsp.servers.arduino_language_server.filetypes

Set of filetypes for which to attempt to resolve {root_dir}. May be empty, or server may specify a default value.

Type: null or (list of string)

Default: null

Declared by:

plugins.lsp.servers.arduino_language_server.rootDir

A function (or function handle) which returns the root of the project used to determine if lspconfig should launch a new language server, or attach a previously launched server when you open a new buffer matching the filetype of the server.

Type: null or lua function string

Default: null

Plugin default: "nil"

Declared by:

plugins.lsp.servers.arduino_language_server.settings

The settings for this LSP.

Type: attribute set of anything

Default: { }

Example:

{
  callback = {
    __raw = ''
      function()
        print('nixvim')
      end
    '';
  };
  foo_bar = 42;
  hostname = "localhost:8080";
}

Declared by: