Skip to content

Instantly share code, notes, and snippets.

@nanonanomachine
Created August 28, 2021 08:00
Show Gist options
  • Save nanonanomachine/1bfbbc2238f057c2fc8770105ecc6824 to your computer and use it in GitHub Desktop.
Save nanonanomachine/1bfbbc2238f057c2fc8770105ecc6824 to your computer and use it in GitHub Desktop.
vim-iced + kaocha test under cursor without vim-iced-kaocha
function! KaochaTestNs() abort
let l:yank = @"
call iced#nrepl#ns#yank_name()
let l:ns = @"
let l:kaocha_run = "(k/run '".l:ns.")"
call iced#repl#execute('eval_code', "(require '[kaocha.repl :as k])", {'ignore_session_validity': v:true})
call iced#repl#execute('eval_code', l:kaocha_run, {'ignore_session_validity': v:true})
let @" = l:yank
endfunction
function! KaochaTestUnderCursor() abort
let l:yank = @"
call iced#nrepl#ns#yank_name()
let l:ns = @"
normal yiw
let l:kaocha_run = "(k/run '".l:ns."/".@".")"
call iced#repl#execute('eval_code', "(require '[kaocha.repl :as k])", {'ignore_session_validity': v:true})
call iced#repl#execute('eval_code', l:kaocha_run, {'ignore_session_validity': v:true})
let @" = l:yank
endfunction
aug MyClojureSetting
au!
au FileType clojure nmap <silent><buffer> <Leader>ktn :call KaochaTestNs()<CR>
au FileType clojure nmap <silent><buffer> <Leader>ktt :call KaochaTestUnderCursor()<CR>
aug END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment