Skip to content
This repository was archived by the owner on Feb 23, 2025. It is now read-only.

Commit

Permalink
Merge pull request #323 from liquidz/dev
Browse files Browse the repository at this point in the history
3.0.2
  • Loading branch information
liquidz authored Mar 19, 2021
2 parents f254303 + fb1820e commit 7d11d3b
Show file tree
Hide file tree
Showing 21 changed files with 96 additions and 42 deletions.
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.0.2 (2021-03-20)
// {{{
=== Changed
* Changed one-line document to use `timer` feature instead of `CursorHold`/`CursorHoldI` auto command.
** Now you can adjust delay time for displaying one-line document with `g:iced#nrepl#auto#document_delay` option.
* Bumped iced-nrepl to 1.2.2.
* Bumped joker to 0.16.0.
// }}}

== 3.0.1 (2021-03-13)
// {{{
=== Added
Expand Down
10 changes: 9 additions & 1 deletion autoload/iced/component/timer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ function! s:timer.stop(timer) abort
return timer_stop(a:timer)
endfunction

function! s:start_lazily_callback(id, callback, _) abort dict
let self.ids[a:id] = -1
return a:callback()
endfunction

function! s:timer.start_lazily(id, time, callback, ...) abort
let timer_id = get(self.ids, a:id, -1)
if timer_id != -1 | call self.stop(timer_id) | endif
let self.ids[a:id] = self.start(a:time, a:callback, get(a:, 1, {}))
let self.ids[a:id] = self.start(
\ a:time,
\ funcref('s:start_lazily_callback', [a:id, a:callback], self),
\ get(a:, 1, {}))
endfunction

function! iced#component#timer#start(_) abort
Expand Down
11 changes: 11 additions & 0 deletions autoload/iced/nrepl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function! s:initialize_nrepl() abort
\ 'cljs': '',
\ 'cljs_repl': '',
\ },
\ 'cljs': {
\ 'env': {},
\ },
\ 'nrepl_version': {},
\ 'iced_nrepl_enabled': v:false,
\ }
Expand Down Expand Up @@ -127,6 +130,14 @@ function! iced#nrepl#cljs_session() abort
return s:nrepl['sessions']['cljs']
endfunction

function! iced#nrepl#set_cljs_env(env) abort
let s:nrepl['cljs']['env'] = copy(a:env)
endfunction

function! iced#nrepl#get_cljs_env() abort
return s:nrepl['cljs']['env']
endfunction

function! iced#nrepl#check_session_validity(...) abort
let ext = expand('%:e')
let sess_key = iced#nrepl#current_session_key()
Expand Down
9 changes: 9 additions & 0 deletions autoload/iced/nrepl/auto.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let s:save_cpo = &cpoptions
set cpoptions&vim

let g:iced#nrepl#auto#does_switch_session = get(g:, 'iced#nrepl#auto#does_switch_session', v:false)
let g:iced#nrepl#auto#document_delay = get(g:, 'iced#nrepl#auto#document_delay', 500)
let s:leaving = v:false
let s:is_bufenter_enabled = v:false

Expand Down Expand Up @@ -63,5 +64,13 @@ function! iced#nrepl#auto#enable_bufenter(bool) abort
let s:is_bufenter_enabled = a:bool
endfunction

function! iced#nrepl#auto#cursor_moved() abort
let timer = iced#system#get('timer')
call timer.start_lazily(
\ 'document_current_form',
\ g:iced#nrepl#auto#document_delay,
\ {-> iced#nrepl#document#current_form()})
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
21 changes: 9 additions & 12 deletions autoload/iced/nrepl/cljs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ let s:save_cpo = &cpoptions
set cpoptions&vim

let g:iced#cljs#default_env = get(g:, 'iced#cljs#default_env', 'figwheel-sidecar')
let s:using_env = {}
let s:env_options = []
let s:quit_code = ':cljs/quit'

let s:env = {
Expand Down Expand Up @@ -44,7 +42,7 @@ function! iced#nrepl#cljs#check_switching_session(eval_resp, evaluated_code) abo

let ns = a:eval_resp['ns']
let ext = expand('%:e')
let env_name = get(s:using_env, 'name', '')
let env_name = get(iced#nrepl#get_cljs_env(), 'name', '')

if eq_to_clj_session && ns ==# g:iced#nrepl#init_cljs_ns
let p = s:set_cljs_session(eval_session)
Expand All @@ -58,7 +56,7 @@ function! iced#nrepl#cljs#check_switching_session(eval_resp, evaluated_code) abo
call iced#message#info('started_cljs_repl')
return p
elseif eq_to_cljs_session
\ && !get(s:using_env, 'ignore-quit-detecting', v:false)
\ && !get(iced#nrepl#get_cljs_env(), 'ignore-quit-detecting', v:false)
\ && a:evaluated_code ==# s:quit_code
call s:unset_cljs_session()
call iced#nrepl#change_current_session('clj')
Expand Down Expand Up @@ -127,8 +125,7 @@ function! iced#nrepl#cljs#stop_repl(...) abort
endfunction

function! iced#nrepl#cljs#reset() abort
let s:using_env = {}
let s:env_options = []
call iced#nrepl#set_cljs_env({})
endfunction

function! iced#nrepl#cljs#start_repl_via_env(env_key, ...) abort
Expand All @@ -137,7 +134,7 @@ function! iced#nrepl#cljs#start_repl_via_env(env_key, ...) abort
return iced#message#error('invalid_cljs_env')
endif

if empty(s:using_env)
if empty(iced#nrepl#get_cljs_env())
let env = s:env[env_key](a:000)
if type(env) != v:t_dict | return iced#message#error_str(env) | endif

Expand All @@ -163,25 +160,25 @@ function! iced#nrepl#cljs#start_repl_via_env(env_key, ...) abort
let opt = copy(env)
call extend(opt, {'pre': pre_code})
if iced#nrepl#cljs#start_repl(env_code, opt)
let s:using_env = env
call iced#nrepl#set_cljs_env(env)
endif
endif
endfunction

function! iced#nrepl#cljs#stop_repl_via_env() abort
if !empty(s:using_env)
let Post_code_f = get(s:using_env, 'post-code', '')
if !empty(iced#nrepl#get_cljs_env())
let Post_code_f = get(iced#nrepl#get_cljs_env(), 'post-code', '')
let post_code = type(Post_code_f) == v:t_func ? Post_code_f() : ''
if iced#nrepl#cljs#stop_repl({'post': post_code})
let s:using_env = {}
call iced#nrepl#set_cljs_env({})
endif
else
call iced#nrepl#cljs#stop_repl()
endif
endfunction

function! iced#nrepl#cljs#is_current_env_shadow_cljs() abort
return (get(s:using_env, 'name', '') ==# 'shadow-cljs')
return (get(iced#nrepl#get_cljs_env(), 'name', '') ==# 'shadow-cljs')
endfunction

" c.f. :h :command-completion-custom
Expand Down
4 changes: 3 additions & 1 deletion autoload/iced/nrepl/cljs/figwheel_main.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ function! iced#nrepl#cljs#figwheel_main#get_env(options) abort
endif

let s:build_id = a:options[0]
return {'pre-code': funcref('s:pre_code'),
return {
\ 'name': 'figwheel-main',
\ 'pre-code': funcref('s:pre_code'),
\ 'env-code': funcref('s:env_code'),
\ 'post-code': funcref('s:post_code')}
endfunction
Expand Down
4 changes: 3 additions & 1 deletion autoload/iced/nrepl/cljs/figwheel_sidecar.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ let s:save_cpo = &cpo
set cpo&vim

function! iced#nrepl#cljs#figwheel_sidecar#get_env(_) abort
return {'pre-code': {-> '(do (require ''figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/start-figwheel!))'},
return {
\ 'name': 'figwheel-sidecar',
\ 'pre-code': {-> '(do (require ''figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/start-figwheel!))'},
\ 'env-code': {-> '(figwheel-sidecar.repl-api/repl-env)'},
\ 'post-code': {-> '(figwheel-sidecar.repl-api/stop-figwheel!)'}}
endfunction
Expand Down
4 changes: 2 additions & 2 deletions bin/iced
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCRIPT_DIR=$(cd $(dirname $0); pwd)
PROJECT_DIR=$(cd $SCRIPT_DIR; cd ..; pwd)
VERSION=$(grep 'Version: ' ${SCRIPT_DIR}/../doc/vim-iced.txt | cut -d' ' -f2)

BASE_DEPENDENCIES='nrepl/nrepl:0.8.3 refactor-nrepl/refactor-nrepl:2.5.1 cider/cider-nrepl:0.25.7 iced-nrepl/iced-nrepl:1.2.1'
BASE_DEPENDENCIES='nrepl/nrepl:0.8.3 refactor-nrepl/refactor-nrepl:2.5.1 cider/cider-nrepl:0.25.7 com.github.liquidz/iced-nrepl:1.2.2'
BASE_MIDDLEWARES='cider.nrepl/wrap-classpath cider.nrepl/wrap-clojuredocs cider.nrepl/wrap-complete cider.nrepl/wrap-debug cider.nrepl/wrap-format cider.nrepl/wrap-info cider.nrepl/wrap-macroexpand cider.nrepl/wrap-ns cider.nrepl/wrap-out cider.nrepl/wrap-spec cider.nrepl/wrap-test cider.nrepl/wrap-trace cider.nrepl/wrap-undef cider.nrepl/wrap-xref refactor-nrepl.middleware/wrap-refactor iced.nrepl/wrap-iced'

CLJS_DEPENDENCIES='cider/piggieback:0.5.2'
Expand Down Expand Up @@ -63,7 +63,7 @@ function iced_repl_usage() {
echo ""
echo "The --dependency option adds extra dependency."
echo "VALUE format is 'PACKAGE_NAME:VERSION'."
echo "For example: --dependency=iced-nrepl:0.4.3"
echo "For example: --dependency=com.github.liquidz/iced-nrepl:0.4.3"
echo ""
echo "The --middleware option adds extra nrepl middleware."
echo "For example: --middleware=iced.nrepl/wrap-iced"
Expand Down
2 changes: 1 addition & 1 deletion clj/template/iced.bash
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function iced_repl_usage() {
echo ""
echo "The --dependency option adds extra dependency."
echo "VALUE format is 'PACKAGE_NAME:VERSION'."
echo "For example: --dependency=iced-nrepl:0.4.3"
echo "For example: --dependency=com.github.liquidz/iced-nrepl:0.4.3"
echo ""
echo "The --middleware option adds extra nrepl middleware."
echo "For example: --middleware=iced.nrepl/wrap-iced"
Expand Down
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:deps {nrepl/nrepl {:mvn/version "0.8.3"}
refactor-nrepl/refactor-nrepl {:mvn/version "2.5.1"}
cider/cider-nrepl {:mvn/version "0.25.7"}
iced-nrepl/iced-nrepl {:mvn/version "1.2.1"}}
com.github.liquidz/iced-nrepl {:mvn/version "1.2.2"}}
:__middlewares__
["cider.nrepl/wrap-classpath"
"cider.nrepl/wrap-clojuredocs"
Expand Down Expand Up @@ -34,7 +34,7 @@
:replace-paths ["clj/jackin"]
:extra-deps {org.panchromatic/mokuhan {:mvn/version "0.1.1"}}
:main-opts ["-m" "iced-jackin"]}
:outdated {:extra-deps {antq/antq {:mvn/version "RELEASE"}
:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "RELEASE"}
org.slf4j/slf4j-nop {:mvn/version "RELEASE"}}
:main-opts ["-m" "antq.core"]}
:dev {}}}
9 changes: 7 additions & 2 deletions doc/pages/configuration/advanced.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Following values are supported.
| {help_html}#g%3Aiced_enable_auto_document[g:iced_enable_auto_document]
| `'none'`
| Enable automatic displaying one-line document. +
This will be done by https://vim-jp.org/vimdoc-en/autocmd.html#CursorHold[CursorHold] and https://vim-jp.org/vimdoc-en/autocmd.html#CursorHoldI[CursorHoldI] auto command. +
This will be done by https://vim-jp.org/vimdoc-en/autocmd.html#CursorMoved[CursorMoved] / https://vim-jp.org/vimdoc-en/autocmd.html#CursorMovedI[CursorMovedI] auto command and https://vim-jp.org/vimdoc-en/eval.html#timer[timer]. +
+
The value should be one of `'normal'`, `'insert'` or `'any'`. +
Otherwise, this option will be disabled.
Expand All @@ -100,7 +100,12 @@ Otherwise, this option will be disabled.
| {help_html}#g%3Aiced_max_distance_for_auto_document[g:iced_max_distance_for_auto_document]
| `2`
| Max line distance to display one-line document. +
See also |g:iced_enable_auto_document|.
See also {help_html}#g%3Aiced_enable_auto_document[g:iced_enable_auto_document].

| {help_html}#g%3Aiced%23nrepl%23auto%23document_delay[g:iced#nrepl#auto#document_delay]
| `500`
| Delay time for displaying one-line document. +
Unit is milli sec.

|===

Expand Down
6 changes: 4 additions & 2 deletions doc/pages/reference/docstring.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The explicit way is to execute one of the following commands.

The implicit way is the Auto Document feature.
This feature will automatically display a one-line documentation string on the right of cursor line.
This will be done by `CursorHold` and `CursorHoldI` auto command.
This will be done by https://vim-jp.org/vimdoc-en/autocmd.html#CursorMoved[CursorMoved] / https://vim-jp.org/vimdoc-en/autocmd.html#CursorMovedI[CursorMovedI] auto command and https://vim-jp.org/vimdoc-en/eval.html#timer[timer].

- {help_html}#g%3Aiced_enable_auto_document[g:iced_enable_auto_document]: Enable auto document feature.
- {help_html}#g%3Aiced%23nrepl%23auto%23document_delay[g:iced#nrepl#auto#document_delay]: Define delay time for displaying auto document.
{help_html}#g%3Aiced_enable_auto_document[g:iced_enable_auto_document] is a configuration to enable auto document feature.
23 changes: 16 additions & 7 deletions doc/vim-iced.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*vim-iced.txt* Clojure interactive development environment for Vim8/Neovim

Version: 3.0.1
Version: 3.0.2
Author : Masashi Iizuka <[email protected]>
License: MIT LICENSE

Expand Down Expand Up @@ -138,7 +138,7 @@ LEININGEN~
>
{:user
{:dependencies [[nrepl "0.8.3"]
[iced-nrepl "1.2.1"]
[com.github.liquidz/iced-nrepl "1.2.2"]
[cider/cider-nrepl "0.25.7"]]
:repl-options {:nrepl-middleware [cider.nrepl/wrap-classpath
cider.nrepl/wrap-clojuredocs
Expand Down Expand Up @@ -168,7 +168,7 @@ BOOT~
(swap! boot.repl/*default-dependencies* concat
'[[refactor-nrepl "2.5.1"]
[cider/cider-nrepl "0.25.7"]
[iced-nrepl "1.2.1"]])
[com.github.liquidz/iced-nrepl "1.2.2"]])
(swap! boot.repl/*default-middleware* concat
'[cider.nrepl/wrap-classpath
Expand Down Expand Up @@ -196,7 +196,7 @@ SHADOW-CLJS~
{
:dependencies [[refactor-nrepl "2.5.1"]
[cider/cider-nrepl "0.25.7"]
[iced-nrepl "1.2.1"]]
[com.github.liquidz/iced-nrepl "1.2.2"]]
}
<
.nrepl.edn (local config) or $HOME/.nrepl/nrepl.edn (global config)
Expand Down Expand Up @@ -1532,6 +1532,7 @@ KEY MAPPINGS *vim-iced-key-mappings*
Configurable options are:
- |g:iced_enable_auto_document|
- |g:iced_enable_popup_document|
- |g:iced#nrepl#auto#document_delay|

*<Plug>(iced_use_case_open)*
<Plug>(iced_use_case_open)
Expand Down Expand Up @@ -1742,7 +1743,7 @@ g:iced#nrepl#connect#auto_connect_timeout_ms
When you set `-1`, vim-iced will wait forever.
Default value is `5000`.

s*g:iced#paredit#slurp_max_depth*
*g:iced#paredit#slurp_max_depth*
g:iced#paredit#slurp_max_depth
Maximum depth for slurping.
Default value is `5`.
Expand Down Expand Up @@ -2071,7 +2072,7 @@ AUTO DOCUMENT~
*g:iced_enable_auto_document*
g:iced_enable_auto_document
Enable automatic displaying one-line document.
This will be done by |CursorHold| and |CursorHoldI| auto command.
This will be done by |CursorMoved| / |CursorMovedI| auto command and |timer|.

The value should be one of `'normal'`, `'insert'` or `'any'`.
Otherwise, this option will be disabled.
Expand All @@ -2081,7 +2082,9 @@ g:iced_enable_auto_document
`'every'` : Enabled on normal and insert mode.

Default value is `'none'`.
See also |g:iced_enable_popup_document|.
See also:
- |g:iced_enable_popup_document|
- |g:iced#nrepl#auto#document_delay|

*g:iced_enable_popup_document*
g:iced_enable_popup_document
Expand All @@ -2103,6 +2106,12 @@ g:iced_max_distance_for_auto_document

Default value is `2`.

*g:iced#nrepl#auto#document_delay*
g:iced#nrepl#auto#document_delay
Delay time for displaying one-line document.
Unit is milli sec.
Default value is `500`.

------------------------------------------------------------------------------
AUTO INDENT *vim-iced-customizing-auto-indent*

Expand Down
6 changes: 3 additions & 3 deletions ftplugin/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if exists('g:loaded_vim_iced')
finish
endif
let g:loaded_vim_iced = 1
let g:vim_iced_version = 30001
let g:vim_iced_version = 30002
let g:vim_iced_home = expand('<sfile>:p:h:h')
" NOTE: https://github.com/vim/vim/commit/162b71479bd4dcdb3a2ef9198a1444f6f99e6843
" Add functions for defining and placing signs.
Expand Down Expand Up @@ -314,15 +314,15 @@ if g:iced_enable_auto_document ==# 'normal'
\ || g:iced_enable_auto_document ==# 'every'
aug vim_iced_auto_document_normal
au!
au CursorHold *.clj,*.cljs,*.cljc call iced#nrepl#document#current_form()
au CursorMoved *.clj,*.cljs,*.cljc call iced#nrepl#auto#cursor_moved()
aug END
endif

if g:iced_enable_auto_document ==# 'insert'
\ || g:iced_enable_auto_document ==# 'every'
aug vim_iced_auto_document_insert
au!
au CursorHoldI *.clj,*.cljs,*.cljc call iced#nrepl#document#current_form()
au CursorMovedI *.clj,*.cljs,*.cljc call iced#nrepl#auto#cursor_moved()
aug END
endif

Expand Down
2 changes: 1 addition & 1 deletion installer/joker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

version='0.15.7'
version='0.16.0'
file='joker.zip'
if [ "$(uname)" == 'Darwin' ]; then
os='mac'
Expand Down
2 changes: 1 addition & 1 deletion scripts/deps_check.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SCRIPT_DIR=$(cd $(dirname $0); pwd)
TARGETS=("nrepl" "cider/cider-nrepl" "refactor-nrepl" "iced-nrepl")
TARGETS=("nrepl" "cider/cider-nrepl" "refactor-nrepl" "com.github.liquidz/iced-nrepl")

for TARGET in ${TARGETS[@]}; do
EXPECTED_VERSION=$(grep "${TARGET} " ${SCRIPT_DIR}/../deps.edn \
Expand Down
2 changes: 1 addition & 1 deletion test/resources/shadow_cljs/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:deps {nrepl/nrepl {:mvn/version "123"}
cider/cider-nrepl {:mvn/version "234"}
refactor-nrepl/refactor-nrepl {:mvn/version "345"}
iced-nrepl/iced-nrepl {:mvn/version "456"}}
com.github.liquidz/iced-nrepl {:mvn/version "456"}}

:__middlewares__
["cider.nrepl/wrap-classpath"
Expand Down
Loading

0 comments on commit 7d11d3b

Please sign in to comment.