tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.74k stars 139 forks source link

Removal of `g:fireplace_nrepl_sessions` broke `vim-clojure-highlight`. #341

Closed jrdoane closed 5 years ago

jrdoane commented 5 years ago

As of this commit 46b98b2317aa46cd426a3086591fe90529520e1b, the g:fireplace_nrepl_sessions variable was removed. vim-clojure-highlight was using this to see if a nrepl connect had been established. Can the existence of a session be had another way so vim-clojure-highlight can be updated with a fix?

jrdoane commented 5 years ago

I may have fixed my own issue, but I'd like a second opinion to make sure. I updated the s:session_exists function in vim-clojure-highlight with this in my own fork: https://github.com/jrdoane/vim-clojure-highlight

function! s:session_exists()
    if exists('g:fireplace_nrepl_sessions') && len(g:fireplace_nrepl_sessions)
        return 1
    endif
    " Fall through in case we're using a newer version of fireplace.
    try
        let client = fireplace#client()
        return has_key(client, 'transport')
    catch /./
    endtry
    return 0
endfunction

Where the original was just this:

function! s:session_exists()
    return exists('g:fireplace_nrepl_sessions') && len(g:fireplace_nrepl_sessions)
endfunction

Does this look like an okay approach to see if an nrepl connection is available?

tpope commented 5 years ago

The old check was bad because all it tested for was the existence of a connection, regardless of whether it applied to the current buffer or not. I recommend using fireplace#op_available('eval') for both old and new versions of Fireplace.