sublimelsp / LSP-tailwindcss

Tailwind css support for Sublime's LSP plugin
MIT License
55 stars 6 forks source link

Add is_allowed_to_start method #7

Closed predragnikolic closed 3 years ago

predragnikolic commented 3 years ago

Thanks guys for the tips that you left in the previous PR.

Start the server only if the tailwind.config.js is present and if the user has tailwind css installed in node_modules.

How to test.

  1. Create a index.js file.
  2. Open it and you should see an error message printed - LSP-tailwindcss - no tailwind.config.js present in {PATH}

next

  1. create an empty tailwind.config.js file at the root.
  2. Restart ST, now you should see "LSP-tailwindcss - No tailwindcss package found in node_modules for path {PATH}. Make sure to install the tailwindcss npm package."

next in terminal type:

  1. npm init -y - that creates a package json file.
  2. Install the dep with npm install -D tailwindcss
  3. Restart ST, now you will see no errors.

NOTE:

I noticed a bug where the LSP-typescript plugin won't start if the LSP-tailwindcss plugin don't start.

  1. I have LSP-typescript and LSP-tailwindcss installed.
  2. If I create a index.js file in an empty folder.
  3. The tailwindcss server wont be initialized(this is expected, because the folder doesn't meet the server requirements), but the LSP-typescript plugin won't be started as well(which is not expected) :)
rchl commented 3 years ago

I noticed a bug where the LSP-typescript plugin won't start if the LSP-tailwindcss plugin don't start.

I can't quite see that happening.

Note that LSP-typescript also implements is_allowed_to_start and won't start if there are no workspace folders.

rwols commented 3 years ago

I noticed a bug where the LSP-typescript plugin won't start if the LSP-tailwindcss plugin don't start.

I think it's a bug in LSP :) Before the early-exit in start_async in plugin/core/windows.py, we should call this as well:

https://github.com/sublimelsp/LSP/blob/9196febec744b0a88ff0d1b215830b63c1051fd5/plugin/core/windows.py#L345-L347