LuaLS / LuaLS/lua-language-server

Adding global definitions always indents with 4 spaces

Open
#2,146 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the VSCode action that adds an allowed global to .luarc.json, then inspect how the existing file's indentation is read or preserved. Reproduce the issue with a file using two-space indentation and confirm that marking a global as defined keeps that formatting rather than inserting four spaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.