about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2016-12-08T15·17-0500
committerWilliam Carroll <wpcarro@gmail.com>2016-12-08T15·17-0500
commit539b2fd32f483a58e4ccf088b02a0eed69a38456 (patch)
tree1bc45a87d100c0d61af6ecf00227eda2338cf75a
parent085a7e446d4df1eb356e7a62655170f2fa68eea4 (diff)
Adds Elixir test jumper support
-rw-r--r--configs/.vimrc42
1 files changed, 42 insertions, 0 deletions
diff --git a/configs/.vimrc b/configs/.vimrc
index 11e3c52e8190..9c676c82a3f1 100644
--- a/configs/.vimrc
+++ b/configs/.vimrc
@@ -476,3 +476,45 @@ endfunction
 vnoremap <silent> / :<C-U>call RangeSearch('/')<CR>:if strlen(g:srchstr) > 0\|exec '/'.g:srchstr\|endif<CR>
 vnoremap <silent> ? :<C-U>call RangeSearch('?')<CR>:if strlen(g:srchstr) > 0\|exec '?'.g:srchstr\|endif<CR>
 
+
+" 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 <leader>t :call ExTestToggle()<CR>
+
+
+" 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
+