JohnnyMorganz / luau-lsp

Language Server Implementation for Luau
MIT License
239 stars 56 forks source link

Automatically expand ends #220

Open LastTalon opened 1 year ago

LastTalon commented 1 year ago

When writing code I often encounter the situation where I leave a block empty temporarily to come back to it later. This ends up looking something like this.

local function test() end

Later, when I return to add this I place my cursor and add a new line, which results in something like this.

local function test()
 end

However it would be much more convenient (and expected) for this to autoexpand to something like this.

local function test()

end

This would give it similar behavior to table expansion, like the following.

local t = {}

When using the same workflow currently becomes this.

local t = {

}
JohnnyMorganz commented 1 year ago

I think this is something that needs to be set in the language-configuration.json or syntax file, although I'm not yet sure how to do this.

I notice that it also looks like sumneko's Lua also doesn't do this, so maybe it's unknown if it's even possible

LastTalon commented 1 year ago

I notice that it also looks like sumneko's Lua also doesn't do this, so maybe it's unknown if it's even possible

This extension does this for me. Perhaps its a setting I have set with it?

JohnnyMorganz commented 1 year ago

https://user-images.githubusercontent.com/19635171/200691849-b4c0b9de-9bc9-43dc-9a9c-f74c69ebb73c.mp4

It did not work for me, would be interesting to know if yours is different

LastTalon commented 1 year ago

For me that extension operates exactly as described. I checked the settings I use and don't see any that would affect this behavior.

I've tested it while disabling all other extensions as well with the same behavior. And for completeness, Roblox LSP, based on the Lua LSP, also has this behavior.

LastTalon commented 1 year ago

Let me know if you still need help getting this behavior from other lsps. We can talk in real time if that helps.

JohnnyMorganz commented 1 year ago

I was still unable to reproduce this with the stock Lua grammar in VSCode or the sumneko extension. Can you screen capture the example behaviour you are looking for?

LastTalon commented 1 year ago

Here's a short clip of the behavior I get when using sumneko's extension. I looked and don't see any particular setting for it, so I believe it should be active all the time with that extension.

https://user-images.githubusercontent.com/2075484/211166240-e2325865-f65b-4bc2-b14b-84b4335b4387.mp4

LastTalon commented 1 year ago

I'm not using any Lua LSPs actively at the moment, so my ability to test/encounter these behaviors is going to be slow until I'm actively using them again.