Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Adds way to skip header file provider #565

Merged
merged 2 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ The following Visual Studio Code settings are available for the Arduino extensio
"arduino.additionalUrls": "",
"arduino.logLevel": "info",
"arduino.enableUSBDetection": true,
"arduino.disableTestingOpen": false
"arduino.disableTestingOpen": false,
"arduino.skipHeaderProvider": false,
}
```
- `arduino.path` - Path to Arduino, you can use a custom version of Arduino by modifying this setting to include the full path. Example: `C:\\Program Files\\Arduino` for Windows, `/Applications` for Mac, `/home/$user/Downloads/arduino-1.8.1` for Linux. (Requires a restart after change). The default value is automatically detected from your Arduino IDE installation path.
Expand All @@ -69,6 +70,7 @@ The following Visual Studio Code settings are available for the Arduino extensio
- `arduino.logLevel` - CLI output log level. Could be info or verbose. The default value is `"info"`.
- `arduino.enableUSBDetection` - Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`.
- `arduino.disableTestingOpen` - Disable/enable auto sending a test message to serial port for checking open status. The default value is `false` (a test message will be sent).
- `arduino.skipHeaderProvider` - Enable/disable the extension providing completion items for headers. The functionality is included in newer versions of the C++ extension. The default value is `false`.

The following settings are per sketch settings of the Arduino extension. You can find them in
`.vscode/arduino.json` under the workspace.
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@
"arduino.ignoreBoards": {
"type": "array",
"default": []
},
"arduino.skipHeaderProvider": {
"type": "boolean",
"default": false
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/arduino/vscodeSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const configKeys = {
ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
IGNORE_BOARDS: "arduino.ignoreBoards",
SKIP_HEADER_PROVIDER: "arduino.skipHeaderProvider",
};

export interface IVscodeSettings {
Expand All @@ -22,6 +23,7 @@ export interface IVscodeSettings {
enableUSBDetection: boolean;
disableTestingOpen: boolean;
ignoreBoards: string[];
skipHeaderProvider: boolean;
updateAdditionalUrls(urls: string | string[]): void;
}

Expand Down Expand Up @@ -69,6 +71,10 @@ export class VscodeSettings implements IVscodeSettings {
this.setConfigValue(configKeys.IGNORE_BOARDS, value, true);
}

public get skipHeaderProvider(): boolean {
return this.getConfigValue<boolean>(configKeys.SKIP_HEADER_PROVIDER);
}

public async updateAdditionalUrls(value) {
await this.setConfigValue(configKeys.ADDITIONAL_URLS, value, true);
}
Expand Down
4 changes: 4 additions & 0 deletions src/langService/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from "vscode";
import * as constants from "../common/constants";
import * as util from "../common/util";

import { VscodeSettings } from "../arduino/vscodeSettings";
import ArduinoActivator from "../arduinoActivator";
import ArduinoContext from "../arduinoContext";
import { ArduinoWorkspace } from "../common/workspace";
Expand Down Expand Up @@ -35,6 +36,9 @@ export class CompletionProvider implements vscode.CompletionItemProvider {

public async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position):
Promise<vscode.CompletionItem[]> {
if (VscodeSettings.getInstance().skipHeaderProvider) {
return [];
}
if (!ArduinoContext.initialized) {
await ArduinoActivator.activate();
}
Expand Down