Rust-Analyzer VSCode-Plugin with Tauri - visual-studio-code

When working on a Tauri project in VSCode, I get the following error message from the rust-analyzer plugin.
rust-analyzer failed to discover workspace
I know that the cause of the problem is that I loaded the Tauri project as my workspace in VSCode which does not have a Cargo.toml in its project root, but in the Rust-related sub-directory src-tauri. Is there a way I can tell the plugin that it should refer to this sub-directory src-tauri for the Cargo.toml? The workaround is to switch the workspace to src-tauri every time I touch the Rust code, which is quite inconvenient.

You can use the rust-analyzer.linkedProjects setting in VSCode. It takes a list of paths pointing to Cargo.toml files.
Try adding this to your settings.json:
"rust-analyzer.linkedProjects": [
"src-tauri/Cargo.toml",
],

Related

Why doesn't emmet.extensionsPath default to the .vscode/ folder?

I have just started customizing my VS Code project with some project specific emmet snippets (by adding a snipptest.json into the project).
It is possible to just configure "emmet.extensionsPath": [".vscode/"], which will make the snippets file be found for every project.
No I ask myself: Why do I need to manually add the .vscode folder to the emmet search path?
Is there a potential problem with that configuration I don't see? OR other reasons I shouldn't do this?
And if this is totally valid, why isn't this the default behaviour?

Visual Studio Code .vscode directory disappeared from workspace

Today when I opened my workspace in VS code, one of my extensions displayed an error message, telling me that there is some option missing in settings. I went looking for it in settings.json, just to find out my whole .vscode directory is gone along with settings.json file in it, and now I have to create everything from scratch once again. I checked reciclyng bin, it wasn't there either. I don't know whether it's a VS code problem, or somme Windows 10 shenanigans, but I can't be sure this won't happen again, because I have no idea how it happened in the first place.
If you are working on a collaborative project with colleagues or other devs then someone might have changed the settings in .vscode/setting.json
Check this issue
You can exclude files and folder to hide in workspace by adding files.exlude in the settings.json file

VSCode hides folder contents when certain files are opened

I have an angular project open in VSCode, but whenever I activate certain file tabs it hides every file & folder inside my src/ directory!
Here's a screen recording of what happens: https://imgur.com/kQrIUdQ
No other folders are affected, and nothing is actually chnaged in the src/ folder. I can seect a *.ts file, close VSCode, and then re-open it with that *.ts file active and the folder contents shows again until I activate a tab that does this again.
This is extremely annoying and I've never seen this happen before. let me know if you need any other information to help diagnose this issue.
Edit: My installed extensions are as follows:
Angular Language Service 0.1.11
AutoHotkey 0.2.2
C# 1.18.0
Code Spell Checker v1.6.10
Hosts Language v1.1.1
npm v0.3.5
npm Intellisense v1.3.0
Prettify JSON v0.0.3
stylelint v0.48.0
TSLint v1.0.0

VSCode code autocomplete behavior

I noticed that VSCode uses only the files that are opened in editors (tabs) for looking up names for code auto complete. It is strange for me. To my mind the more usual behavior is to look up all files in opened folder, but not use only the opened files. Is this behavior by design ?
Try creating a jsconfig.json file at the root of your workspace:
{
"exclude": [
"node_modules"
]
}
This tells VSCode to treat all JS files in your workspace as part of a single project, even if the files have not been opened yet. You can find more information about jsconfig.json files in our documentation
Actually, to consider the opened folder as JS project, the "jsconfig.json" is required. Read more here

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?