-
-
Save jonathanstiansen/533d00ad13798e33024e91457fa46bf0 to your computer and use it in GitHub Desktop.
VSCode Elixir Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Place your snippets for elixir here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
"Define a LiveView module": { | |
"prefix": ["dllive", "deflive"], | |
"body": [ | |
"defmodule ${TM_DIRECTORY/.*lib\\/(([^\\/]*))|([\\/])([^\\/]*)/${2:/pascalcase}${4:+.}${4:/pascalcase}/g}.${TM_FILENAME_BASE/(.+)/${1:/pascalcase}/} do", | |
"\t@moduledoc \"\"\"\n\t$2\n\t\"\"\"", | |
"\tuse ${TM_DIRECTORY/.*lib\\/(([^\\/]*)(\\/.*)*)/${2:/pascalcase}/g}, :live_view\n", | |
"\tdef render(assigns) do\n\t\t~L\"\"\"\n\t\t<div>$4</div>\n\t\t\"\"\"\n\tend", | |
"", | |
"\tdef mount(${5|_params,params,%{}|}, ${6|_session,session,%{}|}, socket) do\n\t\t$0\n\t\t{:ok, socket}\n\tend", | |
"end\n" | |
] | |
}, | |
"Define a LiveView component": { | |
"prefix": ["dlcomponet", "deflivecomponent"], | |
"body": [ | |
"defmodule ${TM_DIRECTORY/.*lib\\/(([^\\/]*))|([\\/])([^\\/]*)/${2:/pascalcase}${4:+.}${4:/pascalcase}/g}.${TM_FILENAME_BASE/(.+)/${1:/pascalcase}/} do", | |
"\t@moduledoc \"\"\"\n\t$2\n\t\"\"\"", | |
"\tuse ${TM_DIRECTORY/.*lib\\/(([^\\/]*)(\\/.*)*)/${2:/pascalcase}/g}, :live_component\n", | |
"\tdef render(assigns) do\n\t\t~L\"\"\"\n\t\t<div>$4</div>\n\t\t\"\"\"\n\tend", | |
"end\n" | |
] | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment