VS Code, Syntax highlighting Powershell - powershell

Ive been scratching my head with this one. Previously VS Code highlighted Powershell scripts and modules just fine with highlighting functions in yellow and variables $var in light blue. Both as part of a string and "stand-alone". However, suddenly it doesn't highlight functions or variables anymore? I've tried to uninstall and reinstall the powershell extension from Microsoft, as well as disable and re-enable the built in language support for powershell.
I've not been able to find any support regarding this issue and hope that I might be able to find it here.

Have you tried this?
File Association.
Basically:
The easiest way I've found for a global association is simply to Ctrl+k m (or Ctrl+Shift+P and type "change language mode") with a file of the type you're associating open.
In the first selections will be the option "Configure File Association for 'x' " (whatever file type - see image attached). Selecting this gives you the option to choose the language and will then make the filetype association permanent.

if you start your code block with a ```PowerShell it will highlight the syntax properly.
I've noticed that you may also need to end your code block with a ``` in VSCode specifically.

Related

how to specify what's considered an error, so that I can get squiggly lines

I'm programming in C, and often times I see myself forgetting to type the '&' when using scanf. I've used replit in the past and there, in that case the variable gets a squiggly underline showing it's wrong. Is there any way I could configure this in VS Code, in other words, can I specify what's considered an error?
Add the C/C++ extension from Microsoft. It will add IntelliSense
Use this link to learn how to add extensions: LINK
Use this link to read about customizing IntelliSense for your needs: LINK
(unless it already does what you need)

Adding the run-code option to a new language in VSCode

I'm currently writing my own language and I'm at a point where I would like to publish it to the VSCode-Marketplace so people can test it.
I have written a language extension and a syntax highlighter with the Yeoman-Generator and now want to merge it with my executable file that launches the interpreter, so that a file can get interpreted after clicking the run-code button.
I now have checked multiple articles, like:
How to add a run button in visual studio code? - StackOverflow
How to define or support a code language on Visual Studio? - StackOverflow
Debugger Extension Guide - VSCode API
However, I haven't found anything useful.
Currently, the code-runner displays the following error, when clicking on run, or pressing the shortcut:
(Code language not supported or defined.)
But even after a lot of browsing Google for adding new language support to the code-runner, I found absolutely nothing helpful.
(See this page, idk what Settings/Preferences they are referring to!?)
I also was not successful with tasks, as they don't seem to connect to the run-buttom or debug-button in any way.
My question is: How can I make the run-button execute a custom bash-command, when a file in my language is opened?
Okay, I finally did it.
For anyone wondering:
You have to go to the settings and type "code-runner" into the search bar.
Scroll down a little, and you should find the code runner-executor map.
Click on the "edit in settings.json" button.
Now a .json-file should've opened. There are two possible scenarios: Either, there is a json-object called code-runner.executorMapBy... or not.
If there is none, type code-runner.executorMapByFileExtension and let autocomplete do the job.
If the json-object exists, add the file-extension and a bash command that executes your compiler/interpreter. It gets automatically executed in the directory the program-file lies in.
Now still dont know, how to include the settings in my extension, but that was already a big step. Further help is still appreciated!
There is an open source extension called code runner, you can check source code there.

List of all available commands in VSCode

Where can I find the list of all commands available in VSCode and their description?
I'm only aware of these sources:
In the official docs:
This list which only seems to include a subset of Visual Studio Code commands that you might use with vscode.commands.executeCommand API (why is this only a subset of the full list?)
This other list in the keybindings doc, which also only seems to include a subset of all commands available (I suppose those tied to a default keybinding?)
In the editor itself:
I can see a list of commands when I open the "default keybindings". Many actions are commented out with //, but interestingly I don't think this includes all the commands either (e.g. maximizeOtherEditor isn't listed)
Does VSCode have an official list of commands (commandID's) either in its documentation or in its code base? If not:
What's the closest to it?
What's a good way to navigate the code base to try to find all commands and what they do?
I believe that content of "Preferences: Default Keyboard Shortcuts (JSON)" (command ID workbench.action.openDefaultKeybindingsFile) really shows comprehensive list of all native and extensions-contributed commands VSC knows about at moment when invoked.
This file shows keys from VSC's defaults and extension manifests.
Commands with no suggested defaults are those commented out at the end of file.
Their descriptions (as seen in the Command Palette, Keyboard Shortcuts settings, extension Contributions tab and elsewhere) are supposedly in localization properties and I believe there is currently no way to see them along their respective command IDs in single convenient "localized" list. So for now the only way to read the description of command found in aforementioned JSON is pasting its ID into Keyboard Shortcuts search field. (Would be delighted to be proven wrong.)
In case someone ever fell on this and just wanted a quick-list of VSCode commands to browse through: https://gist.github.com/skfarhat/4e88ef386c93b9dceb98121d9457edbf
If you do, please note the VSCode version and commit. These may well be out of date by the time you read them.

Indentation for files that don't have a registered formatter

It seems that I am getting this problem since version 1.18, honestly I don't remember.
With VSCodeVim installed I used to press the = key to get my code (Elixir, embedded elixir, ...) indented properly.
Am I missing something, like a configuration, that would allow me to re-indent my files without having a nagging "Formatter for file x not installed".
This is honestly the only things that nags me with VSCode so far, love the speed, the capabilities and the UI...
Just posting my comment as an answer
Try using the reindent lines command. This command should work for many languages even if you don't have a formatting extension for that language installed
Select the contents of file.Bottom right corner shows spaces/tabs: 2/4. You can click on that and indent the whole file.

VSCode Error/Warning Validation Decoration Setting

10 shillings to whomever can tell me how to switch the error/warning decoration in vscode from a squiggly underline to an outline. It's what I am used to in Sublime Text, but I cannot seem to find the option to change it in vscode. Perhaps it is not possible? Knowing that would be a sufficient answer too.
As far as I know, there isn't a setting for this.
There IS an extension point for decorating text that would allow this, but as far as I know it isn't possible to access the errors for a file from the API to decorate the text. You can create new ones, but I don't believe it is possible to access existing errors.
tl;dr - I don't think this is possible at the moment.
`Microsoft/vscode issue 9209 points out more recently (2019/2020) to:
Error Gutter: This is the VSCodium (or Visual Studio Code) version of error gutters available in other text editors, such as Sublime Text or Atom.
And:
Error Lens: ErrorLens turbo-charges language diagnostic features by making diagnostics stand out more prominently, highlighting the entire line wherever a diagnostic is generated by the language and also prints the message inline.