sniprun icon indicating copy to clipboard operation
sniprun copied to clipboard

[Feature Request] Dynamic cwd

Open sharpchen opened this issue 1 month ago • 3 comments

Is your feature request related to a problem? Please describe. sometimes I like to test some simple thing by writing a script and inspect the result by sniprun, but such operation might need to understand the context(the cwd). I don't want to leave neovim but let the interpreter know where it should be executed.

Describe the solution you'd like add a cwd option which is of type string | fun(): string so we can dynamically eval it for each execution.

Describe alternatives you've considered

Additional context

sharpchen avatar Nov 29 '25 20:11 sharpchen

I'm not sure I understand exactly what you'd like, is it:

  1. a config option (global or per-interpreter, or both ?)

    require'sniprun'.setup({
      cwd="...", -- global option would be there
      interpreter_options = { 
        <intepreter_name> = {
           cwd = "..."; -- per-interpreter option would go there
        }
      }
    })
    

    with maybe a special case "." for "the current nvim's cwd ? Sniprun would then set this value as CWD for spawned interpreter processes

  2. a Lua/, sniprun-specific hook that would be directly called from the evaluated script, aka the so called 'dynamically eval' part ?

michaelb avatar Nov 30 '25 18:11 michaelb

Yes per-interpreter options is what I expected

sharpchen avatar Nov 30 '25 20:11 sharpchen

I cooked something on the 'dev' branch. If you want to test (and possibly have something to say about it) instructions to install that version depend usually on your plugin manager, to select the 'dev' branch. You'll also need to have a Rust toolchain installed, and set sh ./install.sh 1 as install script.

If you don't want / can't test, no worries, this will end up on the future new version that will be released sooner or later (but from that point any change request will be considerably slower to take into account)

global and per-interpreter "cwd" config keys (as in the example) are now available and respected by sniprun's sub-process (building, running, background REPL processes...)

        interpreter_options = {
          Python3_original = {
            cwd = '/tmp/a',
          },
        },
Image

michaelb avatar Dec 09 '25 19:12 michaelb