Skip to content

Commit

Permalink
Merge pull request #830 from lubyrex/youle_mod
Browse files Browse the repository at this point in the history
Added option to enable snippet support for coc completion source.
  • Loading branch information
nickspoons committed Jan 26, 2023
2 parents 0b643d4 + 4d728ae commit 3799c45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 10 additions & 3 deletions autoload/OmniSharp/actions/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function! s:StdioGetCompletions(partial, opts, Callback) abort
\ && &completeopt =~# 'popup'
let wantDoc = wantDocPopup ? 'false'
\ : g:omnicomplete_fetch_full_documentation ? 'true' : 'false'
let wantSnippet = g:OmniSharp_want_snippet ? 'true' : 'false'
let wantSnippet = g:OmniSharp_want_snippet ? 'true' : g:OmniSharp_coc_snippet ? 'true' : 'false'
let s:last_startcol = has_key(a:opts, 'startcol')
\ ? a:opts.startcol
\ : col('.') - len(a:partial) - 1
Expand All @@ -94,7 +94,7 @@ function! s:StdioGetCompletionsRH(Callback, wantDocPopup, response) abort
if g:OmniSharp_want_snippet
let word = cmp.MethodHeader != v:null ? cmp.MethodHeader : cmp.CompletionText
let menu = cmp.ReturnType != v:null ? cmp.ReturnType : cmp.DisplayText
elseif g:OmniSharp_completion_without_overloads
elseif g:OmniSharp_completion_without_overloads && !g:OmniSharp_coc_snippet
let word = cmp.CompletionText
let menu = ''
else
Expand All @@ -105,8 +105,15 @@ function! s:StdioGetCompletionsRH(Callback, wantDocPopup, response) abort
if word == v:null
continue
endif
let snipCompletionText = get(cmp, 'Snippet', '')
let isSnippet = (snipCompletionText != cmp.CompletionText .. '$0')
\ && (snipCompletionText != cmp.CompletionText)
\ && (!empty(snipCompletionText))

let completion = {
\ 'snip': get(cmp, 'Snippet', ''),
\ 'snip': snipCompletionText,
\ 'insertText': isSnippet ? snipCompletionText : '',
\ 'isSnippet': isSnippet,
\ 'word': word,
\ 'menu': menu,
\ 'icase': 1,
Expand Down
7 changes: 7 additions & 0 deletions doc/omnisharp-vim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ Use this to pass custom options to fzf >
Use this option to enable snippet completion, when ultisnips is available.
Default: 0 >
let g:OmniSharp_want_snippet = 0
<
*g:OmniSharp_coc_snippet*
Use this option to enable snippet completion for coc source. For this feature
to be enabled it is required that g:OmniSharp_want_snippet is set to 0. Only
supports stdio server.
Default: 0 >
let g:OmniSharp_coc_snippet = 0
<
*g:OmniSharp_completion_without_overloads*
Use this option to get completion results without method arguments.
Expand Down
3 changes: 3 additions & 0 deletions plugin/OmniSharp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ let g:OmniSharp_want_snippet = get(g:, 'OmniSharp_want_snippet', 0)
" Only has effect if OmniSharp_want_snippet is 0.
let g:OmniSharp_completion_without_overloads = get(g:, 'OmniSharp_completion_without_overloads', 0)

" Does not work well when OmniSharp_want_snippet is 1.
let g:OmniSharp_coc_snippet = get(g:, 'OmniSharp_coc_snippet', 0)

let g:omnicomplete_fetch_full_documentation = get(g:, 'omnicomplete_fetch_full_documentation', 1)

command! -bar -nargs=? OmniSharpInstall call OmniSharp#Install(<f-args>)
Expand Down

0 comments on commit 3799c45

Please sign in to comment.