0

I'm working with pytest and have keybindings set up to run all the tests in the specific file I'm working on. The command I run is:

:! pytest -vs "<C-r>%"

However, the output of this bash command has no colour! Is it possible to have the coloured output you would get in a regular terminal inside the bash command output of neovim? I'd rather not run :term if possible.

I can add images if required.

Thanks.

4
  • 1
    Did you try --color=yes, as per $ pytest --help?
    – romainl
    May 2 at 16:23
  • I just did and i got an output like this: ^[[32mPASSED^[[0m. I'm assuming the nvim output can't represent the colours implied by those symbols.
    – tcotts
    May 3 at 9:59
  • Yes. I know you said that you don't want :term but it would work better.
    – romainl
    May 3 at 10:41
  • would it be possible to pipe a command into the :term and have it run automatically?
    – tcotts
    May 3 at 10:44

1 Answer 1

0

For anyone looking for an answer to this, I figured out a workaround.

First, you need a command to split a :term into a regular split:

command! -nargs=* T split | terminal <args>

You can change this to a vsplit if you'd like.

Now, you can update your test shortcut to use that command:

autocmd FileType python nnoremap <leader>test :w<CR>:T pytest -vs "<C-r>%"<CR>

This works for me, and the terminal that opened can be closed with :q.

1
  • This must be NeoVim specific, because in Vim :terminal does split automatically.
    – D. Ben Knoble
    May 6 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.