I use Neovim as an IDE for Python development. When I execute a Python script inside Neovim using the :terminal
command, and an error occurs, I get an output similar to the following:
Traceback (most recent call last):
File "/path/to/my_script.py", line 25, in <module>
result = calculate_something(x, y)
File "/path/to/my_script.py", line 15, in calculate_something
return x / y
ZeroDivisionError: division by zero
or pytest
shows such a error output:
my_app/my_module.py:123: in process_data
data = self.read_file(file_path)
my_app/file_utils.py:456: in read_file
with open(file_path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'missing_file.txt'
This output shows the file path, line number, and the error that occurred. I would like to be able to select one of these lines from the error output (e.g., File "/path/to/my_script.py", line 25, in ) and jump to the corresponding file and line in a new window within Neovim.
There are probably more error traceback stylings. So I dont want to write it my own and would hope that other face similiar demands and a good solution is already available.
Is there a built-in feature or a plugin that can help me achieve this? If so, how can I configure it to work with the error output format shown above?
Or is there an alternative workflow instead of using the :terminal
command to get a similiar result.