-- nixos-config - My current NixOS configuration -- -- Copyright (C) 2025 Benedikt Peetz -- SPDX-License-Identifier: GPL-3.0-or-later -- -- This file is part of my nixos-config. -- -- You should have received a copy of the License along with this program. -- If not, see . local ls = require("luasnip") local fmt = require("luasnip.extras.fmt").fmt local get_visual = function(_, parent) if #parent.snippet.env.SELECT_RAW > 0 then return ls.snippet_node(nil, ls.insert_node(1, parent.snippet.env.SELECT_RAW)) else return ls.snippet_node(nil, ls.insert_node(1, "")) end end local translation_table = { ["("] = ")", ["{"] = "}", ["["] = "]" } -- Return snippet tables return { -- LEFT/RIGHT ALL BRACES ls.snippet( { trig = "([^%a])l([%(%[%{])", regTrig = true, wordTrig = false, snippetType = "autosnippet", }, fmt("{}\\left{}{}\\right{}", { ls.function_node(function(_, snip) return snip.captures[1] end), ls.function_node(function(_, snip) return snip.captures[2] end), ls.dynamic_node(1, get_visual), ls.function_node(function(_, snip) return translation_table[snip.captures[2]] end), }) ), }