-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.lua
More file actions
299 lines (279 loc) Β· 6.22 KB
/
progress.lua
File metadata and controls
299 lines (279 loc) Β· 6.22 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
---@diagnostic disable: unused-local
-- REQUIRED {{{
local ls = require("luasnip")
local s = ls.s --> snippet
local i = ls.i --> insert node
local t = ls.t --> text node
local d = ls.dynamic_node
local c = ls.choice_node
local f = ls.function_node
local sn = ls.snippet_node
local rep = require("luasnip.extras").rep
local fmta = require("luasnip.extras.fmt").fmta
local snippets, autosnippets = {}, {}
-- }}}
-- OTHER STUFFS {{{
local lock_type = {
"no-lock",
"",
"exclusive-lock"
}
local def_types = {
"variable",
"frame",
"query",
"buffer",
"stream",
"input parameter",
"output parameter",
"temp-table"
}
local data_types = {
"character",
"decimal",
"integer",
"handle",
"date",
"logical",
"void"
}
local access_type = {
"public",
"private",
"protected"
}
local input_types = {
"input",
"output",
"input-output",
}
-- Returns table containing insert node with provided options
local get_options = function(arg)
local x = {}
for key, value in pairs(arg) do
table.insert(x, i(1, arg[key]))
end
return x
end
-- Finds the passed argument in the current buffer
local find = function(arg)
local found = false
local count = vim.api.nvim_buf_line_count(0)
for line = 1, count, 1 do
if string.find(vim.api.nvim_buf_get_lines(0,0,-1,false)[line], arg) then
found = true
break
else
found = false
end
end
return found
end
-- }}}
-- DEFINITION SNIPPET {{{
local def_fmt = fmta(
[[
define <var_type> <var_name> <data_type> no-undo.
]],
{
var_type = c(1, get_options(def_types)),
var_name = d(2, function(_, snip)
return sn(1, i(1,snip.env.TM_SELECTED_TEXT[1] or {"<++>"}))
end),
data_type = c(3, {
i(1, "as character"),
i(1, "as integer"),
i(1, "as decimal"),
i(1, "as date"),
i(1, "as logical"),
i(1, "like"),
i(1, "for"),
}),
}
)
local def_snippet = s("define", def_fmt)
table.insert(snippets, def_snippet)
-- }}}
-- MESSAGE SNIPPET {{{
local msg_fmt = fmta(
[[
{{ us/bbi/pxmsg.i <mesg_type>=<mesg> &errorlevel=<error_level> }}
]],
{
mesg_type = c(1, {
i(1, "&msgnum"),
i(1, "&msgtext"),
}
),
mesg = i(2, "<++>"),
error_level = i(3, "<++>"),
}
)
local msg_snippet = s("pxmsg", msg_fmt)
table.insert(snippets, msg_snippet)
-- }}}
-- FIND SNIPPET {{{
local find_fmt = fmta(
[[
find <no> <table_name> <lock>
where <table_field> <condition> no-error.
if available <table_name1> then do:
end. /* if available <table_name2> then do: */
]],
{
no = c(1, {
i(1, "first"),
i(1, "last"),
i(1, "next"),
i(1, "prev")
}),
table_name = d(2, function(_, snip)
return sn(1, i(1,snip.env.TM_SELECTED_TEXT[1] or {"<++>"}))
end),
table_field = i(3, "<++>"),
condition = d(4, function()
if find("mfdeclre.i") or find("mfdtitle.i") then
return sn(1, i(1,"= global_domain "))
else
return sn(1, i(1,"= <++>"))
end
end),
lock = c(5, get_options(lock_type)),
table_name1 = rep(2),
table_name2 = rep(2),
}
)
local find_snippet = s(
{trig = "find", regTrig = false, hidden = false},
find_fmt
)
table.insert(snippets, find_snippet)
-- }}}
-- FOR SNIPPET {{{
local for_fmt = fmta(
[[
for <no> <table_name> <lock>
where <table_field> <condition>:
<code>
end. /* for <no1> <table_name1> <lock1> */
]],
{
no = c(1, {
i(1, "each"),
i(1, "first"),
i(1, "last"),
i(1, "next"),
i(1, "prev")
}),
table_name = d(2, function(_, snip)
return sn(1, i(1,snip.env.TM_SELECTED_TEXT[1] or {"<++>"}))
end),
lock = c(3, get_options(lock_type)),
table_field = i(4, "<++>"),
condition = d(5, function()
if find("mfdeclre.i") or find("mfdtitle.i") then
return sn(1, i(1,"= global_domain"))
else
return sn(1, i(1,""))
end
end),
code = i(6, "/* Add Logic */"),
no1 = rep(1),
table_name1 = rep(2),
lock1 = rep(3),
}
)
local for_snippet = s(
{trig = "for", regTrig = false, hidden = false},
for_fmt
)
table.insert(snippets, for_snippet)
-- }}}
-- METHOD SNIPPET {{{
-- local method_fmt =
-- }}}
-- FUNCTION SNIPPET {{{
local function_fmt = fmta(
[[
function <func_name> returns <return_type>
(input <args>):
define variable <var_name> as <data_type>.
<code>
return <var_name1>.
end function. /* function <func_name1> returns <return_type1> */
]],
{
func_name = d(1, function(_, snip)
return sn(1, i(1,snip.env.TM_SELECTED_TEXT[1] or {"<++>"}))
end),
return_type = c(2,get_options(data_types)),
args = i(3, "<++>"),
var_name = i(4, "<++>"),
data_type = rep(2),
code = i(5, "/* Add Logic */"),
var_name1 = rep(4),
func_name1 = rep(1),
return_type1 = rep(2),
}
)
local function_snippet = s(
{trig = "func", regTrig = false, hidden = false},
-- "function",
function_fmt
)
table.insert(snippets, function_snippet)
-- }}}
-- QUERY SNIPPET {{{
local query_fmt = fmta(
[[
create query <query_name>.
<query_buffers>:set-buffers(<buffers>).
<query_prepare>:query-prepare("<query_logic>").
<query_open>:query-open().
do while <query_next>:get-next():
end. /*do while <query_next1>:get-next():*/
<query_close>:query-close().
]],
{
query_name = d(1, function(_, snip)
return sn(1, i(1,snip.env.TM_SELECTED_TEXT[1] or {"<++>"}))
end),
query_buffers = rep(1),
buffers = i(3,"<++>"),
query_prepare = rep(1),
query_logic = i(5,"<++>"),
query_open = rep(1),
query_next = rep(1),
query_next1 = rep(1),
query_close = rep(1),
}
)
local query_snippet = s(
{trig = "build-query", regTrig = false, hidden = false},
query_fmt
)
table.insert(snippets, query_snippet)
-- }}}
local fDatasetWrite = fmta(
[[
dataset <dataset_name>:write-xml(
"file", /* Target Type */
"<filename>", /* File Name */
true, /* Formatted */
?, /* Encoding */
?, /* Scheme Location */
false, /* Write Scheme */
false /* Min Scheme */
).
]],
{
dataset_name = i(1,"<++>"),
filename = i(2,"<++>")
}
)
local sDatasetWrite = s(
{trig = "dataset-write-xml", regTrig = false, hidden = false},
fDatasetWrite
)
table.insert(snippets, sDatasetWrite)
return snippets, autosnippets