summaryrefslogtreecommitdiff
path: root/luasnip_snippets/lua.json
blob: 86f95e3100bc420bbc7b965e5272b98a530c2cb8 (plain)
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
{
  "#!": {
    "prefix": "#!",
    "description": "#!/usr/bin/env lua",
    "body": [
      "#!/usr/bin/env lua",
      "$0"
    ],
    "luasnip": {
      "priority": -50
    }
  },
  "forp": {
    "prefix": "forp",
    "description": "pair for loop",
    "body": [
      "for ${1:name},${2:val} in pairs(${3:table_name}) do",
      "\t$0",
      "end"
    ]
  },
  "fori": {
    "prefix": "fori",
    "description": "ipair for foop",
    "body": [
      "for ${1:idx},${2:val} in ipairs(${3:table_name}) do",
      "\t$0",
      "end"
    ]
  },
  "do": {
    "prefix": "do",
    "description": "do block",
    "body": [
      "do",
      "\t$0",
      "end"
    ]
  },
  "repeat": {
    "prefix": "repeat",
    "description": "repeat loop",
    "body": [
      "repeat",
      "\t$1",
      "until $0"
    ]
  },
  "while": {
    "prefix": "while",
    "description": "while loop",
    "body": [
      "while $1 do",
      "\t$0",
      "end"
    ]
  },
  "if": {
    "prefix": "if",
    "description": "if statement",
    "body": [
      "if $1 then",
      "\t$0",
      "end"
    ]
  },
  "ife": {
    "prefix": "ife",
    "description": "if/else statement",
    "body": [
      "if $1 then",
      "\t$2",
      "else",
      "\t$0",
      "end"
    ]
  },
  "eif": {
    "prefix": "eif",
    "description": "if/elseif statement",
    "body": [
      "if $1 then",
      "\t$2",
      "elseif $3 then",
      "\t$0",
      "end"
    ]
  },
  "eife": {
    "prefix": "eife",
    "description": "if/elseif/else statement",
    "body": [
      "if $1 then",
      "\t$2",
      "elseif $3 then",
      "\t$4",
      "else",
      "\t$0",
      "end"
    ]
  },
  "pcall": {
    "prefix": "pcall",
    "description": "pcall statement",
    "body": [
      "local ok, err = pcall(${1:your_function})",
      "if not ok then",
      "\thandler(${2:ok, err})",
      "${3:else",
      "\tsuccess(${4:ok, err})",
      "}end"
    ]
  },
  "local": {
    "prefix": "local",
    "description": "local x = 1",
    "body": "local ${1:x} = ${0:1}"
  },
  "use": {
    "prefix": "use",
    "description": "Use",
    "body": "use { '$1' \\}"
  },
  "req": {
    "prefix": "req",
    "description": "Require",
    "body": "require('$1')"
  }
}