From 88f409c2ce54d5932742693695f11c72a05ea08c Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Fri, 5 Jan 2024 12:17:54 -0700 Subject: [PATCH] Select visual contents and highlight insert nodes. --- .../jrpotter/neovim/config/utils/luasnip.lua | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/users/jrpotter/neovim/config/utils/luasnip.lua b/users/jrpotter/neovim/config/utils/luasnip.lua index 97be621..49b77b1 100644 --- a/users/jrpotter/neovim/config/utils/luasnip.lua +++ b/users/jrpotter/neovim/config/utils/luasnip.lua @@ -4,14 +4,18 @@ local luasnip = require('luasnip') local types = require('luasnip.util.types') 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 sn = luasnip.snippet_node - return isn(pos, { - f(function(_, parent) - return parent.snippet.env.LS_SELECT_DEDENT or {} - end) - }, '$PARENT_INDENT\t') + return isn(pos, d(1, function(_, parent) + local res, env = {}, parent.snippet.env + for _, ele in ipairs(env.LS_SELECT_DEDENT or {}) do + table.insert(res, ele) + end + return sn(nil, i(1, res)) + end), '$PARENT_INDENT\t') end function M.choice_index(choice_node) @@ -34,11 +38,14 @@ function M.setup() virt_text = { { '●', 'DiagnosticWarn' } }, }, }, + [types.insertNode] = { + passive = { + hl_group = 'DiagnosticHint', + }, + }, [types.choiceNode] = { active = { virt_text = { { '⧨', 'DiagnosticHint' } }, - -- Include in case one of our choice options is an empty string. - hl_group = 'DiagnosticOk', }, }, },