Select visual contents and highlight insert nodes.

main
Joshua Potter 2024-01-05 12:17:54 -07:00
parent 41579e25a0
commit 88f409c2ce
1 changed files with 15 additions and 8 deletions

View File

@ -4,14 +4,18 @@ local luasnip = require('luasnip')
local types = require('luasnip.util.types') local types = require('luasnip.util.types')
function M.visual_isn(pos) function M.visual_isn(pos)
local f = luasnip.function_node local d = luasnip.dynamic_node
local i = luasnip.insert_node
local isn = luasnip.indent_snippet_node local isn = luasnip.indent_snippet_node
local sn = luasnip.snippet_node
return isn(pos, { return isn(pos, d(1, function(_, parent)
f(function(_, parent) local res, env = {}, parent.snippet.env
return parent.snippet.env.LS_SELECT_DEDENT or {} for _, ele in ipairs(env.LS_SELECT_DEDENT or {}) do
end) table.insert(res, ele)
}, '$PARENT_INDENT\t') end
return sn(nil, i(1, res))
end), '$PARENT_INDENT\t')
end end
function M.choice_index(choice_node) function M.choice_index(choice_node)
@ -34,11 +38,14 @@ function M.setup()
virt_text = { { '', 'DiagnosticWarn' } }, virt_text = { { '', 'DiagnosticWarn' } },
}, },
}, },
[types.insertNode] = {
passive = {
hl_group = 'DiagnosticHint',
},
},
[types.choiceNode] = { [types.choiceNode] = {
active = { active = {
virt_text = { { '', 'DiagnosticHint' } }, virt_text = { { '', 'DiagnosticHint' } },
-- Include in case one of our choice options is an empty string.
hl_group = 'DiagnosticOk',
}, },
}, },
}, },