-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use it with Ruby on Rails bundled tailwind #34
Comments
Just chiming in for clarity: Rails now ship with the new pkg powered binary: https://tailwindcss.com/blog/standalone-cli. Rails and Phoenix are moving away from including npm scripts and bundling by default citing the default support for ES6 and http2 in-browser being good enough to provide unbundled code and "liberating" users by letting them choose the bundler of their choice if need be. That being said, it just means that the plugin should be adapting "is_tailwind_installed" to check for the binary as fallback for not finding the node module. I would suggest to prioritize the node_module if it's found first, over the binary, in case someone installs the binary globally but is still working on a project with local node modules. |
I'm will probably drop the is_allowed_to_start logic entirely Line 27 in f8da7c5
I left this comment a while ago, |
Yeah, I think that would remove useless complexity on your end and you could simply gracefully log a message in the console if you can't find any tailwind executables. I don't know how other people manage their LSP servers, but I enable most of mine globally since I work with the same stack very often so it makes sense. 🤷 |
This kind of method is there to guard against a modal dialog informing the user that the server won’t start. If the tailwindcss server doesn’t reply with an error to the initialize request then it’s okay to remove this check. If not, then you could expect new issues about this server not starting in web projects that are not set up for tailwind. |
The selectors should probably also get extended to include text.html.ruby, text.html.rails, text.haml |
Created a PR to fix this.
I do not develop in ruby/rails, If you can create a PR for that, I would happily review it. |
Adding this PR too it now works out of the box for Rails :) |
Have it been tested to work? I just tried it out and it does not seem to work for me. I'm running Rails 7 with the standalone version of Tailwind and I do not get autocompletions in Rails related files ( |
Actually got it working by adding a language id override for {
"text.html.rails": "html"
} What didn't seem to work however was going into {
"settings":
{
"tailwindCSS.includeLanguages": {
"rails": "html"
}
},
} Not sure why. According to the tailwindcss-intellisense documentation it should be enough. I've attached the LSP debug output below. LSP debug output
|
As far as I can see by inspecting the vscode extension, the
|
Of course your solution should be fine too for this specific server if it doesn't care about |
Are you sure? I found the following reference to These settings are also editable from within this package as can be seen my opening
This isn't necessary as the default rules will take the last part of any scope by default. |
That's the only reference which means that it's not really used anywhere.
Right. So the alternative is to not touch the mapping but include the |
Yes, I could do that as a "work around" for now. I think what I'm trying to convey (sorry, if I'm not being clear) is that we should probably support these settings. They don't seem to be specific to the VSCode extension. Settings are being read from a given source. The server asks for them via the Configuration Request. The client then notifies the server about changes using the DidChangeConfiguration Notification. I believe what's lacking is some initial "glue code" in this package. We could read the settings before starting the server, and pass If the above doesn't make sense, I'd argue that we shouldn't really have these settings available at all. But given that they're defined, I believe the intention is that we can make use of them. Looking at the debug info I posted earlier as well, it looks like the settings are picked up correctly by the plugin as it is today, so it's just a matter of hooking them up. Excerpt from the LSP communication
I'd be happy to submit a pull request for it if we think it makes sense. 🙂 |
It would be easiest to add the Will just clarify that the server doesn't process |
@rchl thanks for clarifying. 🙏 I went through the source code again and you're right. Given that, I think it makes sense to bootstrap the server with whatever you've provided in However, I could also see us dropping |
That's usually how we deal with server settings that are actually handled in the (VScode) extension. But, whatever solution is fine by me. |
@rwols yeah, perhaps that's the better option. In doing so, we could make a pass over the current settings and remove anything else that is VSCode extension specific. I guess that would be overall less confusing. There are still options that are worth keeping like |
The downside of that is that then we need to document our alternative rather than redirect to official documentation. |
Hi I'm creating a new Rails project with
rails new example -c tailwind
This setup works without npm installed by providing the official tailwindcss executable that is standalone and puts a shim here:
~/.rbenv/shims/tailwindcss
However when I want to use the LSP now I can't because it says tailwind is not installed even though I clearly have access to it and it works in my rails project.
Is there a way to specify the tailwind executable or install the language server globally?
How can this work with Rails?
The text was updated successfully, but these errors were encountered: