-
Notifications
You must be signed in to change notification settings - Fork 0
/
postfixes.yml
142 lines (126 loc) · 3.17 KB
/
postfixes.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# List of some scopes (just in case..):
#
# source.actionscript.2 source.dosbatch source.ini.editorconfig
# source.applescript source.dot source.jade
# source.asp source.erlang source.java
# source.c source.gdb.session source.java-props
# source.c++ source.gdbregs source.jl
# source.camlp4.ocaml source.git source.js
# source.clojure source.go source.js.rails
# source.cmake source.gradle source.json
# source.coffee source.groovy source.json.bower
# source.cs source.gruntfile.coffee source.json.npm
# source.css source.gruntfile.js source.jsx
# source.d source.gulpfile.coffee source.less
# source.diff source.gulpfile.js source.lisp
# source.disasm source.haskell source.lua
# source.dockerfile source.ini source.makefile
#
# source.matlab source.regexp
# source.nant-build source.regexp.python
# source.objc source.ruby
# source.objc++ source.ruby.rails
# source.ocaml source.rust
# source.ocamllex source.sass
# source.ocamlyacc source.scala
# source.pascal source.scss
# source.perl source.shell
# source.php source.sql
# source.procfile source.sql.ruby
# source.puppet source.stylus
# source.pyjade source.swift
# source.python source.tcl
# source.qml source.ts
# source.r source.yaml
# source.r-console
# Structure of fix
#
# {scope}[ {scope}[...]]: - one or multiple (separated by whitespace) scopes
# - cmd - trigger string
# target - regex pattern
# fix - template
# Available variables
#
# $--> - indent
# $cursor - cursor position
# $0 - whole matched string
# $X - RegEx group indexed from 1
# Some examples:
# Python
source.python:
# If
- cmd: "if"
target: ".+"
fix: |
if $0:
$-->
# If not
- cmd: "ifn"
target: ".+"
fix: |
if !$0:
$-->
# Read file
- cmd: "rf"
target: "(.+?)\\s?[=\\s]\\s?(.+)"
fix: |
with open($2) as f:
$-->$1 = f.read()
# Write file
- cmd: "wf"
target: "(.+?)\\s?[=\\s]\\s?(.+)"
fix: |
with open($1, "w") as f:
$-->f.write($2)
# Javascript, Typescript
source.js source.ts:
# If
- cmd: "if"
target: ".+"
fix: |
if ($0) {
$-->$cursor
}
# Inlined If
- cmd: "ifi"
target: ".+"
fix: |
if ($0)
# If not
- cmd: "ifn"
target: ".+"
fix: |
if (!$0) {
$-->$cursor
}
# Equality
- cmd: "eq"
target: "(.+)\\s(.+)"
fix: |
if ($1 === $2) {
$-->$cursor
}
# Function
- cmd: "fun"
target: "([a-zA-Z0-9_]+)\\s?(.*)"
fix: |
function $1($2) {
$-->$cursor
}
# Log
- cmd: "lg"
target: ".+"
fix: |
console.log($0)
# Fetch
- cmd: "fetch"
target: ".+"
fix: |
fetch($0)
$-->.then(res => {
$-->$-->$cursor
$-->})
$-->.catch(err => {
$-->$-->
$-->})
# ... and so on