Skip to content

Commit

Permalink
breaking: Remove IcedThreadFirst and IcedThreadLast commands
Browse files Browse the repository at this point in the history
cf. #419
  • Loading branch information
liquidz committed Aug 13, 2022
1 parent 32afda9 commit 2315763
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 85 deletions.
22 changes: 0 additions & 22 deletions autoload/iced/nrepl/op/iced/sync.vim
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,5 @@ function! iced#nrepl#op#iced#sync#calculate_indent_level(code, line_num, alias_m
\ })
endfunction

function! iced#nrepl#op#iced#sync#refactor_thread_first(code) abort
if !iced#nrepl#is_connected() | return iced#message#error('not_connected') | endif

return iced#nrepl#sync#send({
\ 'id': iced#nrepl#id(),
\ 'op': 'iced-refactor-thread-first',
\ 'session': iced#nrepl#current_session(),
\ 'code': a:code,
\ })
endfunction

function! iced#nrepl#op#iced#sync#refactor_thread_last(code) abort
if !iced#nrepl#is_connected() | return iced#message#error('not_connected') | endif

return iced#nrepl#sync#send({
\ 'id': iced#nrepl#id(),
\ 'op': 'iced-refactor-thread-last',
\ 'session': iced#nrepl#current_session(),
\ 'code': a:code,
\ })
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo
30 changes: 0 additions & 30 deletions autoload/iced/nrepl/refactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -317,36 +317,6 @@ function! iced#nrepl#refactor#add_ns(ns_name) abort
endif
endfunction " }}}

" iced#nrepl#refactor#thread_first / iced#nrepl#refactor#thread_last {{{
function! s:threading(fn) abort
let view = winsaveview()
let reg_save = @@

try
let code = iced#paredit#get_outer_list_raw()
if !empty(code)
let resp = a:fn(code)
if has_key(resp, 'error')
call iced#message#error_str(resp['error'])
elseif has_key(resp, 'code')
let @@ = resp['code']
silent normal! gv"0p
endif
endif
finally
let @@ = reg_save
call winrestview(view)
endtry
endfunction

function! iced#nrepl#refactor#thread_first() abort
call s:threading({code -> iced#nrepl#op#iced#sync#refactor_thread_first(code)})
endfunction

function! iced#nrepl#refactor#thread_last() abort
call s:threading({code -> iced#nrepl#op#iced#sync#refactor_thread_last(code)})
endfunction " }}}

" iced#nrepl#refactor#add_arity {{{
function! iced#nrepl#refactor#add_arity() abort
let view = winsaveview()
Expand Down
6 changes: 0 additions & 6 deletions ftplugin/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ command! IcedCleanNs call iced#nrepl#refactor#clean_ns()
command! IcedCleanAll call iced#nrepl#refactor#clean_all()
command! -nargs=? IcedAddMissing call iced#nrepl#refactor#add_missing_ns(<q-args>)
command! -nargs=? IcedAddNs call iced#nrepl#refactor#add_ns(<q-args>)
command! IcedThreadFirst call iced#nrepl#refactor#thread_first()
command! IcedThreadLast call iced#nrepl#refactor#thread_last()
command! IcedExtractFunction call iced#nrepl#refactor#extract_function()
command! IcedAddArity call iced#nrepl#refactor#add_arity()
command! IcedMoveToLet call iced#let#move_to_let()
Expand Down Expand Up @@ -288,8 +286,6 @@ nnoremap <silent> <Plug>(iced_clean_ns) :<C-u>IcedCleanNs<CR>
nnoremap <silent> <Plug>(iced_clean_all) :<C-u>IcedCleanAll<CR>
nnoremap <silent> <Plug>(iced_add_missing) :<C-u>IcedAddMissing<CR>
nnoremap <silent> <Plug>(iced_add_ns) :<C-u>IcedAddNs<CR>
nnoremap <silent> <Plug>(iced_thread_first) :<C-u>IcedThreadFirst<CR>
nnoremap <silent> <Plug>(iced_thread_last) :<C-u>IcedThreadLast<CR>
nnoremap <silent> <Plug>(iced_extract_function) :<C-u>IcedExtractFunction<CR>
nnoremap <silent> <Plug>(iced_add_arity) :<C-u>IcedAddArity<CR>
nnoremap <silent> <Plug>(iced_move_to_let) :<C-u>IcedMoveToLet<CR>
Expand Down Expand Up @@ -429,8 +425,6 @@ function! s:default_key_mappings() abort
call s:define_mapping('nmap', '<Leader>rca', '<Plug>(iced_clean_all)')
call s:define_mapping('nmap', '<Leader>ram', '<Plug>(iced_add_missing)')
call s:define_mapping('nmap', '<Leader>ran', '<Plug>(iced_add_ns)')
call s:define_mapping('nmap', '<Leader>rtf', '<Plug>(iced_thread_first)')
call s:define_mapping('nmap', '<Leader>rtl', '<Plug>(iced_thread_last)')
call s:define_mapping('nmap', '<Leader>ref', '<Plug>(iced_extract_function)')
call s:define_mapping('nmap', '<Leader>raa', '<Plug>(iced_add_arity)')
call s:define_mapping('nmap', '<Leader>rml', '<Plug>(iced_move_to_let)')
Expand Down
27 changes: 0 additions & 27 deletions test/nrepl_refactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,6 @@ function! s:suite.clean_ns_test() abort
endfunction
" }}}

" thread_first/last {{{
function! s:thread_relay(msg) abort
if a:msg['op'] ==# 'iced-refactor-thread-first'
return {'status': ['done'], 'code': '(thread first refactored)'}
elseif a:msg['op'] ==# 'iced-refactor-thread-last'
return {'status': ['done'], 'code': '(thread last refactored)'}
endif
return {'status': ['done']}
endfunction

function! s:suite.thread_first_test() abort
call s:ch.mock({'status_value': 'open', 'relay': funcref('s:thread_relay')})
call s:buf.start_dummy(['(foo (bar (baz 1) 2)|)'])
call iced#nrepl#refactor#thread_first()
call s:assert.equals(s:buf.get_texts(), '(thread first refactored)')
call s:buf.stop_dummy()
endfunction

function! s:suite.thread_last_test() abort
call s:ch.mock({'status_value': 'open', 'relay': funcref('s:thread_relay')})
call s:buf.start_dummy(['(foo (bar (baz 1) 2)|)'])
call iced#nrepl#refactor#thread_last()
call s:assert.equals(s:buf.get_texts(), '(thread last refactored)')
call s:buf.stop_dummy()
endfunction
" }}}

" add_arity {{{
function! s:add_arity_relay(msg) abort
if a:msg['op'] ==# 'iced-format-code-with-indents'
Expand Down

0 comments on commit 2315763

Please sign in to comment.