You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Type: async<Tab>
func fetchData()async->Data{
// cursor here
}
Error handling
// Type: dotry<Tab>
do{trysomethingThatThrows()}catch{
// cursor here
}
Configuration
Enable/Disable Snippets
require("swift").setup({
features= {
snippets= {
enabled=true, -- Enable/disable snippetsnotify_on_load=false, -- Show notification when loadedwarn_if_missing=false, -- Warn if LuaSnip not found
},
},
})
Custom Keybindings for LuaSnip
-- Example: Use Tab and Shift-Tab to navigate snippetslocalluasnip=require("luasnip")
vim.keymap.set({"i", "s"}, "<Tab>", function()
ifluasnip.expand_or_jumpable() thenluasnip.expand_or_jump()
elsereturn"<Tab>"endend, { expr=true })
vim.keymap.set({"i", "s"}, "<S-Tab>", function()
ifluasnip.jumpable(-1) thenluasnip.jump(-1)
endend)
Adding Custom Snippets
You can add your own snippets by extending the snippets collection:
-- In your configlocalswift_snippets=require("swift.snippets")
-- Add custom snippetstable.insert(swift_snippets.snippets, {
trigger="custom",
name="My Custom Snippet",
dscr="Description of my snippet",
body= {
"// Custom code here",
"$0",
},
})
Or create a separate snippet file and load it with LuaSnip: