zed icon indicating copy to clipboard operation
zed copied to clipboard

Tailwind LSP support in Ruby files for Phlex Components

Open bradgessler opened this issue 2 years ago • 6 comments

Check for existing issues

  • [X] Completed

Describe the feature

Similar to https://github.com/zed-industries/zed/issues/6340 and https://github.com/zed-industries/zed/issues/6306, Tailwind LSP auto-complete would be useful in Ruby (.rb) code for authoring Phlex components.

If applicable, add mockups / screenshots to help present your vision of the feature

I have this working in Sublime Text at https://gist.github.com/bradgessler/1907d07593918fb5d2f27911bccc75f4

Here's what it looks like in .rb files when decorating the class: attribute with a Tailwind class:

Screenshot 2023-11-07 at 8 22 01 AM

bradgessler avatar Nov 07 '23 16:11 bradgessler

I agree this would be a kiler feature. One way to get there might be to support language server configuration so the community can build support for things like this. See https://github.com/zed-industries/zed/issues/4511

I would be a lot more motivated to build a Phlex extension for ruby-lsp if I could configure Zed to use it.

joeldrapper avatar Nov 08 '23 00:11 joeldrapper

People have been able to get this working in Neovim and VS Code. https://github.com/orgs/phlex-ruby/discussions/536#discussioncomment-5543709

joeldrapper avatar Apr 06 '24 12:04 joeldrapper

In VSCode, Tailwind can be configured to work in Ruby files like this. Is there any way to access the same configuration in Zed?

{
  "tailwindCSS.includeLanguages": {
    "ruby": "html"
  },
  "tailwindCSS.experimental.classRegex": [
	"\\bclass:\\s*[\"']([^\"']*)[\"']",
  ]
}

joeldrapper avatar Apr 19 '24 12:04 joeldrapper

This would be great. I am not using phlex but this addition would also make it work for standard ERB rails helper tags, like <%= f.label :keywords, class: "block text-sm ... i assume? Currently it only works with plain HTML in ERB files

drale2k avatar Apr 25 '24 23:04 drale2k

I think we will be able to have it working soon after https://github.com/zed-industries/zed/issues/5830 and https://github.com/zed-industries/zed/pull/11360 🚀

kucho avatar May 15 '24 20:05 kucho

That’s awesome!

joeldrapper avatar May 15 '24 20:05 joeldrapper

I'm pretty sure with these settings and the latest version of the Ruby extension (which includes this: https://github.com/zed-industries/zed/pull/12742) this is fixed:

{
  "languages": {
    "Ruby": {
      "language_servers": ["tailwindcss-language-server", "..."]
    }
  },
  "lsp": {
    "tailwindcss-language-server": {
      "settings": {
        "includeLanguages": {
          "erb": "html",
          "ruby": "html"
        },
        "experimental": {
          "classRegex": ["\\bclass:\\s*['\"]([^'\"]*)['\"]"]
        }
      }
    }
  }
}

And @joeldrapper tweeted that it works: https://twitter.com/joeldrapper/status/1798812799898136856

Happy to reopen if it doesn't work though.

mrnugget avatar Jun 07 '24 04:06 mrnugget