From 3d94211018aa28c32605e001e62b3dbe7f9305f3 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Fri, 19 Mar 2021 02:22:55 +0300 Subject: [PATCH] v0.0.1 --- .eslintrc.js | 23 +++++++++++++++ .vscode/extensions.json | 5 ++++ .vscode/launch.json | 14 +++++++++ .vscode/settings.json | 3 ++ README.md | 15 ++++++++++ package.json | 21 +++++++++++++ snippets.json | 65 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 146 insertions(+) create mode 100644 .eslintrc.js create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 package.json create mode 100644 snippets.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..91729d3 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,23 @@ +/**@type {import('eslint').Linter.Config} */ +// eslint-disable-next-line no-undef +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: { + 'semi': [ + 2, + "always" + ], + '@typescript-eslint/no-unused-vars': 0, + '@typescript-eslint/no-explicit-any': 0, + '@typescript-eslint/explicit-module-boundary-types': 0, + '@typescript-eslint/no-non-null-assertion': 0, + } +}; diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..12ffc20 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9e6d2e6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ] + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..89401d0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.insertSpaces": false +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..20476c9 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Golang snippets + +Extensions with frequently used snippets for productive go development. + +Extension in active development! Your contribution is always welcome :) + +| Prefix| Description | Example | +| :---- |:-----------:| -------:| +| `pkg` | Package header line | `package test` | +| `tyi` | Type interface declaration | ```type test interface { }``` | +| `tys` | Type structure declaration | ```type test struct { }``` | +| `construct` | Constructor for structure type | see in action | +| `var` | Variable with type and value | `var test string = "hello"` | +| `stack` | Stack from array of types | see in action | + diff --git a/package.json b/package.json new file mode 100644 index 0000000..cec58e7 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "gosnippets", + "displayName": "Useful Golang snippets", + "description": "Snippets for productive work", + "version": "0.0.1", + "publisher": "Alexander NeonXP Kiryukhin", + "engines": { + "vscode": "^1.28.0" + }, + "categories": [ + "Snippets" + ], + "contributes": { + "snippets": [ + { + "language": "golang", + "path": "./snippets.json" + } + ] + } +} diff --git a/snippets.json b/snippets.json new file mode 100644 index 0000000..294d806 --- /dev/null +++ b/snippets.json @@ -0,0 +1,65 @@ +{ + "Interface declaration": { + "body": [ + "type $1 interface {", + "\t$0", + "}" + ], + "description": "go interface type", + "prefix": "tyi" + }, + "Package line": { + "body": [ + "package ${TM_DIRECTORY/.+\\/(.+)$/${1:/downcase}/}", + "", + "$0" + ], + "description": "package header", + "prefix": "pkg" + }, + "Stack from array": { + "body": [ + "type ${1:name} []${2:type}", + "", + "func (s *$1) Push(item $2) {", + "\t*s = append(*s, item)", + "}", + "", + "func (s *$1) Pop() (item $2) {", + "\tif len(*s) == 0 {", + "\t\treturn", + "\t}", + "", + "\t*s, item = (*s)[:len(*s)-1], (*s)[len(*s)-1]", + "\treturn item", + "}" + ], + "description": "stack from array type", + "prefix": "stack" + }, + "Structure constructor": { + "body": [ + "// New instance of $1 type.", + "func New${1:type}(${2}) *$1 {", + "\t$3", + "\treturn &$1{$4}", + "}" + ], + "description": "constructor for structure type", + "prefix": "construct" + }, + "Structure declaration": { + "body": [ + "type $1 struct {", + "\t$0", + "}" + ], + "description": "strucutre type", + "prefix": "tys" + }, + "Variable declaration": { + "body": "var $1 $2 = $3", + "description": "variable with type and value", + "prefix": "var" + } +}