merrickluo / lsp-tailwindcss

the lsp-mode client for tailwindcss
GNU General Public License v3.0
180 stars 21 forks source link

Doesn't seem to activate #36

Closed jrbrodie77 closed 2 years ago

jrbrodie77 commented 2 years ago

Thanks for writing this package, this could make Emacs viable for web stuff for me.

I can't seem to get tailwind completions. I have followed your setup instructions (I'm using DOOM). If I create an html file, I get web-mode, I also get code completions in that file. But if I do something like <div class=" there's no sign of any css completions.

Any recommendations for debugging the startup of this LSP server? I did enable add-on mode by setting the var to t, but I only seem to get html-ls as my lsp server.

thanks!

merrickluo commented 2 years ago

Did you install the tailwindcss language server executable? if not, please read this part in readme.

If it still won't start, you can try M-x lsp-describe-session or open *lsp-log* buffer to see if there is something usefule.

jrbrodie77 commented 2 years ago

I figured it out!! I was setting lsp-tailwindcss-add-on-mode after my use-package line. When lsp-tailwindcss regiters itself as an lsp client, the value of the add-on variable must be already true.

Here's the config that worked. Originally my first two lines were swapped, which didn't work.


(setq lsp-tailwindcss-add-on-mode t)
(use-package lsp-tailwindcss)
(setq lsp-tailwindcss-major-modes '(svelte-mode html-mode sgml-mode mhtml-mode web-mode css-mode))
merrickluo commented 2 years ago

Yeah, you need to set it before the package loads, and use-package did provide a :init block for that, your config should look like this:

(use-package lsp-tailwindcss
  :init
  (setq lsp-tailwindcss-add-on-mode t)
  :config
  (setq lsp-tailwindcss-major-modes '(svelte-mode html-mode sgml-mode mhtml-mode web-mode css-mode)))

Glad you figured it out! I should add this to the readme.

Zeta611 commented 1 year ago

Hi! Thank you for creating the package.

I stumbled upon this page after I failed to activate tailwindcss lsp in rescript-mode. As it turns out, I did not understand what "add-on" mode is, and how it was relevant to my situation. I simply added rescript-mode and tried to debug my settings.

Also in the linked lsp document, it is not so descriptive about what add-on does. It would be really helpful if there is a sentence or two about what it does.

I'd really like to make a pull request to the README, but I still don't quite understand what it means.

merrickluo commented 1 year ago

the add-on mode means it can be run alongside another language server, say if you are editing a jsx file, you can have a js language server and tailwindcss language server running simultaneously. Since tailwindcss is mainly used in jsx or HTML files, so I recommend turning add-on mode on in the readme.

Zeta611 commented 1 year ago

Thank you for your explanation!