Skip to content

Commit 2205888

Browse files
authored
Merge pull request #866 from nickspoons/completion-kinds
Include completion "kind"
2 parents f9c5d3e + cb31ab9 commit 2205888

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

autoload/OmniSharp/actions/complete.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function! s:StdioGetCompletions(partial, opts, Callback) abort
7878
\ 'WantDocumentationForEveryCompletionResult': wantDoc,
7979
\ 'WantSnippet': wantSnippet,
8080
\ 'WantMethodHeader': 'true',
81+
\ 'WantKind': 'true',
8182
\ 'WantReturnType': 'true'
8283
\}
8384
let opts = {
@@ -117,6 +118,7 @@ function! s:StdioGetCompletionsRH(Callback, wantDocPopup, response) abort
117118
\ 'word': word,
118119
\ 'menu': menu,
119120
\ 'icase': 1,
121+
\ 'kind': s:ToKind(cmp.Kind),
120122
\ 'dup': g:OmniSharp_completion_without_overloads ? 0 : 1
121123
\}
122124
if a:wantDocPopup
@@ -132,6 +134,20 @@ function! s:StdioGetCompletionsRH(Callback, wantDocPopup, response) abort
132134
call a:Callback(completions, a:wantDocPopup)
133135
endfunction
134136

137+
function! s:ToKind(roslynKind)
138+
" Values defined in:
139+
" https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.Abstractions/Models/v1/Completion/CompletionItem.cs#L104C6-L129C28
140+
let variable = ['Color', 'Event', 'Field', 'Keyword', 'Variable', 'Value']
141+
let function = ['Constructor', 'Function', 'Method']
142+
let member = ['Constant', 'EnumMember', 'Property', 'TypeParameter']
143+
let typedef = ['Class', 'Enum', 'Interface', 'Module', 'Struct']
144+
return
145+
\ index(variable, a:roslynKind) >= 0 ? 'v' :
146+
\ index(function, a:roslynKind) >= 0 ? 'f' :
147+
\ index(member, a:roslynKind) >= 0 ? 'm' :
148+
\ index(typedef, a:roslynKind) >= 0 ? 't' : ''
149+
endfunction
150+
135151
function! s:CBGet(opts, completions, ...) abort
136152
let s:last_completions = a:completions
137153
let s:complete_pending = 0

0 commit comments

Comments
 (0)