return { "L3MON4D3/LuaSnip", even = "VaryLazy", config = function() local ls = require "luasnip" -- some shorthands... local s = ls.snippet local sn = ls.snippet_node local t = ls.text_node local i = ls.insert_node local f = ls.function_node local c = ls.choice_node local d = ls.dynamic_node local r = ls.restore_node ls.setup { region_check_events = { "CursorHold", "InsertLeave" }, delete_check_events = { "TextChanged", "InsertEnter" }, history = false, } ls.add_snippets("all", { s("flutterhttp", { t "Future> ", i(2, "function()"), t { " async {", '\tfinal url = "https://$apiBasePath/' }, i(3), t { '";', "\tfinal client = Client();", "\ttry {", "\t\tfinal headers = await _getHeaders(" }, i(4), t { ");" }, i(5), t { "", "\t\tfinal response = await client." }, i(6, "get"), t { "(Uri.parse(url), headers: headers," }, i(7), t { ");", "\t\tswitch (response.statusCode) {", "\t\t\tcase 200:", "\t\t\t\tfinal json = jsonDecode(response.body);", "\t\t\t\treturn Result.ok(.fromJson(json));", }, i(8), t { "", "\t\t\tdefault:", '\t\t\t\tthrow "Unknown error withcode ${response.statusCode.toString()}";', "\t\t\t}", "\t} catch (e) {", "\t\treturn Result.error(Exception(e));", "\t} finally {", "\t\tclient.close();", "\t}", "}", }, }), }) vim.keymap.del({ "i", "s" }, "") vim.keymap.set({ "i", "s" }, "", function() ls.jump(1) end, { silent = true }) vim.keymap.set({ "i", "s" }, "", function() ls.jump(-1) end, { silent = true }) end, }