neovim-tasks icon indicating copy to clipboard operation
neovim-tasks copied to clipboard

Redirect input

Open EderBeldad opened this issue 1 year ago • 5 comments

Can't find a way to redirect input by using the configuration files. Is there a way?

I tried something like:

{
    "cmake": {
        "cmd": "cmake",
        "dap_name": "lldb",
        "target": "longest-palindrome",
        "build_dir": "build",
        "args": {
            "configure": ["-DCMAKE_EXPORT_COMPILE_COMMANDS=1"],
            "debug": ["<", "./sample-input.txt"]
        },
        "build_type": "Debug"
    }
}

EderBeldad avatar Sep 02 '23 14:09 EderBeldad

        "debug": ["<", "./sample-input.txt"]

Should it be "debug": [">", "./sample-input.txt"]?

Shatur avatar Sep 02 '23 14:09 Shatur

Should it be "debug": [">", "./sample-input.txt"]?

That would redirect output, not input (and would also be a desirable feature!).

Ideally (imho) it should work as vscode. Although having stdin/stdout as extra parameters would also be convenient.

EderBeldad avatar Sep 02 '23 15:09 EderBeldad

Oh, I see. Makes sense, but not sure if it's possible. I use Job API from plenary: https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/job.lua If it does not support it, I can't fix it. I would suggest to open issue there.

Shatur avatar Sep 02 '23 15:09 Shatur

Seems that it has support for it (kind of):

https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/job.lua#L667C17-L667C17

This allows for sending data into stdin after job has started. (It would require for the file to be opened, read, and sent into the job)

EderBeldad avatar Sep 02 '23 16:09 EderBeldad

Right, then we probably could add support for it by providing additional stdin parameter with paths. And just use it in this function: https://github.com/Shatur/neovim-tasks/blob/f42b164499b6e833ac6b94993abc215fc4a0db17/lua/tasks/runner.lua#L98

I currently busy at the moment, but if you would like to play with it - PRs are welcome.

Shatur avatar Sep 02 '23 16:09 Shatur