I created a new project with create-react-app. I have configured prettier tool. Unfortunately, formatting on save doesn't work on this project. Works fine on other projects. What could have happened?
My VSCode setting is:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSaveMode": "modifications",
}
Since this is a new project, I presume that means it is not in source control. The setting "modifications" will not work in that situation, as described on the site (https://code.visualstudio.com/docs/getstarted/settings):
// Controls if format on save formats the whole file or only modifications. Only applies when `editor.formatOnSave` is enabled.
// - file: Format the whole file.
// - modifications: Format modifications (requires source control).
// - modificationsIfAvailable: Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted.
Try using "modificationsIfAvailable" instead:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSaveMode": "modificationsIfAvailable",
}
Related
I am using VSCode with the clangd extension for C++ development (through Remote SSH extension). I have my .clang-format and .clang-tidy files with the rules I want to enforce. If I format the code manually (either Ctrl-Alt-F or right click -> Format document) the code gets formatted without any issues. Same if I manually go for the clang-tidy suggested fixes (Ctrl-.). Instead, if I save, nothing happens.
These are my settings overrides for C++. I tried moving them inside the different levels (User, Remote, Workspace) but there is no difference.
"[cpp]": {
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
}
The same rules for ESLint or rustfmt work with no issues.
I investigated the quick-fix issue a bit, and found that "editor.codeActionsOnSave": { "source.fixAll": true } relies on a new Language Server Protocol (LSP) enhancement added in LSP 3.17 (code actions with type source.fixAll).
Clangd does not currently support this, but it seems to me like it shouldn't be too difficult to add support for it, as clangd already classifies quick-fixes based on whether they're suitable for being applied automatically (e.g. Select All --> "Auto Fix..." makes use of this).
I filed https://github.com/clangd/clangd/issues/1446 with some more details.
I use a simple java code to generate doxc to PDF. The library is used to conversation is documents4j.
The same code is run in one machine, and not run in another. The other machine always get "com.documents4j.throwables.ConversionInputException: The input file seems to be corrupt" error.
VB script occurs the problem:
if i delete the "dummy-password-to-avoid-lock" string, it works fine.
Occurs error: Set wordDocument = wordApplication.Documents.Open(inputFile, False, True, False, "dummy-password-to-avoid-lock")
Generate PDF fine: Set wordDocument = wordApplication.Documents.Open(inputFile, False, True, False)
Is there any possibility to change VBSscript from java code?
Example the converter? IConverter converter = LocalConverter.builder().setVBScript().build(); ?
This seems to be a problem introduced in documents4j version 1.1.3. Try the previous version 1.1.2. I might need to undo this change since older Word versions do not seem to accept the password workaround.
Friends,
I have the following code in files.exclude in User settings which I understand is global unless you want to override in Workspace settings
"files.exclude": {
"**/.terraform/": true,
"**/.plan": true,
"**/.tfstate": true
}
The above code works perfectly fine, hiding the unwanted .terraform folder but not working as expected for files ending in .plan and .tfstate or .tfstate.backup files.
I want terraform plan and state files to be ignore by Visual Studio Code, how to achieve that?
Please find below snapshot, I am still seeing .plan and .tfstate or .tfstate.backup files.:
Looks like your glob patterns are off. Assuming you want these exclusions to be recursive, I believe you're looking for this:
"files.exclude": {
"**/.terraform/": true,
"**/*.plan": true,
"**/*.tfstate*": true,
}
I'm using organizeImports on save, but there are some instances where the order matters and this causes an issue. I can't find anywhere if there's a way to simply ignore a page, either through comments within the page (ideally) or within the config settings.
Perhaps there's an extension that provides this functionality if not baked in. In any case, really appreciate any help tracking down a solution for this.
Couldn't find how to do it properly but here is a solution that might solve your end needs if you use prettier.
The way I handled organizeImports selectively for files was as follow.
1 - Make sure your default formatter is prettier (as explained below)
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
2 - In your settings set formatOnSave to true but organizeImports to false such as below.
{
"editor.codeActionsOnSave": {
"source.organizeImports": false
},
"editor.formatOnSave": true
}
3 - Install https://github.com/simonhaenisch/prettier-plugin-organize-imports
This is a prettier plugin that allows organizing import as part of the prettier formatting and has an option to disable organize import for files (i.e. // organize-imports-ignore )
If you're using ESLint (which I would highly recommend), you can use sort-imports or import/order (via eslint-plugin-import) to sort your import statements across the entire project, then ignore the rule in specific files/regions with special comments, like this:
/* eslint-disable import/order */
import * from "abcdefg";
import "cool-module";
// etc...
VSCode has a great ESLint plugin, which in combination with
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
will auto format and fix your code whenever the file is saved.
I need to ignore .history folder from intellisense.
Now it looks like this when I start typing Focus:
As you can see intellisense will offer me every Identical class found in .history folder and this is very very confusing (and find correct one).
I try find something in vscode settings, and on editor site but no success.
.history folder is ignored from git, display in explorer, and tslint:
"files.exclude": {
"**/.history": true ...
},
"files.watcherExclude": {
"**/.history/**": true ...
},
"tslint.exclude": ["**/.history/**"] ...
How to achieve ignore .history from intellisense?
Next part is based on the answer from Matt
An important assumption:
Visual Studio Code itself does not contain automatic import and you need an extension for it.
Solution:
I am using extension Auto Import (steoates.autoimport) which contains the setting autoimport.filesToScan. I changed default value from "**/*.{ts,tsx}" to "{src,e2e,node_modules}/**/*.{ts,tsx}" and now everything work as I expected.
Those suggestions are coming whatever extension you have installed that is providing auto-import functionality. Please check to see if that extension has its own exclude setting that you also need to configure
In your settings.json, you could add this:
"autoimport.filesToScan": "./index.{ts,tsx} ./App.{ts,tsx} ./src/**.*.{ts,tsx}"
Or, if you prefer:
"autoimport.filesToScan": "./{index,App,src/**}.{ts,tsx}"