sublimelsp / LSP-tailwindcss

Tailwind css support for Sublime's LSP plugin
MIT License
54 stars 5 forks source link

Add support for other file types #9

Closed countfak closed 3 years ago

countfak commented 3 years ago

Thanks for the great extension.

For regular HTML files, it works great. However, the extension stops working completely once a file is associated to another file type.

For example, Twig template files use the regular .html extension but include special mustache {{ }} syntax. I'm using another extension to get tag highlighting for these files. But once I associate this file as "Twig" LSP-tailwindcss does not work.

Anything I'm missing?

predragnikolic commented 3 years ago

Hello, Glad you like it.

This plugin LSP-tailwindcss which uses the https://github.com/tailwindlabs/tailwindcss-intellisense language server. The language server supports multiple languages. But currently LSP-tailwindcss is configured to work with these languages: https://github.com/sublimelsp/LSP-tailwindcss/blob/master/LSP-tailwindcss.sublime-settings#L3-L64

From the command palette, you can choose Preferences: LSP-tailwindcss Settings and add to the languagesyour twig language configuration. (you can create a PR once you made it work for you)

Can you tell me what you Sublime Text version is and what syntax highlighter plugin you use for Twig?

countfak commented 3 years ago

Hi, thanks for your help, I got it working. I edited the first part of the "languages" setting as follow:

{
  "languageId": "html",
  "scopes": ["text.html.basic", "embedding.php", "text.blade", "text.html.twig"],
  "syntaxes": [
    "Packages/HTML/HTML.sublime-syntax",
    "Packages/PHP/PHP.sublime-syntax",
    "Packages/Laravel Blade Highlighter/blade.sublime-syntax",
    "Packages/Twig/Twig.sublime-syntax"
  ]
}

To recap, in the "languageId": "html" block, that's what I did:

I'm on Sublime Text 4109 The package I use for the Twig syntax is BetterTwig: https://packagecontrol.io/packages/Twig

predragnikolic commented 3 years ago

Thanks,

For Sublime Text 3 the syntaxes key is required, while for Sublime Text 4 it is not. (For ST4 the scopes key is sufficient)

predragnikolic commented 3 years ago

FWIW to get the sytnax, you can open up the ST console with ctrl+` and paste:

>>> view.settings().get('syntax')
'Packages/Twig/resources/syntax/Twig.sublime-syntax'

I will create a PR to add twig support.

predragnikolic commented 3 years ago

Because I am not sure what languages the tailwindcss language server supports I opened an issue where I asked that question: https://github.com/tailwindlabs/tailwindcss-intellisense/issues/360#issue-930532711

rwols commented 3 years ago

Who is still using ST3 though? Why put effort into supporting that?

predragnikolic commented 3 years ago

lsp_utils does most of the work.

But I was thinking about this lately and I do not see a reason why would someone not want to install ST 4 and I can't think of any reasons.

I think that anyone can install ST4 stable without a license and use it, though they will probably get popups to buy the license.

But on the other side, I really do not want to maintain the syntaxes key. :) That said, I think that I should slowly move on forward and only support ST4.

rchl commented 3 years ago

I'd like to be the voice of pragmatism here and maintain ST3 support for as long as possible. :)

Adding a syntax entry is a close to zero effort when you have to figure out the correct selector to use anyway.

countfak commented 2 years ago

Hi, I just got this Package Control message this morning and I thought it might be interesting:

BetterTwig v2.0.0
  -----------------

  ** Breaking Changes **

   - Note that even though this is a major version upgrade, the only breaking change
     in this release is that the syntax name is changed from "Twig.sublime-syntax"
     to "HTML (Twig).sublime-syntax". This is done to better reflect the fact that
     the Twig syntax now extends HTML syntax to provide highlighting for both Twig
     & HTML specific code. If you are referring the syntax by its name for any purpose,
     then please change it to "HTML (Twig).sublime-syntax".

Basically, it says that the syntax name is changed from "Twig.sublime-syntax" to "HTML (Twig).sublime-syntax". Everything is still working fine for me, but maybe the syntax name in the package settings should be updated?

predragnikolic commented 2 years ago

Thanks, for the heads-up, Will update that.

predragnikolic commented 2 years ago

will be done in #32