Skip to content

Commit

Permalink
Merge pull request #866 from nickspoons/completion-kinds
Browse files Browse the repository at this point in the history
Include completion "kind"
  • Loading branch information
nickspoons authored Oct 18, 2024
2 parents f9c5d3e + cb31ab9 commit 2205888
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions autoload/OmniSharp/actions/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function! s:StdioGetCompletions(partial, opts, Callback) abort
\ 'WantDocumentationForEveryCompletionResult': wantDoc,
\ 'WantSnippet': wantSnippet,
\ 'WantMethodHeader': 'true',
\ 'WantKind': 'true',
\ 'WantReturnType': 'true'
\}
let opts = {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2205888

Please sign in to comment.