New line triggered replace tab indent to spaces
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Formatting
Expected Behaviour
do nothing
Actual Behaviour
tab indent replaced to spaces
Reproduction steps
add new line
Additional Notes
configuration has no effect
"Lua.format.enable": false,
"Lua.format.defaultConfig": {
"indent_style": "tab"
},
Log File
No response
This feature is format on type, which is based on what vscode thinks is the indentation of the current file.
yeap, Lua.typeFormat.config.format_line: "false"
disables this, thank
Nevertheless Select indentation has no effect
also, looks like need a Lua.typeFormat.enable option
this is vscode basic config
But what if I don’t want to disable this for another lua formatter?
No other lua plugin supports type format.
emmyluacodestyle is lua's only fully functional formatter with vscode support.
hm, i use stylua or what you mean by 'fully functional'?
hm, i use stylua or what you mean by 'fully functional'?
It's good to use stylua, so my explanation doesn't matter.
See this also on emacs using lsp-mode. Looking at the trace from the logs emacs is sending the following options in the textdocument/onTypeFormatting message:
"options": {
"tabSize": 2,
"insertSpaces": false,
"trimTrailingWhitespace": true,
"insertFinalNewline": true,
"trimFinalNewlines": true
},
These options get ignored and the server always responds by reformatting one or more proceeding lines using an indent level of 4 characters and indenting with spaces despite me having the following settings in my .editorconfig
[*.lua]
indent_size = 2
indent_style = tab
tab_width = 2
insert_final_newline = true
end_of_line = lf
trim_trailing_whitespace = true
max_line_length = 120
Heres an example full message (with the filename elided)
"textDocument/onTypeFormatting": {
"uri": "<removed>"
},
"options": {
"tabSize": 2,
"insertSpaces": false,
"trimTrailingWhitespace": true,
"insertFinalNewline": true,
"trimFinalNewlines": true
},
"ch": "\n",
"position": {
"line": 1336,
"character": 0
}
}
I'm not 100% sure if this is always the case but this problem manifests most noticably when the lines being reformatted are actually already correctly indented. In other cases I think the server returns the correct formatting adjustment.