Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: ability to add prepend/append code #32

Open
al1-ce opened this issue May 20, 2024 · 1 comment
Open

Feature Request: ability to add prepend/append code #32

al1-ce opened this issue May 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@al1-ce
Copy link

al1-ce commented May 20, 2024

I.e for running C or C++ or D code i'd have to prepend and append some code before running it

For C it'd be something like

#include <stdio.h>

int main() {
    // SELECTED CODE GOES HERE
    return 0;
}

For C++ it'd be something like

#include <iostream>

int main() {
    // SELECTED CODE GOES HERE
    return 0;
}

For D it'd be something like

/+ dub.sdl:
name "test"
+/

import std;

void main() {
    // SELECTED CODE GOES HERE
}

So possibly allow in file_types to have definition of something like file_template, i.e

opts = {
    file_types = {
        d = {
            cmd = "dub run --single",
            file_template = '/+ dub.sdl:\nname "test"\n+/\nimport std;\nvoid main() {\n${CODE}\n}\n'
        }
    }
}
@jellydn jellydn added the enhancement New feature or request label May 21, 2024
@al1-ce
Copy link
Author

al1-ce commented May 21, 2024

Ok, still related to #33 imagine this scenario. I'm selecting entire file and make it run. If to implement this feature then there would be big collision and shadowing. I.e

/+ dub.sdl:
name "test"
+/

import std;

void main() {
    // QuickCodeRunner injected code start
/+ dub.sdl:
name "test"
+/

import std;
import core.thread;

void main() {
    writeln("Hello");
    Thread.sleep(2000);
    writeln("After wait");
}
    // QuickCodeRunner injected code end
}

Not the ideal scenario, so this would also require something to allow code to be executed without templates, like a command :QuickCodeRunnerAsIs or something similar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants