15 Commits

Author SHA1 Message Date
Omar Elhawary
8caef47d1d
fix(tailwindcss): revert broken config detection #4376
Problem:
`find_tailwind_global_css` attempted to address #4204, where `experimental.configFile` was set using the return value of `vim.fs.find()`.
The language server rejected this with `Invalid experimental.configFile
configuration, not initializing` because `configFile` expects either a string or
a key-value record (object), not an array/list. This was a syntax issue, not
a detection issue.

Using the correct syntax for `configFile` in Lua should be
sufficient to address the original issue. Right now, `find_tailwind_global_css`
always runs for users who haven't explicitly set `configFile` — overriding the
LSP's native detection and **forcing anyone who wants to opt out to manually set
all entry-points by hand.**

Solution:
- Remove `find_tailwind_global_css` entirely and restores `configFile` to its
  default `nil` so the `tailwindcss` LSP handles project detection natively.
- Simplify `before_init` based on [this suggestion from the initial
  PR](https://github.com/neovim/nvim-lspconfig/pull/4222#discussion_r3018499628).

The following syntax worked for me while testing to explicitly set the
`configFile` based on the [official
docs](https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssexperimentalconfigfile)
for single entry-point:

> [!NOTE]
> Single entry-point is resolved relative to the workspace root (`root_dir` — verify with `:checkhealth vim.lsp`)

```lua
vim.lsp.config('tailwindcss', {
  settings = {
    tailwindCSS = {
      experimental = {
        -- v3: config file
        configFile = 'tailwind.config.js',
        -- v4: CSS entry-point
        -- configFile = 'src/styles/app.css',
      },
    },
  },
})
```

For projects with multiple entry-points, or different projects, the following
syntax can be used for multiple entry-points:

> [!NOTE]
> Keys are relative to `root_dir` as above, but from my testing on macOS, absolute paths worked better

```lua
vim.lsp.config('tailwindcss', {
  settings = {
    tailwindCSS = {
      experimental = {
        configFile = {
          ['tailwind.config.js'] = '/Users/username/path/to/project-a/**',
          ['src/main.css'] = '/Users/username/path/to/project-b/**',
        },
      },
    },
  },
})
```

#### Project or Local Configuration

For project-specific settings without modifying your global Neovim config:

1. Enable in your Neovim config:
   ```lua
   vim.o.exrc = true
   ```
2. Create `.nvim.lua` in the project root:
   ```lua
   vim.lsp.config('tailwindcss', {
     settings = {
       tailwindCSS = {
         experimental = {
           configFile = 'tailwind.config.ts',
         },
       },
     },
   })
   ```
3. Open `.nvim.lua` and run `:trust` to allow the file, then restart Neovim.
4. Verify with `:checkhealth vim.lsp`.
2026-04-05 10:33:03 -04:00
besserwisser
fe209bc10c
feat(tailwindcss): support multiple import patterns #4371 2026-04-03 14:43:21 -04:00
KhaNguyen
23bfb2a76b
fix(tailwindcss_ls): add experimental.configFile to support Tailwind v4 #4222 2026-03-31 17:20:42 -04:00
Yi Ming
89fd0361b3 docs: apply auto-generated annotations to LSP configs 2026-03-13 23:39:05 +08:00
David
82af15ba58
fix(tailwindcss): dynamic registration for didWatchChangedFiles #4206
Not having this was leading to the lsp falling back to watching *all* files,
and causes nasty side effects such as https://github.com/DopplerHQ/cli/issues/502
2025-11-20 14:57:45 -08:00
Igor
030a72f0aa chore: add type annotation for configs 2025-08-18 23:39:23 -03:00
Joshua Sattler
3db16ceeea
fix(tailwindcss): use ".git" root marker fallback for tailwind v4 #3980
Since tailwind v4 it is not required to have a tailwind.config.* in
the project 1. The current configuration is preventing the LSP to attach to the configured file types in cases when no tailwind.config.* or none of the other markers (package.json etc.) is present. This commit fixes this limitation by providing .git as a fallback and by documenting this limitation.
2025-07-29 18:02:51 -07:00
Stuart Fraser
1ddc1a2e69
feat(tailwindcss): root_dir for rails/phoenix #3935
The location of the config in Rails and Phoenix does not represent the
root of the project. We can look inside mix.lock and Gemfile.lock for
the existence of tailwind, which guarantees that it's the root.
2025-07-03 09:51:41 -07:00
ndlrfz
8adb3b5938
feat(tailwind): add "postcss.config.js" root marker #3884
The new `django-tailwind` package comes with the Tailwind
CSS 4 by default, which migrated to the `postcss.config.js`.
2025-06-02 03:46:06 -07:00
David Bernheisel
4ed821c76f
feat(tailwindcss): detect tailwind in rails django phoenix #3834
This is copying some additions that tailwind-tools.nvim makes. There
are web frameworks such as Rails, Django, and older Phoenix that places
tailwind config files in asset folders.
2025-05-22 02:41:56 -07:00
David Bernheisel
1e4f1a6538
feat(tailwindcss): map elixir and heex ft to phoenix-heex #3854
tailwind-intellisense won't activate unless the filetype is detected
as an HTML-based file. Elixir `.ex` files can have `~H` sigils with
HEEX syntax inside or `~E` sigils with eelixir syntax. It's also typical
to have `.html.heex` files entirely of HEEX syntax. Both of these are
recognized in Elixir's tree-sitter injections.scm
2025-05-22 02:36:14 -07:00
Justin M. Keyes
c671605ad0
refactor: generalize insert_package_json() #3833 2025-05-10 07:42:35 -07:00
David Bernheisel
af4a9f5ce5
feat(tailwindcss): add detection for Phoenix projects #3831
Enhance root directory detection for the latest versions of
TailwindCSS v4, which no longer require tailwind.config.* or
postcss.config.*.

For Phoenix projects, they are typically generated or add Tailwind
installed via https://github.com/phoenixframework/tailwind which will
now be detected by scanning the mix.lock file for the included package.

Phoenix projects that install tailwindcss via package.json should still
work.
2025-05-09 17:44:12 -07:00
Maksim Terpilovskii
36e6a86c9e
fix(tailwindcss): improve root dir detection for tailwind v4 #3765 2025-04-23 04:48:41 -07:00
Sasha
828aa3ded7
feat(tailwind): add vim.lsp.config support 2025-04-21 07:42:09 -07:00