Skip to content
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

Docker support #254

Closed
LandonSchropp opened this issue Dec 9, 2017 · 6 comments
Closed

Docker support #254

LandonSchropp opened this issue Dec 9, 2017 · 6 comments

Comments

@LandonSchropp
Copy link

At work, we do all of our local development inside of Docker containers. Is there an easy way to configure vim-test to prepend Docker to the test commands? Barring that, can I override the command vim-test uses and set my own?

@janko
Copy link
Member

janko commented Dec 9, 2017

@LandonSchropp Yes, you can register a transformation function that will be applied for each test command.

function! DockerTransform(cmd) abort
  " return test command wrapped in docker stuff
endfunction

let g:test#custom_transformations = {'docker': function('DockerTransform')}
let g:test#transformation = 'docker'

@LandonSchropp
Copy link
Author

Awesome! Thank you.

@jvanbaarsen
Copy link

@LandonSchropp Did you manage to get this to work?

@LandonSchropp
Copy link
Author

LandonSchropp commented Feb 8, 2018

@jvanbaarsen: I'm using Neovim, so I went ahead and wrote my own custom functions that call terminal to give myself a bit more control.

function! RunTests(command_variable)
  if !exists(a:command_variable)
    echo 'The ' . a:command_variable ' variable must be set to run this command.'
    return
  endif

  execute 'let l:command = ' . a:command_variable
  let l:command = substitute(l:command, '$file', expand('%'), 'g')

  split
  execute 'terminal ' . l:command
endfunction

function! TestSuite()
  call RunTests('g:test#suite_command')
endfunction

function! TestFile()
  call RunTests('g:test#file_command')
endfunction

I then mapped those functions to keyboard shortcuts. This also allows me to substitute $file with the current file name when the commands are run.

@Artem-Schander
Copy link

For the googlers:
You could create a local vimrc and add something like let g:test#php#phpunit#executable = 'docker-compose exec app vendor/bin/phpunit' in it.
Worked for me.

@felippemr
Copy link

Kind of a hack but, if you are using neoterm and ssh into the container you can still use the default executor since vim-test will paste the command in the neoterm opened. I tested it and it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants