nvim/UltiSnips/javascript.snippets

165 lines
2.7 KiB
Plaintext
Raw Normal View History

2020-03-19 15:47:31 +00:00
snippet todo "// TODO"
// TODO $0
endsnippet
snippet if "if ( ... ) { ... }"
if ($1) {
2020-04-25 20:55:30 +00:00
$0
2020-03-19 15:47:31 +00:00
}
endsnippet
snippet cl "console.log( ... )"
2020-04-26 11:47:16 +00:00
console.log($0);
2020-03-19 15:47:31 +00:00
endsnippet
2021-11-05 09:40:50 +00:00
snippet cw "console.warn( ... )"
console.warn($0);
endsnippet
snippet f "for (...)"
for (let index=0; index < $1; index += 1) {
$0
}
endsnippet
snippet fr "for (...)"
for (let index=${1:0}; index ${2:<} $3; index ${4:+=} ${5:1}) {
$0
}
endsnippet
2021-10-22 19:26:40 +00:00
snippet .fe "...forEach( ... );" i
.forEach(($1) => {
2020-04-25 20:55:30 +00:00
$0
2021-10-22 19:26:40 +00:00
});
2020-03-19 15:47:31 +00:00
endsnippet
2021-11-21 12:18:12 +00:00
snippet .ael "...addEventListener( ... );" i
2021-10-22 19:26:40 +00:00
.addEventListener('$1', ($2) => {
2020-04-25 20:55:30 +00:00
$0
2021-10-22 19:26:40 +00:00
});
2020-03-19 15:47:31 +00:00
endsnippet
snippet st "setTimeout( ... )"
setTimeout(() => {$0
}, ${1:1000});
endsnippet
2021-10-22 19:26:40 +00:00
snippet dq "document.querySelector( ... )"
document.querySelector($0)
endsnippet
snippet dqa "document.querySelectorAll( ... )"
document.querySelectorAll($0)
endsnippet
snippet cdq "const ... = document.querySelector( ... )"
const $1 = document.querySelector($0);
endsnippet
snippet cdqa "const ... = document.querySelectorAll( ... )"
const $1 = document.querySelectorAll($0);
endsnippet
2020-03-19 15:47:31 +00:00
snippet jsx "import React ..."
2020-04-25 20:55:30 +00:00
import React from "react";
class $1 extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render() {
return (
<${2:div} className={this.props.className}>
$0
</$2>
);
}
}
2020-03-19 15:47:31 +00:00
export default () => (
2020-04-25 20:55:30 +00:00
<S.$1}></S.$1>
);
2020-03-19 15:47:31 +00:00
endsnippet
2020-04-25 20:55:30 +00:00
snippet jsxs "import React ... styled"
import React from "react";
import styled from "styled-components";
2020-03-19 15:47:31 +00:00
2020-04-25 20:55:30 +00:00
const S = {};
class $1 extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render() {
return (
<${2:div} className={this.props.className}>
$0
</$2>
);
}
}
S.$1 = styled($1)\`
\`;
2020-03-19 15:47:31 +00:00
export default () => (
2020-04-25 20:55:30 +00:00
<S.$1}></S.$1>
);
2020-03-19 15:47:31 +00:00
endsnippet
2020-04-25 20:55:30 +00:00
snippet jsc "class ... extends React.Component"
class $1 extends React.Component \{
${2: constructor(props) \{
super(props);
this.state = \{
\}
\}}
render() \{
return (
<${3:div}${4: className=\{this.props.className\}}>
$0
</$3>
);
}
2020-03-19 15:47:31 +00:00
}
endsnippet
2020-04-25 20:55:30 +00:00
2020-04-27 10:54:42 +00:00
snippet th "this.handle..."
this.handle${1:Click} = this.handle$1.bind(this);
endsnippet
2020-04-29 13:55:37 +00:00
snippet tb "this ... = ... .bind(this);"
this.$1 = this.$1.bind(this);
endsnippet
2020-05-10 15:28:18 +00:00
snippet wprb
import { registerBlockType } from '@wordpress/blocks';
const blockStyle = {
color: red,
backgroundColor: pink,
};
registerBlockType( '${1:namespace}/${2:block-name}', {
title: '$3',
icon: '${4:universal-access-alt}',
category: '${5:layout}',
example: {},
2020-05-10 21:23:19 +00:00
edit( { className } ) {
return <div className={ className }>Hello World, step 1 (from the editor).</div>;
2020-05-10 15:28:18 +00:00
},
save() {
return <div style={ blockStyle }>Hello World, step 1 (from the frontend).</div>;
},
} );
endsnippet