Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode 里面无法使用和lua相关的formatter #213

Open
kyrosle opened this issue Jul 13, 2023 · 8 comments
Open

vscode 里面无法使用和lua相关的formatter #213

kyrosle opened this issue Jul 13, 2023 · 8 comments
Labels

Comments

@kyrosle
Copy link

kyrosle commented Jul 13, 2023

Xmake 版本

2.8.1

操作系统版本和架构

fedora

描述问题

vscode 里面无法使用和lua相关的formatter, 下载了lua-formamter 也还是没用

  "[xmake]": {
    "editor.defaultFormatter": "Koihik.vscode-lua-format"
  },
  "files.associations": {
    "*.xmake": "lua"
  },

这些设置也是没用

期待的结果

即便没有配备, 希望也可以用lua-formatter 之类的工具

工程配置

普通的创建项目

附加信息和错误日志

@kyrosle kyrosle added the bug label Jul 13, 2023
@waruqi
Copy link
Member

waruqi commented Jul 13, 2023

不支持

@CodeAnxiety
Copy link

CodeAnxiety commented Sep 27, 2024

Is there an alternative solution for formatting xmake.lua files?

My current workaround is to switch the file association to Lua, do the format, then switch back to Xmake, but this isn't very user friendly and doesn't work with auto-format on save.

@waruqi
Copy link
Member

waruqi commented Sep 27, 2024

Is there an alternative solution for formatting xmake.lua files?

My current workaround is to switch the file association to Lua, do the format, then switch back to Xmake, but this isn't very user friendly and doesn't work with auto-format on save.

see https://xmake.io/#/guide/syntax_description?id=optional-scope-configuration-syntax

@CodeAnxiety
Copy link

The issue I'm having, and I assume OP had as well, is that the format functionality doesn't work for xmake.lua files when the language mode is set to xmake.

When I attempt it I get an alert saying there is no formatter available and it directs me to look on the marketplace.

Manually specifying the default formatter for [xmake] to any of the existing [lua] formatters does not work because they do not support the "xmake" language. Hence the need to shuffle back and forth to the lua language mode.

Apologies if this was unrelated to the original comment, I'm relying on Google translate.

@star-hengxing
Copy link
Contributor

The best way is to write our own formatter based on antlr4, like https:/Koihik/LuaFormatter , but I have no time to do that.

@CodeAnxiety
Copy link

CodeAnxiety commented Sep 28, 2024

The existing lua formatter plugins work well enough, the issue stems from the vscode-xmake plugin registering xmake.lua as a different language ([xmake] instead of [lua]). This prevents vscode from recognizing those lua formatters as applicable to xmake.lua files.

You have to manually change the file association to work around it.

@waruqi
Copy link
Member

waruqi commented Sep 28, 2024

We cannot set it to the Lua language. Otherwise, we cannot set the xmake icon independently, and there is no automatic completion of xmake API.

@CodeAnxiety
Copy link

I'll try forking https:/Koihik/vscode-lua-format and changing the language to [xmake]. That might be the easiest route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants