Skip to content

About

Code formatter plugin for Acode editor for Android

Resources

Stars

60 stars

Watchers

2 watching

Forks

Repository files navigation

Acode Plugin: Prettier

Version License

Prettier is an opinionated code formatter that enforces a consistent style across your codebase. It automatically formats your code by parsing it and re-printing it with its own rules, taking the maximum line length into account and wrapping code when necessary.

This plugin brings the power of Prettier to Acode, the lightweight code editor for Android. With this plugin, you can format your code with just a tap or keyboard shortcut, ensuring clean and consistent formatting across all your projects.

Repository: github.com/deadlyjack/acode-plugin-prettier

Requirements

  • Acode editor for Android
  • Internet connection (for initial plugin installation)

Installation

There are three ways to install this plugin:

Method 1: Plugin Manager (Recommended)

This is the easiest way to install the plugin:

  1. Open Acode and tap the menu icon (three horizontal lines) in the top-left corner
  2. Go to Settings → Plugins
  3. Browse the available plugins and find Prettier
  4. Tap Install to add it to your editor
  5. Restart Acode to activate the plugin

Method 2: Remote Installation

If you have a direct URL to the plugin file:

  1. Open Acode and go to Settings → Plugins
  2. Tap the '+' icon
  3. Select REMOTE
  4. Enter the plugin file URL (e.g., a GitHub release URL)
  5. Tap Install

Method 3: Local Installation

If you have the plugin .zip file downloaded on your device:

  1. Download the plugin file (.zip) to your Android device
  2. Open Acode and navigate to Settings → Plugins
  3. Tap the '+' icon
  4. Select LOCAL
  5. Choose the downloaded plugin file
  6. Tap Install

For more details on installing plugins, visit the Acode documentation.

Features

This plugin provides powerful formatting capabilities to help you maintain clean, consistent code:

  • Format Entire Document: Quickly format your entire file using Acode's built-in formatter. This ensures your whole file follows consistent styling rules, making it easier to read and maintain.

  • Format Selection: Need to format just a specific section? Select the lines you want to format and use the "Prettier: Format Selection" command. Perfect for cleaning up specific code blocks without affecting the rest of your file.

    • Keyboard shortcut: Ctrl-Shift-F (with external keyboard)
    • Smart behavior: Formats your selection when text is highlighted, or the entire document if nothing is selected
    • Expands partial line selections to full lines and formats them in document context. Prettier may expand the range to a complete syntax node.
  • Configuration Support: Respects .prettierrc and other Prettier configuration files in your project. This means your formatting preferences travel with your code, ensuring consistency across team members and devices.

  • Customizable Options: Can't use config files? No problem! The plugin provides 24+ formatting options in its settings panel, including print width, tabs vs spaces, semicolons, quotes, trailing commas, and much more.

  • Advanced Error Handling: When formatting issues occur, the plugin provides detailed error messages and logs to help you understand what went wrong. Access logs through the plugin settings for troubleshooting.

  • Web Worker Support: Formatting runs asynchronously in the background, ensuring your editor remains responsive even when formatting large files.

Supported Languages

Prettier can format files in multiple languages and frameworks. This plugin supports all of them:

Web Languages

HTML CSS SCSS Less

Extensions: .html .htm .css .scss .less

JavaScript & TypeScript

JavaScript TypeScript React

Extensions: .js .cjs .es .mjs .jsx .ts .tsx .mts .cts

Frameworks & Libraries

Vue Handlebars

Extensions: .vue .hbs .handlebars

Data & Markup

JSON Markdown YAML

Extensions: .json .md .yaml .yml

Usage

Formatting the Entire Document

  1. Open any supported file in Acode
  2. Use Acode's built-in "Format Code" command or the format button in the UI

Formatting Selection

  1. Select the lines you want to format
  2. Use one of these methods:
    • Press Ctrl-Shift-F if you have an external keyboard connected
    • Open the command palette and search for "Prettier: Format Selection"
    • Use Acode's QuickTools menu to access the format command

Note: If no text is selected, the entire document will be formatted.

Configuration

The plugin supports multiple ways to configure Prettier's formatting behavior. You can use configuration files in your project, or customize settings directly in the plugin.

Configuration Files

The plugin looks beside the current file and then walks up to its nearest opened workspace root. This includes Android SAF tree roots and nested workspace folders. Without an opened workspace, it checks only the file’s directory. The nearest configuration wins:

  • package.json or package.yaml with a prettier object
  • .prettierrc (JSON or YAML format)
  • .prettierrc.json / .prettierrc.json5
  • .prettierrc.yaml / .prettierrc.yml
  • .prettierrc.toml
  • .prettierrc.js / prettier.config.js
  • .prettierrc.mjs / prettier.config.mjs
  • .prettierrc.cjs / prettier.config.cjs

Example 1: Basic .prettierrc with 2-space indentation

{
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": false,
  "printWidth": 80
}

Example 2: .prettierrc with no semicolons and single quotes

{
  "tabWidth": 2,
  "useTabs": false,
  "semi": false,
  "singleQuote": true,
  "trailingComma": "es5",
  "bracketSpacing": true,
  "arrowParens": "avoid"
}

Configuration Priority:

Within the same directory, the prettier object in package.json takes priority over standalone configuration files. Lookup uses directory listings when available. Android’s built-in external-storage SAF provider uses one complete listing per level; other providers also probe omitted config names because listings may be partial or hide dotfiles. If listing fails, concurrent existence checks are used. Failed candidate probes are skipped; an unreadable or invalid selected config still reports an error. Configs are checked again on every format so external edits take effect immediately. If no config exists, the plugin settings apply. A project config uses Prettier defaults for options it does not specify.

JavaScript configs must export a self-contained object (export default or module.exports). They execute with Acode privileges, so only use JavaScript configs from projects you trust. Keep Allow JavaScript configs disabled for untrusted projects; enable it in plugin settings only when you trust the config code. Disabled JavaScript configs are skipped with a warning once per config per session, allowing other configs in the directory, parent configs, or plugin settings to apply. JSON, JSON5, YAML, and TOML remain available. New installs and upgrades without a saved preference default to disabled. Existing saved enabled/disabled preferences are preserved, including during settings migrations. Node imports, shared config packages, TypeScript configs, external formatter plugins, and overrides are not supported. External plugins and overrides are ignored with a one-time warning per config during the plugin session; base options still apply. Empty arrays do not warn. XML is not registered because no XML parser is bundled.

Troubleshooting syntax errors

Prettier formats valid syntax; it cannot repair incomplete code. For example, import Navbar from needs a module path before the following import './globals.css' statement. Fix the incomplete import and format again. Failed formatting leaves your code unchanged. Tap a log entry to navigate to its location, or press Back to close the logs.

Available Settings

If you prefer not to use configuration files, you can customize all formatting options directly in the plugin settings. Available options include:

  • printWidth - Maximum line length before wrapping (default: 80)
  • tabWidth - Number of spaces per indentation level (default: 4)
  • useTabs - Use tabs instead of spaces for indentation (default: false)
  • semi - Add semicolons at the end of statements (default: true)
  • singleQuote - Use single quotes instead of double quotes (default: false)
  • quoteProps - When to quote object properties ("as-needed", "consistent", "preserve")
  • jsxSingleQuote - Use single quotes in JSX (default: false)
  • trailingComma - Add trailing commas where valid ("none", "es5", "all")
  • bracketSpacing - Add spaces inside object brackets (default: true)
  • bracketSameLine - Put closing bracket on same line in HTML/JSX (default: false)
  • arrowParens - Include parentheses around arrow function parameters ("always", "avoid")
  • requirePragma - Only format files with @format pragma (default: false)
  • insertPragma - Insert @format pragma at top of formatted files (default: false)
  • proseWrap - How to wrap prose in Markdown ("always", "never", "preserve")
  • htmlWhitespaceSensitivity - HTML whitespace handling ("css", "strict", "ignore")
  • vueIndentScriptAndStyle - Indent <script> and <style> in Vue files (default: false)
  • endOfLine - Line ending style ("lf", "crlf", "cr", "auto")
  • embeddedLanguageFormatting - Format embedded code ("auto", "off")
  • singleAttributePerLine - Force single attribute per line in HTML/JSX (default: false)

And many more options for specific languages and plugins. Access these settings through Settings → Plugins → Prettier in Acode.

Support

Need help or found a bug? We're here to assist!

Reporting Issues

If you encounter any problems or have suggestions for improvements:

  1. Check the existing issues to see if it's already reported
  2. If not, create a new issue with:
    • A clear description of the problem
    • Steps to reproduce the issue
    • Your Acode version and Android version
    • Example code that demonstrates the issue (if applicable)

Getting Help

Your feedback helps make this plugin better for everyone!

Development

Use Node.js 22.22.2+, 24.15+ (LTS recommended), or 26+:

npm ci
npm test
npm run build-release
npm run test:release

The Node engine range follows jsdom’s supported releases.

The release archive is dist.zip; its manifest lists the actual generated worker chunks. Babel stays on the compatible 7.x line to avoid an unrelated compiler migration. Tests cover formatting, selections, worker races/lifecycle, safe logs/back navigation, config lookup, and bundled language parsers.

Build, packaging, and development-server scripts live in dev/; .vscode/ contains only editor settings. The plain development build does not package a ZIP. npm run start-dev explicitly enables archive packaging for watch builds, and its public tunnel serves only /dist.zip. Archive creation is asynchronous and the completed ZIP is replaced atomically.

The main-thread fallback loads on demand and shares its parser chunk with the worker. Flow, Acorn, and Meriyah remain available through an explicit config parser option. Vendor syntax is transpiled with Babel; BigInt exponentiation stays native because Math.pow cannot accept BigInts. The inherited browserslist is a transpilation target, not a guarantee of runtime/API support in old WebViews. The lowest WebView verified for this release is Android WebView 124; older engines and iOS have not been validated.

Contributing

Contributions are welcome! Whether you want to fix a bug, add a feature, or improve documentation, your help is appreciated.

To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to your branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Please ensure your code follows the existing style and includes appropriate tests if applicable.

Repository: github.com/deadlyjack/acode-plugin-prettier

License

This project is licensed under the MIT License.

Copyright (c) 2026 Ajit Kumar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Code formatter plugin for Acode editor for Android

Resources

Stars

60 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages