Skip to content

Commit

Permalink
Merge pull request #380 from liquidz/dev
Browse files Browse the repository at this point in the history
3.7.4
  • Loading branch information
liquidz authored Jan 8, 2022
2 parents d654951 + 34e19fb commit a76f3ca
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 151 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ jobs:
name: document
path: target/html

nightly-deploy:
if: github.ref == 'refs/heads/dev'
needs: [asciidoc, help]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@master
with:
name: document
path: document
- uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PERSONAL_ACCESS_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
with:
args: deploy --dir=document --prod
# nightly-deploy:
# if: github.ref == 'refs/heads/dev'
# needs: [asciidoc, help]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/download-artifact@master
# with:
# name: document
# path: document
# - uses: netlify/actions/cli@master
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PERSONAL_ACCESS_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# with:
# args: deploy --dir=document --prod

deploy:
if: github.ref == 'refs/heads/main'
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. This change

== Unreleased (dev)

== 3.7.4 (2022-01-09)
// {{{
=== Changed
* https://github.com/liquidz/vim-iced/issues/225[#225] https://github.com/liquidz/vim-iced/issues/372[#372]: Updated to use `ns` optional parameter in evaluating code.

=== Fixed
* Fixed to open zip file correctly on v8.2.3606 or later.
// }}}

== 3.7.3 (2021-12-29)
// {{{
=== Changed
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,6 @@ and https://github.com/liquidz/iced-nrepl[iced-nrepl].

== License

Copyright (c) 2018-2021 http://twitter.com/uochan[Masashi Iizuka]
Copyright (c) 2018-2022 http://twitter.com/uochan[Masashi Iizuka]

Distributed under the MIT License.
29 changes: 15 additions & 14 deletions autoload/iced/clojuredocs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ function! s:parse_qualified_symbol(qualified_symbol) abort
let i = stridx(a:qualified_symbol, '/')
if i < 0 | return {} | endif

return {
return iced#promise#resolve({
\ 'ns': a:qualified_symbol[0:i-1],
\ 'name': a:qualified_symbol[i+1:],
\ }
\ })
endfunction

function! s:construct_error_message() abort
Expand Down Expand Up @@ -122,18 +122,19 @@ endfunction

function! iced#clojuredocs#open(symbol) abort
call iced#message#echom('fetching')
call iced#promise#call('iced#nrepl#ns#in', [])
\.then({_ -> (stridx(a:symbol, '/') > 0)
\ ? s:parse_qualified_symbol(a:symbol)
\ : iced#promise#call('iced#nrepl#var#get', [a:symbol])})
\.then({resp -> iced#util#has_status(resp, 'no-info')
\ ? iced#promise#reject('not-found')
\ : s:lookup(resp)})
\.then({resp -> iced#util#has_status(resp, 'no-doc')
\ ? iced#message#error_str(s:construct_error_message())
\ : s:show_doc(resp)},
\ {err -> iced#message#error_str(s:construct_error_message())})
\.catch({err -> iced#message#error('unexpected_error', err)})

let p = (stridx(a:symbol, '/') > 0)
\ ? s:parse_qualified_symbol(a:symbol)
\ : iced#promise#call('iced#nrepl#var#get', [a:symbol])

call p.then({resp -> iced#util#has_status(resp, 'no-info')
\ ? iced#promise#reject('not-found')
\ : s:lookup(resp)})
\.then({resp -> iced#util#has_status(resp, 'no-doc')
\ ? iced#message#error_str(s:construct_error_message())
\ : s:show_doc(resp)},
\ {err -> iced#message#error_str(s:construct_error_message())})
\.catch({err -> iced#message#error('unexpected_error', err)})
endfunction

let &cpoptions = s:save_cpo
Expand Down
12 changes: 7 additions & 5 deletions autoload/iced/nrepl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,8 @@ function! s:warm_up() abort
endif

if iced#nrepl#check_session_validity(v:false)
if iced#nrepl#ns#name() ==# s:nrepl['init_ns']
call iced#nrepl#ns#in()
else
call iced#nrepl#ns#load_current_file({_ -> ''})
endif
\ && iced#nrepl#ns#name_by_buf() !=# s:nrepl['init_ns']
call iced#nrepl#ns#load_current_file({_ -> ''})
endif
call iced#format#set_indentexpr()

Expand Down Expand Up @@ -640,6 +637,11 @@ function! iced#nrepl#eval(code, ...) abort
\ 'callback': Callback,
\ }

let ns_name = get(option, 'ns', '')
if !empty(ns_name)
let msg['ns'] = ns_name
endif

if has_key(option, 'use-printer?')
let msg['nrepl.middleware.print/print'] = get(s:printer_dict, g:iced#nrepl#printer, s:printer_dict['default'])
endif
Expand Down
14 changes: 2 additions & 12 deletions autoload/iced/nrepl/auto.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,7 @@ function! iced#nrepl#auto#bufenter() abort

if !iced#nrepl#is_connected() | return | endif
call s:auto_switching_session()
" eval `in-ns` automatically
" NOTE: Do not use `iced#nrepl#ns#in` here
" because ns-name by `*in*` var may be different in new buffer.
if ! iced#nrepl#check_session_validity(v:false) | return | endif
let ns_name = iced#nrepl#ns#name_by_buf()
let ns_name = (empty(ns_name))
\ ? iced#nrepl#init_ns()
\ : ns_name
if !empty(ns_name)
call iced#nrepl#ns#in(ns_name, {_ -> ''})
endif
call iced#nrepl#ns#create()
endfunction

function! iced#nrepl#auto#bufread() abort
Expand All @@ -49,7 +39,7 @@ function! iced#nrepl#auto#bufread() abort
call s:auto_switching_session()
if !iced#nrepl#check_session_validity(v:false) | return | endif

call iced#nrepl#ns#require_if_not_loaded_promise()
call iced#nrepl#ns#create()
call iced#format#set_indentexpr()
endfunction

Expand Down
15 changes: 7 additions & 8 deletions autoload/iced/nrepl/cljs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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)
" 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})
return iced#nrepl#eval#code(s:quit_code, {'session': 'clj', 'ignore_session_validity': v:true, 'verbose': v:false, 'ignore_ns': v:true})
endfunction

function! s:unset_cljs_session() abort
Expand Down Expand Up @@ -49,24 +49,23 @@ function! iced#nrepl#cljs#check_switching_session(eval_resp, evaluated_code) abo
let env_name = iced#nrepl#cljs#env_name()

if eq_to_clj_session && ns ==# g:iced#nrepl#init_cljs_ns
" Switch to CLJS session from CLJ session
let p = s:set_cljs_session(eval_session)
" shadow-cljs forces you to change current session to CLJS
if ext !=# 'clj' || env_name ==# 'shadow-cljs'
call iced#nrepl#change_current_session('cljs')
call iced#nrepl#ns#in()
call iced#hook#run('session_switched', {'session': 'cljs'})
endif

call iced#message#info('started_cljs_repl')
return p

elseif eq_to_cljs_session
\ && !get(iced#nrepl#get_cljs_env(), 'ignore-quit-detecting', v:false)
\ && a:evaluated_code ==# s:quit_code
" Quit CLJS session
call s:unset_cljs_session()
call iced#nrepl#change_current_session('clj')
if ext !=# 'cljs'
call iced#nrepl#ns#in()
endif

call iced#message#info('quitted_cljs_repl')
call iced#hook#run('session_switched', {'session': 'clj'})
Expand Down Expand Up @@ -108,20 +107,20 @@ function! iced#nrepl#cljs#start_repl(code, ...) abort
else
let code = printf('(do %s (cider.piggieback/cljs-repl %s))', pre_code, a:code)
endif
call iced#nrepl#eval#code(code, {'ignore_session_validity': v:true})
call iced#nrepl#eval#code(code, {'ignore_session_validity': v:true, 'ignore_ns': v:true})
return v:true
endif
return v:false
endfunction

function! iced#nrepl#cljs#stop_repl(...) abort
if iced#nrepl#cljs_session() !=# ''
call iced#nrepl#eval#code(s:quit_code, {'session': 'cljs', 'ignore_session_validity': v:true})
call iced#nrepl#eval#code(s:quit_code, {'session': 'cljs', 'ignore_session_validity': v:true, 'ignore_ns': v:true})

let opt = get(a:, 1, {})
let post_code = get(opt, 'post', '')
if !empty(post_code)
call iced#nrepl#eval#code(post_code, {'ignore_session_validity': v:true})
call iced#nrepl#eval#code(post_code, {'ignore_session_validity': v:true, 'ignore_ns': v:true})
endif
return v:true
endif
Expand Down
13 changes: 5 additions & 8 deletions autoload/iced/nrepl/document.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ endfunction

function! s:generate_doc_by_meta(symbol) abort
let code = iced#socket_repl#document#code(a:symbol)
return iced#promise#call('iced#nrepl#ns#in', [])
\.then({_ -> iced#promise#call('iced#nrepl#eval', [code])})
let opt = {'ns': iced#nrepl#ns#name_by_buf()}
return iced#promise#call('iced#nrepl#eval', [code, opt])
\.then({resp -> get(resp, 'value', '')})
\.then({value -> substitute(value, '\(^"\|"$\)', '', 'g')})
\.then({value -> substitute(trim(value), '\\n', "\n", 'g')})
Expand Down Expand Up @@ -160,8 +160,7 @@ endfunction
function! iced#nrepl#document#open(symbol) abort
if iced#nrepl#is_supported_op('info')
if !iced#nrepl#check_session_validity() | return | endif
return iced#promise#call('iced#nrepl#ns#in', [])
\.then({_ -> iced#promise#call('iced#nrepl#var#get', [a:symbol])})
return iced#promise#call('iced#nrepl#var#get', [a:symbol])
\.then({resp -> s:generate_doc(resp)})
\.then(funcref('s:view_doc_on_buffer'))
else
Expand All @@ -181,8 +180,7 @@ function! iced#nrepl#document#popup_open(symbol) abort
if !iced#nrepl#check_session_validity()
return iced#promise#resolve(v:false)
endif
return iced#promise#call('iced#nrepl#ns#in', [])
\.then({_ -> iced#promise#call('iced#nrepl#var#get', [a:symbol])})
return iced#promise#call('iced#nrepl#var#get', [a:symbol])
\.then({resp -> s:generate_doc(resp)})
\.then(funcref('s:view_doc_on_popup'))
else
Expand Down Expand Up @@ -416,8 +414,7 @@ endfunction

function! iced#nrepl#document#usecase(symbol) abort
let ns = iced#nrepl#ns#name()
return iced#promise#call('iced#nrepl#ns#in', [])
\.then({_ -> iced#promise#call('iced#nrepl#var#get', [a:symbol])})
return iced#promise#call('iced#nrepl#var#get', [a:symbol])
\.then({resp -> s:__usecase_find_references(resp)})
\.then({refs -> s:find_usecase(refs)})
endfunction
Expand Down
10 changes: 8 additions & 2 deletions autoload/iced/nrepl/eval.vim
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ function! iced#nrepl#eval#code(code, ...) abort
unlet opt['callback']
endif

if !get(opt, 'ignore_ns', v:false)
let ns_name = iced#nrepl#ns#name_by_buf()
if !empty(ns_name)
let opt['ns'] = ns_name
endif
endif

try
return iced#nrepl#ns#require_if_not_loaded_promise()
\.then({_ -> iced#promise#call('iced#nrepl#eval', [code, opt])})
return iced#promise#call('iced#nrepl#eval', [code, opt])
\.then(Callback)
finally
let @@ = reg_save
Expand Down
16 changes: 8 additions & 8 deletions autoload/iced/nrepl/navigate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,18 @@ function! iced#nrepl#navigate#browse_references(symbol) abort
elseif stridx(symbol, ':') == 0
call s:fn_refs_callback(s:clj_kondo_analysis_to_fn_refs(kondo.keyword_usages(symbol[1:])))
else
call iced#nrepl#ns#in({_ -> iced#nrepl#var#get(symbol, {resp ->
call iced#nrepl#var#get(symbol, {resp ->
\ s:got_var_info(resp, {ns, symbol ->
\ s:fn_refs_callback(s:clj_kondo_analysis_to_fn_refs(kondo.references(ns, symbol)))
\ })})})
\ })})
endif
elseif iced#nrepl#is_supported_op('fn-refs')
" Use cider-nrepl's xref op
" In this case, only loaded vars are detected.
call iced#nrepl#ns#in({_ -> iced#nrepl#var#get(a:symbol, {resp ->
call iced#nrepl#var#get(a:symbol, {resp ->
\ s:got_var_info(resp, {ns, symbol ->
\ iced#nrepl#op#cider#fn_refs(ns, symbol, s:fn_refs_callback)
\ })})})
\ })})
else
call iced#message#error('not_supported')
endif
Expand All @@ -455,17 +455,17 @@ function! iced#nrepl#navigate#browse_dependencies(symbol) abort
let kondo = iced#system#get('clj_kondo')
if kondo.is_analyzed()
" Use clj-kondo's analysis
call iced#nrepl#ns#in({_ -> iced#nrepl#var#get(a:symbol, {resp ->
call iced#nrepl#var#get(a:symbol, {resp ->
\ s:got_var_info(resp, {ns, symbol ->
\ s:fn_deps_callback(s:clj_kondo_analysis_to_fn_deps(kondo.dependencies(ns, symbol)))
\ })})})
\ })})
elseif iced#nrepl#is_supported_op('fn-deps')
" Use cider-nrepl's xref op
" In this case, only loaded vars are detected.
call iced#nrepl#ns#in({_ -> iced#nrepl#var#get(a:symbol, {resp ->
call iced#nrepl#var#get(a:symbol, {resp ->
\ s:got_var_info(resp, {ns, symbol ->
\ iced#nrepl#op#cider#fn_deps(ns, symbol, s:fn_deps_callback)
\ })})})
\ })})
else
call iced#message#error('not_supported')
endif
Expand Down
Loading

0 comments on commit a76f3ca

Please sign in to comment.