Skip to content

Commit 7e88f13

Browse files
authored
Merge pull request #796 from nickspoons/snippet-for-generic-types
Snippet for generic types
2 parents aec2068 + b680ac2 commit 7e88f13

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

autoload/OmniSharp.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function! OmniSharp#Complete(findstart, base) abort
5252
endwhile
5353
return start
5454
else
55-
return OmniSharp#actions#complete#Get(a:base)
55+
let opts = { 'startcol': col('.') - 1 }
56+
return OmniSharp#actions#complete#Get(a:base, opts)
5657
endif
5758
endfunction
5859

autoload/OmniSharp/actions/complete.vim

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ set cpoptions&vim
44
let s:generated_snippets = get(s:, 'generated_snippets', {})
55
let s:last_completion_dictionary = get(s:, 'last_completion_dictionary', {})
66

7-
function! OmniSharp#actions#complete#Get(partial, ...) abort
8-
let opts = a:0 ? { 'Callback': a:1 } : {}
7+
function! OmniSharp#actions#complete#Get(partial, opts) abort
98
if !OmniSharp#IsServerRunning()
109
return []
1110
endif
11+
let opts = type(a:opts) == type({}) ? a:opts : { 'Callback': a:opts }
1212
if g:OmniSharp_server_stdio
1313
let s:complete_pending = 1
14-
call s:StdioGetCompletions(a:partial, function('s:CBGet', [opts]))
14+
call s:StdioGetCompletions(a:partial, opts, function('s:CBGet', [opts]))
1515
if !has_key(opts, 'Callback')
1616
" No callback has been passed in, so this function should return
1717
" synchronously, so it can be used as an omnifunc
@@ -41,11 +41,7 @@ function! OmniSharp#actions#complete#ExpandSnippet() abort
4141
return
4242
endif
4343

44-
let line = strpart(getline('.'), 0, col('.')-1)
45-
let remove_whitespace_regex = '^\s*\(.\{-}\)\s*$'
46-
47-
let completion = matchstr(line, '.*\zs\s\W.\+(.*)')
48-
let completion = substitute(completion, remove_whitespace_regex, '\1', '')
44+
let completion = strpart(getline('.'), s:last_startcol, col('.') - 1)
4945

5046
let should_expand_completion = len(completion) != 0
5147

@@ -67,13 +63,16 @@ function! OmniSharp#actions#complete#ExpandSnippet() abort
6763
endfunction
6864

6965

70-
function! s:StdioGetCompletions(partial, Callback) abort
66+
function! s:StdioGetCompletions(partial, opts, Callback) abort
7167
let wantDocPopup = OmniSharp#popup#Enabled()
7268
\ && g:omnicomplete_fetch_full_documentation
7369
\ && &completeopt =~# 'popup'
7470
let wantDoc = wantDocPopup ? 'false'
7571
\ : g:omnicomplete_fetch_full_documentation ? 'true' : 'false'
7672
let wantSnippet = g:OmniSharp_want_snippet ? 'true' : 'false'
73+
let s:last_startcol = has_key(a:opts, 'startcol')
74+
\ ? a:opts.startcol
75+
\ : col('.') - len(a:partial) - 1
7776
let parameters = {
7877
\ 'WordToComplete': a:partial,
7978
\ 'WantDocumentationForEveryCompletionResult': wantDoc,

autoload/asyncomplete/sources/OmniSharp.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ function! asyncomplete#sources#OmniSharp#completor(opt, ctx) abort
77

88
let startcol = column - kwlen
99

10-
call OmniSharp#actions#complete#Get(kw, {results->
11-
\ asyncomplete#complete(a:opt['name'], a:ctx, startcol, results)})
10+
let opts = {
11+
\ 'startcol': startcol - 1,
12+
\ 'Callback': {results->
13+
\ asyncomplete#complete(a:opt['name'], a:ctx, startcol, results)}
14+
\}
15+
call OmniSharp#actions#complete#Get(kw, opts)
1216
endfunction
1317

1418
" vim:et:sw=2:sts=2

autoload/coc/source/OmniSharp.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function! coc#source#OmniSharp#init() abort
77
endfunction
88

99
function! coc#source#OmniSharp#complete(options, callback) abort
10-
call OmniSharp#actions#complete#Get(a:options.input, a:callback)
10+
let opts = { 'Callback': a:callback }
11+
call OmniSharp#actions#complete#Get(a:options.input, opts)
1112
endfunction
1213

1314
" vim:et:sw=2:sts=2

autoload/deoplete/source/omnisharp.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ endfunction
1212
function! deoplete#source#omnisharp#sendRequest(lhs, partial) abort
1313
let s:currentLhsRequest = a:lhs
1414
let g:deoplete#source#omnisharp#_results = v:null
15-
call OmniSharp#actions#complete#Get(a:partial, {results -> s:onReceivedResponse(a:lhs, results)})
15+
let opts = {
16+
\ 'Callback': {results -> s:onReceivedResponse(a:lhs, results)}
17+
\}
18+
call OmniSharp#actions#complete#Get(a:partial, opts)
1619
endfunction

autoload/ncm2/sources/OmniSharp.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ let s:loaded = 1
55

66
function! ncm2#sources#OmniSharp#on_complete(ctx) abort
77
let kw = matchstr(a:ctx['typed'], '\(\w*\W\)*\zs\w\+$')
8-
call OmniSharp#actions#complete#Get(kw, {
9-
\ results -> ncm2#complete(a:ctx, a:ctx['startccol'], results)
10-
\})
8+
let opts = {
9+
\ 'Callback': {results -> ncm2#complete(a:ctx, a:ctx['startccol'], results)}
10+
\}
11+
call OmniSharp#actions#complete#Get(kw, opts)
1112
endfunction
1213

1314
" vim:et:sw=2:sts=2

0 commit comments

Comments
 (0)