Skip to content

williamboman/prettierd

 
 

Repository files navigation

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.

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

Using with TCP (moar speed)

Following the instructions from https://github.com/mantoni/core_d.js#moar-speed:

$ PORT=`cat ~/.prettierd | cut -d" " -f1`
$ TOKEN=`cat ~/.prettierd | cut -d" " -f2`
$ echo "$TOKEN $PWD file.ts" | cat - file.ts | nc localhost $PORT

Supported languages

Checkout src/service.ts for a list of supported languages/extensions. Feel free to open a PR if you're missing something.

Editor integration

I use this directly with neovim's TCP client, see more details in this blog post or my configuration.

Alternatively, one 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 ...
  }
})

About

prettier, as a daemon

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 90.0%
  • JavaScript 10.0%