fix(tailwind): additional settings (#5266)

Make it possible to define your own tailwind settings in opts, and merge
them with the default, additional Phoenix settings in tailwind.lua

## Description

Add the possibility to add your own tailwind settings in opts and have
them deep merged into the default `opts.settings`

I needed this for configuring support for tailwind when coding on a
[htmgo](https://htmgo.dev/docs/misc/tailwind-intellisense) project in
Neovim.

E.g.
```lua
return {
  "neovim/nvim-lspconfig",
  opts = {
    servers = {
      tailwindcss = {
        filetypes_include = { "go" },
        settings = {
          tailwindCSS = {
            includeLanguages = {
              go = "html",
            },
            experimental = {
              classRegex = {
                { "Class\\(([^)]*)\\)", '["`]([^"`]*)["`]' },
                { "ClassX\\(([^)]*)\\)", '["`]([^"`]*)["`]' },
                { "ClassIf\\(([^)]*)\\)", '["`]([^"`]*)["`]' },
                { "Classes\\(([^)]*)\\)", '["`]([^"`]*)["`]' },
              },
            },
          },
        },
      },
    },
  },
}
```

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
This commit is contained in:
Torbjørn Vatn
2025-10-20 11:07:12 +02:00
committed by GitHub
parent 9d345dec44
commit d2f9885d6b

View File

@@ -24,6 +24,20 @@ return {
filetypes_include = {},
-- to fully override the default_config, change the below
-- filetypes = {}
-- additional settings for the server, e.g:
-- tailwindCSS = { includeLanguages = { someLang = "html" } }
-- can be addeded to the settings table and will be merged with
-- this defaults for Phoenix projects
settings = {
tailwindCSS = {
includeLanguages = {
elixir = "html-eex",
eelixir = "html-eex",
heex = "html-eex",
},
},
},
},
},
setup = {
@@ -39,17 +53,6 @@ return {
return not vim.tbl_contains(opts.filetypes_exclude or {}, ft)
end, opts.filetypes)
-- Additional settings for Phoenix projects
opts.settings = {
tailwindCSS = {
includeLanguages = {
elixir = "html-eex",
eelixir = "html-eex",
heex = "html-eex",
},
},
}
-- Add additional filetypes
vim.list_extend(opts.filetypes, opts.filetypes_include or {})
end,