Skip to content

function snippet seems broken by PR #3005 in non released latest master (after v3.13.5) #3021

Closed
@tomlau10

Description

@tomlau10

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

MacOS

What is the issue affecting?

Completion

Expected Behaviour

local t = {}

table.sort(t, |) -- trigger completion at `|` will show `fun(a: <T>, b: <T>):boolean`
-- and choosing it should complete as

table.sort(t, function (a, b)
    
end)

Actual Behaviour

but now it becomes something like this

local t = {}

table.sort(t, function (${1:a}, ${2:b})
    $0
end)

Reproduction steps

local t = {}

table.sort(t, |) -- trigger completion at `|` and choose the first provided function snippet

Additional Notes

I just checked out latest master (cb964c6 as of the time being) and found this issue.
After doing git bisect, it points to the following commit which is #3005 by @andrewbraxton

a3dd298664a55be46a2603642559eb91656ba18e is the first bad commit
commit a3dd298664a55be46a2603642559eb91656ba18e
Author: Andrew Braxton <andrewcbraxton@gmail.com>
Date:   Tue Dec 24 22:21:01 2024 -0500

    Send the correct `insertTextFormat`
    
    Per LSP specification, `insertTextFormat` should be `2` for snippets and
    `1` for plain text. Using `2` unconditionally can make clients behave in
    unexpected ways.
    
    The code calling into `provider.lua` sets `insertTextFormat` to 2 for
    all snippets and leaves it nil for other types, so we can reuse that
    information in `provider.lua` to make sure we send the correct value.

 script/provider/provider.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Maybe the change works for neovim, but it's definitely broken for doc.type.function snippet in vscode 😕
(for others snippet like repeat .. until it works normally)

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions