Q: Can I configure VSCode to take a .clang-format file from my home directory? - visual-studio-code

I want to use the same clang-format file for all my project since I have multiple. But I don't want to have them in every workspace and i already have a clang-format file in my home directory, how can I make this work?
Or is this impossible?
I have already seen this question:
How can i configure clang format without .clang-format file in every workspace?
but my clang-format file is like 80 lines long and I just want to edit the stuff locally on my home without having to change it in vscode as well.

Maybe this will help.
The clang-format -style=file is somewhat misleading.
file is not the path to the file you want but rather tells clang-format to use the .clang-format file it can find within the project folders - going all the way up.
And as VSCode is the case, the C++ extension is using by default the clang-format in the VSCode extensions folder.
Which should make the clang-format to go cd .. until it finds .clang-format in your workspace folder

Set "clang-format.style": "file" property to fix it.

Related

Can VS Code editor workspace files specify default starting directory

I want to have a single place to store all my Visual Studio Code editor workspace files. I know I can use Workspaces: Save Workspace As to save the workspace file wherever I want, however, when I open a terminal the current working directory is the location where the workspace file is stored. I want to be able to specify (for each individual workspace) what the starting directory should be. Is that possible?
I discovered that by default the path element of the -workspace file is stored relative to the workspace file. By changing that to store the absolute path (which, I understand may not be the solution in all cases), it does work as I was intending.

Configuring VSC clang format with global.clang-format file

I basically have a similiar question to this one:
How can i configure clang format without .clang-format file in every workspace?
I'm using the Visual Studio Code editor (version 1.43) with the Clang-Format extension developed by Xaver (https://marketplace.visualstudio.com/items?itemName=xaver.clang-format#overview)
I adjusted the clang extension settings "Clang-format: Executable" option to point to the "clang-format.exe" of my VSC installation.
Furthermore I set "Clang-format: Style" to "file".
My clang-file is currently located inside my projects source folder.
As I want to use my clang settings for every project and don't want to copy the clang file into every project workspace manually (and maybe have to change every single copy later on), I tried to make the extension use a globally located clang-file which is inside the VSCs extention folder.
So my first approach was to relocate the clang-file into the "VSC 1.43\data" directory.
My second attempt was to locate it right inside the extension folder "C:\User\VSC 1.43\data\extensions\xaver.clang-format-1.9.0" where a default file was already present.
Unfortunately both attempts seem not to work. I can invoke the formatting with "Format Document" but another clang file seems to get utilized.
Only if I put the file back into the source code directory, my clang rules are getting utilized correctly.
So basically:
MyProject\SourceCode\clang-file --> Works
VSC\data\clang-file --> Doesn't work
VSC\data\extensions\xaver.clang-format-1.9.0\clang-file --> Doesn't work
Can I tell the extension to search for the clang file inside of the extensions installation directory instead of the current workspace?
Note: I just installed the clang-format extension and adjusted the mentioned extension settings above. I did not tamper with the VSC settings.json.
Thank you in advance and best regards :)
Evox402
As specified in the documentation:
When using -style=file, clang-format for each input file will try to find the .clang-format file located in the closest parent directory of the input file. When the standard input is used, the search is started from the current directory.
Actually I believe it searches for either .clang-format or _clang_format.
This explains:
MyProject\SourceCode\clang-file --> Works
You could move the .clang-format file to MyProject, or any parent directory above that, so that it is shared between projects.

vscode multiroot workspace path environment variable

I am using the multiroot workspace functionality to view source files from my c project along with several external libraries. I am using trying to use cpptools extension for intellisense and other functionality. I would like to set default include paths at the workspace level relative to the .code-workspace file. Using ${workspaceFolder} resolves to the path of the folder containing the viewed file. Is there an environment variable that will always resolve the path of the code-workspace file? Or is the a configuration variable I can set and then use ${config:variable}?
I have tried using variables scoped per workspace as described here: https://code.visualstudio.com/docs/editor/variables-reference#_variables-scoped-per-workspace-folder. But, that did not work either. I could use absolute paths and everything would work fine, but I am trying to keep things portable so other people can check out the repository and simply open the .code-workspace file and have everything set up already.
At the time of the question the cpptools extension did not support the ${workspaceFolder:} syntax for enviroment variables. With the latest update, this is now working.

Where is the config folder for JetBrains IDE?

I am trying to add a custom color theme to my phpstorm and everything I read says you need to add a colors folder inside of the config folder, and then copy the xml or icls file in there, but I can't find the config folder.
C:\Program Files\JetBrains\PhpStorm 2017.1.3
I am in the right directory but there is no folder called config and I'm not sure what to do. Could it be in some different place?
have a look at
https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs
you should find your config files under
c:\Users\yourname\.PhpStorm2016.1\config

Disable Auto Generation of .vscode Folder

I often like to use VSCode to quick view some projects to pull snippets from them. However, this leads to a ton of additional .vscode folders being placed on my drive in any folder I use the right-click -> Open with VSCode option.
Is there a way to disable this folder from being created every time vscode loads somewhere new?
This issue was due to the 'C/C++ for Visual Studio Code' extension being outdated.
Upgrading to the latest version of this extension has fixed the problem.
That is not the standard behaviour of VSCode, normally the .vscode only gets generated once there is something like a launch.json put into it. Mind checking what's actually in there?