Skip to content

Update the compiler plugin #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changelog.mkd
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v0.7.0 2020-02-07

* Updated the pytest command and fixed the color bug.
* Added additional arguments support.

### v0.6.0 2013-08-03

* Include detailed multi-line error message as plain message
Expand Down
38 changes: 35 additions & 3 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,53 @@

* Download stable version at vim.org: [pytest-compiler]
* Or, use a [plugin manager] and install from
<https://github.com/5long/pytest-vim-compiler>
<https://github.com/5long/pytest-vim-compiler>.
For example, with [vim-plug]:

```vim
Plug '5long/pytest-vim-compiler'
```

## Usage

Just execute `:compiler pytest` and you're done.
Well, no. You're gonna need one of the following:
Well, no. You're going to need one of the following:

* plain `:make`. see [Vim docs for more][doc make]
* plain `:make`. See [Vim docs for more][doc make]
* [MakeGreen](https://github.com/reinh/vim-makegreen)
* [dispatch.vim](https://github.com/tpope/vim-dispatch)

## Configuration

| Name | type | Default |
|--------------------------|--------|---------|
| `g:pytest_compiler_args` | string | `""` |

If set in your vim configuration, it will always be passed to CompilerSet as
additional arguments, saving you the trouble to manually add flags you use every
time (for example: `--ff --junit-xml=report.xml`).

You can define this at runtime as well, but you will have to call `:compiler pytest`
again, after.

Even when defined, you can still pass additional arguments with each make run.

### Fixing pytest layout in Dispatch windows

You'll notice that the pytest layout is broken in the quickfix window when running `:Dispatch`.

To fix that, install the pytest plugin [pytest-vimqf](https://github.com/CarloDePieri/pytest-vimqf)
and add the relative flag in your vim configuration:

```vim
let g:pytest_compiler_args = "--vim-quickfix"
```

## License

MIT Licensed. See file LICENSE.

[pytest-compiler]: http://www.vim.org/scripts/script.php?script_id=4508
[plugin manager]: http://vim-scripts.org/vim/tools.html
[vim-plug]: https://github.com/junegunn/vim-plug
[doc make]: http://vimdoc.sourceforge.net/htmldoc/usr_30.html#30.1
7 changes: 6 additions & 1 deletion compiler/pytest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ endif
let s:cpo_save = &cpo
set cpo-=C

CompilerSet makeprg=py.test\ --tb=short\ -q
let s:compiler_set = "CompilerSet makeprg=pytest\\ --color=no\\ --tb=short\\ -q"
if exists('g:pytest_compiler_args')
let s:args = substitute(g:pytest_compiler_args, " ", "\\\\ ", "g")
let s:compiler_set .= "\\ " . s:args
endif
execute s:compiler_set

CompilerSet errorformat=
\%-G=%#\ ERRORS\ =%#,
Expand Down