OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.72k stars 168 forks source link

Omnisharp-vim not working with Ultisnips on Completion snippets #795

Closed huyHA9597 closed 2 years ago

huyHA9597 commented 2 years ago

Hi. I'm struggling with how to config to use the Completion snippets.

Currently I'm using OmniSharp-vim, Ultisnips and coc.nvim.

Here are some configs that I use in init.vim file:

let g:OmniSharp_want_snippet=1
let g:OmniSharp_server_stdio = 1
let g:OmniSharp_server_use_mono = 0
let g:OmniSharp_server_use_net6 = 1
let NERDTreeShowHidden=1
let g:NERDTreeWinPos = "left"
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/plugged/ultisnips']
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsRemoveSelectModeMappings = 0
let g:UltiSnipsExpandTrigger = '<Tab>'
let g:UltiSnipsJumpForwardTrigger = '<Tab>'
let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'
let g:UltiSnipsListSnippets="<C-Tab>"

Whenever I use a method (e.g. Console.WriteLine(long value)), the popup suggestion's ok.

Screen Shot 2022-07-11 at 16 39 44

But when I enter, omnisharp only show the it will jump out of the parameter. I have to remove long value and continue to code.

Screen Shot 2022-07-11 at 16 40 02

It happens with all the methods and functions that has parameter snippets. Currently I'm not sure the error comes from conflict between coc.nvim and omnisharp-vim or not.

nickspoons commented 2 years ago

But when I enter What do you mean by this? Do you mean hit the enter key <cr>? You've configured ultisnips to use <Tab>.

This config works fine for me:

asciicast

huyHA9597 commented 2 years ago

Hi @nickspoons,

Sorry for late reply. I found out in my init.vim file there is another completion snippet plugin so the error occurred. I'd fixed that and the completion snippets is working now.

But still there is the snippet for generic template like Action<T> or Func<T> that the completion snippet is not worked. However with Action<T>(object @object, IntPtr method) liked delegate, the snippet is still functioning OK.

I tagged the video about this problem in the comment. Can you check again?

asciicast

nickspoons commented 2 years ago

Yeah snippet completion like that has only been implemented for methods. Without the (...) part it's a type declaration which doesn't currently support snippets.

huyHA9597 commented 2 years ago

Thank you very much. Issue closed.

nickspoons commented 2 years ago

@huyHA9597 I've re-opened as I think we can do this better. I've just created PR #796 which seems to work pretty well for me with various completion providers, including coc.

Are you able to try it out and see if it works for you?

huyHA9597 commented 2 years ago

Hi @nickspoons. Sorry for late reply.

Since the last time when I closed the issue, I manually added some snippets for Action<T> liked type on vim-snippets plugin so I didn't notice your notification. Really sorry about that. :((

Anyway, I've just pulled your PR #796 code and tested on my environment. It works really well. I don't have to use my custom snippets anymore.

Thank you very much!

Screen Shot 2022-07-14 at 00 12 15
nickspoons commented 2 years ago

Thanks for testing, @huyHA9597. I've been using this for a few days too and it seems like a good fix, I'll merge it.