From 96bc2b0b98c703ec118adbfe57fed93a28a533ee Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 24 Apr 2020 20:49:23 +0100 Subject: [PATCH 1/5] undo center on insert --- init.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.vim b/init.vim index 9876014..1e5b458 100644 --- a/init.vim +++ b/init.vim @@ -435,10 +435,10 @@ iabbrev ct'' content-type: ''; "----------------------------------------------------------------------------}}} " #autocommands {{{ -" center on insert {{{ - augroup CenterInsert +" template files {{{ + augroup templates autocmd! - autocmd InsertEnter * norm zt + autocmd BufNewFile *.sh 0read ~/.config/nvim/templates/template.sh | normal G augroup END " }}} From c2963b69ad5e46cea7f61b13712d2b55bb4985f7 Mon Sep 17 00:00:00 2001 From: ray Date: Sat, 25 Apr 2020 16:11:44 +0100 Subject: [PATCH 2/5] add html/css templates --- init.vim | 10 +++------- templates/template.css | 15 +++++++++++++++ templates/template.html | 31 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 templates/template.css create mode 100644 templates/template.html diff --git a/init.vim b/init.vim index 1e5b458..943d660 100644 --- a/init.vim +++ b/init.vim @@ -439,13 +439,9 @@ iabbrev ct'' content-type: ''; augroup templates autocmd! autocmd BufNewFile *.sh 0read ~/.config/nvim/templates/template.sh | normal G - augroup END - -" }}} -" template files {{{ - augroup templates - autocmd! - autocmd BufNewFile *.sh 0read ~/.config/nvim/templates/template.sh | normal G + autocmd BufNewFile *.html 0read ~/.config/nvim/templates/template.html | normal gg + autocmd BufNewFile *.css 0read ~/.config/nvim/templates/template.css | normal G + autocmd BufNewFile *.scss 0read ~/.config/nvim/templates/template.css | normal G augroup END " }}} diff --git a/templates/template.css b/templates/template.css new file mode 100644 index 0000000..e190019 --- /dev/null +++ b/templates/template.css @@ -0,0 +1,15 @@ +html, +body { + padding: 0; + margin: 0; +} + +body { + font-size: 100%; + box-sizing: border-box; + background-color: pink; +} + +* { + box-sizing: inherit; +} diff --git a/templates/template.html b/templates/template.html new file mode 100644 index 0000000..9037327 --- /dev/null +++ b/templates/template.html @@ -0,0 +1,31 @@ + + + + + + + THE TITLE IS THIS! + + + + + + + + + + + + +
+
+ +
+
+ +
+
+ + + + From 058cd4214cde54997b6197b3cf5aa3b64d4279f7 Mon Sep 17 00:00:00 2001 From: ray Date: Sat, 25 Apr 2020 16:19:06 +0100 Subject: [PATCH 3/5] rename default filenames --- templates/template.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/template.html b/templates/template.html index 9037327..cc39a5a 100644 --- a/templates/template.html +++ b/templates/template.html @@ -11,7 +11,7 @@ - + @@ -26,6 +26,6 @@
- + From 53b0720cd172a37241efd7570ca0a5a0b5c079a1 Mon Sep 17 00:00:00 2001 From: ray Date: Sat, 25 Apr 2020 21:55:30 +0100 Subject: [PATCH 4/5] update react snippets --- UltiSnips/javascript.snippets | 90 +++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/UltiSnips/javascript.snippets b/UltiSnips/javascript.snippets index c0fcd10..527154e 100644 --- a/UltiSnips/javascript.snippets +++ b/UltiSnips/javascript.snippets @@ -4,7 +4,7 @@ endsnippet snippet if "if ( ... ) { ... }" if ($1) { - $0 + $0 } endsnippet @@ -18,21 +18,21 @@ endsnippet snippet if "if ( ... ) { ... }" if ($1) { - $0 + $0 } endsnippet snippet ifelse "if ( ... ) { ... } else { ... }" if ($1) { - $2 + $2 } else { - $0 + $0 } endsnippet snippet for "for ( ... ) { ... }" for (let ${1:index} = ${2:0}; $1 $3; $1${4:++}) { - $0 + $0 } endsnippet @@ -42,36 +42,74 @@ setTimeout(() => {$0 endsnippet snippet jsx "import React ..." -import React from "react" +import React from "react"; + +class $1 extends React.Component { + constructor(props) { + super(props); + this.state = { + } + } + + render() { + return ( + <${2:div} className={this.props.className}> + $0 + + ); + } +} export default () => ( - <${1:div}>$0 -) + +); endsnippet -snippet jsxs "import React ... (styled)" -import React from "react" -import styled from "styled-components" +snippet jsxs "import React ... styled" +import React from "react"; +import styled from "styled-components"; -const $1 = styled.${2:div}\` - $3 -\` +const S = {}; + +class $1 extends React.Component { + constructor(props) { + super(props); + this.state = { + } + } + + render() { + return ( + <${2:div} className={this.props.className}> + $0 + + ); + } +} + +S.$1 = styled($1)\` +\`; export default () => ( - <$1>$0 -) + +); endsnippet -snippet xc "class ..." -class $1 extends React.component { - constructor(props) { - super(props) - this.setState({$0}) - } +snippet jsc "class ... extends React.Component" +class $1 extends React.Component \{ +${2: constructor(props) \{ + super(props); + this.state = \{ + \} + \}} - render() { - return ( - ) - } + render() \{ + return ( + <${3:div}${4: className=\{this.props.className\}}> + $0 + + ); + } } endsnippet + From eca9369e9282aac1ba80173bc31f7b2403ce799e Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 26 Apr 2020 12:47:16 +0100 Subject: [PATCH 5/5] update snippets --- UltiSnips/javascript.snippets | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/UltiSnips/javascript.snippets b/UltiSnips/javascript.snippets index 527154e..90f43b1 100644 --- a/UltiSnips/javascript.snippets +++ b/UltiSnips/javascript.snippets @@ -8,12 +8,8 @@ if ($1) { } endsnippet -snippet cl; "console.log( ... );" -console.log($0); -endsnippet - snippet cl "console.log( ... )" -console.log($0) +console.log($0); endsnippet snippet if "if ( ... ) { ... }"