alfredodeza / pytest.vim

Runs your UnitTests with py.test displaying red/green bars and errors
274 stars 40 forks source link

`Pytest <action> -s` should open a new window #72

Closed wookayin closed 1 year ago

wookayin commented 4 years ago

Current behavior: Running Pytest <file> -s on a window (where a normal python buffer is opened) would switch the current window to a terminal one. After the test is done, the window would be closed.

I think this behavior is inconvenient as it closes the file I was working on. How can we run Pytest ... -s in a new window (split) or a tab? Thanks!

alfredodeza commented 4 years ago

Ah, that behavior drops you to a terminal and you don't want that, correct? If you are using gvim (or MacVim on OSX) it should try to open a window within Vim I think. Have you tried that?

wookayin commented 4 years ago

No, it doesn't work in that way (even on GUI vims). :term always replace the current buffer. The following patch works for me, but we may need to have a configuration point about where the window should be opened.

     if has('terminal')
-        exe ":term " . pdb_command
+        exe ":botright vsplit term://" . pdb_command
     elseif has('nvim')
-        exe ":terminal! " . pdb_command
+        exe ":botright vsplit term://" . pdb_command
     else
alfredodeza commented 4 years ago

Something is not right here... what version of Vim are you using? Is it NeoVim or plain Vim?

What happens if you execute a command with :term like:

:terminal ls

Does it open a new split? (it should in Vim).

My suspicion is that you either have NeoVim, or you are using an old version of Vim.

In Vim 8.1 and newer, the default behavior for :terminal <command> is to open a split.

wookayin commented 4 years ago

I see. I was on neovim and now confirm that on vanilla vim :terminal splits by default. Neovim and vim8 work differently. Sorry about the confusion!

Now that it turns out that this is a neovim-specific problem, I think for the first if statement (e.g. has('terminal')) we can keep as-is and for the second one (for neovim) we can use an explicit split/vpslit command modifier.

alfredodeza commented 4 years ago

I am no longer maintaining neovim since Vim made the changes I was looking for (async support mainly) in version 8. I encourage you to switch back!

If you could submit a PR for the nvim changes you proposed, I would be happy to merge.

ubmarco commented 4 years ago

Thanks for this plugin, I'm experimenting with it currently. I also use neovim and don't see a tab/window opening with our without -s. I think changing from neovim to vim is not an easy thing to do because other plugins do only work with neovim (e.g. rely on the floating windows feature). I at least won't switch back. Is there an option to support both? Opening a vertical split terminal can be done via :vsplit | terminal.

alfredodeza commented 4 years ago

Thanks for the comment @ubmarco . Like I mentioned, I no longer use NeoVim, so I can't ensure that changes like this work seamlessly. However, if you are up for it, and the patch in this thread works for you, I'm happy to merge a PR.