Note that this is specific to Arduino IDE 1.x. Like most modern applications, Arduino IDE 2.x does this transparently. As long as the sketch is in a saved state, Arduino IDE 2.x will automatically pick up any changes you make to the files externally, without any need to configure it to do so.
It does have a language-server based diagnostic capability, as we would get from VS Code (when the relevant extension is installed) or other professional IDEs.
However, this is disabled by default. We decided to do this because the diagnostics are prone to false positives. Those false positives are likely to cause confusion for beginners. The primary cause of false positives is the deferred library discovery system used by the language server:
The "context-aware" features (e.g., autocomplete, "IntelliSense", suggestions, "Go to Definition") only work for objects from a library after one of these events occurs following the time of the addition of the #include directive for a library's header file in a sketch:
- The sketch is opened in Arduino IDE
- A different board is selected in the Arduino IDE menus
- The sketch is compiled
The reason for the deferred awareness of objects from libraries compared to the awareness of other objects in the sketch (which is updated after every edit to the code) is that the awareness of library objects is dependent on a process known as "library discovery", where Arduino IDE scans all installed libraries for a header files matching the #include directives of the sketch program and picks which libraries to add to the compiler's "search path". That "library discovery" process is somewhat resource intensive. The overhead of that resource usage is insignificant when it is done as part of the occasional manually triggered compile operation, but more significant when it comes to the continuous processing that is done to support the "context-aware" features. The developers decided to change to this "deferred discovery" approach for the "context-aware" feature support in response to user complaints that the previous approach was too heavy for lower spec PCs.
So this means that, until a library discovery is triggered, false diagnostics would be shown for any reference to an object from a library.
It is possible to enable the "problems" feature via the Arduino IDE advanced settings. Even though it might not be suitable for a new user, a more experienced user has the ability to evaluate each of the problem detections and differentiate the legitimate ones from the spurious ones that should be ignored. I'll provide instruction you can follow to enable the feature:
- Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
A menu will appear on the editor toolbar:
- Select the "Preferences: Open Settings (UI)" command from the menu.
ⓘ You can scroll down through the list of commands to find it or type the name in the field.
A "Preferences" tab will open in the Arduino IDE main panel.
- Type
arduino.language.realTimeDiagnostics in the "Search Settings" field of the "Preferences" tab.
- Check the box under the "Arduino › Language: Real Time Diagnostics" setting.
- Close the Preferences tab by clicking its X icon.
You will now find that a "squiggle" appears under each "problem" detected by the language server.
You can open a "Problems" view that lists all the diagnostics by running the "Toggle Problems View" command from the command palette.
Note that, in addition to the expected false positives that occur due to library discovery not yet having been performed, there are other causes of false positives. Some of these spurious detections are the result of corner case mismatches in behavior between the Clang C++ compiler used by the language server that produces the diagnostics and the GCC compiler that is used to compile the sketch programs.
So you definitely must be prepared to evaluate the diagnostics and ignore those that don't actually represent a problem.