Skip to content

Commit

Permalink
Merge pull request #231 from liquidz/dev
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
liquidz authored Jun 27, 2020
2 parents 1dee027 + 6fdf6ec commit 5b5af43
Show file tree
Hide file tree
Showing 43 changed files with 730 additions and 140 deletions.
3 changes: 3 additions & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
;; FIXME
:unresolved-namespace {:level :info}

:unresolved-symbol
{:exclude [%s]}
}
}

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/vim_neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Install cljstyle
run: ../installer/cljstyle.sh
working-directory: ./bin
- name: Install jet
run: ../installer/jet.sh
working-directory: ./bin
- name: Run themis
env:
THEMIS_VIM: ${{ steps.vim.outputs.executable }}
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file. This change

== Unreleased (dev)

== 2.0.0 (2020-06-28)
// {{{
=== Added
* Added support for test integration on plain nREPL with following commands.
** This functionality was sponsored by https://www.clojuriststogether.org[Clojurists Together] as a part of their "Summer of Bugs" program.
** `:IcedTestUnderCursor`, `:IcedTestNs`, `:IcedTestAll`
** Now you can run tests on https://github.com/borkdude/babashka/blob/master/doc/repl.md#nrepl[Babashka]!
* Added `IcedUnaliasNs` command.
* Added `IcedUpdateTool` command.
* Added https://github.com/candid82/joker[joker] as a code formatter.

=== Fixed
* Fixed to be able to get var from quoated symbols.
* Fixed to be able to detect the namespace name in `in-ns` form.
* Fixed to reset supported ops when reconnecting.
* Fixed not to display extra messages on starting shadow-cljs REPL.

=== Removed
* https://github.com/liquidz/vim-iced/issues/226[#226]: (Breaking) Removed ClojureScript support for `Nashorn` and `GraalJS`.
** c.f. https://clojurescript.org/news/2020-04-24-release
// }}}

== 1.5.5 (2020-06-08)
// {{{
=== Changed
Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.PHONY: all vital test themis docker_themis html document pip_install lint clj-lint
.PHONY: all vital test themis themis_nvim html document pip_install lint clj-lint
.PHONY: python_doctest bb_script_test version_check deps_check
.PHONY: clean clean-all bin outdated repl

PWD=$(shell pwd)
NVIM=$(shell which nvim)

PLUGIN_NAME = iced
VITAL_MODULES = \
Expand Down Expand Up @@ -31,11 +32,8 @@ test: themis lint python_doctest version_check deps_check
themis: .vim-themis .vim-sexp
./.vim-themis/bin/themis

docker_themis: .vim-themis .vim-sexp
docker run --rm -v $(PWD):/root --entrypoint './.vim-themis/bin/themis' uochan/vim:latest

docker_neovim_themis: .vim-themis .vim-sexp
docker run --rm -v $(PWD):/mnt/volume lambdalisue/neovim-themis:latest
themis_nvim:
THEMIS_VIM=$(NVIM) ./.vim-themis/bin/themis

html: doc/vim-iced.txt
bash scripts/html.sh
Expand Down
2 changes: 0 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ Browsing tapped values https://twitter.com/uochan/status/1146982101662572544[:mo
Supports followings currently.
- https://github.com/bhauman/figwheel-main[Figwheel Main], https://github.com/bhauman/lein-figwheel[lein-figwheel]
- https://github.com/thheller/shadow-cljs[shadow-cljs]
- https://github.com/graalvm/graaljs[GraalJS]
- Nashorn

|:electric_plug:
|Socket REPL
Expand Down
17 changes: 17 additions & 0 deletions autoload/iced/component/format/joker.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let s:save_cpo = &cpoptions
set cpoptions&vim

function! iced#component#format#joker#start(this) abort
call iced#util#debug('start', 'format joker')

if !executable('joker')
call iced#promise#sync(a:this['installer'].install, ['joker'], 30000)
endif

let d = deepcopy(a:this.format_native_image)
let d.command = ['joker', '--format', '-']
return d
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
59 changes: 52 additions & 7 deletions autoload/iced/component/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ function! s:installed(fullname, callback, _) abort dict
endfunction

function! s:installer.install(name, ...) abort
let Callback = get(a:, 1, {v -> v})
let Callback = ''
let option = {}

if a:0 == 1
let Callback = get(a:, 1, {v -> v})
elseif a:0 == 2
let option = get(a:, 1, {})
let Callback = get(a:, 2, {v -> v})
endif

let fullname = get(self.fullname, a:name, a:name)

if executable(a:name)
Expand All @@ -36,12 +45,14 @@ function! s:installer.install(name, ...) abort
let installer = printf('%s/installer/%s.sh', self.root_dir, a:name)
let install_dir = printf('%s/%s', self.root_dir, self.install_dir_name)

call iced#message#info('required_to_install', fullname)
let res = self.io.input(iced#message#get('confirm_installation', fullname, install_dir))
" for line break
echom ' '
if res !=# '' && res !=# 'y' && res !=# 'Y'
return Callback(v:false)
if ! get(option, 'force', v:false)
call iced#message#info('required_to_install', fullname)
let res = self.io.input(iced#message#get('confirm_installation', fullname, install_dir))
" for line break
echom ' '
if res !=# '' && res !=# 'y' && res !=# 'Y'
return Callback(v:false)
endif
endif

if !filereadable(installer)
Expand All @@ -56,6 +67,40 @@ function! s:installer.install(name, ...) abort
\ })
endfunction

function! s:installer.reinstall(fullname, ...) abort
let Callback = get(a:, 1, {_ -> iced#message#info('finish_to_install', a:fullname)})
let name = ''

for k in keys(self.fullname)
if self.fullname[k] ==# a:fullname
let name = k
break
endif
endfor

if empty(name)
let name = a:fullname
endif

let iced_bin = printf('%s/bin/%s', g:vim_iced_home, name)
if executable(name) && !filereadable(iced_bin)
return iced#message#warning('not_installed_by_iced', a:fullname)
endif

if delete(iced_bin) != 0
return iced#message#error('delete-error')
endif

return self.install(name, {'force': v:true}, Callback)
endfunction

function! iced#component#installer#complete(arg_lead, cmd_line, cursor_pos) abort
let files = globpath(printf('%s/installer', g:vim_iced_home), '*.sh', v:false, v:true)
let files = map(files, {_, v -> fnamemodify(v, ':t:r')})
let files = map(files, {_, v -> get(s:installer.fullname, v, v)})
return join(files, "\n")
endfunction

function! iced#component#installer#start(this) abort
call iced#util#debug('start', 'installer')
let s:installer.job = a:this['job']
Expand Down
14 changes: 13 additions & 1 deletion autoload/iced/nrepl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function! s:initialize_nrepl() abort
\ 'cljs': '',
\ 'cljs_repl': '',
\ },
\ 'nrepl_version': {},
\ }
endfunction
let s:nrepl = s:initialize_nrepl()
Expand All @@ -26,6 +27,8 @@ let s:printer_dict = {
\ 'default': 'cider.nrepl.pprint/pprint',
\ }

let s:supported_ops = {}

let s:V = vital#iced#new()
let s:L = s:V.import('Data.List')

Expand All @@ -49,6 +52,10 @@ function! iced#nrepl#init_ns() abort
\ : g:iced#nrepl#init_cljs_ns
endfunction

function! iced#nrepl#version() abort
return s:nrepl['nrepl_version']
endfunction

function! s:set_message(id, msg) abort
let s:messages[a:id] = a:msg
endfunction
Expand All @@ -59,6 +66,7 @@ endfunction

function! iced#nrepl#reset() abort
let s:nrepl = s:initialize_nrepl()
let s:supported_ops = {}
call iced#cache#clear()
call iced#nrepl#cljs#reset()
call iced#nrepl#connect#reset()
Expand Down Expand Up @@ -530,6 +538,7 @@ function! iced#nrepl#eval(code, ...) abort
\ 'line': get(option, 'line', pos[1]),
\ 'column': get(option, 'column', pos[2]),
\ 'nrepl.middleware.print/stream?': 1,
\ 'verbose': get(option, 'verbose', v:true),
\ 'callback': Callback,
\ }

Expand Down Expand Up @@ -598,11 +607,14 @@ function! iced#nrepl#describe(callback) abort
\ })
endfunction

let s:supported_ops = {}
function! iced#nrepl#is_supported_op(op) abort " {{{
if empty(s:supported_ops)
let resp = iced#promise#sync('iced#nrepl#describe', [])

if has_key(resp, 'versions')
let s:nrepl['nrepl_version'] = copy(resp.versions)
endif

if !has_key(resp, 'ops')
return iced#message#error('unexpected_error', 'Invalid :describe op response')
endif
Expand Down
5 changes: 2 additions & 3 deletions autoload/iced/nrepl/cljs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ let s:quit_code = ':cljs/quit'
let s:env = {
\ 'figwheel-sidecar': function('iced#nrepl#cljs#figwheel_sidecar#get_env'),
\ 'figwheel-main': function('iced#nrepl#cljs#figwheel_main#get_env'),
\ 'nashorn': function('iced#nrepl#cljs#nashorn#get_env'),
\ 'graaljs': function('iced#nrepl#cljs#graaljs#get_env'),
\ 'shadow-cljs': function('iced#nrepl#cljs#shadow_cljs#get_env'),
\ }

Expand All @@ -22,7 +20,8 @@ function! s:set_cljs_session(original_cljs_session) abort

call iced#nrepl#set_session('cljs', a:original_cljs_session)
call iced#nrepl#set_session('clj', cloned_cljs_session)
return iced#nrepl#eval#code(s:quit_code, {'session': 'clj', 'ignore_session_validity': v:true})
" Quit **CLONED** cljs session to work as a clj session
return iced#nrepl#eval#code(s:quit_code, {'session': 'clj', 'ignore_session_validity': v:true, 'verbose': v:false})
endfunction

function! s:unset_cljs_session() abort
Expand Down
10 changes: 0 additions & 10 deletions autoload/iced/nrepl/cljs/graaljs.vim

This file was deleted.

10 changes: 0 additions & 10 deletions autoload/iced/nrepl/cljs/nashorn.vim

This file was deleted.

6 changes: 5 additions & 1 deletion autoload/iced/nrepl/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ endfunction
function! s:candidate(c) abort
let arglists = get(a:c, 'arglists', [])
let arglists = map(arglists, {_, v -> s:format_arglist(v)})
let doc = get(a:c, 'doc', '')
let doc = get(a:c, 'doc')
if empty(doc)
let doc = ''
endif

return {
\ 'word': a:c['candidate'],
\ 'kind': get(s:type_to_kind_dict, get(a:c, 'type', 'var')),
Expand Down
15 changes: 11 additions & 4 deletions autoload/iced/nrepl/eval.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@ function! s:parse_error(err) abort
endif
endfunction

function! iced#nrepl#eval#err(err) abort
function! iced#nrepl#eval#err(err, ...) abort
let opt = get(a:, 1, {})
let is_verbose = get(opt, 'verbose', v:true)

if empty(a:err)
return iced#qf#clear()
endif

let err_info = s:parse_error(a:err)
if !empty(err_info)
call iced#qf#set([err_info])
call iced#message#error_str(err_info['text'])
if is_verbose
call iced#message#error_str(err_info['text'])
endif
else
call iced#message#error_str(a:err)
if is_verbose
call iced#message#error_str(a:err)
endif
endif
endfunction

Expand All @@ -58,7 +65,7 @@ function! iced#nrepl#eval#out(resp, ...) abort
call iced#message#error_str(a:resp['ex'])
endif

call iced#nrepl#eval#err(get(a:resp, 'err', ''))
call iced#nrepl#eval#err(get(a:resp, 'err', ''), opt)

if has_key(opt, 'code')
return iced#nrepl#cljs#check_switching_session(a:resp, opt.code)
Expand Down
13 changes: 13 additions & 0 deletions autoload/iced/nrepl/ns.vim
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,18 @@ function! iced#nrepl#ns#clear_cache() abort
call iced#nrepl#op#refactor#__clear_cache()
endfunction

function! iced#nrepl#ns#unalias(alias_name, ...) abort
let ns_name = iced#nrepl#ns#name()
let alias_name = empty(a:alias_name) ? iced#nrepl#var#cword() : a:alias_name
let Callback = get(a:, 1, '')

if type(Callback) != v:t_func
let Callback = {_ -> iced#message#info('unaliased', alias_name)}
endif

let code = printf("(ns-unalias '%s '%s)", ns_name, alias_name)
return iced#nrepl#eval(code, Callback)
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
21 changes: 19 additions & 2 deletions autoload/iced/nrepl/ns/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@ set cpo&vim
function! iced#nrepl#ns#util#search() abort
call cursor(1, 1)
let line = trim(getline('.'))
if line !=# '(ns' && line[0:3] !=# '(ns '
return search('(ns[ \r\n]')
if line ==# '(ns' || line[0:3] ==# '(ns '
return 1
elseif line ==# '(in-ns' || line[0:7] ==# '(in-ns '
return 1
else
let [l1, c1] = searchpos('(ns[ \r\n]', 'n')
let [l2, c2] = searchpos('(in-ns[ \r\n]', 'n')
if l1 == 0 && l2 == 0
return 0
elseif l1 != 0 && l2 == 0
call cursor(l1, c1)
elseif l1 == 0 && l2 != 0
call cursor(l2, c2)
elseif l1 < l2
call cursor(l1, c1)
else
call cursor(l2, c2)
endif
endif

return 1
endfunction

Expand Down
Loading

0 comments on commit 5b5af43

Please sign in to comment.