summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/completion/completion.lua25
-rw-r--r--test/completion/common.lua54
3 files changed, 13 insertions, 67 deletions
diff --git a/changelog.md b/changelog.md
index b27a26fe..14cf621e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
## 3.5.0
* `CHG` `---@diagnostic disable: <ERR_NAME>` can suppress syntax errors
+* `CHG` `completion.callSnippet` no longer generate parameter types
* `FIX` [#1278](https://github.com/sumneko/lua-language-server/issues/1278)
## 3.4.1
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index a8895f72..69488e36 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -160,32 +160,19 @@ local function buildFunctionSnip(source, value, oop)
if oop then
table.remove(args, 1)
end
- local len = #args
- local truncated = false
- if len > 0 and args[len]:match('^%s*%.%.%.:') then
- table.remove(args)
- truncated = true
- end
- for i = #args, 1, -1 do
- if args[i]:match('^%s*[^?]+%?:')
- or args[i]:match('^%.%.%.') then
- table.remove(args)
- truncated = true
- else
- break
- end
- end
local snipArgs = {}
for id, arg in ipairs(args) do
- local str = arg:gsub('^(%s*)(.+)', function (sp, word)
+ local str, count = arg:gsub('^(%s*)(%.%.%.)(.+)', function (sp, word)
return ('%s${%d:%s}'):format(sp, id, word)
end)
+ if count == 0 then
+ str = arg:gsub('^(%s*)([^:]+)(.+)', function (sp, word)
+ return ('%s${%d:%s}'):format(sp, id, word)
+ end)
+ end
table.insert(snipArgs, str)
end
- if truncated and #snipArgs == 0 then
- snipArgs = {'$1'}
- end
return ('%s(%s)'):format(name, table.concat(snipArgs, ', '))
end
diff --git a/test/completion/common.lua b/test/completion/common.lua
index fe09dea2..81368e6e 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -934,7 +934,7 @@ mt:f<??>
{
label = 'f(a, b, c)',
kind = define.CompletionItemKind.Snippet,
- insertText = 'f(${1:a: any}, ${2:b: any}, ${3:c: any})',
+ insertText = 'f(${1:a}, ${2:b}, ${3:c})',
},
}
@@ -2688,7 +2688,7 @@ zzzz<??>
{
label = 'zzzz(a)',
kind = define.CompletionItemKind.Snippet,
- insertText = 'zzzz(${1:a: any})',
+ insertText = 'zzzz(${1:a})',
},
{
label = 'zzzz(a, b)',
@@ -2698,7 +2698,7 @@ zzzz<??>
{
label = 'zzzz(a, b)',
kind = define.CompletionItemKind.Snippet,
- insertText = 'zzzz(${1:a: any}, ${2:b: any})',
+ insertText = 'zzzz(${1:a}, ${2:b})',
},
}
@@ -2719,28 +2719,7 @@ foo<??>
{
label = 'foo(a, b, c, ...)',
kind = define.CompletionItemKind.Snippet,
- insertText = 'foo(${1:a: any})',
- },
-}
-
-TEST [[
----@param a any
----@param b? any
----@param c? any
----@vararg any
-local function foo(a, b, c, ...) end
-foo<??>
-]]
-{
- {
- label = 'foo(a, b, c, ...)',
- kind = define.CompletionItemKind.Function,
- insertText = 'foo',
- },
- {
- label = 'foo(a, b, c, ...)',
- kind = define.CompletionItemKind.Snippet,
- insertText = 'foo(${1:a: any})',
+ insertText = 'foo(${1:a}, ${2:b?}, ${3:c?}, ${4:...})',
},
}
@@ -2761,28 +2740,7 @@ foo<??>
{
label = 'foo(a, b, c, ...)',
kind = define.CompletionItemKind.Snippet,
- insertText = 'foo($1)',
- },
-}
-
-TEST [[
----@param a? any
----@param b any
----@param c? any
----@vararg any
-local function foo(a, b, c, ...) end
-foo<??>
-]]
-{
- {
- label = 'foo(a, b, c, ...)',
- kind = define.CompletionItemKind.Function,
- insertText = 'foo',
- },
- {
- label = 'foo(a, b, c, ...)',
- kind = define.CompletionItemKind.Snippet,
- insertText = 'foo(${1:a?: any}, ${2:b: any})',
+ insertText = 'foo(${1:a?}, ${2:b?}, ${3:c?}, ${4:...})',
},
}
@@ -2800,7 +2758,7 @@ foo<??>
{
label = 'foo(f)',
kind = define.CompletionItemKind.Snippet,
- insertText = 'foo(${1:f: fun(a: any, b: any)})',
+ insertText = 'foo(${1:f})',
},
}
Cared['insertText'] = false