init
This commit is contained in:
14
snippets/package.json
Normal file
14
snippets/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "user snippets",
|
||||
"engines": {
|
||||
"vscode": "^1.11.0"
|
||||
},
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": "rust",
|
||||
"path": "./rust.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
43
snippets/rust.json
Normal file
43
snippets/rust.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"New Yew function component": {
|
||||
"prefix": "yewfc",
|
||||
"body": [
|
||||
"#[derive(PartialEq, Properties)]",
|
||||
"pub struct ${1:ComponentName}Props {}",
|
||||
"",
|
||||
"#[function_component]",
|
||||
"pub fn $1(props: &${1}Props) -> Html {",
|
||||
" let ${1}Props {} = props;",
|
||||
" html! {",
|
||||
" <${2:div}>$0</${2}>",
|
||||
" }",
|
||||
"}"
|
||||
],
|
||||
"description": "Create a minimal Yew function component"
|
||||
},
|
||||
"New Yew struct component": {
|
||||
"prefix": "yewsc",
|
||||
"body": [
|
||||
"pub struct ${1:ComponentName};",
|
||||
"",
|
||||
"pub enum ${1}Msg {",
|
||||
"}",
|
||||
"",
|
||||
"impl Component for ${1} {",
|
||||
" type Message = ${1}Msg;",
|
||||
" type Properties = ();",
|
||||
"",
|
||||
" fn create(ctx: &Context<Self>) -> Self {",
|
||||
" Self",
|
||||
" }",
|
||||
"",
|
||||
" fn view(&self, ctx: &Context<Self>) -> Html {",
|
||||
" html! {",
|
||||
" $0",
|
||||
" }",
|
||||
" }",
|
||||
"}"
|
||||
],
|
||||
"description": "Create a new Yew component with a message enum"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user