diff --git a/README.md b/README.md index 493cfb2..a4e4890 100644 --- a/README.md +++ b/README.md @@ -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*) diff --git a/ftplugin/haskell.vim b/ftplugin/haskell.vim index 16bf19c..07791e9 100644 --- a/ftplugin/haskell.vim +++ b/ftplugin/haskell.vim @@ -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 @@ -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() @@ -256,6 +270,9 @@ map cv :call CuminoEvalVisual() "Mnemonic: cumino (Show) Type map ct :call CuminoShowTypeUnderTheCursor() +"Mnemonic: cumino Send +map cs :call CuminoSendToGhci() + "Kill cumino before exiting Vim autocmd VimLeavePre * call CuminoCloseSession()