nvim-snippy icon indicating copy to clipboard operation
nvim-snippy copied to clipboard

Visual indicators for empty placeholders (tab stops)

Open heygarrett opened this issue 3 years ago • 2 comments

Description

Is snippy expected to fill empty tab stops with placeholder text? Using lua-language-server, most of the snippets already have placeholder text at the tab stops, but the function () snippet does not. Because of that I couldn't tell where the tab stops were:
Screen Recording 2022-09-22 at 12 54 00

Steps to Reproduce

snippy config:

return {
	"dcampos/nvim-snippy",
	config = function()
		local loaded, snippy = pcall(require, "snippy")
		if not loaded then return end

		vim.api.nvim_create_autocmd("CompleteDone", {
			group = vim.api.nvim_create_augroup("snippy", { clear = true }),
			callback = function() snippy.complete_done() end,
		})

		snippy.setup({
			mappings = {
				is = {
					["<tab>"] = "next",
					["<s-tab>"] = "previous",
				},
			},
		})
	end,
}
  1. Set up lua-language-server and omnicomplete
  2. In a Lua file type local func then trigger omnicomplete with <c-x><c-o>
  3. Select the function () snippet from the pop-up menu then hit <esc> or <c-y>

Expected Result

The tab stops would have placeholder text to indicate where the tab stops are.

Actual Result

There's no placeholder text for tab stops.

Additional Context

No response

heygarrett avatar Sep 22 '22 17:09 heygarrett

Hi,

Is snippy expected to fill empty tab stops with placeholder text? Using lua-language-server, most of the snippets already have placeholder text at the tab stops, but the function () snippet does not.

I don't think the snippet engine should do that, personally, because sometimes the user really may want to have an empty placeholder for some tab stops. Maybe the language server could be changed to add the placeholders?

Because of that I couldn't tell where the tab stops were

Yes, I agree it would be nice to have some visual indicators. Currently, neovim still doesn't support "inline" virtual text (which they call "anticonceal"), but when it does, I think we could add some character to act like a virtual cursor for every empty tab stop, much like in VSCode.

Currently, the only way to "find" the tab stops is by pressing <tab> (or whichever mapping you may use).

dcampos avatar Sep 22 '22 22:09 dcampos

I'm already eager for anticonceal, and I love the idea of potentially using it for this. Thanks for the explanation! It seems for now I'll just need to be conscious of not always having placeholders to work from.

heygarrett avatar Sep 23 '22 00:09 heygarrett