From c1ec4cdaf215f22c86040584cb1eef2b3ac2b741 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 12 Jul 2019 22:29:15 +0900 Subject: Fix socket server --- template/c/base-socket-server.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/template/c/base-socket-server.c b/template/c/base-socket-server.c index 4fed22e..5e41e40 100644 --- a/template/c/base-socket-server.c +++ b/template/c/base-socket-server.c @@ -1,5 +1,19 @@ #ifdef _WIN32 # include +# include +# include +static void +socket_perror(const char *s) { + CHAR buf[512]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + WSAGetLastError(), + 0, + buf, + sizeof(buf)/sizeof(buf[0]), + NULL); + printf("%s: %s", s, buf); +} #else # include # include @@ -8,6 +22,7 @@ # include # include #define closesocket(fd) close(fd) +#define socket_perror(s) perror(s) #endif int @@ -23,35 +38,35 @@ main(int argc, char* argv[]) { WSAStartup(MAKEWORD(2, 0), &wsa); #endif - if ((server_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - perror("reader: socket"); + if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + socket_perror("reader: socket"); exit(1); } memset((char *) &reader_addr, 0, sizeof(reader_addr)); reader_addr.sin_family = PF_INET; reader_addr.sin_addr.s_addr = htonl(INADDR_ANY); - //reader_addr.sin_port = htons(8000); - reader_addr.sin_port = 0; + reader_addr.sin_port = htons(8000); if (bind(server_fd, (struct sockaddr *)&reader_addr, sizeof(reader_addr)) < 0) { - perror("reader: bind"); + socket_perror("reader: bind"); exit(1); } - size_t socklen = sizeof(reader_addr); + socklen_t socklen = sizeof(reader_addr); if (getsockname(server_fd, (struct sockaddr *)&reader_addr, &socklen) < 0) { - perror("reader: bind"); + socket_perror("getsockname: bind"); exit(1); } if (listen(server_fd, 5) < 0) { - perror("reader: listen"); - close(server_fd); + socket_perror("reader: listen"); + closesocket(server_fd); exit(1); } + writer_len = sizeof(writer_addr); if ((client_fd = accept(server_fd,(struct sockaddr *)&writer_addr, &writer_len)) < 0) { - perror("reader: accept"); + socket_perror("reader: accept"); exit(1); } @@ -62,7 +77,7 @@ main(int argc, char* argv[]) { if (n == 0) { break; } else if (n == -1) { - perror("recv"); + socket_perror("recv"); exit(EXIT_FAILURE); } else { send(client_fd, buf, n, 0); -- cgit v1.2.3-54-g00ecf From df88ac36ed24e68d7d9d7e4d9aa471575d3c79bd Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 14 Aug 2019 15:01:05 +0900 Subject: Create FUNDING.yml --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..351ae11 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: mattn # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] -- cgit v1.2.3-54-g00ecf From 2f49560db7699d7988a817a4f69f8b684cecdfee Mon Sep 17 00:00:00 2001 From: hiroebe Date: Mon, 16 Sep 2019 17:17:12 +0900 Subject: Use shiftwidth() instead of &shiftwidth --- autoload/sonictemplate.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index 9397efa..1fc6451 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -281,7 +281,7 @@ function! sonictemplate#apply(name, mode, ...) abort if !buffer_is_not_empty let c = substitute(c, '{{_inline_}}\s*', '', 'g') if &expandtab || (&shiftwidth && &tabstop != &shiftwidth) - let c = substitute(c, "\t", repeat(' ', &shiftwidth), 'g') + let c = substitute(c, "\t", repeat(' ', shiftwidth()), 'g') endif silent! %d _ silent! put = c @@ -309,9 +309,9 @@ function! sonictemplate#apply(name, mode, ...) abort endif let c = indent . substitute(substitute(c, "\n", "\n".indent, 'g'), "\n".indent."\n", "\n\n", 'g') if len(indent) && (&expandtab || (&shiftwidth && &tabstop != &shiftwidth) || indent =~ '^ \+$') - let c = substitute(c, "\t", repeat(' ', min([len(indent), &shiftwidth])), 'g') + let c = substitute(c, "\t", repeat(' ', min([len(indent), shiftwidth()])), 'g') elseif &expandtab || (&shiftwidth && &tabstop != &shiftwidth) - let c = substitute(c, "\t", repeat(' ', &shiftwidth), 'g') + let c = substitute(c, "\t", repeat(' ', shiftwidth()), 'g') endif if line('.') < line('$') silent! normal! dd @@ -360,9 +360,9 @@ function! sonictemplate#postfix() if c =~ "\n" let c = indent . substitute(substitute(c, "\n", "\n".indent, 'g'), "\n".indent."\n", "\n\n", 'g') if len(indent) && (&expandtab || (&shiftwidth && &tabstop != &shiftwidth) || indent =~ '^ \+$') - let c = substitute(c, "\t", repeat(' ', min([len(indent), &shiftwidth])), 'g') + let c = substitute(c, "\t", repeat(' ', min([len(indent), shiftwidth()])), 'g') elseif &expandtab || (&shiftwidth && &tabstop != &shiftwidth) - let c = substitute(c, "\t", repeat(' ', &shiftwidth), 'g') + let c = substitute(c, "\t", repeat(' ', shiftwidth()), 'g') endif call setline('.', line) if line('.') < line('$') -- cgit v1.2.3-54-g00ecf From 31de6a5e48b65dface121e654e40e06de6bf364a Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 2 Oct 2019 09:25:34 +0900 Subject: Update postfix completion --- template/go/pattern.stpl | 23 +++++++++++++++++++++++ template/java/pattern.stpl | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/template/go/pattern.stpl b/template/go/pattern.stpl index 1fe0989..26ac4c6 100644 --- a/template/go/pattern.stpl +++ b/template/go/pattern.stpl @@ -56,3 +56,26 @@ \(\S.*\)\.spr\%[int]l\%[n]$ {{_cursor_}} fmt.Sprintln({{$1}}) + +\(\S\+\)\.func$ + func {{$1}} { + {{_cursor_}} + } + +\(\S\+\)\.struct$ + type {{$1}} struct { + {{_cursor_}} + } + +\(\S\+\)\.int$ + {{$1}} int + {{_cursor_}} + +\(\S\+\)\.string$ + {{$1}} string + {{_cursor_}} + +\(\S\+\)\.bool$ + {{$1}} bool + {{_cursor_}} + diff --git a/template/java/pattern.stpl b/template/java/pattern.stpl index 2a48364..69ad725 100644 --- a/template/java/pattern.stpl +++ b/template/java/pattern.stpl @@ -9,3 +9,9 @@ \(\S.*\)\.pr\%[int]l\%[n]$ System.out.println({{$1}}); {{_cursor_}} + +\(\S.*\)\.false$ + assertFalse({{$1}});{{_cursor_}} + +\(\S.*\)\.true$ + assertTrue({{$1}});{{_cursor_}} -- cgit v1.2.3-54-g00ecf From 807562bbebb7b7c033823ebd3b13b32a814d4f7f Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 2 Oct 2019 10:41:10 +0900 Subject: Use flag n for feedkeys --- autoload/sonictemplate.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index 1fc6451..6146b3d 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -327,7 +327,7 @@ function! sonictemplate#apply(name, mode, ...) abort else silent! call search('{{_cursor_}}\zs', 'w') silent! foldopen - silent! call feedkeys(repeat("\", 12)) + silent! call feedkeys(repeat("\", 12), 'n') endif endif endfunction -- cgit v1.2.3-54-g00ecf From 51a9cec47ad815451a8cdf1408a50ea525111442 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 2 Oct 2019 11:26:01 +0900 Subject: Fix feedkeys --- autoload/sonictemplate.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index 6146b3d..b857a25 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -379,7 +379,7 @@ function! sonictemplate#postfix() if stridx(c, '{{_cursor_}}') != -1 silent! call search('{{_cursor_}}\zs', 'w') silent! foldopen - silent! call feedkeys(repeat("\", 12)) + silent! call feedkeys(repeat("\", 12), 'n') endif break endif -- cgit v1.2.3-54-g00ecf From 5e752a5bf606ec50fffca5a2269ade32a22c1fe4 Mon Sep 17 00:00:00 2001 From: Wallyss Lima Date: Thu, 3 Oct 2019 11:58:22 -0300 Subject: replace deprecated MANTAINER with LABEL in Dockerfile --- template/dockerfile/base-main.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/dockerfile/base-main.dockerfile b/template/dockerfile/base-main.dockerfile index de043d3..cc87523 100644 --- a/template/dockerfile/base-main.dockerfile +++ b/template/dockerfile/base-main.dockerfile @@ -1,4 +1,4 @@ FROM {{_input_:FROM_image}} -MAINTAINER {{_input_:author}} <{{_input_:email}}> +LABEL maintainer "{{_input_:author}} <{{_input_:email}}>" RUN {{_cursor_}} -- cgit v1.2.3-54-g00ecf From 4e1b1a36a95e899ad4415d7b4373e2c0e3ff05af Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 6 Oct 2019 21:29:01 +0900 Subject: Add build.gradle for kotlin --- template/groovy/base-gradle-kotlin.gradle | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 template/groovy/base-gradle-kotlin.gradle diff --git a/template/groovy/base-gradle-kotlin.gradle b/template/groovy/base-gradle-kotlin.gradle new file mode 100644 index 0000000..66898ea --- /dev/null +++ b/template/groovy/base-gradle-kotlin.gradle @@ -0,0 +1,22 @@ +buildscript { + ext { + kotlinVersion = '1.3.10' + } + repositories { + mavenCentral() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + } +} + +apply { + plugin 'kotlin' + plugin 'eclipse' + plugin 'idea' +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" + testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion" +} -- cgit v1.2.3-54-g00ecf From 47c0d77f6cad63ea17b0fa6c87d585768c35cf89 Mon Sep 17 00:00:00 2001 From: anekos Date: Thu, 14 Nov 2019 18:46:36 +0900 Subject: Avoid updating register --- autoload/sonictemplate.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index b857a25..c42e4d3 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -285,7 +285,7 @@ function! sonictemplate#apply(name, mode, ...) abort endif silent! %d _ silent! put = c - silent! normal! ggdd + silent! normal! gg"_dd else if c[len(c)-1] == "\n" let c = c[:-2] @@ -314,7 +314,7 @@ function! sonictemplate#apply(name, mode, ...) abort let c = substitute(c, "\t", repeat(' ', shiftwidth()), 'g') endif if line('.') < line('$') - silent! normal! dd + silent! normal! "_dd endif silent! put! =c endif -- cgit v1.2.3-54-g00ecf From e746cdf5c5dc8d3849b7e2517c4a24e57d931dd3 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sat, 21 Dec 2019 23:11:46 +0900 Subject: Strictly --- autoload/sonictemplate.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index c42e4d3..c857cc8 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -68,7 +68,7 @@ function! s:get_candidate(fts, lead) endif try let ft = s:get_filetype() - let cxt = sonictemplate#lang#{ft!=""?ft:"_"}#guess() + let cxt = sonictemplate#lang#{ft !=# '' ? ft : '_'}#guess() if has_key(cxt, 'prefix') let prefix = cxt['prefix'] call s:setopt('prefix', cxt['prefix']) -- cgit v1.2.3-54-g00ecf From 20a19f48f9db3a32c3ebc0352fe094bd9816cd38 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 25 Dec 2019 17:04:37 +0900 Subject: Add base-main.scala --- template/scala/base-main.scala | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 template/scala/base-main.scala diff --git a/template/scala/base-main.scala b/template/scala/base-main.scala new file mode 100644 index 0000000..f0ba3a5 --- /dev/null +++ b/template/scala/base-main.scala @@ -0,0 +1,6 @@ +object {{_name_}} { + def main(args: Array[String]): Unit = { + println("{{_cursor_}}") + } +} + -- cgit v1.2.3-54-g00ecf From 0925277597e5db0e4b601aecc290b79db239b174 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 27 Dec 2019 15:59:12 +0900 Subject: Add snippets for typescript --- template/typescript/base-class.ts | 5 +++++ template/typescript/snip-class.ts | 5 +++++ template/typescript/snip-ctor.ts | 7 +++++++ template/typescript/snip-dowhile.ts | 3 +++ template/typescript/snip-endregion.ts | 1 + template/typescript/snip-error.ts | 1 + template/typescript/snip-for.ts | 4 ++++ template/typescript/snip-foreach-lambda.ts | 3 +++ template/typescript/snip-forin.ts | 6 ++++++ template/typescript/snip-forof.ts | 3 +++ template/typescript/snip-function.ts | 3 +++ template/typescript/snip-get.ts | 5 +++++ template/typescript/snip-if.ts | 3 +++ template/typescript/snip-ifelse.ts | 5 +++++ template/typescript/snip-import-statement.ts | 1 + template/typescript/snip-log.ts | 1 + template/typescript/snip-new.ts | 1 + template/typescript/snip-private-method.ts | 3 +++ template/typescript/snip-prop.ts | 9 +++++++++ template/typescript/snip-public-method.ts | 6 ++++++ template/typescript/snip-ref.ts | 1 + template/typescript/snip-region.ts | 1 + template/typescript/snip-set.ts | 5 +++++ template/typescript/snip-settimeout.ts | 3 +++ template/typescript/snip-switch.ts | 8 ++++++++ template/typescript/snip-throw.ts | 1 + template/typescript/snip-trycatch.ts | 5 +++++ template/typescript/snip-warn.ts | 1 + template/typescript/snip-while.ts | 3 +++ 29 files changed, 103 insertions(+) create mode 100644 template/typescript/base-class.ts create mode 100644 template/typescript/snip-class.ts create mode 100644 template/typescript/snip-ctor.ts create mode 100644 template/typescript/snip-dowhile.ts create mode 100644 template/typescript/snip-endregion.ts create mode 100644 template/typescript/snip-error.ts create mode 100644 template/typescript/snip-for.ts create mode 100644 template/typescript/snip-foreach-lambda.ts create mode 100644 template/typescript/snip-forin.ts create mode 100644 template/typescript/snip-forof.ts create mode 100644 template/typescript/snip-function.ts create mode 100644 template/typescript/snip-get.ts create mode 100644 template/typescript/snip-if.ts create mode 100644 template/typescript/snip-ifelse.ts create mode 100644 template/typescript/snip-import-statement.ts create mode 100644 template/typescript/snip-log.ts create mode 100644 template/typescript/snip-new.ts create mode 100644 template/typescript/snip-private-method.ts create mode 100644 template/typescript/snip-prop.ts create mode 100644 template/typescript/snip-public-method.ts create mode 100644 template/typescript/snip-ref.ts create mode 100644 template/typescript/snip-region.ts create mode 100644 template/typescript/snip-set.ts create mode 100644 template/typescript/snip-settimeout.ts create mode 100644 template/typescript/snip-switch.ts create mode 100644 template/typescript/snip-throw.ts create mode 100644 template/typescript/snip-trycatch.ts create mode 100644 template/typescript/snip-warn.ts create mode 100644 template/typescript/snip-while.ts diff --git a/template/typescript/base-class.ts b/template/typescript/base-class.ts new file mode 100644 index 0000000..f6acef4 --- /dev/null +++ b/template/typescript/base-class.ts @@ -0,0 +1,5 @@ +class {{_input_:name}} { + constructor({{_input_:parameters}}) { + {{_cursor_}} + } +} diff --git a/template/typescript/snip-class.ts b/template/typescript/snip-class.ts new file mode 100644 index 0000000..f6acef4 --- /dev/null +++ b/template/typescript/snip-class.ts @@ -0,0 +1,5 @@ +class {{_input_:name}} { + constructor({{_input_:parameters}}) { + {{_cursor_}} + } +} diff --git a/template/typescript/snip-ctor.ts b/template/typescript/snip-ctor.ts new file mode 100644 index 0000000..f77e911 --- /dev/null +++ b/template/typescript/snip-ctor.ts @@ -0,0 +1,7 @@ +/** + * + */ +constructor() { + super(); + {{_cursor_}} +} diff --git a/template/typescript/snip-dowhile.ts b/template/typescript/snip-dowhile.ts new file mode 100644 index 0000000..b9c2ac9 --- /dev/null +++ b/template/typescript/snip-dowhile.ts @@ -0,0 +1,3 @@ +do { + {{_cursor_}} +} while ({{_input_:condition}}); diff --git a/template/typescript/snip-endregion.ts b/template/typescript/snip-endregion.ts new file mode 100644 index 0000000..56ce7f5 --- /dev/null +++ b/template/typescript/snip-endregion.ts @@ -0,0 +1 @@ +//#endregion diff --git a/template/typescript/snip-error.ts b/template/typescript/snip-error.ts new file mode 100644 index 0000000..a520e5b --- /dev/null +++ b/template/typescript/snip-error.ts @@ -0,0 +1 @@ +console.error({{_cursor_}}); diff --git a/template/typescript/snip-for.ts b/template/typescript/snip-for.ts new file mode 100644 index 0000000..275290b --- /dev/null +++ b/template/typescript/snip-for.ts @@ -0,0 +1,4 @@ +for (let {{_input_:index}} = 0; {{_input_:index}} < {{_input_:array}}.length; {{_input_:index}}++) { + const {{_input_:element}} = {{_input_:array}}[{{_input_:index}}]; + {{_cursor_}} +} diff --git a/template/typescript/snip-foreach-lambda.ts b/template/typescript/snip-foreach-lambda.ts new file mode 100644 index 0000000..5c3ed8a --- /dev/null +++ b/template/typescript/snip-foreach-lambda.ts @@ -0,0 +1,3 @@ +{{_input_:array}}.forEach({{_input_:element}} => { + {{_cursor_}} +}); diff --git a/template/typescript/snip-forin.ts b/template/typescript/snip-forin.ts new file mode 100644 index 0000000..44ec674 --- /dev/null +++ b/template/typescript/snip-forin.ts @@ -0,0 +1,6 @@ +for (const {{_input_:key}} in {{_input_:object}}) { + if ({{_input_:object}}.hasOwnProperty({{_input_:key}})) { + const {{_input_:element}} = {{_input_:object}}[{{_input_:key}}]; + {{_cursor_}} + } +} diff --git a/template/typescript/snip-forof.ts b/template/typescript/snip-forof.ts new file mode 100644 index 0000000..70d6432 --- /dev/null +++ b/template/typescript/snip-forof.ts @@ -0,0 +1,3 @@ +for (const {{_input_:iterator}} of {{_input_:object}}) { + {{_cursor_}} +} diff --git a/template/typescript/snip-function.ts b/template/typescript/snip-function.ts new file mode 100644 index 0000000..efe355d --- /dev/null +++ b/template/typescript/snip-function.ts @@ -0,0 +1,3 @@ +function {{_input_:name}}({{_input_:params}}:{{_input_:type}}) { + {{_cursor_}} +} diff --git a/template/typescript/snip-get.ts b/template/typescript/snip-get.ts new file mode 100644 index 0000000..12fce22 --- /dev/null +++ b/template/typescript/snip-get.ts @@ -0,0 +1,5 @@ + +public get {{_input_:value}}() : {{_input_:string}} { + {{_input_:return {{_cursor_}}}} +} + diff --git a/template/typescript/snip-if.ts b/template/typescript/snip-if.ts new file mode 100644 index 0000000..8c0c27a --- /dev/null +++ b/template/typescript/snip-if.ts @@ -0,0 +1,3 @@ +if ({{_input_:condition}}) { + {{_cursor_}} +} diff --git a/template/typescript/snip-ifelse.ts b/template/typescript/snip-ifelse.ts new file mode 100644 index 0000000..7df2562 --- /dev/null +++ b/template/typescript/snip-ifelse.ts @@ -0,0 +1,5 @@ +if ({{_input_:condition}}) { + {{_cursor_}} +} else { + +} diff --git a/template/typescript/snip-import-statement.ts b/template/typescript/snip-import-statement.ts new file mode 100644 index 0000000..fbf67d0 --- /dev/null +++ b/template/typescript/snip-import-statement.ts @@ -0,0 +1 @@ +import { {{_cursor_}} } from "{{_input_:module}}"; diff --git a/template/typescript/snip-log.ts b/template/typescript/snip-log.ts new file mode 100644 index 0000000..dbd5b94 --- /dev/null +++ b/template/typescript/snip-log.ts @@ -0,0 +1 @@ +console.log({{_cursor_}}); diff --git a/template/typescript/snip-new.ts b/template/typescript/snip-new.ts new file mode 100644 index 0000000..0a4c8ea --- /dev/null +++ b/template/typescript/snip-new.ts @@ -0,0 +1 @@ +const {{_input_:name}} = new {{_input_:type}}({{_input_:arguments}});{{_cursor_}} diff --git a/template/typescript/snip-private-method.ts b/template/typescript/snip-private-method.ts new file mode 100644 index 0000000..f23dbb0 --- /dev/null +++ b/template/typescript/snip-private-method.ts @@ -0,0 +1,3 @@ +private {{_input_:name}}() { + {{_cursor_}} +} diff --git a/template/typescript/snip-prop.ts b/template/typescript/snip-prop.ts new file mode 100644 index 0000000..7d8933e --- /dev/null +++ b/template/typescript/snip-prop.ts @@ -0,0 +1,9 @@ + +private _{{_input_:value}} : {{_input_:string}}; +public get {{_input_:value}}() : {{_input_:string}} { + return this._{{_input_:value}}; +} +public set {{_input_:value}}(v : {{_input_:string}}) { + this._{{_input_:value}} = v; +} + diff --git a/template/typescript/snip-public-method.ts b/template/typescript/snip-public-method.ts new file mode 100644 index 0000000..7191874 --- /dev/null +++ b/template/typescript/snip-public-method.ts @@ -0,0 +1,6 @@ +/** + * {{_input_:name}} + */ +public {{_input_:name}}() { + {{_cursor_}} +} diff --git a/template/typescript/snip-ref.ts b/template/typescript/snip-ref.ts new file mode 100644 index 0000000..83eee32 --- /dev/null +++ b/template/typescript/snip-ref.ts @@ -0,0 +1 @@ +/// diff --git a/template/typescript/snip-region.ts b/template/typescript/snip-region.ts new file mode 100644 index 0000000..45bd931 --- /dev/null +++ b/template/typescript/snip-region.ts @@ -0,0 +1 @@ +//#region {{_cursor_}} diff --git a/template/typescript/snip-set.ts b/template/typescript/snip-set.ts new file mode 100644 index 0000000..974dab1 --- /dev/null +++ b/template/typescript/snip-set.ts @@ -0,0 +1,5 @@ + +public set {{_input_:value}}(v : {{_input_:string}}) { + this.{{_cursor_}} = v; +} + diff --git a/template/typescript/snip-settimeout.ts b/template/typescript/snip-settimeout.ts new file mode 100644 index 0000000..ee2c258 --- /dev/null +++ b/template/typescript/snip-settimeout.ts @@ -0,0 +1,3 @@ +setTimeout(() => { + {{_cursor_}} +}, {{_input_:timeout}}); diff --git a/template/typescript/snip-switch.ts b/template/typescript/snip-switch.ts new file mode 100644 index 0000000..625208e --- /dev/null +++ b/template/typescript/snip-switch.ts @@ -0,0 +1,8 @@ +switch ({{_input_:key}}) { + case {{_input_:value}}: + {{_cursor_}} + break; + + default: + break; +} diff --git a/template/typescript/snip-throw.ts b/template/typescript/snip-throw.ts new file mode 100644 index 0000000..86ca9f6 --- /dev/null +++ b/template/typescript/snip-throw.ts @@ -0,0 +1 @@ +throw "{{_cursor_}}"; diff --git a/template/typescript/snip-trycatch.ts b/template/typescript/snip-trycatch.ts new file mode 100644 index 0000000..9d8b2de --- /dev/null +++ b/template/typescript/snip-trycatch.ts @@ -0,0 +1,5 @@ +try { + {{_cursor_}} +} catch ({{_input_:error}}) { + +} diff --git a/template/typescript/snip-warn.ts b/template/typescript/snip-warn.ts new file mode 100644 index 0000000..213eecc --- /dev/null +++ b/template/typescript/snip-warn.ts @@ -0,0 +1 @@ +console.warn({{_cursor_}}); diff --git a/template/typescript/snip-while.ts b/template/typescript/snip-while.ts new file mode 100644 index 0000000..55d9298 --- /dev/null +++ b/template/typescript/snip-while.ts @@ -0,0 +1,3 @@ +while ({{_input_:condition}}) { + {{_cursor_}} +} -- cgit v1.2.3-54-g00ecf From 4d00bdb4b7e60e0466d3a6e5791779f8ebe7d8fc Mon Sep 17 00:00:00 2001 From: sgur Date: Tue, 14 Jan 2020 16:28:05 +0900 Subject: Prefix noautocmd to normal! commands which trigger TextChange events. Fix #38 --- autoload/sonictemplate.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index c857cc8..8fe6e1c 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -295,7 +295,7 @@ function! sonictemplate#apply(name, mode, ...) abort let c = join(split(c, "\n"), "") let oldindentexpr = &indentexpr let &indentexpr = '' - silent! exe "normal! a\=c\" + noautocmd silent! exe "normal! a\=c\" let &indentexpr = oldindentexpr return else @@ -373,7 +373,7 @@ function! sonictemplate#postfix() call setline('.', line) let oldindentexpr = &indentexpr let &indentexpr = '' - silent! exe "normal! a\=c\" + noautocmd silent! exe "normal! a\=c\" let &indentexpr = oldindentexpr endif if stridx(c, '{{_cursor_}}') != -1 -- cgit v1.2.3-54-g00ecf