-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vim plugin that starts new specs from a template
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
" vim: set ts=4 sw=4 et: | ||
|
||
" Start new specs from a template. | ||
au BufNewFile *Spec.hs call s:CreateSpecTemplate() | ||
|
||
let s:template = expand("<sfile>:h") . "/../../example/Spec.hs" | ||
|
||
function s:CreateSpecTemplate() | ||
|
||
" read template | ||
let input = readfile(s:template) | ||
call append(0, input) | ||
|
||
" append leaves an empty line at the end of the file, remove it | ||
d | ||
|
||
" adapt module name | ||
0 | ||
execute 's/\<Spec\>/' . expand("%:t:r") | ||
|
||
" place cursor on first describe | ||
/describe | ||
endfunction |