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

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.

Related

Visual Studio Code Automatic Preview Mode on Sidebar navigation?

I've recently moved to Visual Studio Code from Sublime Text.
Something that I'm missing is the "automatic preview mode" (I don't know the exact name): in ST, if I navigate the files in the sidebar with the keyboard, every file is automatically opened in a (static) preview editor.
I couldn't find anything similar in VSC. The most similar functionality requires me to single-click, but I have two problems with this:
I'm a "keyboard-prevalent" user, and (single-)clicking defeats the purpose;
in ST this happens automatically, so it's faster anyway.
Am I missing something?
I've been searching for a while, but can't find anything relevant. It seems there are references to this functionality from Search Files (Ctrl+P), but I'm looking this functionality on the sidebar, since I use this while working on files of a single directory.

Haskero not finding definitions

I installed the Haskero plugin into VS Code as per the instructions there. I then followed the steps outlined in https://gitlab.com/vannnns/haskero/blob/master/client/doc/installation.md, or specifically Steps 5 and 6 as I already had a Stack project built in that directory. VS code starts up and it opens the project folder. When I hover over a function for example it shows the signature for that function, but when I select "Go to Definition", after thinking for a bit, it returns "No definition found for XXX". This is even when the definition is in the same file. For types, the hover displays nothing at all.
P.S. What puzzles me is that I don't recall anywhere associating ghc with the VS Code project so I am curious as to how it knows which compiler to use?
It appears to be working now. I had to do a complete build before it was able to construct the necessary indices

VSCode custom snippets list in activitybar/sidebar - extension recommendation?

Dear fellow VSCode users!
My collection of custom snippets has become rather vast lately, with all of documentation writing that I have to do. And it's becoming kind of difficult to remember all the shortcuts.
I know I can search for snippets and browse their list via the command palette, but it requires quite some extra typing and/or clicking.
Is there an existing extension that would add a new activity bar icon and provide a list of all user-defined snippets in the sidebar, allowing one to simply click on the desired snippet and thus insert it?
I imagine I'm not the only person on the planet to desire such a feature, but I honestly can't seem to be able to find it searching the Marketplace or using Google.
Thanks for all your suggestions.
Just made an extension. Snippets View. Tested only on Windows.
It's not complete yet, but has basic functionality...

How to prevent Visual Studio Code from opening abc.exe in editor?

I've just started with Visual Studio Code.
One thing I find really strange is, if my code compiles to an *.exe, and I select it in the explorer, VS Code tries to "open" it, as if it was a text file, and then complains it's a binary file.
Ideally, it should do nothing when I select it, and I should have to easy way of running it if I want, like "double-click" or some option in context menu. I don't want to hide the .exe, I just want VSCode to know it cannot edit it, so it shouldn't try.
[EDIT] In case someone wonders why I'd single-left-click on something where that click "makes no sense", it's because I've spent the last 15 years using an IDE where that does nothing except select the file in the explorer, and so I got into the habit of click on things while I'm "thinking about it", for example when I'm talking about this file to someone else. That's a hard habit to get rid of, in particular since I'm still using that IDE in my "day job".
As far as I know, this is not possible. There aren't any settings to control this and extensions can't block an editor from opening.
An extension COULD automatically close any tabs that were opened for a .exe file. So if you clicked on it and a tab opened, the extension could close it. I don't know if such an extension exists.
Otherwise you can create a feature request on github: https://www.github.com/microsoft/vscode/issues/new

How to hook into the Visual Studio IntelliSense completion keys to change when it triggers

Visual Studio 2015 does not have a way to only select IntelliSense when I press Enter or Tab anymore in C# for 2015. It's available for JavaScript but not C#.
I'm trying to create a MEF project and hook into the IntelliSense to change this behaviour for C# files. Just to get started, I tried to implement this sample plugin from Microsoft:
https://msdn.microsoft.com/en-us/library/ee372314.aspx
The sample compiles, but it does not work. Nothing in the code is triggered from the debugged IDE. The samples tells to start a new text file and press "a" to get demo IntelliSense, but it never trigger.
Here's the code project if anyone want to look into it:
http://ontime.zdata.no/donwload/ProperIntellisense.zip
Could someone guide me in the right direction here, the documentation in this area is very fluid.
There isn't a supported way to use the APIs to customize this. The behavior you're looking to change falls under the Roslyn project on GitHub so you're more than welcome to file a bug there as feedback. You're also welcome to send a pull request, but at this point it's really tricky to make a change to the editor components of Roslyn and apply those to your locally installed Visual Studio. It's something we're working on fixing but it's not done yet.
The workaround is to press Ctrl+Alt+Space when inside the editor. That will toggle into the correct IntelliSense behaviour. Not a very easy thing to find, but it saved my day. They should probably give better information about this toggle feature, and make it more visible.. Still, it will not be remembered after closing the IDE, so you have to do it every time you start the IDE.