Skip to content

Instantly share code, notes, and snippets.

@zamaterian
Created January 20, 2016 09:43

Revisions

  1. zamaterian created this gist Jan 20, 2016.
    30 changes: 30 additions & 0 deletions clojure-repl.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    " requires neovim

    "https://github.com/neovim/neovim/pull/2076#issuecomment-77793644
    if has("nvim")
    tnoremap <Leader>e <C-\><C-n>
    tnoremap <C-Enter> startinsert
    au TermOpen * let g:last_term_job_id = b:terminal_job_id
    endif

    function! SendToTerm(lines)
    call jobsend(g:last_term_job_id, add(a:lines, ''))
    endfunction

    function! ResetReplTerm()
    " if lost which term is a repl term, call from a repl term
    let g:last_term_job_id = b:terminal_job_id
    endfunction

    function! SendToREPL(sexp)
    call fireplace#session_eval(a:sexp)
    endfunction

    function! SyncRepl()
    call SendToREPL("(require '[clojure.pprint :refer [pprint]])(require '[clojure.repl :refer :all])")
    call SendToTerm([" (in-ns '" . fireplace#ns() . ") "])
    endfunction

    function! RefreshNS()
    call SendToREPL("(require '[clojure.tools.namespace.repl :refer [refresh]])(refresh)")
    endfunction