Koihik / vscode-lua-format

Reformats your Lua source code
Apache License 2.0
56 stars 13 forks source link

config path does not work #40

Closed shu307 closed 3 years ago

shu307 commented 3 years ago

vscode 1.61.0 x64 Windows 10 x64 21H1 19043.1237 I set the configuration path to "C:\Users\username\.vscode\lua-format.config". There is no change in the document and no error message after clicking "Format Document" or using the shortcut key. It works normally when the path is configured incorrectly (with an error message) or the path is not configured

shu307 commented 3 years ago

few suggestions: allow simple struct to stay in one line t = {a= 1, b=1} allow to chop down arguments of a function call if there is a line break.

fun (
    aaaaaaaaaaaaaaa,
    bbbbbbbbbbbbb,
    cccccccccccccccc,
    ddddddddddddd
)
InappropriatePenguin commented 3 years ago

@shu307, I was just experiencing the same issue. It seems like the extension code uses this function to check if the path is absolute and if this function returns false for the path you gave, the extension searches your workspace directory instead.

In your case, I think using double backslashes would fix it: C:\\Users\\username\\.vscode\\lua-format.config

shu307 commented 3 years ago

@shu307, I was just experiencing the same issue. It seems like the extension code uses this function to check if the path is absolute and if this function returns false for the path you gave, the extension searches your workspace directory instead.

In your case, I think using double backslashes would fix it: C:\\Users\\username\\.vscode\\lua-format.config

Thanks for your suggestions, but I don't think it's a path issue. Because there is no error message, it means that the file can be found but it cannot be read correctly for some unknown reasons. When you configure the Config Path option to "C:\..\..", the "\" before "\" will be automatically added, so actually in the file "settings.json" , it is "C:\\..\\.." . Using "/" doesn't work either. If you still have this issue and did not give up on LuaFormatter, I've found another extension lua helper which is also based on LuaFormatter. There is a configurable file whose path is ".vscode\extensions\yinfei.luahelper-xxx\server\luafmt.config". And, it works.

------edited-------

I've figured it out. Because my configuration file was copied from here, maybe some deprecated keys caused this error.

InappropriatePenguin commented 3 years ago

@shu307 thank you for the update :)

My issue was on macOS and for me, I believe it was because I was using ~/path/to/file.cfg. Unlike you, I was getting an error that it couldn't find the specified file. In my case, I managed to fix it by providing an absolute path that starts with /.