Neovim 0.5 has a built-in language server client (LSP) that’s easily extensible with the efm-langserver. Inspired by Dr. Nic’s recent post on dev.to I wanted to get rustywind working with efm-langserver. I don’t even use Tailwind… yet, but I’ve been a fan for quite a while.

I’ll leave it to the reader to get efm-langserver installed, but I wanted to share my config. I use ~/.config/efm-langserver/config.yaml to configure formatters & linters, and I configure efm in Neovim in ~/.config/nvim/init.lua. Here are the relevant parts:

efm-langserver config

version: 2

tools:
  tailwind-class-sort: &tailwind-class-sort
    format-command: 'rustywind --stdin'
    format-stdin: true

languages:
  html:
    - <<: *tailwind-class-sort

neovim lua config

lspconfig.efm.setup({
  filetypes = {"html"},
  init_options = {documentFormatting = true},
})

Check out my dotfiles repo commit and you can view more of the files to see how they’re all put together. Now, when you write the file, you’ll get automatic class sorting. Fun stuff!

- Jesse