Skip to content

Commit

Permalink
Cumino 0.4: Added the possibility to send raw expression to ghci
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfredo committed Oct 3, 2012
1 parent caa7507 commit 83228a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -16,6 +16,7 @@ Cumino is the vim way to prepare Haskell recipies:
# Features

* Send to ghci your type, function and instances definitions
* Type your function invokation in Vim an watch them be evaluated in Ghci
* Test in insolation snippet of code sending visual selection to ghci
* Show the type of the function under the cursor
* Possibility to set a list of ghci flags inside your .vimrc (e.g, *-XOverloadedString*)
Expand Down
17 changes: 17 additions & 0 deletions ftplugin/haskell.vim
Expand Up @@ -116,6 +116,11 @@ def cumino_show_type_under_the_cursor():
write_to_buffer_raw(":t " + function_name)
send_buffer_to_tmux()

def cumino_send_to_ghci():
expr = vim.eval("cmd")
write_to_buffer_raw(expr)
send_buffer_to_tmux()

def write_to_buffer_raw(content):
"""
Same of write_buffer, except that
Expand Down Expand Up @@ -232,6 +237,15 @@ fun! CuminoShowTypeUnderTheCursor()
endif
endfun

fun! CuminoSendToGhci()
if CuminoSessionExists()
call inputsave()
let cmd = input('Expr?: ')
call inputrestore()
python cumino_send_to_ghci()
endif
endfun

fun! CuminoCloseSession()
if CuminoSessionExists()
if g:cumino_owner == getpid()
Expand All @@ -256,6 +270,9 @@ map <LocalLeader>cv :<BS><BS><BS><BS><BS>call CuminoEvalVisual()<RETURN>
"Mnemonic: cumino (Show) Type
map <LocalLeader>ct :call CuminoShowTypeUnderTheCursor()<RETURN>
"Mnemonic: cumino Send
map <LocalLeader>cs :call CuminoSendToGhci()<RETURN>
"Kill cumino before exiting Vim
autocmd VimLeavePre * call CuminoCloseSession()

Expand Down

0 comments on commit 83228a0

Please sign in to comment.