How to add Format config file to VSCode workspace using Ionide - visual-studio-code

I want to add specific workspace setting for Formatting for F#
I see that Ionide for VSCode uses FsAutoComplete which in turns uses Fantomas as the Formatter and that Fantomas has config file support (not documented), but I tried to add .fantomas-config and fantomas-config.json in the root of my project and the config file was ignored.
Ultimately what I want to achieve is:
preserve new lines made by me.
set the "word wrap" column length
Other common formatting options like indentation etc.

Related

How to get the same format for vim-prettier and vscode-prettier?

I have vim-prettier installed and also have the vscode extension for prettier installed.
They format differently however. I would like to use vim-prettier to format the same way I would for vscode's prettier.
I followed vscode's configuration and it lead me to /home/user/.prettierrc.json but it is empty and only has {} inside of it.
I put let g:prettier#autoformat = ["/home/user/.prettierrc.json"]
inside my .vimrc file but it does not format to the same way vscode-prettier does.
Is there a way to do this?
So first I tried whereis prettier and compared it to the value i get from running :PrettierCliPath
prettier is in /usr/local/bin/prettier
and the one that vim uses is in /home/user/node_modules/.bin/prettier
I tried to set my vimrc to point to the first one via
let g:prettier#exec_cmd_path = "~/path/to/cli/prettier"
But it didn't work. It gave me a syntax error whenever I tried to run prettier in vim.
After a long time I noticed this line in the README for vim-prettier
Note: vim-prettier default settings differ from prettier intentionally. However they can be configured by:
and it gave a bunch of settings like let g:prettier#config#print_width = 'auto'
So I ended up just manually configuring each setting to the desired result.
Now I want to find a way to only allow these settings for a certain filetype(html) so that the formatter for html and css are different instead of the same.

VSCode emmet issue after changing case for file name

I am new to using VSCode and emmet for expanding filenames, etc.
Currently, I'm working on a React project and found an issue where, for example:
I create a files named, say, myfile.jsx for my MyFile component
Realize I want the file name capitalized to match the component name, so I rename it to MyFile.jsx
When trying to use emmet to import the file to use the component in, say, my App.js it imports the old filename myfile.jsx (without the updated casing).
In other words, emmet is not picking up in the change in casing for file names.
Is there a way to somehow refresh the cache for emmet / have this update without having to restart VSCode?
Thanks!

VSCode convert project to 4 spaces

I used the Vue cli to create a project and it uses 2 spaces by default. I want to get 4 spaces. I've turned off detect indentation, set tab size to 4 but no amount of running format document will change - for example - this little js file that was created.
I also tried to change things with eslint. It spots the errors but --fix has no effect
If I start a new object then the spaces are correct though.
I am using an extension called Vetur and in my VS Code settings file I added the following rule: "vetur.format.options.tabSize": 4,
Also for initial indentation I have added the following rules:
"vetur.format.styleInitialIndent": true,
"vetur.format.scriptInitialIndent": true,
If you are not using this extension, do you have a .editorconfig file in your solution and/or have you looked at your VS Code settings for conflicting rules?

Any way to have workspace/folder settings ONLY apply to files in that workspace/folder and not random files outside the workspace?

I know about workspace settings. My issue is that workspace settings also apply to any files that are opened not in that workspace. Example:
"editor.formatOnSave": true // put this in some workspace settings.
open a file not in that workspace (maybe in a different project) in the same window. This happens when I type $ code ~/someFile.txt
When I save that file, it gets formatted when it shouldn't.
Any workarounds?
Specifically for saving a file without formatting, try new command for saving without formatting. Just added in v1.28.0:
The new command Save without Formatting
(workbench.action.files.saveWithoutFormatting) can be used to save a
file without triggering any of the save participants (for example,
formatters, remove trailing whitespace, final newline). The default
keybinding is Ctrl+K S. This is useful when editing files outside your
normal projects, which may have different formatting conventions.

How to set default file type to be All Files(*.*) in VS Code?

Now my default file type of Visual Studio Code is Plain Text.
If I save a new file with name like a.in, it will save as a.in.txt. I have to change the dropdown to All Files.
I find the same problems in github: 1, 2. However, they seem not solve my problem.
This is not possible in the general case in VSCode.
The issue is that you cannot assign "no extension" to a language, and as per the links you mentioned, the All Files (*.*) option is disabled by upstream (electron).
Therefore, you will either have to remove the extension manually, OR you can create the file first (using the terminal, Explorer, an extension, etc.) and then open that existing file.
There is a way to change the default extension (but not to All Files)
Add the following line to your settings.json
"files.defaultLanguage": "<language>",
Replace <language> with the language of your choice.
Now, whenever you make a new a file, the default file language will be <language>.
A special value for <language> is ${activeEditorLanguage} which is the language of the file last opened (useful if, say, you copy a piece of code from one file to save as another).
Unfortunately, this does not fully answer the question, but provides a partial solution.