lukas-reineke / lsp-format.nvim

A wrapper around Neovims native LSP formatting.
564 stars 27 forks source link

how to format code with prettier, stylua #29

Closed itsuki0927 closed 2 years ago

itsuki0927 commented 2 years ago

I want to ask how to use prettier to format code, I see that efm lsp is used in the documentation, but I don't use this, I just installed simple tsserver, vuels, cssls lsp, I don't see the specific usage in the documentation , can you provide a demo?

lsp info: WechatIMG2092

tsserver setup: WechatIMG2094

on_attach: WechatIMG2102

this is my code, but it's not work, am i missing something? and if I also want to format the lua file using stylua, What should we do?

lukas-reineke commented 2 years ago

lsp-format.nvim does not format itself. It just a wrapper for language servers. So you need a language server that can format with prettier or stylua. I use EFM for this. There are other options as well, like https://github.com/jose-elias-alvarez/null-ls.nvim

For how to configure them, please look at their documentation.