CppCXY / EmmyLuaCodeStyle

fast, powerful, and feature-rich Lua formatting and checking tool.
MIT License
140 stars 27 forks source link

editorconfig file fully cancels Lua.format.defaultConfig #63

Closed ltWolfik closed 1 year ago

ltWolfik commented 2 years ago

I've noticed, that Lua.format.defaultConfig setting works fine if .editorconfig absents, but if .editorconfig exists in project - Lua.format.defaultConfig does nothing. It seems be better if Lua.format.defaultConfig would be merged with .editorconfig (with priority for .editorconfig). For example, if .editorconfig does not have keep_one_space_between_table_and_bracket option - then use the same one from Lua.format.defaultConfig (if present).

I use the formatter through sumneko LSP in vscode. Thanks a lot.

tomasklaen commented 2 years ago

A little off topic, but there's no discussions and I don't want to make a new issue for this.

How do you set up defaultConfig? I added this to vscode's User/settings.json:

"Lua.format.defaultConfig": {
    "indent_style": "tab",
    "tab_width": "4"
}

And it had no effect.

ltWolfik commented 2 years ago

@tomasklaen, maybe conflict with native vscode settings? Like the following:

"[lua]": {
    "editor.insertSpaces": false,
    "editor.tabSize": 4
},
tomasklaen commented 2 years ago

This is everything inside my [lua] property:

"[lua]": {
    "editor.defaultFormatter": "CppCXY.emmylua-codestyle"
}
CppCXY commented 2 years ago

Lua.format.defaultConfig only valid for sumneko lua plugin. in sumneko, the language server protocol should be respected, so indentation use the parameters of the LSP

CppCXY commented 2 years ago

see https://github.com/CppCXY/EmmyLuaCodeStyle/issues/22 You may need to use translater

tomasklaen commented 2 years ago

I am using sumneko's lua plugin, but I'm using EmmyLuaCodeStyle to format the code because sumneko's formatter ignores some editorconfig properties.

Is there no way to make these 2 work together?

I've tried adding this to Lua.format.defaultConfig:

"insertSpaces": "false",
"tabSize": "4",

And this to [lua]:

"editor.insertSpaces": false,
"editor.tabSize": 4

And again, no effect. Can someone just give me a snippet or some example/documentation somewhere how to configure the default formatting options? 😢

CppCXY commented 2 years ago

sumneko formatter is my formatter. but my plugin not support Lua.format.defaultConfig or editor settings. it only read .editorconfig plugin. You can set the formatter to sumneko lua because that's what I provide

tomasklaen commented 2 years ago

@CppCXY I'm using this one instead of sumneko's on your own recomendation :) So the linked issue has been resolved, and sumneko now reads indentation style from editorconfig instead of user settings?

CppCXY commented 2 years ago

no, for sumneko, Indentation comes from editor settings, you can set editor setting for indentation

CppCXY commented 2 years ago

Sumnkeo has already been updated to the latest version, so the functionality is consistent