Closed dezza closed 3 years ago
Can you share a minimal vimrc and instructions to reproduce the problem?
I will cut down my own vimrc to least reproducible and report back.
Thanks!
filetype plugin indent on
set backspace =indent,eol,start
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
and
prabirshrestha/vim-lsp
mattn/vim-lsp-settings
SirVer/ultisnips
thomasfaingnaert/vim-lsp-ultisnips
thomasfaingnaert/vim-lsp-snippets
honza/vim-snippets
in /pack
I still cannot find snippets like "main", "err" from the UltiSnips golang file (in https://github.com/honza/vim-snippets/blob/master/UltiSnips/go.snippets) when triggering omnifunc= only my own functions and stdlib as usual. Self-compiled recent vim
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 19 2021 18:23:24)
Included patches: 1-2784
Compiled by dza@adrafinil
Big version with GTK3 GUI. Features included (+) or not (-):
+acl +cryptv +fork() +modify_fname +persistent_undo +syntax +visualextra
+arabic +cscope -gettext +mouse +popupwin +tag_binary +viminfo
+autocmd +cursorbind -hangul_input +mouseshape +postscript -tag_old_static +vreplace
+autochdir +cursorshape +iconv +mouse_dec +printer -tag_any_white +wildignore
-autoservername +dialog_con_gui +insert_expand -mouse_gpm -profile -tcl +wildmenu
+balloon_eval +diff +ipv6 -mouse_jsbterm -python +termguicolors +windows
-balloon_eval_term +digraphs +job +mouse_netterm +python3 +terminal +writebackup
+browse +dnd +jumplist +mouse_sgr +quickfix +terminfo +X11
++builtin_terms -ebcdic +keymap -mouse_sysmouse +reltime +termresponse -xfontset
+byte_offset +emacs_tags +lambda +mouse_urxvt +rightleft +textobjects +xim
+channel +eval +langmap +mouse_xterm +ruby +textprop +xpm
+cindent +ex_extra +libcall +multi_byte +scrollbind +timers -xsmp
+clientserver +extra_search +linebreak +multi_lang +signs +title +xterm_clipboard
+clipboard -farsi +lispindent -mzscheme +smartindent +toolbar -xterm_save
+cmdline_compl +file_in_path +listcmds -netbeans_intg +sound +user_commands
+cmdline_hist +find_in_path +localmap +num64 +spell +vartabs
+cmdline_info +float -lua +packages +startuptime +vertsplit
+comments +folding +menu +path_extra +statusline +virtualedit
+conceal -footer +mksession +perl -sun_workshop +visual
I still cannot find snippets like "main", "err" from the UltiSnips golang file (in https://github.com/honza/vim-snippets/blob/master/UltiSnips/go.snippets) when triggering omnifunc= only my own functions and stdlib as usual.
That's to be expected: this plugin doesn't change the completion items returned by omnifunc
: it only makes sure that when you select a completion item returned from a language server, its snippet is expanded (if it has any).
IIUC, the snippets returned by the language server work? That means that this plugin works correctly.
To also include pre-defined UltiSnips snippets in your completion menu, you need to create a custom omnifunc
, or install a completion plugin which includes an UltiSnips completion source.
Alright! Afaik gopls / golang doesn’t have any snippets
"To also include pre-defined UltiSnips snippets in your completion menu, you need to create a custom omnifunc, or install a completion plugin which includes an UltiSnips completion source."
Sorry to comment on an old issue, probably I don't get something obvious, but I don't understand then why is this called vim-lsp-ultisnips
if it just gets the snippets from the language server anyway? Where's the UltiSnips part? It's calling the expansion for the item?
In the demo gif I see in the completion menu that somehow the entries are existing for which you are auto-completing. Does that mean you created a custom omnifunc for the purpose of the demo? Or do you know a completion plugin that has UltiSnips as a completion source?
After reading the README, I thought enabling your plugin would get the integration to vim-lsp so the menus + completion would work similarly to youcompleteme. Having only the capacity to expand if only if they would magically be present in the menu, but without a reasonable way to add them to the said menu, severely restricts the usability of this plugin.
Sorry to comment on an old issue, probably I don't get something obvious, but I don't understand then why is this called
vim-lsp-ultisnips
if it just gets the snippets from the language server anyway? Where's the UltiSnips part? It's calling the expansion for the item?
It's called vim-lsp-ultisnips
because it integrates vim-lsp and UltiSnips. vim-lsp communicates with the language server, and gets the list of snippets from it. But it does not implement snippet logic in vim, so it cannot "expand" the snippets. For that, you need a snippet plugin like UltiSnips, neosnippet, or vim-vsnip. This plugin simply ensures that whenever you select an item in the completion menu that came from vim-lsp, its corresponding snippet (if any) is expanded using UltiSnips. It does not change which items are in the completion menu at all, for that you need a completion plugin.
In the demo gif I see in the completion menu that somehow the entries are existing for which you are auto-completing. Does that mean you created a custom omnifunc for the purpose of the demo?
I use the omnifunc lsp#complete
from vim-lsp, not a custom one. The completion entries vector
, push_back
, func
, etc. are provided by the clangd language server, I didn't define them manually.
Or do you know a completion plugin that has UltiSnips as a completion source?
You can try asyncomplete.vim, from the same author as vim-lsp. This plugin adds an asynchronous completion popup that can obtain its completion items from UltiSnips (i.e. the snippets you define yourself, or those from https://github.com/honza/vim-snippets), vim-lsp, etc. See https://github.com/prabirshrestha/asyncomplete.vim#sources for a full list of sources.
I still don't see any suggestions omnifunc
<C-x><C-o>
using golang. I am unsure how to debug this, ultisnips triggers fine on tab (default). I only really havevim-lsp
,ultisnips
and these pluginsvim-lsp-ultisnips
andvim-lsp-snippets
, no extra completion library on top.