arduino / arduino-language-server

An Arduino Language Server based on Clangd to Arduino code autocompletion
GNU Affero General Public License v3.0
120 stars 11 forks source link

Feature Request: read sketch.json for project-specific settings (e.g. FQBN) #100

Open nalzok opened 2 years ago

nalzok commented 2 years ago

Requiring a -fqbn option on the command line makes it difficult to set project-specific board names, and the current workaround calls for hardcoded FQBN for each individual project, which is inconvenient and error-prone. It would be great if arduino-language-server could accept a -project-root option and check the sketch.json inside the project root directory to access all project-specific settings.

bradcush commented 2 years ago

This should already be the case if your sketch.json file is at the same level as your ino file. In my case I'm using arduino_language_server with the Neovim built-in LSP which sets the root directory for the language server based on the location of the ino file. I haven't dug too deep but I have one language server client per root directory. I'm guessing if the language server process is started from a directory that contains a sketch.json file then it will use it.

alessio-perugini commented 11 months ago

@nalzok it is possible. Just create a sketch.yaml in the root of your project and add the following key: default_fqbn: your_fqbn. By doing so you can change your neovim lspconfig removing the custom function and the -fqbn flag.

default_fqbn: arduino:avr:uno