Look for clang-format installed on system before defaulting to bundled version (#4855)
This commit is contained in:
@@ -1768,6 +1768,7 @@
|
||||
"vscode-extension-telemetry": "^0.1.2",
|
||||
"vscode-languageclient": "^5.2.1",
|
||||
"vscode-nls": "^4.1.1",
|
||||
"which": "^2.0.2",
|
||||
"yauzl": "^2.10.0"
|
||||
},
|
||||
"resolutions": {
|
||||
@@ -1938,4 +1939,4 @@
|
||||
"binaries": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"c_cpp.command.rescanWorkspace.title": "Rescan Workspace",
|
||||
"c_cpp.command.vcpkgClipboardInstallSuggested.title": "Copy vcpkg install command to clipboard",
|
||||
"c_cpp.command.vcpkgOnlineHelpSuggested.title": "Visit the vcpkg help page",
|
||||
"c_cpp.configuration.clang_format_path.description": "The full path of the clang-format executable.",
|
||||
"c_cpp.configuration.clang_format_path.description": "The full path of the clang-format executable. If not specified, and clang-format is available in the environment path, that is used. If not found in the environment path, a copy of clang-format bundled with the extension will be used.",
|
||||
"c_cpp.configuration.clang_format_style.description": "Coding style, currently supports: Visual Studio, LLVM, Google, Chromium, Mozilla, WebKit. Use \"file\" to load the style from a .clang-format file in the current or parent directory. Use {key: value, ...} to set specific parameters. For example, the \"Visual Studio\" style is similar to: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4 }",
|
||||
"c_cpp.configuration.clang_format_fallbackStyle.description": "Name of the predefined style used as a fallback in case clang-format is invoked with style \"file\" but the .clang-format file is not found. Possible values are Visual Studio, LLVM, Google, Chromium, Mozilla, WebKit, none, or use {key: value, ...} to set specific parameters. For example, the \"Visual Studio\" style is similar to: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4 }",
|
||||
"c_cpp.configuration.clang_format_sortIncludes.description": "If set, overrides the include sorting behavior determined by the SortIncludes parameter.",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { CommentPattern } from './languageConfig';
|
||||
import * as which from 'which';
|
||||
|
||||
function getTarget(): vscode.ConfigurationTarget {
|
||||
return (vscode.workspace.workspaceFolders) ? vscode.ConfigurationTarget.WorkspaceFolder : vscode.ConfigurationTarget.Global;
|
||||
@@ -30,7 +31,14 @@ export class CppSettings extends Settings {
|
||||
super("C_Cpp", resource);
|
||||
}
|
||||
|
||||
public get clangFormatPath(): string { return super.Section.get<string>("clang_format_path"); }
|
||||
public get clangFormatPath(): string {
|
||||
let path: string = super.Section.get<string>("clang_format_path");
|
||||
if (!path) {
|
||||
path = which.sync('clang-format', {nothrow: true});
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public get clangFormatStyle(): string { return super.Section.get<string>("clang_format_style"); }
|
||||
public get clangFormatFallbackStyle(): string { return super.Section.get<string>("clang_format_fallbackStyle"); }
|
||||
public get clangFormatSortIncludes(): string { return super.Section.get<string>("clang_format_sortIncludes"); }
|
||||
|
||||
+1
-1
@@ -5335,7 +5335,7 @@ [email protected], which@^1.2.14, which@^1.2.9, which@^1.3.1:
|
||||
dependencies:
|
||||
isexe "^2.0.0"
|
||||
|
||||
which@^2.0.1:
|
||||
which@^2.0.1, which@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
|
||||
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
|
||||
|
||||
Reference in New Issue
Block a user