lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Adding global definitions always indents with 4 spaces

Open Stanzilla opened this issue 2 years ago • 4 comments

Which OS are you using?

Windows

Expected Behaviour

When I use the VSCode function to define a variable as allowed global, it should re-use the formatting of the existing file (luarc.json) when adding it.

Actual Behaviour

It always uses 4 spaces, instead of the 2 the file uses.

Reproduction steps

  1. Have a global in your file
  2. Have a .luarc.json file in your project
  3. Have the LSP complain about it being global
  4. Use the VSC action to mark it as defined

Additional Notes

image image

Log

No response

Stanzilla avatar May 18 '23 21:05 Stanzilla

I have the same issue: the extension always indents 4 spaces instead of 2 although all settings are set to use 2 spaces. I already disabled the Lua.diagnostics.globals in settings to map the behavior to your description, but without any luck. Still it indents 4 spaces.

kassi avatar Jun 18 '23 13:06 kassi

One extension that handles this well AND sorts the entries that get added A-Z is https://github.com/streetsidesoftware/vscode-spell-checker/

Stanzilla avatar Jun 18 '23 13:06 Stanzilla

I also have the same issue :(

SHiLLySiT avatar Aug 03 '23 17:08 SHiLLySiT

Same issue. This has been extremely frustrating for me and I finally tracked it down to the extension I least wanted to be causing it.

edit: perhaps my issue is slightly different. I use tab indents and if I have, say, 3 lines of indented code, then I put my cursor at the end of the middle line and press enter, it converts the middle line to 4 a space indentation. It happens for me without any regard to globals.

JJSax avatar Apr 11 '24 03:04 JJSax