diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cc32a37fb..5678b27e1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.x' - run: pip install -r requirements.txt diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 34afdc8e2..b077c840b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.x' - name: python doctest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b3e7d2f2..3a36850b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: 11 diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 01bfadf00..73bca8b3d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: '16' diff --git a/.github/workflows/vim_neovim.yml b/.github/workflows/vim_neovim.yml index 2e7b083a1..af4f2989a 100644 --- a/.github/workflows/vim_neovim.yml +++ b/.github/workflows/vim_neovim.yml @@ -39,7 +39,7 @@ jobs: env: THEMIS_VIM: ${{ steps.vim.outputs.executable }} run: ./.vim-themis/bin/themis - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.x' - name: Coverage diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 4ee822648..ac7acb126 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,9 +1,19 @@ All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com]. == Unreleased (dev) +// {{{ +=== Added +* Added instant connection support for https://github.com/squint-cljs/squint[Squint]. +** `:IcedInstantConnect squint` -== 3.14.3255 (2023-09-29) +=== Changed +* Bumped build.edn to 0.11.241. +* Bumped cider-nrepl to 0.44.0. +* Bumped refactor-nrepl to 3.9.1. +* Bumped nrepl to 1.1.0. +// }}} +== 3.14.3255 (2023-09-29) // {{{ === Fixed * Fixed `IcedInstantConnect` to work correctly with the latest babashka. diff --git a/README.adoc b/README.adoc index ec28984bb..49b64013d 100644 --- a/README.adoc +++ b/README.adoc @@ -171,6 +171,6 @@ and https://github.com/liquidz/iced-nrepl[iced-nrepl]. == License -Copyright (c) 2018-2023 http://twitter.com/uochan[Masashi Iizuka] +Copyright (c) 2018-2024 https://scrapbox.io/uochan/uochan[Masashi Iizuka] Distributed under the MIT License. diff --git a/autoload/iced/nrepl/connect.vim b/autoload/iced/nrepl/connect.vim index 4b98b6bbb..fac280ce6 100644 --- a/autoload/iced/nrepl/connect.vim +++ b/autoload/iced/nrepl/connect.vim @@ -251,15 +251,56 @@ function! s:__instant_nbb(port) abort endif endfunction +function! s:try_connecting_to_squint(port) abort + try + return iced#repl#connect('nrepl', a:port, { + \ 'with_iced_nrepl': v:false, + \ 'initial_session': 'cljs', + \ 'verbose': v:false, + \ }) + catch + return v:false + endtry +endfunction + +function! s:__instant_squint(port) abort + " NOTE: A job in vim may terminate when outputting long texts such as stack traces. + " So ignoring the standard output etc. + if executable('squint') + let squint_cmd = 'squint' + elseif executable('deno') + let squint_cmd = 'deno run -A npm:squint-cljs@latest' + else + return iced#message#error('command_not_found', 'squint or deno') + endif + let cmd = ['sh', '-c', printf('%s nrepl-server :port %s > /dev/null 2>&1', squint_cmd, a:port)] + let s:running_job = iced#job_start(cmd) + + let s:is_auto_connecting = v:true + call iced#message#echom('connecting') + let result = iced#util#wait({-> + \ empty(s:try_connecting_to_squint(a:port))}, + \ 3000) + let s:is_auto_connecting = v:false + + if result + call iced#message#info('connected_to', printf('port %s', a:port)) + else + call iced#message#error('connect_error') + endif +endfunction + function! iced#nrepl#connect#instant(program) abort if iced#nrepl#is_connected() return iced#message#info('already_connected') endif if a:program ==# 'babashka' - return iced#script#empty_port({port -> s:__instant_babashka(port)}) + return iced#script#bb_empty_port({port -> s:__instant_babashka(port)}) elseif a:program ==# 'nbb' - return iced#script#empty_port({port -> s:__instant_nbb(port)}) + return iced#script#nbb_empty_port({port -> s:__instant_nbb(port)}) + elseif a:program ==# 'squint' + return iced#script#nbb_empty_port({port -> s:__instant_squint(port)}) else return s:__instant_clj() endif diff --git a/autoload/iced/palette.vim b/autoload/iced/palette.vim index 6590c3a2d..89dbd95ca 100644 --- a/autoload/iced/palette.vim +++ b/autoload/iced/palette.vim @@ -3,7 +3,7 @@ set cpoptions&vim let s:default_palette = [ \ 'Connect', 'Disconnect', 'Reconnect', 'Interrupt', 'InterruptAll', - \ 'InstantConnect', 'InstantConnect babashka', 'InstantConnect nbb', 'JackIn', + \ 'InstantConnect', 'InstantConnect babashka', 'InstantConnect nbb', 'InstantConnect squint', 'JackIn', \ 'StartCljsRepl {{env}}', \ 'QuitCljsRepl', 'CycleSession', \ 'EvalNs', 'Undef', 'UndefAllInNs', 'UnaliasNs', diff --git a/autoload/iced/repl.vim b/autoload/iced/repl.vim index 96638eaea..c3e3f06c9 100644 --- a/autoload/iced/repl.vim +++ b/autoload/iced/repl.vim @@ -43,7 +43,7 @@ endfunction " c.f. :h :command-completion-custom function! iced#repl#instant_connect_complete(arg_lead, cmd_line, cursor_pos) abort - let res = ['nrepl', 'babashka', 'nbb'] + let res = ['nrepl', 'babashka', 'nbb', 'squint'] call extend(res, iced#socket_repl#connect#supported_programs()) return join(res, "\n") endfunction @@ -52,6 +52,7 @@ function! iced#repl#instant_connect(target) abort if a:target ==# '' \ || (g:iced#repl#babashka_repl_type ==# 'nrepl' && a:target ==# 'babashka') \ || a:target ==# 'nbb' + \ || a:target ==# 'squint' call iced#nrepl#connect#instant(a:target) elseif a:target ==# 'prepl' call iced#prepl#connect#instant() diff --git a/autoload/iced/script.vim b/autoload/iced/script.vim index d1d014e4d..8c35b7aaa 100644 --- a/autoload/iced/script.vim +++ b/autoload/iced/script.vim @@ -1,17 +1,33 @@ let s:save_cpo = &cpoptions set cpoptions&vim -function! s:setup() abort +function! s:bb_setup() abort if !executable('bb') call iced#promise#sync(iced#system#get('installer').install, ['bb'], 10000) endif endfunction -function! iced#script#empty_port(callback) abort - call s:setup() +function! iced#script#bb_empty_port(callback) abort + call s:bb_setup() let command = printf('bb --prn %s/clj/script/empty_port.clj', g:vim_iced_home) return iced#system#get('job_out').redir(command, a:callback) endfunction +function! s:nbb_command() abort + if executable('nbb') + return 'nbb' + elseif executable('deno') + return 'deno run -A npm:nbb@latest' + endif + + throw 'nbb or deno is not found.' +endfunction + +function! iced#script#nbb_empty_port(callback) abort + let cmd = s:nbb_command() + let command = printf('%s %s/clj/script/nbb_empty_port.cljs', cmd, g:vim_iced_home) + return iced#system#get('job_out').redir(command, a:callback) +endfunction + let &cpoptions = s:save_cpo unlet s:save_cpo diff --git a/autoload/iced/socket_repl/connect.vim b/autoload/iced/socket_repl/connect.vim index ace32daca..159c0fe6f 100644 --- a/autoload/iced/socket_repl/connect.vim +++ b/autoload/iced/socket_repl/connect.vim @@ -32,7 +32,7 @@ function! iced#socket_repl#connect#instant(program) abort return endif - return iced#script#empty_port({port -> s:start_and_connect(port, cmd)}) + return iced#script#bb_empty_port({port -> s:start_and_connect(port, cmd)}) endfunction let &cpoptions = s:save_cpo diff --git a/bin/iced b/bin/iced index 44446f06b..5963fd8ad 100755 --- a/bin/iced +++ b/bin/iced @@ -9,7 +9,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:1.0.0 refactor-nrepl/refactor-nrepl:3.9.0 cider/cider-nrepl:0.38.1 com.github.liquidz/iced-nrepl:1.2.480' +BASE_DEPENDENCIES='nrepl/nrepl:1.1.0 refactor-nrepl/refactor-nrepl:3.9.1 cider/cider-nrepl:0.44.0 com.github.liquidz/iced-nrepl:1.2.480' 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-refresh cider.nrepl/wrap-stacktrace 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.3' diff --git a/build.edn b/build.edn index 6fbe18c0b..3f282f00a 100644 --- a/build.edn +++ b/build.edn @@ -1,5 +1,5 @@ {:lib com.github.liquidz/vim-iced - :version "3.14.{{git/commit-count}}" + :version "3.15.{{git/commit-count}}" :documents [{:file "doc/vim-iced.txt" :match "^Version: " :action :replace diff --git a/clj/script/nbb_empty_port.cljs b/clj/script/nbb_empty_port.cljs new file mode 100644 index 000000000..b2c35439e --- /dev/null +++ b/clj/script/nbb_empty_port.cljs @@ -0,0 +1,13 @@ +(ns nbb-empty-port + (:require + ["net" :as net])) + +(let [server (net/createServer)] + (.on server "listening" (fn [] + (print (.-port (.address server))) + (.close server))) + (js/Promise. + (fn [resolve reject] + (.on server "close" (fn [] (resolve true))) + (.on server "error" (fn [err] (reject err))) + (.listen server 0 "localhost")))) diff --git a/deps.edn b/deps.edn index adc6ab4a7..6b4b0fb1c 100644 --- a/deps.edn +++ b/deps.edn @@ -1,7 +1,7 @@ {:paths ["clj/repl"] - :deps {nrepl/nrepl {:mvn/version "1.0.0"} - refactor-nrepl/refactor-nrepl {:mvn/version "3.9.0"} - cider/cider-nrepl {:mvn/version "0.38.1"} + :deps {nrepl/nrepl {:mvn/version "1.1.0"} + refactor-nrepl/refactor-nrepl {:mvn/version "3.9.1"} + cider/cider-nrepl {:mvn/version "0.44.0"} com.github.liquidz/iced-nrepl {:mvn/version "1.2.480"}} :__middlewares__ ["cider.nrepl/wrap-classpath" @@ -39,6 +39,6 @@ :outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "RELEASE"} org.slf4j/slf4j-nop {:mvn/version "RELEASE"}} :main-opts ["-m" "antq.core"]} - :build {:deps {com.github.liquidz/build.edn {:mvn/version "0.10.227"}} + :build {:deps {com.github.liquidz/build.edn {:mvn/version "0.11.241"}} :ns-default build-edn.main} :dev {}}} diff --git a/doc/vim-iced.txt b/doc/vim-iced.txt index 816f01271..e67e60aa6 100644 --- a/doc/vim-iced.txt +++ b/doc/vim-iced.txt @@ -142,9 +142,9 @@ LEININGEN~ $HOME/.lein/profile.clj > {:user - {:dependencies [[nrepl "1.0.0"] + {:dependencies [[nrepl "1.1.0"] [com.github.liquidz/iced-nrepl "1.2.480"] - [cider/cider-nrepl "0.38.1"]] + [cider/cider-nrepl "0.44.0"]] :repl-options {:nrepl-middleware [cider.nrepl/wrap-classpath cider.nrepl/wrap-clojuredocs cider.nrepl/wrap-complete @@ -162,7 +162,7 @@ LEININGEN~ cider.nrepl/wrap-undef cider.nrepl/wrap-xref iced.nrepl/wrap-iced]} - :plugins [[refactor-nrepl "3.9.0"]]}} + :plugins [[refactor-nrepl "3.9.1"]]}} < *vim-iced-manual-boot* @@ -173,8 +173,8 @@ BOOT~ (require (quote boot.repl)) (swap! boot.repl/*default-dependencies* concat - '[[refactor-nrepl "3.9.0"] - [cider/cider-nrepl "0.38.1"] + '[[refactor-nrepl "3.9.1"] + [cider/cider-nrepl "0.44.0"] [com.github.liquidz/iced-nrepl "1.2.480"]]) (swap! boot.repl/*default-middleware* concat @@ -203,8 +203,8 @@ SHADOW-CLJS~ shadow-cljs.edn > { - :dependencies [[refactor-nrepl "3.9.0"] - [cider/cider-nrepl "0.38.1"] + :dependencies [[refactor-nrepl "3.9.1"] + [cider/cider-nrepl "0.44.0"] [com.github.liquidz/iced-nrepl "1.2.480"]] } < diff --git a/test/component_sign.vim b/test/component_sign.vim index d34dad30a..e597dca62 100644 --- a/test/component_sign.vim +++ b/test/component_sign.vim @@ -51,6 +51,12 @@ function! s:list_in_buffer() abort return list endfunction +function! s:dissoc(d, k) abort + let d = copy(a:d) + unlet d[a:k] + return d +endfunction + function! s:suite.list_in_buffer_test() abort call s:setup() @@ -210,18 +216,31 @@ function! s:suite.refresh_test() abort call s:setup() exec printf(':b %d', bufnr(s:foo_file)) - call s:assert.equals(s:list_in_buffer(), [ - \ {'lnum': 3, 'id': 1, 'name': 'iced_dummy1', 'group': 'default'}, - \ {'lnum': 5, 'id': 1, 'name': 'iced_dummy1', 'group': 'group1'}, - \ {'lnum': 7, 'id': 2, 'name': 'iced_dummy2', 'group': 'default'}, - \ ]) + let before_list_in_buffer = s:list_in_buffer() + let before_ids = map(copy(before_list_in_buffer), {_, v -> v['id']}) + + call s:assert.equals( + \ map(copy(before_list_in_buffer), {_, v -> s:dissoc(v, 'id')}), + \ [ + \ {'lnum': 3, 'name': 'iced_dummy1', 'group': 'default'}, + \ {'lnum': 5, 'name': 'iced_dummy1', 'group': 'group1'}, + \ {'lnum': 7, 'name': 'iced_dummy2', 'group': 'default'}, + \ ]) call s:sign.refresh({'file': s:foo_file}) - call s:assert.equals(s:list_in_buffer(), [ - \ {'lnum': 3, 'id': 3, 'name': 'iced_dummy1', 'group': 'default'}, - \ {'lnum': 5, 'id': 1, 'name': 'iced_dummy1', 'group': 'group1'}, - \ {'lnum': 7, 'id': 4, 'name': 'iced_dummy2', 'group': 'default'}, - \ ]) + + let after_list_in_buffer = s:list_in_buffer() + let after_ids = map(copy(after_list_in_buffer), {_, v -> v['id']}) + + call s:assert.equals( + \ map(copy(after_list_in_buffer), {_, v -> s:dissoc(v, 'id')}), + \ [ + \ {'lnum': 3, 'name': 'iced_dummy1', 'group': 'default'}, + \ {'lnum': 5, 'name': 'iced_dummy1', 'group': 'group1'}, + \ {'lnum': 7, 'name': 'iced_dummy2', 'group': 'default'}, + \ ]) + + call s:assert.not_equals(before_ids, after_ids) call s:teardown() endfunction diff --git a/test/nrepl_eval.vim b/test/nrepl_eval.vim index 561d5374a..402302595 100644 --- a/test/nrepl_eval.vim +++ b/test/nrepl_eval.vim @@ -56,6 +56,9 @@ function! s:suite.code_test() abort let g:iced#eval#keep_inline_result = v:false let g:iced#eval#popup_highlight = 'Comment' let g:iced#eval#inside_comment = v:false + let g:iced#eval#popup_spinner_texts = [''] + let g:iced#eval#popup_align = 'after' + let g:iced#eval#popup_spinner_interval = 100 let p = iced#nrepl#eval#code('(comment (+ 1 2 3))') call iced#promise#wait(p)