You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to configure a "Neovim python IDE" in the past 5 days with mixed success. And nvim-dap seems to work best with my setup. For some reason vimspector screws with my nvim-cpm...
I tried using nvim-dap-python, but I'm not really good at Lua, Vimscript, nor json, so I've been struggling to setup nvim-dap + debugpy for a module.
I use Anaconda in Windows, so I came up with the following config in config.lua for nvim-dap and would like some tips please! Maybe how to configure a .json for the current project once, check if it exists, then reuse it if it does?
Any way, here is how I configured dap.configurations in config.lua:
-- path to python.exe of reference debugpy, installed in the (base) environment in anacondalocalstd_debugpy_python=vim.fn.environ()['CONDA_PYTHON_EXE']
dap.adapters.python= {
type='executable';
command=std_debugpy_python;
args= { '-m', 'debugpy.adapter' };
}
localdap=require('dap')
dap.configurations.python= {
{
name="Python: Launch module";
type='python';
request='launch';
console='integratedTerminal';
module=function() returnvim.fn.input('Module name: '); end;
python=function()
ifvim.fn.environ()['CONDA_DEFAULT_ENV'] ~='base' thenlocalactive_python=vim.fn.environ()['CONDA_PREFIX'] ..'\\python.exe'localyes_no_active_python=vim.fn.input('Use active python.exe (' ..active_python..')? (y/n) ')
ifyes_no_active_python=='n' oryes_no_active_python=='N' thenlocalyes_no_default_python=vim.fn.input('Use default python (' ..std_debugpy_python..')? (y/n) ')
ifyes_no=='n' oryes_no=='N' then-- python.exe from user given pathreturnvim.fn.input("Input python.exe path (cwd is " ..vim.fn.getcwd() .."): ")
else-- python.exe from base anaconda environmentreturnstd_debugpy_pythonendelse-- python.exe from active anaconda environmentreturnactive_pythonendelselocalyes_no_default_python=vim.fn.input('Use default python (' ..std_debugpy_python..')? (y/n) ')
ifyes_no=='n' oryes_no=='N' then-- python.exe from user given pathreturnvim.fn.input("Input python.exe path (cwd is " ..vim.fn.getcwd() .."): ")
else-- python.exe from base anaconda environmentreturnstd_debugpy_pythonendendend
}
}
I do not know how to write the aforementioned .json using Lua/Vimscript. And after that, how to use dap.ext.vscode.load_launchjs?
Edit 1: had to add a condition to check whether the active environment is the base environment. Lot's of repeated code in my example, though
Edit 2: added a check for whether the base environment was active. And changed the environment variables to work in both cmd.exe and powershell
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I've been trying to configure a "Neovim python IDE" in the past 5 days with mixed success. And nvim-dap seems to work best with my setup. For some reason vimspector screws with my nvim-cpm...
I tried using nvim-dap-python, but I'm not really good at Lua, Vimscript, nor json, so I've been struggling to setup nvim-dap + debugpy for a module.
I use Anaconda in Windows, so I came up with the following config in config.lua for nvim-dap and would like some tips please! Maybe how to configure a .json for the current project once, check if it exists, then reuse it if it does?
Any way, here is how I configured dap.configurations in config.lua:
I do not know how to write the aforementioned .json using Lua/Vimscript. And after that, how to use
dap.ext.vscode.load_launchjs
?Edit 1: had to add a condition to check whether the active environment is the base environment. Lot's of repeated code in my example, though
Edit 2: added a check for whether the base environment was active. And changed the environment variables to work in both cmd.exe and powershell
Beta Was this translation helpful? Give feedback.
All reactions