Skip to content

Commit 6d928e1

Browse files
use reduce instead of storing local variable (#1010)
1 parent 8cff8be commit 6d928e1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

autoload/lsp/ui/vim/code_lens.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
function! lsp#ui#vim#code_lens#do(option) abort
99
let l:sync = get(a:option, 'sync', v:false)
1010

11-
let s:items = []
12-
1311
let l:servers = filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_code_lens_provider(v:val)')
1412
if len(l:servers) == 0
1513
return lsp#utils#error('Code lens not supported for ' . &filetype)
@@ -33,13 +31,13 @@ function! lsp#ui#vim#code_lens#do(option) abort
3331
\ lsp#callbag#map({x->{ 'server': server, 'codelens': x }}),
3432
\ )
3533
\ }),
34+
\ lsp#callbag#reduce({acc,curr->add(acc, curr)}, []),
35+
\ lsp#callbag#tap({x->s:chooseCodeLens(x, l:bufnr)}),
3636
\ lsp#callbag#takeUntil(lsp#callbag#pipe(
3737
\ lsp#stream(),
3838
\ lsp#callbag#filter({x->has_key(x, 'command')}),
3939
\ )),
4040
\ lsp#callbag#subscribe({
41-
\ 'next':{x->add(s:items, x)},
42-
\ 'complete': {->s:chooseCodeLens(s:items, l:bufnr)},
4341
\ 'error': {e->s:error(x)},
4442
\ }),
4543
\ )

0 commit comments

Comments
 (0)