pinoyyid
pinoyyid

Reputation: 22306

How can I limit the neovim's autocomplete options to only snippets?

I'm running neovim 0.7 with LuaSnips to develop in Flutter.

I've installed a couple of Flutter snippets libraries, which work OK.

The problem I'm experiencing is that my autocomplete dropdown contains many many lsp suggestions which obscure the snippets. For example, typing provider gives me 30 or so lsp derived suggestions before I get to the snippets at the very bottom.

Is there any way I can either prioritise snippets to the top of the list, or use an alternate autocomple key that only offers snippets?

:CmpStatus gives me

# ready source names                                                                                                                                                                                                                                                                                                         
- buffer                                                                                                                                                                                                                                                                                                                     
- luasnip                                                                                                                                                                                                                                                                                                                    
- path                                                                                                                                                                                                                                                                                                                       
- nvim_lsp:dartls  

Upvotes: 3

Views: 1736

Answers (2)

pinoyyid
pinoyyid

Reputation: 22306

I've found what, for me, is a better approach than autocomplete.

I've installed benfowler/telescope.luasnip and imapped it to Alt-i. This gives me an autocomplete set of snippets, with a preview, which works really well for my use case.

Upvotes: 1

lcheylus
lcheylus

Reputation: 2423

In your nvim-cmp plugin configuration, the order of the sources determines their order in the completion results.

You could also set priority for each source with priority option. If you want to prioritize snippets with luasnip, set the highest priority for it :

sources = {
  { name = 'luasnip', priority = 40 },
  { name = 'nvim_lsp', priority = 30 },
  { name = 'buffer', priority = 20 },
  { name = 'path', priority = 10 },
},

Upvotes: 1

Related Questions