jbockle / format-files Goto Github PK
View Code? Open in Web Editor NEWVS Code extension to format all files in workspace
VS Code extension to format all files in workspace
I use a lot of external libraries, so it would be very nice to run format on all files, but not those in my .gitignore
I wasted much time on
[12:18:02 error] (try-open-document) Unable to open file utils.cpython-36.opt-1.pyc: cannot open file:///utils.cpython-36.opt-1.pyc. Detail: File seems to be binary and cannot be opened as text
although I set "pyc,yaml,sh,png" in the Exclude Pattern. (tried with/without the quotes)
Hi
I have this option in my settings
"tslint.autoFixOnSave": true,
When using format files, it doesn't apply tslint autofixes on the modified files
Can you add it to your plugin?
Egret Wing open project,right click show “Start Format Files: Workspace” ,after click show “Format Files requires an active workspace, please open a workspace and try again”. but in vscode it work well
Goal: to format all files (at any level) at a path (say src). The most general regex.
Todo: This should be a UI option.
Problem: I always forget the regex for this.
The setting won't be applied if it is saved directly in the editor. VSCode has to be reopened to apply the changed settings.
In v3.0.0 you could right click a folder and format all it's contents, but now in 3.1.2 you can only format the entire workspace.
Only origin "*" could work, if I use "c,h,cpp,hpp" instead, it won't match or only match one file.
This is a great tool. Thank you for your effort.
With python I have a __pycache__
folder on most folder levels and I would like to ignore all of them.
I tried:
"formatFiles.excludedFolders": [
".vscode",
".git",
".mypy_cache",
"__pycache__"
],
but this does not work.
I tried adding wildcards, but no luck either.
Also tried the same with the excludePattern
option.
Hi
Your extenstion is super cool, I needed support to format only git checked out files in my workspace so I added that support to your extenstion.
Let me know if this interests you and how I can open a pull request for it ?
Thanks!
How to open progress bar after I close that?
Using the following settings :
"formatFiles.extensionsToInclude": "c,h",
"formatFiles.excludePattern": "**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h",
And launching the formatFiles.start.workspace
command, the extnesion does not find any files to format :
[14:52:51 info.] (ext) Starting Format Files - Workspace
[14:52:51 info.] (validate-in-workspace) found workspace folders: Gpu
[14:52:51 info.] (validate-in-workspace) workspace is valid!
[14:52:51 info.] (select-workspace-folder) a single workspace folder was found, selecting Gpu
[14:52:51 info.] (get-files) creating include glob
[14:52:51 info.] (get-files) **/*.c,h
[14:52:51 info.] (get-files) creating exclude glob
[14:52:51 info.] (get-files) including files.exclude globs
[14:52:51 info.] (get-files) {**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:52:51 info.] (get-files) searching for files in workspace folder 'Gpu' include:**/*.c,h exclude:{**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:52:51 info.] (get-files) Discovered 0 files to format
[14:52:54 info.] (confirm-start) result: undefined
[14:52:54 error] (ext) OperationAborted::
Whereas launching from formatFiles.start.fromGlob
command, using respevely **/*.c
and **/*.h
pattern, the extension finds the files :
[14:57:23 info.] (ext) Starting Format Files - By Glob Pattern
[14:57:23 info.] (validate-in-workspace) found workspace folders: Gpu
[14:57:23 info.] (validate-in-workspace) workspace is valid!
[14:57:23 info.] (select-workspace-folder) a single workspace folder was found, selecting Gpu
[14:57:26 info.] (request-glob) glob entered: **/*.c
[14:57:27 info.] (workspace-validator) Use default excludes?: Yes - Use 'formatFiles' settings in vscode
[14:57:27 info.] (get-files) creating exclude glob
[14:57:27 info.] (get-files) including files.exclude globs
[14:57:27 info.] (get-files) {**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:57:27 info.] (get-files) searching for files in workspace folder 'Gpu' include:**/*.c exclude:{**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:57:27 info.] (get-files) Discovered 29 files to format
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Unit_testing\Test_suites\TS_helloworld\src\TS_HW.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Unit_testing\Test_suites\TS_GLOBAL\src\UTmain.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\array_converter.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\utils.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\moteur_graphe.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\moteur_can.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\crc8.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\crc32.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\crc16.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_timer_synchrone.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_i2c_generique.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_gpio.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_can.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_init.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_gestion_dc.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_etat.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_can.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Data\Src\def_etat.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Data\Src\def_data.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\factory.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_led.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_graphe.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_gpio.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_gestion_puissance.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_gestion_mesure.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_defaut.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\App\Src\api_can.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Configuration\Src\main.c
[14:57:27 info.] (get-files) c:\repo\EmbeddedC\Gpu\Application\Configuration\Src\configurateur.c
[14:57:37 info.] (confirm-start) result: Nevermind
[14:57:37 error] (ext) OperationAborted::Nevermind
Steps to reproduce:
Start format files from workspace
Expected results:
Dialog should show "Start formatting X workspace files?" and then proceeds to formatting the files.
Actual results:
Dialog shows "Start formatting 0 workspace files?" and then nothing happens.
OBS: works fine if I choose the 1st folder.
Shouldn't it by default format only code files and ignore binary files and configure files (.vscode
, .git
)?
Would be handy if we could run formatting on glob matching files.
Much like this plugin opens files via glob pattern https://marketplace.visualstudio.com/items?itemName=bcanzanella.openmatchingfiles
I didn't see any rule-settings in the extension.
Is there a dependency for it, that config the rules?
When format-files is running the status bar offers a button "Cancel formatting". The full output looks something like this:
[Spinner icon] formatting documents: Formatting [path name] [Workspace] Cancel formatting
However, it is really hard to actually click on "Cancel formatting" because its position constantly changes based on how long [path name] is.
Suggestion: Move the button to the left of [path name], so that its position is fixed.
I can't get it to find any files, either using Start Format Files: From Glob or Start Format Files: From Workspace. The log always says
Discovered 0 files to format
It does seem like a standard directory many python users might have. See e.g. github/gitignore#2371
Other ideas would be to ignore .*
by default or even to parse .gitignore
I get an outcome of:
::::::::::::::::::::::::::::::::::::::::::::::::::
[09:01:54 info.] (ext) Starting Format Files - Workspace
[09:01:54 info.] (validate-in-workspace) found workspace folders: crawler
[09:01:54 info.] (validate-in-workspace) workspace is valid!
[09:01:54 info.] (select-workspace-folder) a single workspace folder was found, selecting crawler
[09:01:54 info.] (get-files) creating include glob
[09:01:54 info.] (get-files) folder specified: /c:/Or/Web/crawler/crawler
[09:01:54 info.] (get-files) creating exclude glob
[09:01:54 info.] (get-files) including files.exclude globs
[09:01:54 info.] (get-files) {/node_modules,/.vscode,/dist/,/.chrome,/misc,/sources,/.git,/.svn,/.hg,/CVS,/.DS_Store}
[09:01:54 info.] (get-files) searching for files in workspace folder 'crawler' include:/c:/crawler//. exclude:{/node_modules,/.vscode,/dist/,/.chrome,/misc,/sources,/.git,/.svn,/.hg,/CVS,**/.DS_Store}
[09:01:54 info.] (get-files) Discovered 0 files to format
[09:01:55 info.] (confirm-start) result: Do it!
[09:01:57 info.] (ext) Format Files completed
It says it's disabled because of dependencies.
The dependency is "git" extension.
Can you make it an "optional" dependency, because I don't want this extension doing anything git related.
I have disabled Git extension in vs-code because I don't want all the git vscode commands clogging up the commands list.
I understand I wont be able to use the "ignore git ignore" feature, and that is fair enough, I had no intention of using that anyway.
Hey there,
first i would like to say thank you for the awesome extension. Its a pitty that an extension is required for such a standard feature but you really nailed it.
Sadly i discovered a problem what i think is a memory leak. It happens when i try to format my entire solution which have a lot of files (thousands). But the problem appears also a lot faster (hundred of files).
Observing the memory consumption you can see how it goes up and never comes down again, so you have to restart VSCode and format files folder by folder which i bet is not the intention.
Do you have any idea what could cause the issue?
Im working with the latest official VSCode and the latest MS C++ plugin on a CentOs 7.
Best Regards
Nick
Some of the files in my project are auto generated by an external tool. They are not formatted according to the project formatting rules. I would like to:
If it is helpful, the code generator can also generate a list (full path) of the generated files
For example:
# .gitignore
node_modules
After enable formatFiles.useGitIgnore
:
/myrepo/node_modules/blabla
: ignored as expected.
/myrepo/packages/module-a/node_modules/blabla
: BOOM!!!
Are there any solution for this?
I noticed that after having run "FormatFiles" my TypeScript imports would be rearranged when saving the file.
I have this option enabled:
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
Example:
Result after "FormatFiles"
import {
Directive,
HostListener,
Input,
Output,
EventEmitter
} from "@angular/core";
Result after manually saving the file
import {
Directive,
EventEmitter,
HostListener,
Input,
Output
} from "@angular/core";
I was wondering if more info can be displayed in the Output.
I'm looking for a "base path" so we have an idea where the glob starts from. And "glob used" so we can tell if something funky is going on.
Currently the output looks like this for "Start Format Files: Workspace"
[_info:16:08:32] Starting Format Files - Workspace
[_info:16:08:32] Validating workspace
[_info:16:08:32] Workspace is valid!
[_info:16:08:32] creating include glob
[_info:16:08:32] folder specified: /C:/Users/my-user/Source/test-format-files/bar
[_info:16:08:32] creating exclude glob
[_info:16:08:32] {**/node_modules,**/.vscode,**/dist/**,**/.chrome}
[_info:16:08:32] Found 0
Adding glob pattern to that
[_info:16:08:32] Starting Format Files - Workspace
[_info:16:08:32] Validating workspace
[_info:16:08:32] Workspace is valid!
[_info:16:08:32] creating include glob
[_info:16:08:32] folder specified: /C:/Users/my-user/Source/test-format-files/bar
[_info:16:08:32] glob pattern: * <------------
[_info:16:08:32] creating exclude glob
[_info:16:08:32] {**/node_modules,**/.vscode,**/dist/**,**/.chrome}
[_info:16:08:32] Found 0
Currently output for "Start Format Files: From Glob"
[_info:16:16:56] Starting Format Files - By Glob Pattern
[_info:16:16:56] Validating workspace
[_info:16:16:56] Workspace is valid!
[_info:16:17:02] Found 2
[_info:16:17:02] /c:/Users/my-user/Source/test-format-files/foo/f1.html
[_info:16:17:02] /c:/Users/my-user/Source/test-format-files/bar/b1.html
Adding base path and glob pattern to that
[_info:16:16:56] Starting Format Files - By Glob Pattern
[_info:16:16:56] Validating workspace
[_info:16:16:56] Workspace is valid!
[_info:16:16:56] creating include glob
[_info:16:16:56] folder specified: /C:/Users/my-user/Source/test-format-files <------------
[_info:16:16:56] glob pattern: *.html <------------
[_info:16:17:02] Found 2
[_info:16:17:02] /c:/Users/my-user/Source/test-format-files/foo/f1.html
[_info:16:17:02] /c:/Users/my-user/Source/test-format-files/bar/b1.html
Should make it a bit easier to work out what's going on when stuff isn't behaving as you expect :)
After updating my VSCode to version 1.87, the option to start formatting from within the work tree is greyed out and cannot be clicked. "By Glob" still works.
I've tried an extension bisect and doesn't seem to be a conflict with a different extension.
Would be handy with some kind of progress bar
Given this workspace config
"settings": {
"formatFiles.excludePattern": "**/node_modules/**"
}
I'm seeing this in the log
[14:59:02 info.] (ext) Starting Format Files - Workspace Folder
[14:59:02 info.] (validate-in-workspace) found workspace folders: Backend, Frontend
[14:59:02 info.] (validate-in-workspace) workspace is valid!
[14:59:02 info.] (files-api) searching for files in workspace c:\Users\myuser\my-project
[14:59:02 info.] (files-api) getting include filter
[14:59:02 warn.] (files-api) no filters specified
[14:59:02 info.] (files-api) getting exclude filter
[14:59:02 info.] (files-api) exclusions glob: {**/node_modules/**}
[14:59:02 info.] (files-api) filtering by folder: c:\Users\myuser\my-project\frontend
[14:59:02 info.] (files-api) executing search
[14:59:02 debug] (files-api) excluded:false frontend\node_modules\.package-lock.json
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\ReplaySubject.d.ts
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\ReplaySubject.js
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\ReplaySubject.js.map
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\Rx.d.ts
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\Rx.js
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\Rx.js.map
[14:50:29 debug] (files-api) excluded:false frontend\node_modules\@angular-devkit\build-angular\node_modules\rxjs\Scheduler.d.ts
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\about\compodoc\compodoc.component.html
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\about\compodoc\compodoc.component.ts
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\about\todomvc\todomvc.component.html
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\about\todomvc\todomvc.component.ts
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\shared\components\dumb-component.ts
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\shared\components\dumb-parent-component.ts
[14:55:38 debug] (files-api) excluded:false frontend\node_modules\@compodoc\compodoc\.tmp-compodoc-test-big-app\src\app\shared\components\generic.component.ts
Those paths should be covered by **/node_modules/**
It does not look like format-files is respecting VSCode's workspace settings in its formatFiles.excludePattern pattern. If I ignore files and folders in my workspace, I would expect format-files to follow that. So I guess this is a feature request? :)
[16:53:06 info.] (get-files) searching for files in workspace folder 'pk-next' include:/Users/jon/repos/pk-next/**/*.* exclude:{**/node_modules,**/.vscode,**/dist/**,**/.chrome,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store,**/build,**/logs,**/node_modules,!.vscode,.*,.circleci,**/.next,*.postman_*,**/__mocks__,**/__tests__,**/_testConfig_,**/.messages,**/*.snap,**/package-lock.json,**/yarn.lock,build,docker*,lang,locales,migrations,models,pk-api-process.json,schema,scripts,shipitfile.js,testNotes.txt}
[16:53:06 info.] (get-files) Discovered 0 files to format
I'm guessing the multiple workspace changes caused single folder workspaces to break.
Useful extension, but it skips certain files like .html in my Angular project.
I've updated the settings, but html files are still skipped. CSS files as well.
"formatAll.includeFileExtensions": [
".ts",
".json",
".html"
]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.