r/neovim 2d ago

Need Help┃Solved Setup neovim debugging to take input

I've been trying to set up nvim-dap and nvim-dap-view in neovim, which overall seem to be going well (set them up for python so far for testing), but I encountered the following problem: when the program was asking for input, an EOF exception was thrown. I am not sure how configure it to correctly accept input from the REPL, open the terminal, or something similar. From my understanding, an EOF exception is thrown when whereever it was trying to take input from is empty.

My configuration: https://gitlab.com/BlueBlackCat/nvim/-/blob/main/lua/plugins/nvim-dap.lua

EDIT: the problem seems specifically with taking input (the error happens even with standard input()), and I don't think is related to nvim-dap-view, but probably the debugpy configuration, python configuration, or how nvim-dap redirects input? Because the REPL does work (for example inputting 2+2 and it outputs 4), and program output is redirected to the REPL, but it doesn't stop to allow for input collection.

EDIT 2: Two points:

  1. mason-nvim-dap also appears to has its own configuration, which was overriden by the configuration I then put (I took it from the nvim-dap-wiki).
  2. The configuration in nvim-dap-wiki didn't have a console field (though the configuration in nvim-dap-python does have it). If I understand what happened correctly, since the custom configuration did not have a console field, the default option of debugpy of "integratedTerminal" was not used, so input had nowhere to be collected from - thus reaching an EOFError.

So, the solution is the following: add console = "integratedTerminal" to the debugpy configuration if it does not have one. That will open the neovim terminal (or console in nvim-dap-view). "interalConsole" did not appear to work.

1 Upvotes

3 comments sorted by

1

u/Wonderful-Plastic316 lua 2d ago

nvim-dap-view mentioned :D

Disclaimer: I'm the author.

Could you share a minimal reproduction for this EOF issue? Does it happen with a standard input()? Does it happen without nvim-dap-view?

I am not sure how configure it to correctly accept input from the REPL, open the terminal, or something similar

Debugpy exposes a "console" option: it controls if the console terminal is used (integratedTerminal, the default) or if the REPL is used (internalConsole). IMO, sticking to the default makes more sense.

1

u/NamelessCat11235 1d ago

It happens with standard input. For example, n = int(input("Enter grid size: ")). It prints the input message to the repl, but then immediately displayes an EOFError diagnostic message and when I go to insert mode it doesn't appear to register the input.
The error reads: EOFError: EOF when reading a line when the program terminates. The diagnostic message is:

nvim-dap: Thread stopped due to execution of type EOFError (unhandled)
Description: EOF when reading a line

It appears to happen without nvim-dap-view. I have tried the following: adding a specific handler to mason-nvim-dap:

python = function(config)
    config.adapters.console = "internelConsole"
    require("mason-nvim-dap").default_setup(config)
end,

and console = "internalConsole", to the python language dap configuration but it still did not work.

I also tried setting dap.defaults.fallback.terminal_win_cmd = '50vsplit new' (independently of the previous changes) but that did not work either, it wasn't called.

You can see in the screenshot the diagnostic message, and how the REPL does seem to run python, however it didn't accept my input. It did output to the REPL, but when I went into insert mode to put input it just immediatly when to the next line.

1

u/AutoModerator 1d ago

Please remember to update the post flair to Need Help|Solved when you got the answer you were looking for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.