withastro / docs

Astro documentation
https://docs.astro.build/
MIT License
1.32k stars 1.48k forks source link

Neovim Formating with pretier doesn't work in .astro files #8534

Closed f-amine closed 4 months ago

f-amine commented 4 months ago

📚 Subject area/topic

Neovim Formater Integration with Astro

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/editor-setup/#other-code-editors

📋 Description of content that is out-of-date or incorrect

The current documentation for setting up Prettier and LSP with Neovim does not include necessary configuration details in the package.json for formatting .astro files.

Description

After setting up Prettier and the LSP for Neovim, formatting doesn't work correctly. It took a day to resolve this issue, and it was eventually fixed with help from the Astro Discord community member @Grahf. To save others from similar frustration, please add the following configuration to the documentation:

"prettier": {
  "astroAllowShorthand": true,
  "overrides": [
    {
      "files": "*.astro",
      "options": {
        "parser": "astro"
      }
    }
  ],
  "pluginSearchDirs": [
    "."
  ],
  "plugins": [
    "prettier-plugin-astro"
  ]
}

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

sarah11918 commented 4 months ago

Hi @f-amine ! I'm glad you eventually got this working!

Would you like to make a PR to add this information yourself to the docs page? I could see adding it to the bottom of the page, in the Prettier section, maybe like:

#### Prettier for Neovim

To configure Prettier for Astro in Neovim, use the following configuration:

"prettier": {
  "astroAllowShorthand": true,
  "overrides": [
    {
      "files": "*.astro",
      "options": {
        "parser": "astro"
      }
    }
  ],
  "pluginSearchDirs": [
    "."
  ],
  "plugins": [
    "prettier-plugin-astro"
  ]
}

Do you think this would be a helpful addition? If so, I'd be happy to receive a PR to the docs page!

f-amine commented 4 months ago

Okey I can do that, I'm gonna look for the specific file for that and make a PR right now

sarah11918 commented 4 months ago

Amazing @f-amine - Quick tip - you can just go to that page in docs and click "edit this page" and you'll be taken right there! 🙌

f-amine commented 4 months ago

sent a pr, thanks for the fast reply !!