npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fsouza/prettierd

v0.25.4

Published

prettier, as a daemon

Downloads

43,952

Readme

prettierd

Build Status

Wanna run prettier in your editor, but fast? Welcome to prettierd!

This is built on top of core_d.js and integrates with prettier.

Installation guide

$ npm install -g @fsouza/prettierd

NOTE: npm comes builtin to node.

Alternatively, users may also use homebrew:

$ brew install fsouza/prettierd/prettierd

Using in the command line with node.js

The prettierd script always takes the file in the standard input and the positional parameter with the name of the file:

$ cat file.ts | prettierd file.ts

Supported languages / plugins

Many parsers ship with prettierd, including JavaScript, TypeScript, GraphQL, CSS, HTML and YAML. Please notice that starting with version 0.12.0, prettierd now supports invoking the local version of prettier, so instead of adding new languages to prettierd, you should rely on that feature to use it locally with your custom version of prettier and enabled plugins.

Additional plugins

Additional plugins can be supported by installing them and adding them to the prettier configuration. For example, to use the Ruby plugin, install @prettier/plugin-ruby and add it to your configuration:

{
  // ... other settings
  "plugins": ["@prettier/plugin-ruby"]
}

Then formatting Ruby files should be possible.

Provide Default Configuration

You can provide a default configuration for the prettier via setting the environment variable PRETTIERD_DEFAULT_CONFIG to the exact path of the prettier configuration file.

Local Instance

If you have locally installed prettier in your package, it will use that. Otherwise, it will use the one bundled with the package itself.

If you want to use prettierd exclusively with the locally installed prettier package, you can set the environment variable PRETTIERD_LOCAL_PRETTIER_ONLY (any truthy value will do, good examples are true or 1).

Editor integration

Vim / Neovim

I use this directly with neovim's LSP client, via efm-langserver:

local prettier = {
  formatCommand = 'prettierd "${INPUT}"',
  formatStdin = true,
  env = {
    string.format('PRETTIERD_DEFAULT_CONFIG=%s', vim.fn.expand('~/.config/nvim/utils/linter-config/.prettierrc.json')),
  },
}

Alternatively, you can use prettierme to integrate directly with other editors.

Or, as a third option for users of Vim/Neovim plugins such as formatter.nvim or vim-codefmt, you can configure prettierd in the stdin mode. Below is an example with formatter.nvim:

require('formatter').setup({
  logging = false,
  filetype = {
    javascript = {
        -- prettierd
       function()
          return {
            exe = "prettierd",
            args = {vim.api.nvim_buf_get_name(0)},
            stdin = true
          }
        end
    },
    -- other formatters ...
  }
})

Sublime Text

Prettierd Format

You can use Prettierd Format to format your files with prettierd. After installation, it enables format-on-save for any file supported by Prettier by default.

Fmt

Alternatively, if you're looking for something more advanced that supports multiple formatters, you can use Fmt and configure prettierd for each language scope you wish to format:

{
  "rules": [
    {
      "selector": "source.ts",
      "cmd": ["prettierd", "--stdin-filepath", "$file"],
      "format_on_save": true
    },
    {
      "selector": "source.json"
      // ...
    }
    // ...
  ]
}

Zed

To use Prettierd with Zed, you need to configure the language_overrides adding a format_on_save command for each of the languages you wish to be handling.

[!NOTE] Configuration below assumes you have installed prettierd and gives an example of its path from Homebrew installation. You can check path on your system by running which prettierd.

Example configuration:

{
  "language_overrides": {
    "TypeScript": {
      "format_on_save": {
        "external": {
          "command": "/opt/homebrew/bin/prettierd",
          "arguments": ["--stdin-filepath", "{buffer_path}"]
        }
      }
    }
  }
}

Save your configuration file, and provided you've installed and set the correct path to prettierd program, Zed will start formatting your files on save action.

Other editors

I don't know much about other editors, but feel free to send a pull requests on instructions.