Skip to content

Commit b23a8cc

Browse files
committed
cider: fix refactor-nrepl option passthrough
The method of passing through refactor-nrepl options does not work. Instead of attempting to configure via a stringified Clojure map to send to nrepl, allow the user to set each option explicitly in a way that is more integrated into the vim ecosystem.
1 parent 18d3a33 commit b23a8cc

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ own. Check the implementation file for `<Plug>` bindings.
4949
```vim
5050
let g:cider_no_maps=1 " Disable built-in mappings
5151
52-
" Set refactor-nrepl options, e.g. tell clean-ns to not use prefix forms
53-
let g:refactor_nrepl_options = '{:prefix-rewriting false}'
52+
" Set refactor-nrepl options
53+
let g:refactor_nrepl_prefix_rewriting = 0 " tell clean-ns to not use prefix forms
54+
let g:refactor_nrepl_prune_ns_form = 0 " ... and don't remove unused symbols
5455

5556
" Setup visualmode bindings yourself, to some keys which don't interact
5657
" with e.g. change command

doc/cider.txt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ DOCUMENTATION *cider-documentation*
1616
*cider-no-maps*
1717
g:cider_no_maps Set this option to true to disable built-in maps.
1818

19-
*refactor-nrepl-options*
20-
g:refactor_nrepl_options
21-
Use this option to set settings for refactor-nrepl.
22-
Check https://github.com/clojure-emacs/refactor-nrepl#configure
19+
*refactor-nrepl-prune-ns-form*
20+
g:refactor_nrepl_prune_ns_form
21+
Use this option to set the prune-ns-form option for
22+
refactor-nrepl. Check
23+
https://github.com/clojure-emacs/refactor-nrepl#configure
2324
for documentation.
2425

25-
*cider-cf*
26-
cf{motion} Format the code indicated by {motion}.
26+
*refactor-nrepl-prefix-rewriting*
27+
g:refactor_nrepl_prefix_rewriting
28+
Use this option to set the prefix-rewriting option for
29+
refactor-nrepl. Check
30+
https://github.com/clojure-emacs/refactor-nrepl#configure
31+
for documentation.
32+
33+
*cider-=f*
34+
=f{motion} Format the code indicated by {motion}.
2735
Use <Plug>CiderFormat to map this yourself.
2836
Visual mode mapping is not by default enabled but you
2937
can do that yourself:
@@ -33,15 +41,15 @@ cf{motion} Format the code indicated by {motion}.
3341
Just remeber to use mapping which doesn't conflict
3442
with e.g. change command.
3543

36-
*cider-cff*
37-
cff Format the innertmost form at the cursor.
44+
*cider-=ff*
45+
=ff Format the innertmost form at the cursor.
3846
Like |fireplace-c!|
3947
Use <Plug>CiderFormatCount to map this yourself.
4048

41-
*cider-cF*
42-
cF Format the current file.
43-
Use ggcfG to map this yourself (notice to use your own
44-
|cider-cf| mapping.)
49+
*cider-=F*
50+
=F Format the current file.
51+
Use gg=fG to map this yourself (notice to use your own
52+
|cider-=f| mapping.)
4553

4654
*cider-cdd*
4755
cdd Undefine a variable or unalias namespace a alias

plugin/cider.vim

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ nnoremap <silent> <Plug>CiderUndef :<C-U>call <SID>undef()<CR>
111111
" CleanNs
112112
"
113113

114-
function! s:init_refactor_nrepl() abort
115-
if !exists('b:refactor_nrepl_loaded') && exists('g:refactor_nrepl_options')
116-
let b:refactor_nrepl_loaded = 1
117-
call fireplace#message({'op': 'configure', 'opts': g:refactor_nrepl_options})
118-
endif
119-
endfunction
120-
121114
function! s:paste(text) abort
122115
" Does charwise paste to current '[ and '] marks
123116
let @@ = a:text
@@ -128,8 +121,6 @@ function! s:paste(text) abort
128121
endfunction
129122

130123
function! s:clean_ns() abort
131-
call s:init_refactor_nrepl()
132-
133124
" FIXME: Moves cursor
134125

135126
let p = expand('%:p')
@@ -145,7 +136,17 @@ function! s:clean_ns() abort
145136
call setpos("']", [0, line2, col2, 0])
146137

147138
if expand('<cword>') ==? 'ns'
148-
let res = fireplace#message({'op': 'clean-ns', 'path': p})[0]
139+
let opts = { 'op': 'clean-ns', 'path': p }
140+
141+
if exists('g:refactor_nrepl_prune_ns_form')
142+
let opts['prune-ns-form'] = g:refactor_nrepl_prune_ns_form ? 'true' : 'false'
143+
endif
144+
145+
if exists('g:refactor_nrepl_prefix_rewriting')
146+
let opts['prefix-rewriting'] = g:refactor_nrepl_prefix_rewriting ? 'true' : 'false'
147+
endif
148+
149+
let res = fireplace#message(opts)[0]
149150
let error = get(res, 'error')
150151
if !empty(error)
151152
throw error

0 commit comments

Comments
 (0)