Update snippets
This commit is contained in:
@@ -1 +0,0 @@
|
||||
{}
|
||||
1
lua/snippets/all.lua
Normal file
1
lua/snippets/all.lua
Normal file
@@ -0,0 +1 @@
|
||||
return {}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"Log function": {
|
||||
"prefix": "du",
|
||||
"body": [
|
||||
"console.log($0);"
|
||||
],
|
||||
"description": "Log variable"
|
||||
}
|
||||
}
|
||||
45
lua/snippets/javascript.lua
Normal file
45
lua/snippets/javascript.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
local ls = require 'luasnip'
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
|
||||
return {
|
||||
s('du', { t 'console.log(', i(0), t ');' }),
|
||||
|
||||
s('vue', {
|
||||
t { '<template>', '' },
|
||||
t { '', '</template>', '', '', '<script setup>', '' },
|
||||
i(0),
|
||||
t { '', '</script>', '', '', '<style scoped>', '', '.o-share-page {', '}', '', '</style>' },
|
||||
}),
|
||||
|
||||
s('fun', {
|
||||
t 'function ',
|
||||
i(1),
|
||||
t '(',
|
||||
i(2),
|
||||
t ') {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
}),
|
||||
|
||||
s('afun', {
|
||||
t 'async function ',
|
||||
i(1),
|
||||
t '(',
|
||||
i(2),
|
||||
t ') {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
}),
|
||||
|
||||
s('()', {
|
||||
t '() => {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
}),
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"name": "example-snippets",
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": [
|
||||
"all"
|
||||
],
|
||||
"path": "./snippets/all.json"
|
||||
},
|
||||
{
|
||||
"language": [
|
||||
"php"
|
||||
],
|
||||
"path": "./php.json"
|
||||
},
|
||||
{
|
||||
"language": [
|
||||
"javascript",
|
||||
"vue"
|
||||
],
|
||||
"path": "./javascript-vue.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
{
|
||||
"Dump function": {
|
||||
"prefix": "du",
|
||||
"body": [
|
||||
"dump($0);"
|
||||
],
|
||||
"description": "Dump variable"
|
||||
},
|
||||
"Type dump function": {
|
||||
"prefix": "dt",
|
||||
"body": [
|
||||
"\\PhpStan\\dumpType($0);"
|
||||
],
|
||||
"description": "Dump PHPStan type"
|
||||
},
|
||||
"Test case": {
|
||||
"prefix": "test",
|
||||
"body": [
|
||||
"test($1, function () {",
|
||||
" $0",
|
||||
"});"
|
||||
],
|
||||
"description": "Test case"
|
||||
},
|
||||
"Create doc block": {
|
||||
"prefix": "/**",
|
||||
"body": [
|
||||
"/**",
|
||||
" * $0",
|
||||
" */"
|
||||
]
|
||||
},
|
||||
"DocBlock property": {
|
||||
"prefix": "@p",
|
||||
"body": "@property $1 $$0",
|
||||
"description": "DocBlock property"
|
||||
},
|
||||
"DocBlock boolean property": {
|
||||
"prefix": "@pb",
|
||||
"body": "@property bool $$0",
|
||||
"description": "DocBlock boolean property"
|
||||
},
|
||||
"DocBlock string property": {
|
||||
"prefix": "@ps",
|
||||
"body": "@property string $$0",
|
||||
"description": "DocBlock string property"
|
||||
},
|
||||
"DocBlock int property": {
|
||||
"prefix": "@pi",
|
||||
"body": "@property int $$0",
|
||||
"description": "DocBlock int property"
|
||||
},
|
||||
"DocBlock Collection property": {
|
||||
"prefix": "@pc",
|
||||
"body": "@property \\Illuminate\\Support\\Collection<int, $1> $$0",
|
||||
"description": "DocBlock int property"
|
||||
},
|
||||
"DocBlock date property": {
|
||||
"prefix": "@pd",
|
||||
"body": "@property \\Illuminate\\Support\\Carbon $$0",
|
||||
"description": "DocBlock date property"
|
||||
},
|
||||
"DocBlock model properties": {
|
||||
"prefix": "@pp",
|
||||
"body": [
|
||||
"/**",
|
||||
" * @property int $$id",
|
||||
" * $1",
|
||||
" * @property \\Illuminate\\Support\\Carbon $$created_at",
|
||||
" * @property \\Illuminate\\Support\\Carbon $$updated_at",
|
||||
" *",
|
||||
" * Relationships",
|
||||
" * $2",
|
||||
" */"
|
||||
],
|
||||
"description": "DocBlock model properties"
|
||||
}
|
||||
}
|
||||
84
lua/snippets/php.lua
Normal file
84
lua/snippets/php.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
|
||||
local function psr_namespace(args, snip)
|
||||
local path = snip.env.TM_FILENAME_FULL or ""
|
||||
local root = "/src/"
|
||||
local ns = path:match(root .. "(.*)/[^/]+%.php$")
|
||||
if ns then
|
||||
return ns:gsub("/", "\\")
|
||||
else
|
||||
return "App"
|
||||
end
|
||||
end
|
||||
|
||||
local function class_name(args, snip)
|
||||
local filename = snip.env.TM_FILENAME or ""
|
||||
return filename:match("([^%.]+)") or "ClassName"
|
||||
end
|
||||
|
||||
return {
|
||||
s("du", { t("dump("), i(1), t(");") }),
|
||||
s("dt", { t("\\PhpStan\\dumpType("), i(1), t(");") }),
|
||||
s("ql", {
|
||||
t("\\Illuminate\\Support\\Facades\\DB::listen(function (\\Illuminate\\Database\\Events\\QueryExecuted $e) {"),
|
||||
t({"", " dump($e->sql, $e->bindings);"}),
|
||||
t({"", "});"})
|
||||
}),
|
||||
s("test", {
|
||||
t("test("), i(1), t(", function () {"),
|
||||
t({"", " "}), i(2),
|
||||
t({"", ");"})
|
||||
}),
|
||||
s("/**", {
|
||||
t("/**"),
|
||||
t({"", " * "}), i(1),
|
||||
t({"", " */"})
|
||||
}),
|
||||
s("@p", { t("@property "), i(1), t(" $"), i(2) }),
|
||||
s("@pb", { t("@property bool $"), i(1) }),
|
||||
s("@ps", { t("@property string $"), i(1) }),
|
||||
s("@pi", { t("@property int $"), i(1) }),
|
||||
s("@pc", { t("@property \\Illuminate\\Support\\Collection<int, "), i(1), t("> $"), i(2) }),
|
||||
s("@pd", { t("@property \\Illuminate\\Support\\Carbon $"), i(1) }),
|
||||
s("@pp", {
|
||||
t("/**"),
|
||||
t({"", " * @property int $id"}),
|
||||
t({"", " * "}), i(1),
|
||||
t({"", " * @property \\Illuminate\\Support\\Carbon $created_at"}),
|
||||
t({"", " * @property \\Illuminate\\Support\\Carbon $updated_at"}),
|
||||
t({"", " *", " * Relationships"}),
|
||||
t({"", " * "}), i(2),
|
||||
t({"", " */"})
|
||||
}),
|
||||
s("php", {
|
||||
t("<?php"),
|
||||
t({"", ""}),
|
||||
t("namespace "),
|
||||
f(psr_namespace, {}),
|
||||
t(";"),
|
||||
t({"", "", "/**", " * Class "}),
|
||||
f(class_name, {}),
|
||||
t({"", " */", "class "}),
|
||||
f(class_name, {}),
|
||||
i(1),
|
||||
t({"", "{", " public function __construct()", " {", " "}),
|
||||
i(2, "// TODO: Implement constructor"),
|
||||
t({"", " }", "}"})
|
||||
}),
|
||||
s("pub", {
|
||||
t("public function "), i(1), t("("), i(2), t(")"),
|
||||
t({"", "{"}),
|
||||
t({"", " "}), i(3),
|
||||
t({"", "}"})
|
||||
}),
|
||||
s("pro", {
|
||||
t("protected function "), i(1), t("("), i(2), t(")"),
|
||||
t({"", "{"}),
|
||||
t({"", " "}), i(3),
|
||||
t({"", "}"})
|
||||
}),
|
||||
}
|
||||
Reference in New Issue
Block a user