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

Commit c420b84

Browse files
authored
Merge pull request #439 from liquidz/dev
Next release
2 parents 2964493 + 894cf67 commit c420b84

19 files changed

+172
-22
lines changed

CHANGELOG.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].
22

33
== Unreleased (dev)
4+
// {{{
5+
=== Added
6+
* https://github.com/liquidz/vim-iced/issues/434[#434]: Added a feature to evaluate codes in a user specified context.
7+
** See https://liquidz.github.io/vim-iced/#evaluate_in_context for details.
8+
* https://github.com/liquidz/vim-iced/issues/437[#437] Added `g:iced_clj_kondo_analysis_dirs` option.
9+
10+
=== Changed
11+
* Bumped nrepl to 1.0.0.
12+
* Bumped refactor-nrepl to 3.5.5.
13+
* Bumped iced-nrepl to 1.2.462.
14+
// }}}
415

516
== 3.10.3061 (2022-08-19)
17+
// {{{
18+
=== Fixed
19+
* https://github.com/liquidz/vim-iced/issues/432[#432]: Fixed to ignore case on detecting namespaces.
20+
// }}}
621

722
== 3.10.3057 (2022-08-12)
823
// {{{

autoload/iced/component/clj_kondo.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let s:kondo = {
88
\ 'job_out': '',
99
\ 'option': '',
1010
\ 'user_dir': '',
11+
\ 'lint_opts': '',
1112
\ 'cache_dir': '',
1213
\ '__is_analyzing': v:false,
1314
\ }
@@ -59,12 +60,15 @@ function! s:kondo.analyze(callback) abort
5960
let config = g:iced_enable_clj_kondo_local_analysis
6061
\ ? '{:output {:analysis {:protocol-impls true :locals true :keywords true} :format :json}}'
6162
\ : '{:output {:analysis {:protocol-impls true} :format :json}}'
63+
6264
" NOTE: Using `writefile` will freeze vim/nvim just a little
63-
let command = ['sh', '-c', printf('clj-kondo --parallel --lint %s --config ''%s'' > %s',
64-
\ self.user_dir,
65+
let command = ['sh', '-c', printf('clj-kondo --parallel %s --config ''%s'' > %s',
66+
\ self.lint_opts,
6567
\ config,
6668
\ s:temp_name(self.cache_name()),
6769
\ )]
70+
71+
call iced#util#debug('clj-kondo', printf('analyze %s', command))
6872
call self.job_out.redir(command, funcref('s:analyze__analyzed', [a:callback], self))
6973
endfunction
7074

@@ -431,6 +435,11 @@ function! iced#component#clj_kondo#start(this) abort
431435
let user_dir = iced#nrepl#system#user_dir()
432436
let s:kondo.user_dir = empty(user_dir) ? expand('%:p:h') : user_dir
433437

438+
let analysis_dirs = (len(g:iced_clj_kondo_analysis_dirs) > 0)
439+
\ ? g:iced_clj_kondo_analysis_dirs
440+
\ : [user_dir]
441+
let s:kondo.lint_opts = join(map(copy(analysis_dirs), {_, dir -> printf('--lint %s', dir)}), ' ')
442+
434443
return s:kondo
435444
endfunction
436445

autoload/iced/operation.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ function! s:__eval_and_comment(resp) abort
9898
endif
9999
endfunction
100100

101+
let s:last_context = ''
102+
function! iced#operation#eval_in_context(type) abort
103+
call inputsave()
104+
let context = iced#system#get('io').input(iced#message#get('evaluation_context'), s:last_context)
105+
call inputrestore()
106+
if empty(context) | return | endif
107+
108+
let s:last_context = context
109+
return s:eval({code -> iced#repl#execute('eval_code', printf('(clojure.core/let [%s] %s)', s:last_context, code))})
110+
endfunction
111+
101112
function! iced#operation#macroexpand(type) abort
102113
let view = winsaveview()
103114
let reg_save = @@

bin/iced

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SCRIPT_DIR=$(cd $(dirname $0); pwd)
99
PROJECT_DIR=$(cd $SCRIPT_DIR; cd ..; pwd)
1010
VERSION=$(grep 'Version: ' ${SCRIPT_DIR}/../doc/vim-iced.txt | cut -d' ' -f2)
1111

12-
BASE_DEPENDENCIES='nrepl/nrepl:0.9.0 refactor-nrepl/refactor-nrepl:3.5.4 cider/cider-nrepl:0.28.5 com.github.liquidz/iced-nrepl:1.2.458'
12+
BASE_DEPENDENCIES='nrepl/nrepl:1.0.0 refactor-nrepl/refactor-nrepl:3.5.5 cider/cider-nrepl:0.28.5 com.github.liquidz/iced-nrepl:1.2.462'
1313
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'
1414

1515
CLJS_DEPENDENCIES='cider/piggieback:0.5.3'

build.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{:lib com.github.liquidz/vim-iced
2-
:version "3.10.{{git/commit-count}}"
2+
:version "3.11.{{git/commit-count}}"
33
:documents [{:file "doc/vim-iced.txt"
44
:match "^Version: "
55
:action :replace

deps.edn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{:paths ["clj/repl"]
2-
:deps {nrepl/nrepl {:mvn/version "0.9.0"}
3-
refactor-nrepl/refactor-nrepl {:mvn/version "3.5.4"}
2+
:deps {nrepl/nrepl {:mvn/version "1.0.0"}
3+
refactor-nrepl/refactor-nrepl {:mvn/version "3.5.5"}
44
cider/cider-nrepl {:mvn/version "0.28.5"}
5-
com.github.liquidz/iced-nrepl {:mvn/version "1.2.458"}}
5+
com.github.liquidz/iced-nrepl {:mvn/version "1.2.462"}}
66
:__middlewares__
77
["cider.nrepl/wrap-classpath"
88
"cider.nrepl/wrap-clojuredocs"

doc/pages/evaluation.adoc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,51 @@ If you'd like to define a custom mapping, try below.
9696
nmap <silent> ee <Plug>(iced_eval)<Plug>(sexp_outer_list)``
9797
----
9898

99+
=== Context [[evaluate_in_context]]
100+
101+
There are times when you want to evaluate the contents of a function for confirmation.
102+
103+
[source,clojure]
104+
----
105+
(defn greet [s]
106+
;; We'd like to evaluate the following code!
107+
(str "hello " s))
108+
----
109+
110+
It is tired to bind arguments separately,
111+
or to write function calls in the comment form every time.
112+
113+
[source,clojure]
114+
----
115+
(comment (def s "iced"))
116+
;; or
117+
(comment (greet "iced"))
118+
----
119+
120+
This is where evaluating codes in context help you.
121+
There is a default key bindings to evaluate code in a context.
122+
123+
.Default key mappings
124+
[cols="30a,70"]
125+
|===
126+
127+
| [reftext="evaluating outer list"]
128+
[[evaluate_outer_list]]
129+
outer list
130+
| `{plug_iced_eval_in_context}`
131+
132+
|===
133+
134+
With this mapping, the context input will be required.
135+
136+
The context is `clojure.core/let` style.
137+
For example, the context `s "iced"` will be expanded to the following code.
138+
139+
[source,clojure]
140+
----
141+
(clojure.core/let [s "iced"]
142+
(str "hello " s))
143+
----
144+
145+
See {help_html}#%3CPlug%3E%28iced_eval_in_context%29[<Plug>(iced_eval_in_context)] for more information.
146+

doc/pages/index.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
:plug_iced_eval_outer_top_list: <Leader>et
3737
:plug_iced_eval_at_mark: <Leader>ea
3838
:plug_iced_eval_last_outer_top_list: <Leader>el
39+
:plug_iced_eval_in_context: <Leader>ece
3940
:plug_iced_extract_function: <Leader>ref
4041
:plug_iced_format: ==
4142
:plug_iced_format_all: =G

doc/vim-iced.txt

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ CONTENTS *vim-iced-contents*
2525
Evaluating |vim-iced-evaluating|
2626
Stdout Buffer |vim-iced-stdout-buffer|
2727
Yank the result |vim-iced-yank-the-result|
28+
Evaluating in context |vim-iced-eval-in-context|
2829
Testing |vim-iced-testing|
2930
Plain nREPL |vim-iced-testing-plain-nrepl|
3031
Debugging |vim-iced-debugging|
@@ -138,8 +139,8 @@ LEININGEN~
138139
$HOME/.lein/profile.clj
139140
>
140141
{:user
141-
{:dependencies [[nrepl "0.9.0"]
142-
[com.github.liquidz/iced-nrepl "1.2.458"]
142+
{:dependencies [[nrepl "1.0.0"]
143+
[com.github.liquidz/iced-nrepl "1.2.462"]
143144
[cider/cider-nrepl "0.28.5"]]
144145
:repl-options {:nrepl-middleware [cider.nrepl/wrap-classpath
145146
cider.nrepl/wrap-clojuredocs
@@ -158,7 +159,7 @@ LEININGEN~
158159
cider.nrepl/wrap-undef
159160
cider.nrepl/wrap-xref
160161
iced.nrepl/wrap-iced]}
161-
:plugins [[refactor-nrepl "3.5.4"]]}}
162+
:plugins [[refactor-nrepl "3.5.5"]]}}
162163
<
163164

164165
*vim-iced-manual-boot*
@@ -169,9 +170,9 @@ BOOT~
169170
(require (quote boot.repl))
170171
171172
(swap! boot.repl/*default-dependencies* concat
172-
'[[refactor-nrepl "3.5.4"]
173+
'[[refactor-nrepl "3.5.5"]
173174
[cider/cider-nrepl "0.28.5"]
174-
[com.github.liquidz/iced-nrepl "1.2.458"]])
175+
[com.github.liquidz/iced-nrepl "1.2.462"]])
175176
176177
(swap! boot.repl/*default-middleware* concat
177178
'[cider.nrepl/wrap-classpath
@@ -199,9 +200,9 @@ SHADOW-CLJS~
199200
shadow-cljs.edn
200201
>
201202
{
202-
:dependencies [[refactor-nrepl "3.5.4"]
203+
:dependencies [[refactor-nrepl "3.5.5"]
203204
[cider/cider-nrepl "0.28.5"]
204-
[com.github.liquidz/iced-nrepl "1.2.458"]]
205+
[com.github.liquidz/iced-nrepl "1.2.462"]]
205206
}
206207
<
207208
.nrepl.edn (local config) or $HOME/.nrepl/nrepl.edn (global config)
@@ -402,7 +403,7 @@ EVALUATING *vim-iced-evaluating*
402403
- `<Leader>ei` : Evaluate inner element
403404
- `<Leader>ee` : Evaluate outer list
404405
- `<Leader>et` : Evaluate outer top list
405-
c.f. |vim-iced-customizing-default-keys|
406+
cf. |vim-iced-customizing-default-keys|
406407

407408
Specific evaluation range(`|` means cursor position): >
408409
;; <------------et----------->
@@ -445,7 +446,7 @@ YANK THE RESULT *vim-iced-yank-the-result*
445446

446447
Like vim's behavior, iced shifts the previous result of register 1 into
447448
register 2, 2 into 3, and so forth.
448-
449+
449450
If you have values you don't want to store,
450451
See |g:iced#eval#values_to_skip_storing_register|.
451452

@@ -461,6 +462,27 @@ YANK THE RESULT *vim-iced-yank-the-result*
461462
" mapping for "xee
462463
nmap <silent> ee <Plug>(iced_eval)<Plug>(sexp_outer_list)``
463464
<
465+
------------------------------------------------------------------------------
466+
EVALUATING IN CONTEXT *vim-iced-eval-in-context*
467+
468+
There are times when you want to evaluate the contents of a function
469+
for confirmation.
470+
>
471+
(defn greet [s]
472+
(str "hello " s))
473+
<
474+
It is tired to bind arguments separately, (e.g. `(def s "iced")`)
475+
or to write function calls in the comment form every time.
476+
(e.g. `(comment (greet "iced"))`)
477+
478+
This is where evaluating codes in context help you.
479+
480+
There is a default key bindings to evaluate code in a context.
481+
- `<Leader>ece` : Evaluate outer list in a context
482+
cf. |vim-iced-customizing-default-keys|
483+
484+
See |<Plug>(iced_eval_in_context)| for more information.
485+
464486
==============================================================================
465487
TESTING *vim-iced-testing*
466488

@@ -579,7 +601,8 @@ JUMP TO DEFINITION *vim-iced-tag-jump* *vim-iced-jump-to-def
579601
|:IcedDefJump| to jump to definition.
580602
It is also supported to jump to qualified keywords and local vars.
581603

582-
If the jump destination for keyword is inaccurate or the jump is slow, enabling clj-kondo feature may improve the result.
604+
If the jump destination for keyword is inaccurate or the jump is slow,
605+
enabling clj-kondo feature may improve the result.
583606
- |vim-iced-static-analysis-clj-kondo|
584607

585608
To jump back, you can use default key mapping(<C-t>).
@@ -714,6 +737,11 @@ CLJ-KONDO *vim-iced-static-analysis-clj-kondo*
714737
This can be used to support jumping to local vars.
715738
To enable, see |g:iced_enable_clj_kondo_local_analysis|.
716739

740+
ANALYSIS DIRECTORIES
741+
vim-iced uses the project root directory for analysis by default.
742+
If you want to analyze files only in specific directories,
743+
see |g:iced_clj_kondo_analysis_dirs|.
744+
717745
TIPS
718746
- Cached files will be separated to var definition/usage and
719747
ns definition/usage automatically if you have `jq` or `jet`.
@@ -1086,7 +1114,7 @@ COMMANDS *vim-iced-commands*
10861114
*:IcedJavaDocument*
10871115
:IcedJavaDocument [{class_name}]
10881116
Opens a browser window displaying the javadoc for {class_name}.
1089-
c.f. https://clojuredocs.org/clojure.java.javadoc/javadoc
1117+
cf. https://clojuredocs.org/clojure.java.javadoc/javadoc
10901118

10911119
If {class_name} is not passed,
10921120
the result of `clojure.core/class` for the form under cursor is used.
@@ -1177,7 +1205,7 @@ COMMANDS *vim-iced-commands*
11771205
:IcedFormatSync
11781206
Same as |:IcedFormat|, but it's done synchronously.
11791207
Key is mapped to |<Plug>(iced_format_sync)|.
1180-
1208+
11811209
*:IcedFormatSyncAll*
11821210
:IcedFormatSyncAll
11831211
Same as |:IcedFormatAll|, but it's done synchronously.
@@ -1492,6 +1520,17 @@ KEY MAPPINGS *vim-iced-key-mappings*
14921520
<Plug>(iced_eval_and_comment)<Plug>(sexp_outer_list)``
14931521
<Plug>(iced_eval_and_comment)<Plug>(sexp_outer_top_list)``
14941522
<
1523+
*<Plug>(iced_eval_in_context)*
1524+
<Plug>(iced_eval_in_context)
1525+
Evaluate code in the user specified context.
1526+
The context is `clojure.core/let` style.
1527+
For example, the context `foo "bar" num 10` will be expanded to
1528+
`(clojure.core/let [foo "bar" num 10] ...)`.
1529+
1530+
The input context is saved and will be expanded at the next evaluation.
1531+
1532+
See also |vim-iced-eval-in-context|.
1533+
14951534
*<Plug>(iced_eval_ns)*
14961535
<Plug>(iced_eval_ns)
14971536
Same as |:IcedEvalNs|.
@@ -1907,7 +1946,7 @@ g:iced#eval#mark_at_last
19071946
g:iced#eval#values_to_skip_storing_register
19081947
Evaluated values not to store to numbered registers.
19091948
Default value is `['nil', 'true', 'false']`.
1910-
1949+
19111950
*g:iced#eval#popup_highlight*
19121951
g:iced#eval#popup_highlight
19131952
The highlight setting for popup to display evaluated result.
@@ -1961,7 +2000,7 @@ g:iced#grep#format
19612000
*g:iced#refactor#prefix_rewriting*
19622001
g:iced#refactor#prefix_rewriting
19632002
Should `clean-ns` favor prefix forms in the ns macro?
1964-
c.f. https://github.com/clojure-emacs/refactor-nrepl#available-features
2003+
cf. https://github.com/clojure-emacs/refactor-nrepl#available-features
19652004
Default value is `v:false`.
19662005

19672006
*g:iced#refactor#insert_newline_after_require*
@@ -2056,6 +2095,13 @@ g:iced_enable_clj_kondo_local_analysis
20562095
Default value is `v:false`.
20572096
See also |vim-iced-static-analysis-clj-kondo|.
20582097

2098+
*g:iced_clj_kondo_analysis_dirs*
2099+
g:iced_clj_kondo_analysis_dirs
2100+
If some values are set, vim-iced uses these directories for analysis
2101+
by clj-kondo.
2102+
If this option is empty, vim-iced uses the project root directory.
2103+
Default value is `[]`.
2104+
20592105
*g:iced#navigate#prefer_local_jump*
20602106
g:iced#navigate#prefer_local_jump
20612107
If {v:true}, change the behavior of |:IcedDefJump| to prefer local jumping.
@@ -2438,7 +2484,7 @@ CONNECT PREPARED *hook_event_connect_prepared*
24382484

24392485
Hooked before the start of connection.
24402486
This hook only allows `function` hook type.
2441-
c.f. |hook_report_function|
2487+
cf. |hook_report_function|
24422488

24432489
Following list is passed to reporter.
24442490
e.g. `[{'label': 'nREPL', 'type': 'nrepl', 'port': 12345}]`
@@ -2601,6 +2647,7 @@ g:iced_enable_default_key_mappings
26012647
n <Leader>" <Plug>(iced_jack_in)
26022648
n <Leader>ei <Plug>(iced_eval)<Plug>(sexp_inner_element)``
26032649
n <Leader>ee <Plug>(iced_eval)<Plug>(sexp_outer_list)``
2650+
n <Leader>ece <Plug>(iced_eval_in_context)<Plug>(sexp_outer_list)``
26042651
n <Leader>et <Plug>(iced_eval_outer_top_list)
26052652
n <Leader>ea <Plug>(iced_eval_at_mark)
26062653
n <Leader>el <Plug>(iced_eval_last_outer_top_list)

0 commit comments

Comments
 (0)