From cb31ab9f2ca3622eba43d033da94e899848272d7 Mon Sep 17 00:00:00 2001 From: Nick Jensen Date: Thu, 17 Oct 2024 08:55:58 +1300 Subject: [PATCH] Include completion "kind" --- autoload/OmniSharp/actions/complete.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/autoload/OmniSharp/actions/complete.vim b/autoload/OmniSharp/actions/complete.vim index 9672c412f..0e0dc0905 100644 --- a/autoload/OmniSharp/actions/complete.vim +++ b/autoload/OmniSharp/actions/complete.vim @@ -78,6 +78,7 @@ function! s:StdioGetCompletions(partial, opts, Callback) abort \ 'WantDocumentationForEveryCompletionResult': wantDoc, \ 'WantSnippet': wantSnippet, \ 'WantMethodHeader': 'true', + \ 'WantKind': 'true', \ 'WantReturnType': 'true' \} let opts = { @@ -117,6 +118,7 @@ function! s:StdioGetCompletionsRH(Callback, wantDocPopup, response) abort \ 'word': word, \ 'menu': menu, \ 'icase': 1, + \ 'kind': s:ToKind(cmp.Kind), \ 'dup': g:OmniSharp_completion_without_overloads ? 0 : 1 \} if a:wantDocPopup @@ -132,6 +134,20 @@ function! s:StdioGetCompletionsRH(Callback, wantDocPopup, response) abort call a:Callback(completions, a:wantDocPopup) endfunction +function! s:ToKind(roslynKind) + " Values defined in: + " https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.Abstractions/Models/v1/Completion/CompletionItem.cs#L104C6-L129C28 + let variable = ['Color', 'Event', 'Field', 'Keyword', 'Variable', 'Value'] + let function = ['Constructor', 'Function', 'Method'] + let member = ['Constant', 'EnumMember', 'Property', 'TypeParameter'] + let typedef = ['Class', 'Enum', 'Interface', 'Module', 'Struct'] + return + \ index(variable, a:roslynKind) >= 0 ? 'v' : + \ index(function, a:roslynKind) >= 0 ? 'f' : + \ index(member, a:roslynKind) >= 0 ? 'm' : + \ index(typedef, a:roslynKind) >= 0 ? 't' : '' +endfunction + function! s:CBGet(opts, completions, ...) abort let s:last_completions = a:completions let s:complete_pending = 0