diff options
author | mityu <mityu.email@gmail.com> | 2020-01-21 11:59:51 +0900 |
---|---|---|
committer | mityu <mityu.email@gmail.com> | 2020-01-21 11:59:51 +0900 |
commit | b75b06bd0b099cb7e2c54863dbe91bc3a3028d5f (patch) | |
tree | c80588d1397cd845d1df2be2bc32d759758f5079 /template | |
parent | 670e2e61d089bafacab4d3994578c58794307ef2 (diff) | |
download | vim-sonictemplate-b75b06bd0b099cb7e2c54863dbe91bc3a3028d5f.tar.gz vim-sonictemplate-b75b06bd0b099cb7e2c54863dbe91bc3a3028d5f.tar.bz2 vim-sonictemplate-b75b06bd0b099cb7e2c54863dbe91bc3a3028d5f.zip |
Squashed commit of the following:
commit e972aa09aa158189c36913b62a4344cb3ca78c76
Merge: 0925277 4d00bdb
Author: mattn <mattn.jp@gmail.com>
Date: Tue Jan 14 18:26:58 2020 +0900
Merge pull request #39 from sgur/fix/error_on_normal
Prefix noautocmd to "normal!" commands which trigger TextChange events.
commit 4d00bdb4b7e60e0466d3a6e5791779f8ebe7d8fc
Author: sgur <sgurrr@gmail.com>
Date: Tue Jan 14 16:28:05 2020 +0900
Prefix noautocmd to normal! commands which trigger TextChange events.
Fix #38
commit 0925277597e5db0e4b601aecc290b79db239b174
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Fri Dec 27 15:59:12 2019 +0900
Add snippets for typescript
commit 20a19f48f9db3a32c3ebc0352fe094bd9816cd38
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Wed Dec 25 17:04:37 2019 +0900
Add base-main.scala
commit e746cdf5c5dc8d3849b7e2517c4a24e57d931dd3
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Sat Dec 21 23:11:46 2019 +0900
Strictly
commit c512546f04de8a185d40292dd0860d81d1896130
Merge: 859adef 47c0d77
Author: mattn <mattn.jp@gmail.com>
Date: Thu Nov 14 19:01:33 2019 +0900
Merge pull request #37 from anekos/fix/dont-kill-my-register
Avoid updating register
commit 47c0d77f6cad63ea17b0fa6c87d585768c35cf89
Author: anekos <anekos@snca.net>
Date: Thu Nov 14 18:46:36 2019 +0900
Avoid updating register
commit 859adef1e67cc0fb1a99e4e3f3d58360f5464f02
Merge: 4e1b1a3 5e752a5
Author: mattn <mattn.jp@gmail.com>
Date: Tue Oct 8 16:00:33 2019 +0900
Merge pull request #36 from wallysslima/master
replace deprecated MANTAINER with LABEL in Dockerfile
commit 4e1b1a36a95e899ad4415d7b4373e2c0e3ff05af
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Sun Oct 6 21:29:01 2019 +0900
Add build.gradle for kotlin
commit 5e752a5bf606ec50fffca5a2269ade32a22c1fe4
Author: Wallyss Lima <wallysslima@gmail.com>
Date: Thu Oct 3 11:58:22 2019 -0300
replace deprecated MANTAINER with LABEL in Dockerfile
commit 51a9cec47ad815451a8cdf1408a50ea525111442
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Wed Oct 2 11:26:01 2019 +0900
Fix feedkeys
commit 807562bbebb7b7c033823ebd3b13b32a814d4f7f
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Wed Oct 2 10:41:10 2019 +0900
Use flag n for feedkeys
commit 7db10f422f61819a1a8f45d0dade1de17ecab2b6
Merge: 31de6a5 39cf197
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Wed Oct 2 10:06:35 2019 +0900
Merge branch 'master' of https://github.com/mattn/sonictemplate-vim
commit 31de6a5e48b65dface121e654e40e06de6bf364a
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Wed Oct 2 09:25:34 2019 +0900
Update postfix completion
commit 39cf197d0e46eeff8f905063ba5030e8690169b3
Merge: df88ac3 2f49560
Author: mattn <mattn.jp@gmail.com>
Date: Thu Sep 26 14:28:34 2019 +0900
Merge pull request #34 from hiroebe/fix-shiftwidth
Use shiftwidth() instead of &shiftwidth
commit 2f49560db7699d7988a817a4f69f8b684cecdfee
Author: hiroebe <hiro.ebe.albirex12@gmail.com>
Date: Mon Sep 16 17:17:12 2019 +0900
Use shiftwidth() instead of &shiftwidth
commit df88ac36ed24e68d7d9d7e4d9aa471575d3c79bd
Author: mattn <mattn.jp@gmail.com>
Date: Wed Aug 14 15:01:05 2019 +0900
Create FUNDING.yml
commit c1ec4cdaf215f22c86040584cb1eef2b3ac2b741
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Fri Jul 12 22:29:15 2019 +0900
Fix socket server
Diffstat (limited to 'template')
35 files changed, 187 insertions, 12 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 <ws2tcpip.h> +# include <error.h> +# include <stdio.h> +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 <sys/fcntl.h> # include <sys/types.h> @@ -8,6 +22,7 @@ # include <netdb.h> # include <stdio.h> #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); 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_}} 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/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" +} 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_}} 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_}}") + } +} + 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 @@ +/// <reference path="{{_cursor_}}" /> 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_}} +} |