summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/keyword.lua26
2 files changed, 23 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md
index 6ad9d8e4..aac275e2 100644
--- a/changelog.md
+++ b/changelog.md
@@ -6,6 +6,7 @@
* `CHG` supports `~` in command line
* `CHG` completion: improve workspace words
* `CHG` completion: show words in string
+* `CHG` completion: split `for .. in` to `for .. ipairs` and `for ..pairs`
* `FIX` [#339](https://github.com/sumneko/lua-language-server/issues/339)
## 1.9.0
diff --git a/script/core/keyword.lua b/script/core/keyword.lua
index 08600868..3a6c050c 100644
--- a/script/core/keyword.lua
+++ b/script/core/keyword.lua
@@ -61,11 +61,20 @@ end",
{'for', function (hasSpace, isExp, results)
if hasSpace then
results[#results+1] = {
- label = 'for .. in',
+ label = 'for .. ipairs',
kind = define.CompletionItemKind.Snippet,
insertTextFormat = 2,
insertText = "\z
-${1:key, value} in ${2:pairs(${3:t})} do\
+${1:index}, ${2:value} in ipairs(${3:t}) do\
+\t$0\
+end"
+ }
+ results[#results+1] = {
+ label = 'for .. pairs',
+ kind = define.CompletionItemKind.Snippet,
+ insertTextFormat = 2,
+ insertText = "\z
+${1:key}, ${2:value} in pairs(${3:t})}do\
\t$0\
end"
}
@@ -80,11 +89,20 @@ end"
}
else
results[#results+1] = {
- label = 'for .. in',
+ label = 'for .. ipairs',
+ kind = define.CompletionItemKind.Snippet,
+ insertTextFormat = 2,
+ insertText = "\z
+for ${1:index}, ${2:value} in ipairs(${3:t}) do\
+\t$0\
+end"
+ }
+ results[#results+1] = {
+ label = 'for .. pairs',
kind = define.CompletionItemKind.Snippet,
insertTextFormat = 2,
insertText = "\z
-for ${1:key, value} in ${2:pairs(${3:t})} do\
+for ${1:key}, ${2:value} in pairs(${3:t}) do\
\t$0\
end"
}