thomasfaingnaert / vim-lsp-ultisnips

Language Server Protocol snippets in vim using vim-lsp and UltiSnips
BSD 3-Clause "New" or "Revised" License
37 stars 2 forks source link

Support new vim-lsp #9

Closed hrsh7th closed 4 years ago

hrsh7th commented 4 years ago

This is same to https://github.com/thomasfaingnaert/vim-lsp-neosnippet/pull/1

thomasfaingnaert commented 4 years ago

What language server did you test this on? Snippets no longer work with clangd on my machine.

hrsh7th commented 4 years ago

I tested on vim-language-server. Sorry, I will try re-check.

hrsh7th commented 4 years ago

I'm re-check on vim-language-server and it works well.

My checked steps are below.

I try to use clangd to the next step. (Sorry, I had not use clang and clangd both).

hrsh7th commented 4 years ago

I finally found the reason that is not work when using clangd. https://github.com/thomasfaingnaert/vim-lsp-snippets/pull/5/files#diff-b7178f84627eaeaf3f08efb74ae5d1d5L19

The reason is that it was removed trim. I think this trimming should be in vim-lsp side. Could you tell me the your opinion about it?

hrsh7th commented 4 years ago

trimming has merged in vim-lsp. I checked and worked well on clangd. Could you check with latest vim-lsp and this PR?

thomasfaingnaert commented 4 years ago

I tested again, still no success :( It's not specific to clangd: vim language server doesn't work either.

I did some digging and I found that l:managed_user_data is empty. This results in lsp_expand_snippet not being called. Any idea why that may be?

diff --git a/autoload/lsp/ui/vim/completion.vim b/autoload/lsp/ui/vim/completion.vim
index 342d5c5..fa36fd4 100644
--- a/autoload/lsp/ui/vim/completion.vim
+++ b/autoload/lsp/ui/vim/completion.vim
@@ -34,6 +34,8 @@ function! s:on_complete_done() abort
   " Clear managed user_data.
   call lsp#omni#_clear_managed_user_data_map()

+  call lsp#log('l:managed_user_data', l:managed_user_data)
+
   " If managed user_data does not exists, skip it.
   if empty(l:managed_user_data)
     doautocmd User lsp_complete_done
Mon 13 Jan 2020 17:47:56 CET:["l:managed_user_data",{}]

Currently, vim-lsp-snippets and vim-lsp-ultisnips seem to still work on the latest vim-lsp. What would the advantage be to use g:lsp_snippet_expand?

hrsh7th commented 4 years ago

Thanks and Sorry for your time.

I did some digging and I found that l:managed_user_data is empty. This results in lsp_expand_snippet not being called. Any idea why that may be? It seems same to https://github.com/prabirshrestha/vim-lsp/issues/668.

Currently, vim-lsp-snippets expects vim-lsp/textEdit in user_data. But the key was removed ... So I sent the PR.

g:lsp_snippet_expand has no big advantage it only make easy to integration.

I will try to solve https://github.com/prabirshrestha/vim-lsp/issues/668. I'm very sorry but I will ask you to check after fix.

hrsh7th commented 4 years ago

The PR has merged now (https://github.com/prabirshrestha/vim-lsp/pull/669). I prepare the below environment and checked snippets on clangd.

Use below plugins

Ultisnips settings

let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-l>"
let g:UltiSnipsJumpBackwardTrigger="<c-h>"

Steps

thomasfaingnaert commented 4 years ago

Works perfectly. Thanks for taking the time to look into this! Also congrats on being made contributor on vim-lsp :smile: