Skip to content

Instantly share code, notes, and snippets.

@victorcolina22
Last active October 5, 2024 04:28
Show Gist options
  • Select an option

  • Save victorcolina22/4105b7f7d9a511ab5ae84fcfc5b658d5 to your computer and use it in GitHub Desktop.

Select an option

Save victorcolina22/4105b7f7d9a511ab5ae84fcfc5b658d5 to your computer and use it in GitHub Desktop.
Astro files formatting with prettier for Nvim editor

Astro files formatting

Install the plugins

pnpm/npm add/install -D prettier prettier-plugin-astro

Paste this code into your file ".prettierrc.mjs"

// .prettierrc.mjs
/** @type {import("prettier").Config} */
export default {
  plugins: ["prettier-plugin-astro"],
  arrowParens: "always",
  bracketSameLine: false,
  bracketSpacing: true,
  semi: true,
  experimentalTernaries: false,
  singleQuote: true,
  jsxSingleQuote: true,
  quoteProps: "as-needed",
  trailingComma: "all",
  singleAttributePerLine: false,
  htmlWhitespaceSensitivity: "css",
  vueIndentScriptAndStyle: false,
  proseWrap: "preserve",
  insertPragma: false,
  printWidth: 80,
  requirePragma: false,
  tabWidth: 2,
  useTabs: false,
  embeddedLanguageFormatting: "auto",
  overrides: [
    {
      files: "*.astro",
      options: {
        parser: "astro",
      },
    },
  ],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment