Open oderwat opened 8 years ago
You need specify "nim.project" variable in you workspace settings.json
file with your project nim file
OK. That will help for "real" projects where one has only one main file. But I read in the default config, that if it is not set it always uses the current file in the editor. I guess I interpreted this wrong.
I have some workspace directories where hundreds of different nim scripts reside. Some of them in folders as small projects too. To create what I need I added the "runner" extension and wrote some little shell script which can compile and directly run any file which is open in the editor. Basicly it cd's to the directory of the open file and runs nim with hand-selected options to make the output smooth. This works well now.
I am also author of the Nim part of "script" for Atom, which can run single files as nim/nims and also has some detection code for runnig the "main" file when I start it from one of the "included" files. I think I am going to extend my script for VSC.
I wonder if you do not want a "build + run current file" in your code. I find it very nice to have that available while testing stuff. Would be nice if one could add the options which nim uses to run too.
@oderwat I have added support to run current file in case of non project mode
That is cool! But there is a major problem with that as you do not CD to the directory the file resides in. It also changes focus when used with the keyboard ,such that one can't type in the code after pressing 'f5' until the pane receives focus again.
I think there are a lot more things which would be needed to make it a nice "CodeRunner":
I guess that this is probably not a focus for you :(
Thank You for your proposal, I guess some of them will be implemented a soon
Do you know if there is a way to use the regular terminal window for output? I think that would be really cool to have compilation kinda "remote control" the terminal. BTW: I still don't use build on save because it always seems to lose the focus on the text editor.
No, VSCode does not provide API for access to terminal ;( it also not possible to configure tasks.json in VSCode to use terminal as output,
According build on save I guess it is possible update extension to run configured build tasks (in tasks.json
) instead of hardcoded run nim compile
@oderwat I have added buildOnSave based on tasks.jons recently, could you please check, may be it will solve some of Your problems
@oderwat I have added run file functionality that opens internal terminal windows, compile and run selected file. It can be executed by F6
or from editor context menu. I hope this solution will be cover some of the required functionality.
This functionality seems rather unstable at the minute. I opened a file from outside my "workspace" (VS Code probably calls this something else) and it stopped working. It would be nice to get some sort of error instead of just silence (maybe there is a way to check for errors somewhere in VS Code?).
What I would love is the ability to run any unsaved file. This is what Aporia allows and it is incredibly useful for experimenting, I just open a new tab and press F5. Aporia saves the file in /tmp/aporia, then compiles and runs it.
@dom96 I have added options to run unsaved file
Thank you but this doesn't do what I imagined. In fact, what this does should be the default behaviour.
Assume I have a tab called scratch.nim
open, if I press F6 then this file is compiled and run. When I enable the compileUnsaved setting (or whatever it's called) the file is saved into some dirty file (1), and is compiled and run. This means that I always compile the latest code (even if it's unsaved) which is nice, arguably I think F6 should just save, compile and run the code like in Aporia.
The feature that I want is the following:
echo(42)
And the editor automatically saves the file into /tmp/blah/wherever
, compiles and runs it for me. This is extremely awesome for quick testing of small pieces of code and is something I miss greatly from Aporia.
Feel free to ignore my feature requests. Of course I will likely fork this plugin if you do so :)
(1): /var/folders/qs/3mwpxj8s1td75h2bby7g18xw0000gn/T/vscodenimdirt
, shouldn't this be /tmp/
btw?
I am using Atom + "Nim Extension" + "Script Extension" to have a "compile + run when I press a key" functionality. Is this possible with vscode-nim?
I see that there is a F6 "Nim: Run Project" but it doesn't do anything (for me). Alt+F6 gives an error that the event is not defined. The same happens when I select Nim: Build Project manually from the command palette while activating "build on save" does work and build the current editor file.
I also tried to add an "-r" to the BuildCommand but that gives an error (not a command).
P.S.: I never used Visual Studio Code so I may miss just something obvious.