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
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](https://github.com/LuaLS/vscode-lua/assets/75278/8176629b-2cd0-4b86-9b33-aadbbeb42d12)
![image](https://github.com/LuaLS/vscode-lua/assets/75278/d13c780a-b858-4f00-a16a-92c9b9ca5268)

### Log

_No response_

Contributor guide

Open the contributing guide

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.