Request extra-metadata for completion candidates

In cider-nrepl 0.9.0 there is new extra-metadata option for complete op
[1]. It can be used to enrich the candiate results with additional
properties like arglists and docstring.

This commit adds extra-metadata option to complete call and changes the
candidate function to set fields in omnicomplete result so that arglists
are shown on omnicomplete menu and docstring is shown in preview window.

[1]: https://github.com/clojure-emacs/cider-nrepl/pull/195/files
This commit is contained in:
Juho Teperi 2015-05-15 22:54:08 +03:00
parent 44e766d5a5
commit 9ccaea1f2b

View File

@ -91,9 +91,12 @@ let s:short_types = {
function! s:candidate(val) abort
let type = get(a:val, 'type', '')
let arglists = get(a:val, 'arglists', [])
return {
\ 'word': get(a:val, 'candidate'),
\ 'kind': get(s:short_types, type, type)
\ 'kind': get(s:short_types, type, type),
\ 'info': get(a:val, 'doc', ''),
\ 'menu': empty(arglists) ? '' : '(' . join(arglists, ' ') . ')'
\ }
endfunction
@ -105,7 +108,7 @@ function! fireplace#omnicomplete(findstart, base) abort
try
if fireplace#op_available('complete')
let response = fireplace#message({'op': 'complete', 'symbol': a:base})
let response = fireplace#message({'op': 'complete', 'symbol': a:base, 'extra-metadata': ['arglists', 'doc']})
let trans = '{"word": (v:val =~# ''[./]'' ? "" : matchstr(a:base, ''^.\+/'')) . v:val}'
let value = get(response[0], 'value', get(response[0], 'completions'))
if type(value) == type([])