Skip to content

habamax/vim-elixir-mix-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vim meets Elixir Mix Test

Simple plugin to run mix test for your elixir projects.

animated screen with mix test

1. Why not?

There is vim-test — very capable plugin to run tests for multiple dev environments including elixir and its mix test, why this planet needs elixir_mix_test plugin?

I couldn’t make vim-test run elixir tests for me…​ That is a good reason to invent a new plugin, because why not? :)

It should be fairly simple, have minimun configuration and just work out of the box.

And I mean — just run mix test and show test results in a separate buffer.

img README 1

2. Mappings

There are no default mappings defined for elixir buffers. But there is <Plug>(MixTestRun) you can map to run all your mix tests.

For example, add following mapping to ~/.vim/after/elixir.vim file (create if needed) to define a mapping only for elixir buffers:

nmap <buffer> <leader>tt <Plug>(MixTestRun)

Once you run mix tests there should be new window opened with the name like:

'elixir_project_folder_name' -- mix test output

If your elixir project folder is Hello world, the window name should be:

Hello world -- mix test output

This window has following mappings:

<C-n> - goto next test

<C-p> - goto previous test

<CR> - open file under cursor and jump to the line (the same as gF)

img README 2

3. Commands

:MixTestRun

Run mix test for the elixir project and show test results in a split window.

Elixir project is defined by a nearest to the current buffer upwards location of the mix.exs file.

For example, if you are editing advent/day5/lib/day5.ex file

advent/
│ day1/
│ day2/
│ day3/
│ day4/
│ day5/
│ │ _build/
│ │ config/
│ │ lib/
│ │ │ day5.ex
│ │ test/
│ │ │ day5_test.exs
│ │ │ test_helper.exs
│ │ .formatter.exs
│ │ .gitignore
│ │ README.md
│ │ mix.exs

Then elixir project would be day5.

4. Settings

There is only one option available for now: g:elixir_mix_test_position. It controls where the output window will be created.

Starting from the following windows layout, having cursor on left window:

img README 3
  • let g:elixir_mix_test_position = "default"

    Note
    It uses :new command to create output window (thus the location depends on splitbelow)

    Output window:

    img README 4
  • let g:elixir_mix_test_position = "bottom"

    Output window:

    img README 5
  • let g:elixir_mix_test_position = "right"

    Output window:

    img README 6
  • let g:elixir_mix_test_position = "left"

    Output window:

    img README 7
  • let g:elixir_mix_test_position = "top"

    Output window:

    img README 8

About

Simple mix test for elixir projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published