Skip to content

Add formatter for lua 5.1 #167

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

Merged
merged 1 commit into from
Dec 18, 2020
Merged

Add formatter for lua 5.1 #167

merged 1 commit into from
Dec 18, 2020

Conversation

ElPiloto
Copy link
Contributor

luaformatterfiveone is a formatter for Lua 5.1. It is readily available
through standard via luarocks install formatterfiveone.

@google-cla
Copy link

google-cla bot commented Dec 13, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Dec 13, 2020
@ElPiloto
Copy link
Contributor Author

@googlebot I fixed it

@google-cla
Copy link

google-cla bot commented Dec 13, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Dec 13, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@ElPiloto
Copy link
Contributor Author

@googlebot I fixed it

@google-cla
Copy link

google-cla bot commented Dec 13, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@ElPiloto
Copy link
Contributor Author

@googlebot I fixed it

@google-cla
Copy link

google-cla bot commented Dec 13, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Copy link
Contributor

@dbarnett dbarnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the hassle of whatever was happening w/ the CLA bot there.

luaformatterfiveone is a formatter for Lua 5.1.  It is readily available
through standard via `luarocks install formatterfiveone`.
Copy link
Contributor

@dbarnett dbarnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merging now.

@mxngls
Copy link

mxngls commented Dec 11, 2022

EDIT:

I solved the issue myself. There were two apparent problems:

  1. luaformatterfiveone could not be found by vim-codefmt. Therefore we have to manually set the path of the formatter executable as described here:
:Glaive codefmt luaformatterfiveone_executable='PATH'
  1. Trying to format like this leads to another error saying that a necessary package (checks) cannot be found. We need to manually install this package ourselves with luarocks via:
luarocks install check

After completing these two steps lua files can be formatted as any other file via vim-codefmt.


Error

I followed the installation steps but when trying to format Lua code I get the following error message:

Formatter "luaformatterfiveone" is not available. Setup instructions: Install luaformatterfiveone with luarocks. (https://luarocks.org/modules/ElPiloto/formatterfiveo
ne).

The package as itself is installed as described in the linked repo:

max in ~  -> luarocks list

Rocks installed for Lua 5.1
---------------------------

formatterfiveone
   0.1.2-1 (installed) - /Users/max/.luarocks/lib/luarocks/rocks-5.1

luafilesystem
   1.6.3-2 (installed) - /Users/max/.luarocks/lib/luarocks/rocks-5.1

metalua-compiler
   0.7.3-1 (installed) - /Users/max/.luarocks/lib/luarocks/rocks-5.1

metalua-parser
   0.7.3-2 (installed) - /Users/max/.luarocks/lib/luarocks/rocks-5.1

penlight
   0.9.8-1 (installed) - /Users/max/.luarocks/lib/luarocks/rocks-5.1

Help would be much appreciated.

Thanks in advance.

@mxngls mxngls mentioned this pull request Dec 11, 2022
@dbarnett
Copy link
Contributor

Yeah, so the availability check is just checking if flag path is executable. You don't actually have to change the flag to specify the full path, the default value should work fine for most people, but if you haven't installed it to your path so that you can run luaformatterfiveone in the same terminal you started vim from, it won't show as available.

@nakulj
Copy link
Contributor

nakulj commented Jan 19, 2023

@mxngls thanks! For anyone else running into problems, two tips:

  1. If you have a different version of lua installed, tell luarocks to use 5.1 like so:
luarocks install --lua-dir=/opt/homebrew/opt/[email protected]/  formatterfiveone
  1. You want to
    luarocks install checks
    - there's a missing 's' in the original comment.

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

Successfully merging this pull request may close these issues.

4 participants