summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <bfr@qbus.de>2019-04-02 20:23:12 +0200
committerBenjamin Franzke <bfr@qbus.de>2019-04-02 20:23:12 +0200
commit0594766a2d482949b4219a79909947903b8eff46 (patch)
tree6d7c613a6c91fa37b7efec9aea1d41b57ac1b207
parent86fd4b1a6cd45cef2a8e2e82f6d6941ab060bb25 (diff)
downloaddotfiles-0594766a2d482949b4219a79909947903b8eff46.tar.gz
dotfiles-0594766a2d482949b4219a79909947903b8eff46.tar.bz2
dotfiles-0594766a2d482949b4219a79909947903b8eff46.zip
Add vim Ultisnips
-rw-r--r--.config/vim/UltiSnips/html.snippets31
-rw-r--r--.config/vim/UltiSnips/javascript.snippets9
-rw-r--r--.config/vim/UltiSnips/less.snippets3
-rw-r--r--.config/vim/UltiSnips/php.snippets179
-rw-r--r--.config/vim/UltiSnips/pug.snippets26
-rw-r--r--.config/vim/UltiSnips/xml.snippets7
6 files changed, 255 insertions, 0 deletions
diff --git a/.config/vim/UltiSnips/html.snippets b/.config/vim/UltiSnips/html.snippets
new file mode 100644
index 0000000..c4e0690
--- /dev/null
+++ b/.config/vim/UltiSnips/html.snippets
@@ -0,0 +1,31 @@
+snippet if "Fluid IF block" b
+<f:if condition="{$1}">
+ $2
+</f:if>
+endsnippet
+
+snippet then "Fluid THEN block" b
+<f:then>
+ $1
+</f:then>
+endsnippet
+
+snippet else "Fluid ELSE block" b
+<f:else>
+ $1
+</f:else>
+endsnippet
+
+snippet for "Fluid FOR block" b
+<f:for each="{$1}" as="$2">
+ $3
+</f:for>
+endsnippet
+
+snippet debug "FLUID debug viewhelper" b
+<f:debug inline="TRUE">{${1:_all}}</f:debug>
+endsnippet
+
+snippet image "FLUID image viewhler" b
+<f:image image="{$1}" class="${2:img-responsive}" />
+endsnippet
diff --git a/.config/vim/UltiSnips/javascript.snippets b/.config/vim/UltiSnips/javascript.snippets
new file mode 100644
index 0000000..d4d9475
--- /dev/null
+++ b/.config/vim/UltiSnips/javascript.snippets
@@ -0,0 +1,9 @@
+snippet kview "Keystone view template" b
+var keystone = require('keystone');
+
+exports = module.exports = function (req, res) {
+ var view = new keystone.View(req, res);
+ ${1}
+ view.render('`!p snip.rv=snip.basename`');
+}
+endsnippet
diff --git a/.config/vim/UltiSnips/less.snippets b/.config/vim/UltiSnips/less.snippets
new file mode 100644
index 0000000..2a1f6d4
--- /dev/null
+++ b/.config/vim/UltiSnips/less.snippets
@@ -0,0 +1,3 @@
+snippet rem "definition in rem"
+unit(${1}px / @font-size-base, rem);
+endsnippet
diff --git a/.config/vim/UltiSnips/php.snippets b/.config/vim/UltiSnips/php.snippets
new file mode 100644
index 0000000..8de1d1d
--- /dev/null
+++ b/.config/vim/UltiSnips/php.snippets
@@ -0,0 +1,179 @@
+snippet ns "namespace declaration" b
+namespace ${1:`!p
+abspath = os.path.abspath(path)
+m = re.search(r'([^/]+)/Classes/(.+(?=/))', abspath)
+if m:
+ snip.rv = 'Qbus\\' + \
+ re.sub(r'(^|_)([a-zA-Z])', lambda m: m.group(2).upper(), m.group(1)) + \
+ '\\' + m.group(2).replace('/', '\\')
+else:
+ m = re.search(r'[A-Z].+(?=/)', abspath)
+ if m:
+ snip.rv = m.group().replace('/', '\\')
+
+`};
+endsnippet
+
+
+snippet class "Class declaration template" b
+<?php
+namespace ${1:`!p
+abspath = os.path.abspath(path)
+m = re.search(r'([^/]+)/Classes/(.+(?=/))', abspath)
+if m:
+ snip.rv = 'Qbus\\' + \
+ re.sub(r'(^|_)([a-zA-Z])', lambda m: m.group(2).upper(), m.group(1)) + \
+ '\\' + m.group(2).replace('/', '\\')
+else:
+ m = re.search(r'[A-Z].+(?=/)', abspath)
+ if m:
+ snip.rv = m.group().replace('/', '\\')
+
+`};
+
+/**
+ * $1
+ *
+ * @author ${2:`!v g:snips_author`}
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ */
+class ${1:`!p snip.rv=snip.basename`}`!p
+abspath = os.path.abspath(path)
+if 'Classes/Controller/' in abspath:
+ snip.rv = ' extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController'
+elif 'Classes/Domain/Repository/' in abspath:
+ snip.rv = ' extends \TYPO3\CMS\Extbase\Persistence\Repository'
+elif 'Classes/Domain/Model/' in abspath:
+ snip.rv = ' extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity'
+elif 'Classes/ViewHelpers/' in abspath:
+ snip.rv = ' extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper'
+elif 'Classes/Command/' in abspath:
+ snip.rv = ' extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController'
+`
+{
+ ${VISUAL}${4}
+}
+endsnippet
+
+snippet inject "inject a Class"
+/**
+ * @var ${1:\\Vendor\\Extension\\Namespace\\ClassName}
+ */
+protected $${2:${1/.*(^|\\)([^\\]+)$/\l$2/}};
+
+/**
+ * @param $1 $$2
+ * @return void
+ */
+public function inject${2/\w+\s*/\u$0/}($1 $$2)
+{
+ $this->$2 = $$2;
+}
+$0
+endsnippet
+
+snippet setter "PHP Class Setter" b
+/**
+ * Setter for $1
+ *
+ * @param ${2:string} $$1
+ * @return void
+ */
+public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
+{
+ $this->$1 = $$1;$5
+}
+$0
+endsnippet
+
+snippet getobj "ObjectManager->get" b
+/* @var \$$2 $1 */
+\$${2:${1/.*(?:^|\\)([^\\]+)$/\l$1/}} = $this->objectManager->get(${1:\Vendor\Extension\ClassName}::class);
+endsnippet
+
+snippet inst "TYPO3 makeInstance" b
+/* @var \$${3:$2} $1 */
+\$${2:${1/.*(?:^|\\)([^\\]+)$/\l$1/}} = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(${1:\Vendor\Extension\ClassName}::class);
+endsnippet
+
+snippet dump "TYPO3 var_dump" b
+\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($1);
+endsnippet
+
+snippet dpb "debug_print_backtrace " b
+debug_print_backtrace(${1:DEBUG_BACKTRACE_IGNORE_ARGS});
+endsnippet
+
+snippet action "Extbase Controller action" b
+/**
+ * action $1
+ *
+ * @return void
+ */
+public function ${1:index}Action(${2})
+{
+ ${VISUAL}${3}
+}
+$0
+endsnippet
+
+snippet ifqbus "ifqbus" b
+if ($_SERVER['REMOTE_ADDR'] == '217.92.160.135') {
+ ${1}
+}
+endsnippet
+
+snippet exc "exc" b
+throw new \\${2}Exception("$1", `!p
+import time
+snip.rv = int(time.time())
+`);
+endsnippet
+
+snippet pl "configure TYPO3 Plugin" b
+\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+ 'Qbus.' . $_EXTKEY,
+ '${1:PluginName}',
+ [
+ '${2:ControllerName}' => '${3:list,show}',
+ ],
+ [
+ '$2' => '${4}',
+ ]
+);
+endsnippet
+
+snippet pt "Add TYPO3 plugin in ext_tables.php" b
+\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
+ $_EXTKEY,
+ '${1:PluginName}',
+ '${2:Description}'
+);
+endsnippet
+
+
+snippet gs "PHP Class Getter Setter" b
+/**
+ * Getter for $1
+ *
+ * @return ${2:string}
+ */
+public function get${1/\w+\s*/\u$0/}()
+{
+ return $this->$1;$3
+}
+
+/**
+ * Setter for $1
+ *
+ * @param $2 $$1
+ * @return ${4:`!p snip.rv=snip.basename`}
+ */
+public function set${1/\w+\s*/\u$0/}(${5:${2/(void|string|int|integer|double|float|object|boolean|bool|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
+{
+ $this->$1 = $$1;$6
+
+ ${7:return $this;}
+}
+$0
+endsnippet
diff --git a/.config/vim/UltiSnips/pug.snippets b/.config/vim/UltiSnips/pug.snippets
new file mode 100644
index 0000000..2e3adb8
--- /dev/null
+++ b/.config/vim/UltiSnips/pug.snippets
@@ -0,0 +1,26 @@
+snippet debug "Debug" b
+pre !{JSON.stringify(${1}, null, '\t')}
+endsnippet
+
+snippet dump "Debug" b
+pre !{JSON.stringify(${1}, null, '\t')}
+endsnippet
+
+snippet each "Each" b
+if ${1:objects}.length
+ each $2, i in $1
+ $3
+endsnippet
+
+snippet inc "Includes" b
+include ../includes/$1
+endsnippet
+
+snippet ex "extends" b
+extends ../layouts/${1:base}
+endsnippet
+
+snippet bl "Block" b
+block ${1:content}
+ $2
+endsnippet
diff --git a/.config/vim/UltiSnips/xml.snippets b/.config/vim/UltiSnips/xml.snippets
new file mode 100644
index 0000000..5d38646
--- /dev/null
+++ b/.config/vim/UltiSnips/xml.snippets
@@ -0,0 +1,7 @@
+snippet source "source" b
+<source>$1</source>
+endsnippet
+
+snippet target "target" b
+<target>$1</target>
+endsnippet