From 5be09438cf6897699408d7f995627489d3ecc31c Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:38:49 +0900 Subject: [PATCH 1/9] Update completion to use forward matching --- autoload/iced/complete.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/iced/complete.vim b/autoload/iced/complete.vim index d1dc09753..7e571d4f2 100644 --- a/autoload/iced/complete.vim +++ b/autoload/iced/complete.vim @@ -59,7 +59,7 @@ function! s:ns_var_candidates(ns_name, base, alias) abort let dict = get(resp, 'ns-vars-with-meta', {}) for k in keys(dict) - if stridx(k, a:base) != -1 + if stridx(k, a:base) == 0 call add(result, { \ 'candidate': (empty(a:alias) ? k : printf('%s/%s', a:alias, k)), \ 'arglists': [get(dict[k], 'arglists', '')], @@ -75,7 +75,7 @@ endfunction function! s:ns_alias_candidates(aliases, base) abort let result = [] for alias in a:aliases - if stridx(alias, a:base) != -1 + if stridx(alias, a:base) == 0 call add(result, { \ 'candidate': alias, \ 'type': 'namespace', From bb7e9ab7de07244c000f8068b94e888e1e337fda Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:44:49 +0900 Subject: [PATCH 2/9] Update iced#format to handle error --- autoload/iced/format.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/iced/format.vim b/autoload/iced/format.vim index 036ee0457..c009a56c2 100644 --- a/autoload/iced/format.vim +++ b/autoload/iced/format.vim @@ -15,11 +15,15 @@ function! iced#format#form() abort try let res = iced#paredit#get_current_top_list_raw() let code = res['code'] - if !empty(code) + if empty(code) + call iced#message#warning('finding_code_error') + else let resp = iced#nrepl#iced#sync#format_code(code, g:iced#format#rule) if has_key(resp, 'formatted') && !empty(resp['formatted']) let @@ = resp['formatted'] silent normal! gvp + elseif has_key(resp, 'error') + call iced#message#error_str(resp['error']) endif endif finally From 7e0281a534954aa3ba8eb667b48d389ec68c6aee Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:45:59 +0900 Subject: [PATCH 3/9] Update interruption to ignore reading response error --- autoload/iced/nrepl.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/iced/nrepl.vim b/autoload/iced/nrepl.vim index 7302d9e50..409f7eb7e 100644 --- a/autoload/iced/nrepl.vim +++ b/autoload/iced/nrepl.vim @@ -311,6 +311,8 @@ function! iced#nrepl#interrupt(...) abort return endif let session = get(a:, 1, iced#nrepl#current_session()) + " NOTE: ignore reading error + let s:response_buffer = '' call iced#nrepl#send({ \ 'op': 'interrupt', \ 'session': session, From 5e9b28a48cc7c57f77ebdf64491ae32bcabcaeab Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:46:41 +0900 Subject: [PATCH 4/9] Fix concat handler to allow parallel working --- autoload/iced/nrepl/iced.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/iced/nrepl/iced.vim b/autoload/iced/nrepl/iced.vim index 2070c4d59..0326b929c 100644 --- a/autoload/iced/nrepl/iced.vim +++ b/autoload/iced/nrepl/iced.vim @@ -32,19 +32,19 @@ function! iced#nrepl#iced#grimoire(platform, ns_name, symbol, callback) abort \ }) endfunction -let s:concat_results = [] +let s:concat_results = {} function! s:concat_handler(key, resp) abort for resp in iced#util#ensure_array(a:resp) if has_key(resp, a:key) - call extend(s:concat_results, resp[a:key]) + call extend(s:concat_results[a:key], resp[a:key]) endif endfor - return s:concat_results + return s:concat_results[a:key] endfunction function! iced#nrepl#iced#project_namespaces(callback) abort if !iced#nrepl#is_connected() | return iced#message#error('not_connected') | endif - let s:concat_results = [] + let s:concat_results['namespaces'] = [] call iced#nrepl#send({ \ 'id': iced#nrepl#eval#id(), \ 'op': 'project-namespaces', @@ -55,7 +55,7 @@ endfunction function! iced#nrepl#iced#project_functions(callback) abort if !iced#nrepl#is_connected() | return iced#message#error('not_connected') | endif - let s:concat_results = [] + let s:concat_results['functions'] = [] call iced#nrepl#send({ \ 'id': iced#nrepl#eval#id(), \ 'op': 'project-functions', From 7535ae7c8ba06bd3f1c6827689eba22280868d36 Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:48:17 +0900 Subject: [PATCH 5/9] Disable file cache in namespaces, and functions --- autoload/iced/nrepl/function.vim | 14 +++++++------- autoload/iced/nrepl/ns/transition.vim | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/autoload/iced/nrepl/function.vim b/autoload/iced/nrepl/function.vim index dca4034ab..b6622672d 100644 --- a/autoload/iced/nrepl/function.vim +++ b/autoload/iced/nrepl/function.vim @@ -1,7 +1,7 @@ let s:save_cpo = &cpo set cpo&vim -let s:cache_name = 'functions' +"let s:cache_name = 'functions' function! s:open(mode, resp) abort if !has_key(a:resp, 'file') || empty(a:resp['file']) @@ -31,18 +31,18 @@ endfunction function! s:select(functions) abort if empty(a:functions) | return iced#message#error('not_found') | endif - call ctrlp#iced#cache#write(s:cache_name, a:functions) + "call ctrlp#iced#cache#write(s:cache_name, a:functions) call ctrlp#iced#start({'candidates': a:functions, 'accept': funcref('s:resolve')}) endfunction function! iced#nrepl#function#list() abort - if ctrlp#iced#cache#exists(s:cache_name) - let lines = ctrlp#iced#cache#read(s:cache_name) - call ctrlp#iced#start({'candidates': lines, 'accept': funcref('s:resolve')}) - else + " if ctrlp#iced#cache#exists(s:cache_name) + " let lines = ctrlp#iced#cache#read(s:cache_name) + " call ctrlp#iced#start({'candidates': lines, 'accept': funcref('s:resolve')}) + " else call iced#message#info('fetching') call iced#nrepl#iced#project_functions(funcref('s:select')) - endif + " endif endfunction let &cpo = s:save_cpo diff --git a/autoload/iced/nrepl/ns/transition.vim b/autoload/iced/nrepl/ns/transition.vim index 7b9010591..414f76af3 100644 --- a/autoload/iced/nrepl/ns/transition.vim +++ b/autoload/iced/nrepl/ns/transition.vim @@ -36,22 +36,22 @@ function! iced#nrepl#ns#transition#toggle_src_and_test() abort call s:open('e', toggle_ns) endfunction -let s:cache_name = 'namespaces' +"let s:cache_name = 'namespaces' function! s:select_ns_from_list(namespaces) abort if empty(a:namespaces) | return iced#message#error('not_found') | endif - call ctrlp#iced#cache#write(s:cache_name, a:namespaces) + "call ctrlp#iced#cache#write(s:cache_name, a:namespaces) call ctrlp#iced#start({'candidates': a:namespaces, 'accept': funcref('s:open')}) endfunction function! iced#nrepl#ns#transition#list() abort - if ctrlp#iced#cache#exists(s:cache_name) - let lines = ctrlp#iced#cache#read(s:cache_name) - call ctrlp#iced#start({'candidates': lines, 'accept': funcref('s:open')}) - else + " if ctrlp#iced#cache#exists(s:cache_name) + " let lines = ctrlp#iced#cache#read(s:cache_name) + " call ctrlp#iced#start({'candidates': lines, 'accept': funcref('s:open')}) + " else call iced#message#info('fetching') call iced#nrepl#iced#project_namespaces(funcref('s:select_ns_from_list')) - endif + " endif endfunction let &cpo = s:save_cpo From b3020d274dc13118628f796f89cf8b9cf226035a Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:49:15 +0900 Subject: [PATCH 6/9] Fix to detect unmatching paren correctly --- autoload/iced/paredit.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/iced/paredit.vim b/autoload/iced/paredit.vim index b642c7c64..4eb586ac0 100644 --- a/autoload/iced/paredit.vim +++ b/autoload/iced/paredit.vim @@ -38,6 +38,7 @@ function! iced#paredit#get_current_top_list_raw() abort try while v:true " move to start position of current outer list + let @@ = '' silent exe 'normal! vaby' " no matched parenthesis if empty(@@) @@ -64,7 +65,7 @@ function! iced#paredit#get_current_top_list() abort let view = winsaveview() let reg_save = @@ let res = v:none - + try let res = iced#paredit#get_current_top_list_raw() finally From bc160eb6794ce3d73d67dadaf5387a1bc64cd8a3 Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:51:06 +0900 Subject: [PATCH 7/9] Bump iced-nrepl --- deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index 6b7ac8e4d..72e9393e6 100644 --- a/deps.edn +++ b/deps.edn @@ -3,7 +3,7 @@ :deps {nrepl {:mvn/version "0.4.5"} refactor-nrepl {:mvn/version "2.4.0"} cider/cider-nrepl {:mvn/version "0.18.0"} - iced-nrepl {:mvn/version "0.1.1"}} + iced-nrepl {:mvn/version "0.1.2"}} :aliases {:ancient {:extra-deps {olical/depot {:mvn/version "1.2.0"}} From aeafc9921b94c7b19c2c9bfbb1e5fa7caa1c814f Mon Sep 17 00:00:00 2001 From: liquidz Date: Fri, 14 Sep 2018 17:53:00 +0900 Subject: [PATCH 8/9] ver 0.3.2 --- README.md | 4 ++-- doc/vim-iced.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e0c42c713..a395f31c8 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ See [vim-iced.txt](./doc/vim-iced.txt) for actual mappings. ```clj {:user {:dependencies [[nrepl "0.4.5"] - [iced-nrepl "0.1.0"] + [iced-nrepl "0.1.2"] [cider/cider-nrepl "0.18.0"]] :repl-options {:nrepl-middleware [cider.nrepl/wrap-complete cider.nrepl/wrap-debug @@ -90,7 +90,7 @@ See [vim-iced.txt](./doc/vim-iced.txt) for actual mappings. 1. Start repl - `lein repl` - `boot repl` - - `clojure -Sdeps '{:deps {iced-repl {:git/url "https://github.com/liquidz/vim-iced" :sha "ac7affd6ab4b9e28f917a8900bd19465c8a08b7b"}}}' -m iced-repl` + - `clojure -Sdeps '{:deps {iced-repl {:git/url "https://github.com/liquidz/vim-iced" :sha "bc160eb6794ce3d73d67dadaf5387a1bc64cd8a3"}}}' -m iced-repl` 2. Open source file 3. Evaluate forms (If not connected, vim-iced will connect automatically) diff --git a/doc/vim-iced.txt b/doc/vim-iced.txt index cebd6bf2c..148d428c9 100644 --- a/doc/vim-iced.txt +++ b/doc/vim-iced.txt @@ -1,6 +1,6 @@ *vim-iced.txt* Clojure interactive development environment for Vim8 -Version: 0.3.1 +Version: 0.3.2 Author : uochan License: MIT LICENSE @@ -63,7 +63,7 @@ Leiningen *vim-iced-leiningen* > {:user {:dependencies [[nrepl "0.4.5"] - [iced-nrepl "0.1.1"] + [iced-nrepl "0.1.2"] [cider/cider-nrepl "0.18.0"]] :repl-options {:nrepl-middleware [cider.nrepl/wrap-complete cider.nrepl/wrap-debug @@ -91,7 +91,7 @@ Boot *vim-iced-boot* (swap! boot.repl/*default-dependencies* concat '[[refactor-nrepl "2.4.0"] [cider/cider-nrepl "0.18.0"] - [iced-nrepl "0.1.1"]]) + [iced-nrepl "0.1.2"]]) (swap! boot.repl/*default-middleware* concat '[cider.nrepl/wrap-complete @@ -116,7 +116,7 @@ nREPL Connection *vim-iced-nrepl-connection* REPL needs to be activated beforehand. - `lein repl` - `boot repl` - - `clojure -Sdeps '{:deps {iced-repl {:git/url "https://github.com/liquidz/vim-iced" :sha "ac7affd6ab4b9e28f917a8900bd19465c8a08b7b"}}}' -m iced-repl` + - `clojure -Sdeps '{:deps {iced-repl {:git/url "https://github.com/liquidz/vim-iced" :sha "bc160eb6794ce3d73d67dadaf5387a1bc64cd8a3"}}}' -m iced-repl` |:IcedConnect| to connect nREPL. If not connected at the time of evaluation, From c6866674b2dabc07506e8817a10dfe3b8a5a55ca Mon Sep 17 00:00:00 2001 From: Masashi Iizuka Date: Sat, 15 Sep 2018 08:11:17 +0900 Subject: [PATCH 9/9] Fix indent --- autoload/iced/format.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autoload/iced/format.vim b/autoload/iced/format.vim index c009a56c2..98eb1d233 100644 --- a/autoload/iced/format.vim +++ b/autoload/iced/format.vim @@ -20,10 +20,10 @@ function! iced#format#form() abort else let resp = iced#nrepl#iced#sync#format_code(code, g:iced#format#rule) if has_key(resp, 'formatted') && !empty(resp['formatted']) - let @@ = resp['formatted'] - silent normal! gvp - elseif has_key(resp, 'error') - call iced#message#error_str(resp['error']) + let @@ = resp['formatted'] + silent normal! gvp + elseif has_key(resp, 'error') + call iced#message#error_str(resp['error']) endif endif finally