Skip to content

Commit

Permalink
Update auto connection to start cljs repl automatically for shadow-cljs
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Oct 10, 2020
1 parent a1bb006 commit 55d15b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
5 changes: 5 additions & 0 deletions autoload/iced/nrepl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ function! s:connected(resp, opts) abort

call iced#message#info('connected')
call iced#hook#run('connected', {})

" auto cljs start
if has_key(a:opts, 'cljs_env')
call iced#nrepl#cljs#start_repl_via_env(get(a:opts, 'cljs_env'))
endif
endif
endfunction

Expand Down
23 changes: 17 additions & 6 deletions autoload/iced/nrepl/connect.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ function! s:detect_shadow_cljs_nrepl_port() abort
\ : str2nr(readfile(path)[0]))
endfunction

function! s:__connect_nrepl(port) abort
call iced#repl#connect('nrepl', a:port)
return v:true
endfunction

function! s:__connect_shadow_cljs(port) abort
call iced#repl#connect('nrepl', a:port, {'cljs_env': 'shadow-cljs'})
return v:true
endfunction

function! iced#nrepl#connect#auto(...) abort
let verbose = get(a:, 1, v:true)
let shadow_cljs_port = s:detect_shadow_cljs_nrepl_port()
Expand All @@ -41,15 +51,16 @@ function! iced#nrepl#connect#auto(...) abort
if shadow_cljs_port && nrepl_port
call iced#selector({
\ 'candidates': ['nREPL', 'shadow-cljs'],
\ 'accept': {_, s -> iced#repl#connect('nrepl', (s ==# 'nREPL') ? nrepl_port : shadow_cljs_port)}
\ 'accept': {_, s -> (s ==# 'nREPL')
\ ? s:__connect_nrepl(nrepl_port)
\ : s:__connect_shadow_cljs(shadow_cljs_port)}
\ })
return v:true
else
let port = shadow_cljs_port ? shadow_cljs_port : nrepl_port

if port
call iced#repl#connect('nrepl', port)
return v:true
if shadow_cljs_port
return s:__connect_shadow_cljs(shadow_cljs_port)
elseif nrepl_port
return s:__connect_nrepl(nrepl_port)
endif
endif

Expand Down

0 comments on commit 55d15b2

Please sign in to comment.