From 539b2fd32f483a58e4ccf088b02a0eed69a38456 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 8 Dec 2016 10:17:00 -0500 Subject: [PATCH] Adds Elixir test jumper support --- configs/.vimrc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/configs/.vimrc b/configs/.vimrc index 11e3c52e8..9c676c82a 100644 --- a/configs/.vimrc +++ b/configs/.vimrc @@ -476,3 +476,45 @@ endfunction vnoremap / :call RangeSearch('/'):if strlen(g:srchstr) > 0\|exec '/'.g:srchstr\|endif vnoremap ? :call RangeSearch('?'):if strlen(g:srchstr) > 0\|exec '?'.g:srchstr\|endif + +" Elixir linting via Neomake +let g:neomake_elixir_credo_maker = { + \ 'exe': 'mix', + \ 'args': ['credo', 'list', '%:p', '--format=oneline'], + \ 'errorformat': + \ '%W[F] %. %f:%l:%c %m,' . + \ '%W[F] %. %f:%l %m,' . + \ '%W[R] %. %f:%l:%c %m,' . + \ '%W[R] %. %f:%l %m,' . + \ '%I[C] %. %f:%l:%c %m,' . + \ '%I[C] %. %f:%l %m,' . + \ '%-Z%.%#' + \ } + + +" WIP: Run elixir tests on that line +nnoremap t :call ExTestToggle() + + +" Jumps from an Elixir module file to an Elixir test file. +fun! ExTestToggle() + + if expand('%:e') == "ex" + let l:test_file_name = expand('%:t:r') . "_test.exs" + let l:test_file_dir = substitute(expand('%:p:h'), "/lib/core/", "/test/", "") + let l:full_test_path = join([test_file_dir, test_file_name], "/") + + e `=full_test_path` + + elseif match(expand('%:t'), "_test.exs") != -1 + let l:current_file_name = expand('%:t:r') + let l:offset_amt = strlen(current_file_name) - strlen("_test") + let l:module_file_name = strpart(current_file_name, 0, offset_amt) . ".ex" + let l:module_file_dir = substitute(expand('%:p:h'), "/test/", "/lib/core/", "") + let l:full_module_path = join([module_file_dir, module_file_name], "/") + + e `=full_module_path` + endif + +endfun +