version-fox / vfox-plugin-template

📦 vfox plugin template with GitHub Actions and more!
https://vfox.lhan.me
Apache License 2.0
6 stars 2 forks source link

Setup lua linter and formatter #2

Open bytemain opened 6 months ago

bytemain commented 6 months ago

unified code style can reduce the cost of maintaining and reviewing code, and can find potential risks

aooohan commented 6 months ago

unified code style can reduce the cost of maintaining and reviewing code, and can find potential risks

Agree! But how do we do that?

bytemain commented 6 months ago

just a idea, we ship a new binary called vfox-dev(or what ever).

vfox-dev lint
vfox-dev build

https://github.com/CppCXY/EmmyLuaCodeStyle

there are some code styles linters, but most of them need user clone them and build them on machine.

bytemain commented 6 months ago

or we can use dprint, it is a pluggable and configurable code formatting platform written in rust.

https://dprint.dev/

it has a lua plugin: https://github.com/RubixDev/dprint-plugin-stylua

bytemain commented 6 months ago

CleanShot 2024-03-06 at 20 47 34@2x

I found that it support install by asdf, ahahahah

aooohan commented 6 months ago

I found that it support install by asdf, ahahahah

If we decide to use this, we can also implement a plug-in of our own. After taking a look, it is very easy. 😄

aooohan commented 6 months ago

just a idea, we ship a new binary called vfox-dev(or what ever).

I don't think we need to spend too much time on this, dprint is a good choice.

bytemain commented 6 months ago

ok, I will take a look on install dprint by vfox

axdank commented 6 months ago

we can also use stylua

and add its configuration to the root of the project: stylua.toml

column_width = 120
line_endings = "Unix"
indent_type = "Tabs"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "Never"

[sort_requires]
enabled = false
bytemain commented 6 months ago

yes, the dprint plugin we mentioned above in using stylua to format lua files. and dprint can also format markdown and json files.

aooohan commented 5 months ago

@bytemain @axdank Hi guys, I think I've finished working on the templates for the plugin repository, and I think this issue can be resolved in the template repository.

For example, we could put dprint in the plugin repository, tell the user how to use it, or automate do this work by Github Action.