a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.11k stars 235 forks source link

docs: TailwindCSS setup autocomplete no longer work #819

Open viirak opened 4 days ago

viirak commented 4 days ago

For some reason my Nvim Setup for tailwindcss to work with Templ no longer work. (Only the autocomplete that does not work. The language detection and language-server initiation still works though.)

TailwindCSS langauage server installed via Mason

tailwindcss-language-server
Language Server Protocol implementation for Tailwind CSS.

installed version 0.0.18                                                   
homepage          https://github.com/tailwindlabs/tailwindcss-intellisense 
languages         CSS                                                      
categories        LSP                                                      
executables       tailwindcss-language-server 

From the documentation, https://templ.guide/commands-and-tools/ide-support#neovim--050

This is the setup for tailwind to work with templ

lspconfig.tailwindcss.setup({
    on_attach = on_attach,
    capabilities = capabilities,
    filetypes = { "templ", "astro", "javascript", "typescript", "react" },
    init_options = { userLanguages = { templ = "html" } },
})

But the autocomplete no longer work, until I have to add the includeLanages in the settings. Also, I've found that lspconfig has include "templ" to the default filetypes list, and the userLanguages init options. https://"github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tailwindcss

This works

lspconfig.tailwindcss.setup {
  on_attach = on_attach,
  capabilities = capabilities,
  -- filetypes = { "templ", "astro", "javascript", "typescript", "react" },
  -- init_options = {
  --   userLanguages = { templ = "html" },
  -- },
  settings = {
    tailwindCSS = {
      includeLanguages = {
        templ = "html",
      },
    },
  },
}
Djancyp commented 3 days ago

remove tailwind lsp version 18 and install version 16

asilvadesigns commented 3 days ago

I'm experiencing same issue, what @Djancyp said is correct, running MasonInstall tailwindcss-language-server@0.0.16 fixes the problem.

joerdav commented 1 day ago

Interesting, I wonder what changed between these versions. I do think this would have to be an issue on the tailwindcss project though as we have no control over this apart from documenting proper configuration. I'll keep this open though to track the issue, and potentially as a way to track an update to our docs if needed.

Djancyp commented 1 day ago

@joerdav I have also notice gopls > 0.15.3 break templ lsp .

joerdav commented 1 day ago

@Djancyp yes, that should be fixed in the latest release though, please update and that should fix it: https://github.com/a-h/templ/releases/tag/v0.2.731