Skip to content

Commit

Permalink
breaking: Remove IcedMoveToLet command
Browse files Browse the repository at this point in the history
cf. #419
  • Loading branch information
liquidz committed Aug 22, 2022
1 parent 4c92a9c commit dbb490f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 77 deletions.
47 changes: 0 additions & 47 deletions autoload/iced/let.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,52 +30,5 @@ function! iced#let#jump_to_let() abort
endtry
endfunction

function! iced#let#move_to_let(...) abort
let view = winsaveview()
let reg_save = @@

try
let form = iced#paredit#get_outer_list_raw()
if empty(form) | return iced#message#error('not_found') | endif

let indent = col('.')-1
let form = iced#util#del_indent(indent, form)
let name = get(a:, 1, '')
if empty(name)
let name = trim(input('Name: '))
endif
if empty(name)
return iced#message#echom('canceled')
endif

if iced#let#jump_to_let() == 0
" 6 means `len('(let [')`
let form = iced#util#add_indent(len(name)+1+6, form)
let @@ = iced#util#add_indent(
\ indent, printf("(let [%s %s]\n %s)", name, form, name))
silent normal! gv"0p
else
let pos = getcurpos()
let @@ = name
silent normal! gv"0p
call setpos('.', pos)

silent normal! vi[y
let bindings = @@
let indent = col('.')-1

let form = iced#util#add_indent(len(name)+1, form)
let @@ = iced#util#add_indent(
\ indent, printf("%s\n%s %s", bindings, name, form))
silent normal! gv"0p
endif

let view['lnum'] = view['lnum'] + len(split(form, '\r\?\n'))
finally
let @@ = reg_save
call winrestview(view)
endtry
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo
2 changes: 1 addition & 1 deletion autoload/iced/palette.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let s:default_palette = [
\ 'BrowseRelatedNamespace', 'BrowseSpec', 'BrowseTestUnderCursor',
\ 'BrowseReferences', 'BrowseDependencies',
\ 'CleanNs', 'CleanAll', 'AddNs', 'AddMissing',
\ 'AddArity', 'MoveToLet',
\ 'AddArity',
\ 'RenameSymbol', 'YankNsName',
\ 'BrowseTapped', 'DeleteTapped', 'ClearTapped',
\ 'ToggleWarnOnReflection', 'ToggleTraceVar', 'ToggleTraceNs',
Expand Down
3 changes: 0 additions & 3 deletions ftplugin/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ 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! IcedAddArity call iced#nrepl#refactor#add_arity()
command! IcedMoveToLet call iced#let#move_to_let()
command! -nargs=? IcedRenameSymbol call iced#nrepl#refactor#rename_symbol(<q-args>)
command! IcedYankNsName call iced#nrepl#ns#yank_name()

Expand Down Expand Up @@ -286,7 +285,6 @@ 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_add_arity) :<C-u>IcedAddArity<CR>
nnoremap <silent> <Plug>(iced_move_to_let) :<C-u>IcedMoveToLet<CR>
nnoremap <silent> <Plug>(iced_rename_symbol) :<C-u>IcedRenameSymbol<CR>
nnoremap <silent> <Plug>(iced_yank_ns_name) :<C-u>IcedYankNsName<CR>
Expand Down Expand Up @@ -424,7 +422,6 @@ function! s:default_key_mappings() abort
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>raa', '<Plug>(iced_add_arity)')
call s:define_mapping('nmap', '<Leader>rml', '<Plug>(iced_move_to_let)')
call s:define_mapping('nmap', '<Leader>rrs', '<Plug>(iced_rename_symbol)')

"" Help/Document (<Leader>h)
Expand Down
26 changes: 0 additions & 26 deletions test/let.vim
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,3 @@ function! s:suite.jump_to_let_no_matched_let_test() abort

call s:buf.stop_dummy()
endfunction

function! s:suite.move_to_let_test() abort
call s:buf.start_dummy(['(let [a 1] (inc |a))'])
call iced#let#move_to_let('b')
call s:assert.equals(s:buf.get_texts(),
\ "(let [a 1\n b (inc a)] b)")
call s:buf.stop_dummy()

"" no let
call s:buf.start_dummy(['(do (inc |a))'])
call iced#let#move_to_let('b')
call s:assert.equals(s:buf.get_texts(),
\ "(do (let [b (inc a)]\n b))")
call s:buf.stop_dummy()

"" no let in parent
call s:buf.start_dummy([
\ '(do (let [a 1] a)',
\ ' (inc |a))',
\ ])
call iced#let#move_to_let('b')
call s:assert.equals(s:buf.get_texts(),
\ "(do (let [a 1] a)\n (let [b (inc a)]\n b))")
call s:buf.stop_dummy()
endfunction

0 comments on commit dbb490f

Please sign in to comment.