File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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%" ,
Original file line number Diff line number Diff line change @@ -35,4 +35,4 @@ SortIncludes: false
3535
3636AlignConsecutiveMacros : AcrossEmptyLines
3737
38- AlignConsecutiveAssignments : AcrossEmptyLines
38+ # AlignConsecutiveAssignments: AcrossEmptyLines
Original file line number Diff line number Diff 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+
311331async function onSelectSerialBaudrate ( ) {
312332
313333 const baudList : string [ ] = [
You can’t perform that action at this time.
0 commit comments