Use isn for visual selection indentations.
parent
288ed2d452
commit
60a48b8186
|
@ -47,7 +47,7 @@ for {} in {}:
|
||||||
})[index])
|
})[index])
|
||||||
)
|
)
|
||||||
end, { 1 }),
|
end, { 1 }),
|
||||||
ul.visual_node,
|
ul.visual_dynamic_node(3),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
|
@ -2,19 +2,17 @@ local M = {}
|
||||||
|
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
local types = require('luasnip.util.types')
|
local types = require('luasnip.util.types')
|
||||||
local function_node = require('luasnip').function_node
|
|
||||||
|
|
||||||
M.visual_node = function_node(function(_, snip)
|
function M.visual_dynamic_node(pos)
|
||||||
local env = snip.env
|
local f = luasnip.function_node
|
||||||
if type(env.LS_SELECT_RAW) ~= 'table' then
|
local isn = luasnip.indent_snippet_node
|
||||||
return env.LS_SELECT_RAW
|
|
||||||
end
|
return isn(pos, {
|
||||||
local res = {}
|
f(function(_, parent)
|
||||||
for _, ele in ipairs(env.LS_SELECT_RAW) do
|
return parent.snippet.env.LS_SELECT_DEDENT or {}
|
||||||
table.insert(res, ele)
|
end)
|
||||||
end
|
}, '$PARENT_INDENT\t')
|
||||||
return res
|
end
|
||||||
end, {})
|
|
||||||
|
|
||||||
function M.choice_index(choice_node)
|
function M.choice_index(choice_node)
|
||||||
for i, c in ipairs(choice_node.choices) do
|
for i, c in ipairs(choice_node.choices) do
|
||||||
|
@ -46,6 +44,11 @@ function M.setup()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Track where we are expanding the snippet.
|
||||||
|
luasnip.env_namespace('INFO', {
|
||||||
|
init = function(info) return { POS = info.pos } end,
|
||||||
|
})
|
||||||
|
|
||||||
vim.keymap.set({ 'i', 's' }, '<c-e>', function()
|
vim.keymap.set({ 'i', 's' }, '<c-e>', function()
|
||||||
if luasnip.choice_active() then
|
if luasnip.choice_active() then
|
||||||
return '<Plug>luasnip-next-choice'
|
return '<Plug>luasnip-next-choice'
|
||||||
|
|
Loading…
Reference in New Issue