LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.29k stars 305 forks source link

Add postfix snippet for `unpack` #2719

Closed ofseed closed 3 months ago

ofseed commented 3 months ago

Sometimes we are not sure whether functions return a tuple or a table, assuming we need to get a position containing row and col, wrote:

local position = get_position()

Then we found position here is an integer, not a table (by inlay hint or diagnostic info), which means get position returns a tuple. In this situation, a postfix snippet will be useful because our cursor is at the end of the line. By simply typing @unpack we can turn it into a tuple.

local position = unpack(get_position())

That's why I think this snippet is useful.

sumneko commented 3 months ago

Thank you!