Skip to content

Conversation

@colbat
Copy link
Contributor

@colbat colbat commented Oct 16, 2025

Problem

Root directory is incorrect for projects containing a package.json file in subdirectories.

For a project with a given file structure:

my-monorepo/
├── package.json
├── yarn.lock
├── css/
│   └── css-variables/
│       ├── color.css
│       └── typography.css
└── components/
    └── core/
        └── my-feature/
            ├── package.json           ← 2. causes LSP root to stop here
            ├── feature-component-a/
            │   └── feature-component-a.module.css           ← 1. current open buffer 
            └── feature-component-b/
                └── feature-component-b.module.css

The LSP is using my-feature as the root directory. This directory is not the one where the css variables are defined. It leads to an issue where the css variables are not indexed, and from feature-component-a.module.css auto-completion and jump to definition are not working.

Solution

Using the same root_dir logic as ts_ls (which prefers lockfiles like yarn.lock or .git as root markers) correctly sets the project root to my-monorepo/, allowing css/css-variables/ to be discoverable for the LSP.

Problem:
Root directory was incorrect for projects containing a package.json
file in subdirectories.
@justinmk justinmk merged commit ad9f259 into neovim:master Oct 20, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants