LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

Add interface for applying snippetTextEdits

Open L3MON4D3 opened this issue 3 years ago • 4 comments

This can be useful for rust-analyzer and other lsp-servers implementing their extension. Not 100% sure luasnip is really the best place for this, but it makes more sense than each languageserver-extension wanting to expand these snippets implementing it themselves. (nvim also doesn't really fit since it's just an extension to lsp, and not official)

L3MON4D3 avatar Sep 04 '22 17:09 L3MON4D3

Should not this also expose the companion lsp-capability that should be passed to the lsp-server? I mean, similar to what require('cmp_nvim_lsp').update_capabilities does.

leiserfg avatar Sep 04 '22 18:09 leiserfg

Oh, yeah that makes sense. Is there some standard for how the capabilities are updated? Or would one have to call update_capabilities(caps) manually?

L3MON4D3 avatar Sep 04 '22 18:09 L3MON4D3

Oh, yeah that makes sense. Is there some standard for how the capabilities are updated? Or would one have to call update_capabilities(caps) manually?

Yes, it has to be manually, but it's something that those developing plugins that require it could do, like in this case the guys of rust-tools.

leiserfg avatar Sep 04 '22 19:09 leiserfg

Thanks for taking a look, I had some more stuff to add though :D Applying snippetTextEdits should work pretty well now, but we have some more complexity too: There's a new option for snip_expand, jumplist_insert_func, which can link up snippets in a different way. Problem is, this is subject to some restrictions, and should be done carefully, so I'll have to add some pretty thorough documentation for it (or not document it at all, which would go a bit against having everything in extras not depend on internals) In a similar vein, there's a lot of stuff that needs API for this to be really well-made, so far it's more of a POC

L3MON4D3 avatar Feb 02 '23 10:02 L3MON4D3