Skip to content

Commit 684b182

Browse files
committed
allow create clang-format file
1 parent 39317df commit 684b182

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@
549549
"category": "eide",
550550
"title": "%eide.function.reinstall.binaries%"
551551
},
552+
{
553+
"command": "eide.create.clang-format.file",
554+
"category": "eide",
555+
"title": "Create a new .clang-format template file"
556+
},
552557
{
553558
"command": "_cl.eide.workspace.build",
554559
"title": "%eide.workspace.build%",

res/data/.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ SortIncludes: false
3535

3636
AlignConsecutiveMacros: AcrossEmptyLines
3737

38-
AlignConsecutiveAssignments: AcrossEmptyLines
38+
#AlignConsecutiveAssignments: AcrossEmptyLines

src/extension.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export async function activate(context: vscode.ExtensionContext) {
122122
subscriptions.push(vscode.commands.registerCommand('eide.ReloadJlinkDevs', () => reloadJlinkDevices()));
123123
subscriptions.push(vscode.commands.registerCommand('eide.ReloadStm8Devs', () => reloadStm8Devices()));
124124
subscriptions.push(vscode.commands.registerCommand('eide.selectBaudrate', () => onSelectSerialBaudrate()));
125+
subscriptions.push(vscode.commands.registerCommand('eide.create.clang-format.file', () => newClangFormatFile()));
125126

126127
// internal command
127128
subscriptions.push(vscode.commands.registerCommand('_cl.eide.selectCurSerialName', () => onSelectCurSerialName()));
@@ -308,6 +309,25 @@ function updateSerialportBarState() {
308309
}
309310
}
310311

312+
async function newClangFormatFile() {
313+
314+
let root = WorkspaceManager.getInstance().getWorkspaceRoot();
315+
if (!root) {
316+
const li = WorkspaceManager.getInstance().getWorkspaceList();
317+
if (li.length > 0) {
318+
root = li[0];
319+
}
320+
}
321+
322+
if (root) {
323+
const fSrc = File.fromArray([ResManager.GetInstance().GetAppDataDir().path, '.clang-format']);
324+
fs.copyFileSync(fSrc.path, [root.path, '.clang-format'].join(File.sep));
325+
vscode.window.showInformationMessage(`.clang-format file was created in '${fSrc.dir}' !`);
326+
} else {
327+
vscode.window.showWarningMessage(`No opened workspace or folders !`);
328+
}
329+
}
330+
311331
async function onSelectSerialBaudrate() {
312332

313333
const baudList: string[] = [

0 commit comments

Comments
 (0)