mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supply env/cwd from run options

rcarriga opened this issue · comments

Problem Statement

So I think this is a feature request although from the code it seems that it may have been intended to already be a feature.

I'm trying to allow users to supply env/cwd arguments when running tests with neotest but according to the docs you can only do so with the adapter config.

Why I thought this might be a bug is because here https://github.com/mfussenegger/nvim-dap/blob/master/lua/dap.lua#L191-L194 the env and cwd arguments to the opts are explicitly preserved in the opts table which is then passed to session:spawn but ignored.

Ideas or possible solutions

Set these lines https://github.com/mfussenegger/nvim-dap/blob/master/lua/dap/session.lua#L970-L971 to be

cwd = opts.cwd or options.cwd;
env = opts.env or options.env;

so that dynamic run arguments take priority.

Happy to make the change in a PR just wanted to check if there was a reason they weren't already used.

I'm trying to allow users to supply env/cwd arguments when running tests with neotest but according to the docs you can only do so with the adapter config.

Sounds good to make the change, but keep in mind that this will set the env/cwd for the debug-adapter, and it's not guranteed that those options will be passed along to the debugee.

I suspect the users who requested this want to have the env/cwd set for the debugee, and that must usually be supported by the debug-adapter via dedicated cwd/env options as part of the :h dap-configuration.

Ah hadn't actually thought of that... Maybe best not to expose those options then to avoid confusion if they're not guaranteed to be passed on.

ezoic increase your site revenue