-
Notifications
You must be signed in to change notification settings - Fork 215
Neovim completion is not working in monorepos #1338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide a reproduction repository so I know what the general project structure is? Our Language Server generally supprts multiple configs and bases that off of the |
Here is a dummy repository that shows the issue: https://github.com./tomaszsympi/tw-nvim-mono Steps:
|
@tomaszsympi Looks like that repo isn't public (it 404s) |
@thecrypticace fixed! Sorry, lol. |
All good! I just checked it the project and it seems to work for me but I'm testing in Zed which also uses our language server. I haven't directly tested in Neovim (yet) but I suspect that this is a quirk of the Neovim LSP implementation. The neovim LSP configs for Tailwind CSS appears to look for a tailwind config file or a package.json relative to the opened file / buffer: https://github.com./neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/tailwindcss.lua#L113-L114 I assume what is happening is that in a monorepo a file like Neovim then uses this information to start the language server and uses it as the root of the workspace folders (see https://neovim.io/doc/user/lsp.html#vim.lsp.Config) This would mean the LSP is basically started as if it were inside If that is what is happening then I don't think we can fix that — but I'll have to give it a test a bit later to verify. |
@thecrypticace cursor/zed/vsc work fine, yeah. Thank you for the explanation! I think this is most likely what happens. I will try to move out of nvim-lspconfig to my own lsp config then. Thx again. |
So this root_dir is cached on Neovim level? Per session? Interesting! |
So I tried to disable Btw., I also noticed that the "completion issue" is fixed after adding this line: -- options.lua
vim.lsp.enable({
"tailwindcss",
}) Weird 🤔 . Edit: I'm using LazyVim distro. I will open an issue there. Thx! |
I’ve discovered that the TailwindCSS LSP picks its
root_dir
from the first package I open which containstailwind.config.ts
file —so when I jump into a different package in my monorepo, I lose all completions until I manually restart the server.To work around this, I’ve hooked into
BufEnter
/InsertEnter
and written a tiny utility that:tailwind.config.ts
for the current bufferroot_dir
tailwindcss
LSP if the root_dir has changedIt works, but feels hacky. Is there a cleaner way to make the TailwindCSS LSP automatically pick up each package’s config in a monorepo (e.g. by customizing root_dir in lspconfig)? I can’t hoist the config to the root because the tailwind config differs between packages.
Additional info:
Tailwind LSP: v0.14.16
Tailwind: v3
package manager: pnpm
The text was updated successfully, but these errors were encountered: