From af4a9f5ce58763365999bfc558ddecd20d41f2b7 Mon Sep 17 00:00:00 2001 From: David Bernheisel Date: Fri, 9 May 2025 20:44:12 -0400 Subject: 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. --- lua/lspconfig/util.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lua/lspconfig') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 5d9c213c..979766ae 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -68,6 +68,27 @@ function M.insert_package_json(config_files, field, fname) return config_files end +--- Appends mix.exs files to the `config_files` list if `field` +--- is found in any such file in any ancestor of `fname`. +--- +--- NOTE: this does a "breadth-first" search, so is broken for multi-project workspaces: +--- https://github.com/neovim/nvim-lspconfig/issues/3818#issuecomment-2848836794 +function M.insert_mix_exs(config_files, field, fname) + local path = vim.fn.fnamemodify(fname, ':h') + local root_with_mix = vim.fs.find({ 'mix.lock' }, { path = path, upward = true })[1] + + if root_with_mix then + -- only add package.json if it contains field parameter + for line in io.lines(root_with_mix) do + if line:find(field) then + config_files[#config_files + 1] = vim.fs.basename(root_with_mix) + break + end + end + end + return config_files +end + -- For zipfile: or tarfile: virtual paths, returns the path to the archive. -- Other paths are returned unaltered. function M.strip_archive_subpath(path) -- cgit v1.2.3-70-g09d2