{"id":13682514,"url":"https://github.com/prettier/plugin-lua","last_synced_at":"2025-07-20T14:04:14.566Z","repository":{"id":31483151,"uuid":"128013462","full_name":"prettier/plugin-lua","owner":"prettier","description":"Prettier Lua Plugin (WIP)","archived":false,"fork":false,"pushed_at":"2024-02-11T05:54:46.000Z","size":415,"stargazers_count":82,"open_issues_count":14,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-08T05:01:14.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prettier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"prettier","open_collective":"prettier","tidelift":"npm/prettier"}},"created_at":"2018-04-04T05:50:46.000Z","updated_at":"2025-06-11T07:12:47.000Z","dependencies_parsed_at":"2023-09-24T05:10:53.328Z","dependency_job_id":"82774e8e-f3d2-4db5-a6cf-3ea8c0ea4d02","html_url":"https://github.com/prettier/plugin-lua","commit_stats":{"total_commits":64,"total_committers":10,"mean_commits":6.4,"dds":0.453125,"last_synced_commit":"b3e11b2e53355d59f9c58f96049bc33c1a074387"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/prettier/plugin-lua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prettier","download_url":"https://codeload.github.com/prettier/plugin-lua/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-lua/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135685,"owners_count":23881803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:01:47.350Z","updated_at":"2025-07-20T14:04:14.478Z","avatar_url":"https://github.com/prettier.png","language":"Lua","funding_links":["https://github.com/sponsors/prettier","https://opencollective.com/prettier","https://tidelift.com/funding/github/npm/prettier"],"categories":["Lua"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    🚧 \u0026nbsp;Not Actively Maintained\u0026nbsp;🚧\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"Prettier\"\n  src=\"https://raw.githubusercontent.com/prettier/prettier-logo/master/images/prettier-icon-light.png\"\u003e\n\u003cimg alt=\"Lua\" height=\"180\" hspace=\"25\" vspace=\"15\"\n  src=\"https://commons.wikimedia.org/wiki/Special:Redirect/file/Lua-logo-nolabel.svg\"\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003ePrettier Lua Plugin\u003c/h2\u003e\n\n## Unfinished\n\nPlease note that this plugin is currently unfinished. We don't recommend it for production use.\n\n## Intro\n\nPrettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.\n\nThis plugin adds support for the Lua language to Prettier.\n\n### Input\n\n```lua\nfunction deepcopy(orig)\n  local orig_type = type(orig)\n     local copy\n\n  if orig_type == 'table' then; copy = {}\n  for orig_key, orig_value in next, orig, nil do\n  copy[deepcopy(orig_key)] = deepcopy(orig_value)\n          end\n          setmetatable(\n            copy,\n            deepcopy(\n              getmetatable(orig)))\n      else\n          copy = orig\n      end\n    return copy\n  end\n```\n\n### Output\n\n```lua\nfunction deepcopy(orig)\n\tlocal orig_type = type(orig)\n\tlocal copy\n\n\tif orig_type == \"table\" then\n\t\tcopy = {}\n\t\tfor orig_key, orig_value in next, orig, nil do\n\t\t\tcopy[deepcopy(orig_key)] = deepcopy(orig_value)\n\t\tend\n\t\tsetmetatable(copy, deepcopy(getmetatable(orig)))\n\telse\n\t\tcopy = orig\n\tend\n\treturn copy\nend\n```\n\n## Install\n\nyarn:\n\n```bash\nyarn add --dev prettier @prettier/plugin-lua\n# or globally\nyarn global add prettier @prettier/plugin-lua\n```\n\nnpm:\n\n```bash\nnpm install --save-dev prettier @prettier/plugin-lua\n# or globally\nnpm install --global prettier @prettier/plugin-lua\n```\n\n## Use\n\nIf you installed prettier as a local dependency, you can add prettier as a script in your `package.json`,\n\n```json\n\"scripts\": {\n  \"prettier\": \"prettier\"\n}\n```\n\nalso add it as a plugin to your [prettierrc](https://prettier.io/docs/en/configuration.html),\n\n```json\n\"plugins\": [\n  \"@prettier/plugin-lua\"\n]\n```\n\nand then run it via\n\n```bash\nyarn run prettier path/to/file.lua --write\n# or\nnpm run prettier -- path/to/file.lua --write\n```\n\nIf you installed globally, run\n\n```bash\nprettier path/to/file.lua --write\n```\n\n## Editor integration\n\nIntegration in the prettier plugin for your favorite editor might not be working yet, see the related issues for [VS Code](https://github.com/prettier/prettier-vscode/issues/395), [Atom](https://github.com/prettier/prettier-atom/issues/395) and [Vim](https://github.com/prettier/vim-prettier/issues/119).\n\nFor the moment, you can set up prettier to run on save like this:\n\n### Atom\n\nInstall [save-autorun](https://atom.io/packages/save-autorun) and create a `.save.cson` file in your project with the following content:\n\n```cson\n\"**/*.lua\": \"prettier ${path} --write\"\n```\n\n### VScode\n\nInstall [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) and add the following section to your settings:\n\n```json\n\"emeraldwalk.runonsave\": {\n  \"commands\": [\n    {\n      \"match\": \"\\\\.lua$\",\n        \"cmd\": \"prettier ${file} --write\"\n    }\n  ]\n}\n```\n\n### Vim\n\nAdding the following to `.vimrc` will define a custom command `:PrettierLua` that runs the plugin while preserving the cursor position and run it on save.\n\n```vim\n\" Prettier for Lua\nfunction PrettierLuaCursor()\n  let save_pos = getpos(\".\")\n  %! prettier --stdin --parser=lua\n  call setpos('.', save_pos)\nendfunction\n\" define custom command\ncommand PrettierLua call PrettierLuaCursor()\n\" format on save\nautocmd BufwritePre *.lua PrettierLua\n```\n\n### Sublime Text\n\nInstall [JsPrettier](https://packagecontrol.io/packages/JsPrettier) using [Package Control](https://packagecontrol.io/installation) and add the following to your `\u003cproject_name\u003e.sublime-project` project-level file:\n\n```\n{\n  \"settings\": {\n    \"js_prettier\": {\n      \"auto_format_on_save\": true,\n      \"custom_file_extensions\": [\"lua\"],\n    }\n  }\n}\n\n```\n\nAlternatively, `\"custom_file_extensions\": [\"lua\"]` can be added to the JsPrettier plugin user settings.\n\n## Contributing\n\nIf you're interested in contributing to the development of Prettier for Lua, you can follow the [CONTRIBUTING guide from Prettier](https://github.com/prettier/prettier/blob/master/CONTRIBUTING.md), as it all applies to this repository too.\n\nTo test it out on a Lua file:\n\n- Clone this repository.\n- Run `yarn`.\n- Create a file called `test.lua`.\n- Run `yarn prettier test.lua` to check the output.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprettier%2Fplugin-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprettier%2Fplugin-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprettier%2Fplugin-lua/lists"}