Skip to content

add pytest compiler #23

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
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
14 changes: 12 additions & 2 deletions python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
" Maintainer: Tom Picton <[email protected]>
" Previous Maintainer: James Sully <[email protected]>
" Previous Maintainer: Johannes Zellner <[email protected]>
" Last Change: 2024/05/13
" https://github.com/tpict/vim-ftplugin-python
" Repository: https://github.com/tpict/vim-ftplugin-python
" Last Change: 2024/05/13
" 2024 Dec 01 use pytest compiler (#16130)

if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1
Expand Down Expand Up @@ -134,6 +135,11 @@ elseif executable('python')
setlocal keywordprg=python\ -m\ pydoc
endif

if expand('%:t') =~# get(g:, python_files, '\v^test_.*\.py$|_test\.py$') && executable('pytest')
compiler pytest
let &l:makeprg .= ' %:S'
endif

" Script for filetype switching to undo the local stuff we may have changed
let b:undo_ftplugin = 'setlocal cinkeys<'
\ . '|setlocal comments<'
Expand Down Expand Up @@ -189,5 +195,9 @@ let b:undo_ftplugin = 'setlocal cinkeys<'
\ . '|unlet! b:prev_toplevel'
\ . '|unlet! b:undo_ftplugin'

if get(b:, 'current_compiler', '') ==# 'pytest'
let b:undo_ftplugin .= '| compiler make'
endif

let &cpo = s:keepcpo
unlet s:keepcpo