lsp icon indicating copy to clipboard operation
lsp copied to clipboard

Enable tab for autocompletion

Open isaiahfisher opened this issue 1 year ago • 6 comments

This is not so much a code issue as it is a question or perhaps a suggestion on a configuration to add.

Is there a way to enable the <TAB> keybind to cycle through the autocomplete suggestions and then insert the currently highlighted option once typing? Basically I want to be able to hit tab and have it move through the popover and then insert the highlighted option once I hit for example, rather than using arrow keys + enter.

isaiahfisher avatar Sep 14 '23 19:09 isaiahfisher

Actually I figured out a good way to accomplish this:

inoremap <expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr> <S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"

This snippet will allow your vimrc to use tab for auto-completion. Can we consider adding this as a feature-flag for the lsp configuration?

isaiahfisher avatar Sep 14 '23 19:09 isaiahfisher

I think adding this to README is enough.

lxhillwind avatar Sep 15 '23 09:09 lxhillwind

I added the 2 lines above added to my vimrc.

If I open a file configured to use an lsp, TAB is not working as C-n If I run :so ~/.vimrc, TAB starts acting as C-n

Any idea why?

Cheers!

carlotm avatar Oct 06 '23 11:10 carlotm

@carlotm did you restart your vim after editing the vimrc? You either have to restart vim or source vim for changes to take place. If it is still happening even after restarting vim, I would check what your sourced vimrc path is. There is a variable $MYVIMRC that can be checked to see which vimrc was found and sourced.

isaiahfisher avatar Oct 12 '23 23:10 isaiahfisher

Issue was UltiSnips, if I disable it, everything works ok. Thanks.

carlotm avatar Oct 20 '23 11:10 carlotm

Hello guys, I'm trying to ask here because my question is about completion as well. Hope it's ok. I am new to Vim, so maybe it is a stupid question.

Is it intended behaviour that after <C-y> when choosing the completion parenthesis aren't completed as well?

Screenshot 2024-03-22 at 22 21 16

After I press <C-y> for a first time, the list is reduced: Screenshot 2024-03-22 at 22 21 39

And pressing it again in this particular situation does basically nothing. I'm on Mac, if it matters.

Many thanks!

charamzic avatar Mar 22 '24 21:03 charamzic