Skip to content

Commit

Permalink
Merge pull request #29 from liquidz/dev
Browse files Browse the repository at this point in the history
ver 0.3.2
  • Loading branch information
liquidz authored Sep 14, 2018
2 parents 41a6e97 + c686667 commit 2e53e66
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions autoload/iced/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')],
Expand All @@ -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',
Expand Down
10 changes: 7 additions & 3 deletions autoload/iced/format.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
let @@ = resp['formatted']
silent normal! gvp
elseif has_key(resp, 'error')
call iced#message#error_str(resp['error'])
endif
endif
finally
Expand Down
2 changes: 2 additions & 0 deletions autoload/iced/nrepl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions autoload/iced/nrepl/function.vim
Original file line number Diff line number Diff line change
@@ -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'])
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions autoload/iced/nrepl/iced.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
14 changes: 7 additions & 7 deletions autoload/iced/nrepl/ns/transition.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion autoload/iced/paredit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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(@@)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
Expand Down
8 changes: 4 additions & 4 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

Version: 0.3.1
Version: 0.3.2
Author : uochan <liquidz.uo+vim@gmail.com>
License: MIT LICENSE

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 2e53e66

Please sign in to comment.