LuaSnip
LuaSnip copied to clipboard
Highlight for "zero-width" placeholder
Hello, thanks for the awesome plugin!
I am trying to get a visual indication of the unvisited placeholders when expanding a snippet.
So far I was able to achieve this but only for placeholders/tabstops that had a default "non-zero-width" content:
vim.api.nvim_set_hl(0, 'LuaSnipPlace', { bg = "#363537", italic = true })
local types = require("luasnip.util.types")
require("luasnip").setup({
ext_opts = {
[types.insertNode] = {
unvisited = {
hl_group = "LuaSnipPlace",
},
},
[types.exitNode] = {
unvisited = {
hl_group = "LuaSnipPlace",
},
},
}
})
However, I don't know how to get some visual lighter background on the next character for a zero-width placeholder.
Thanks a lot.
Hi! #935 should have everything you need for this, as long as you neovim is new enough to support inline virtual text
Yes I already came across #935 which allowed me to write the current highlight config (see above).
However, I don't want virtual text, I would just want the background color of the next character to be lighter. It would give the impression that a block cursor is pending at that place. Is this possible ?
Ouh, not as easily: you'd need to find, after each jump (:h luasnip-events), the target of the next one (ls.next_node, or something like that), get its position (node:get_buf_position, or something like that) and place an extmark just behind it (nvim_buf_set_extmark). Also, remove the mark placed for this node, so you'd have to store the id of the placed extmark.
It's probably not that hard concept-wise, but finding all the right API is
Yes this sounds pretty hard to find...