VS Code Extension and command line tool - visual-studio-code

I would like to create a command line tool (CLI), that can be run from the terminal, that will do some stuff in the background, then open a WebView of the results in VS Code. I'm unsure of whether or not this would require 2 components or can be completely run inside of a VS Code Extension. If running separately, I would assume there would need to be some communication layer between the command line process and the extension itself. What is the best approach?
An example of the command:
hydra generate app
The WebView would show the results of the process and a TreeView (HTML) of the results. The HTML would need to be interactive but I have the HTML working as standalone for now.

Related

How to make terminal minimal Vs Code?

I am trying to make terminal interference minimal by removing element I don't need. I am beginner in programming.
I want to remove the highlighted part.:
I am using coderunner and C/C++ Compile Run. I lloked for this on google and but Code-runner: Clear previous output, it does not work for me. Also is there any way I can clear terminal automatically when running the code using ctrl+alt+N instead doing it manually?
If I can't do this in powershell is there any other shell which give this functionality?

VSCode run JavaScript file line by line like REPL

Is it possible to run JavaScript/TypeScript file opened in VSCode line by line?
Like you press something like CMD+XXX+Enter and it runs the current line or code block?
So you can play with code interactively.
P.S.
I don't want to open JS console - I want to run the code (or code snippet) from the file currently opened in Editor.
It should be stateful, you run the first line, then second etc. "Code Runner" plugin not working that way, it forgets the previous run. So you ran the first line, then try to execute the second line - and it complains about undefined variables that were defined in the first one.
VS Code doesn't has this feature built-in, but there are a lot of extensions for it. The most used is Code Runner, but there are many others. For example, Quokka.js executes code as you type and it's the ideal to know the output of some little piece of code.
The new open source VS Code extension Javascript REPL is promising.

Run functionality with Monaco Editor

I wanted to use the Monaco Editor for my project and I want to run the server side languages like C# or node in my Monaco editor(https://github.com/Microsoft/monaco-editor/) which is a open source editor from Microsoft.
Here are few examples for that.
https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-rendering-glyphs-in-the-margin
https://dotnet.microsoft.com/languages
If you see the the above examples you can see they are running c# with run button I wanted to implement same functionality.
I know that I need to install run time for particular language like C# and I have that in my local machine but still I am not able to run it.
Any help will be highly appreciated.
What you see there is not a Monaco feature and is up to you to implement. How you do that, will depend largely on the language you're trying to run.
The first example (and jsFiddle and CodePen and many others) simply displays an iframe to show the result. That iframe loads a file with a unique name that contains the HTML, CSS and JavaScript code entered in the editor. You can confirm that this is what they're doing, using Chrome Dev Tools.
If you're going to run a language like C#, know that you will need full control of your web server. The flow will be something like this:
The user presses the Run button.
You call a web service (that you must develop), passing it the C# code and anything else needed to build a working project (like dependencies).
The web service creates the project from those inputs, invokes the C# compiler, runs the resulting executable, and finally captures the output (both stdout and stderr) into string variables. Those strings are returned by the web service.
Back in the browser, you display the output from the web service.
This is very doable, but getting it to perform well when your volumes pick up will be a special problem.

How to setup Julia in VS code?

I'm coming from a pure Windows Visual Studio programming background with little Linux experience. It seems possible to use VS Code to program in Julia, but I can't figure out how to get things set up correctly.
Does anybody have good example launch.json, tasks.json, or other files that can serve as an example to build from?
This would be a great thing to see in a detailed tutorial.
Here is how things work if you are using the Julia extension for VisualStudio Code.
The extension adds a bunch of new commands. They all start with "julia", so filtering by that string should show you everything you can do with the extension.
In terms of running Julia code, the extension offers only two options right now. First, you can execute a command to start a REPL. This will just show a default Julia prompt, and you can interact with it like you would with any other Julia REPL. The second is that there is also a command, triggered by Ctrl + Enter, to send either the current editor selection or the current editor line to this REPL.
There is currently no further integration offered by the Julia extension. We do plan to add debugger support in the future, at which point I would expect F5 to start the current file in the debugger, or something like that. But that functionality is probably a couple of months away.

Using integrated terminal in a VS Code extension

There are multiple commands having to do with the Integrated Terminal that VS Code offers. In my extension, I am able to open it and focus it using workbench.action.terminal.focus, but running commands in it seems hacky to do through runSelectedText. Ideally I'd like to be able to run commands directly without having intermediate document to simulate selections in and to be able to read their results.
I have found the MainThreadTerminalService which seems to offer what I want, but I don't know how to and if I even can use that from an extension. Scanning node_modules/vscode/vscode.d.ts for terminal didn't yield any results, so I presume it is not possible yet.
Using TerminalPasteAction to run the commands seems as an option, but I would first have to get the command into the clipboard and there doesn't seem to be a good way to listen to the results anyway.
I know I can run a child process and listen to it's standard output and error, but since VS Code offers the integrated terminal window, it would be nice if the user could see the commands as they run in a separate integrated terminal tab exclusive to my extension. Is this possible? Will it be?
Check this thread
https://github.com/Microsoft/vscode/issues/9957
Apparently API is limited but you have
CreateTerminal(name?: string): Terminal
interface Terminal {
name:string;
runCommand(cmd:string)
show(preserveFocus: boolean): void
hide(): void;
dispose(): void;
}