Skip to content

Pyrefly LSP fails to find all references in large monorepo project (Neovim integration) #2039

@angbon

Description

@angbon

Describe the Bug

Pyrefly LSP integration with Neovim is not functioning correctly when working with large monorepo projects. Core LSP features like "Find References", "Rename Symbol", and file renaming with import updates are only partially working, significantly impacting development workflow in large codebases.

Environment

  • Editor: Neovim
  • LSP Client: nvim-lspconfig
  • Pyright Version: 0.47.0
  • Operating System: macOS Darwin 25.1.0
  • Project Type: Large Django monorepo
  • Project Size:
    • ~13.7 million lines of Python code
    • ~113,000 Python files
    • ~143,000 total files

Current Behavior

  1. Find References (vim.lsp.buf.references()):

    • Only finds references in currently opened buffers
    • Shows the definition location
    • Misses references in unopened files throughout the codebase
  2. Rename Symbol (vim.lsp.buf.rename()):

    • Does not work
  3. File Rename with Import Updates:

    • Does not update import statements when renaming/moving files
    • Import references remain pointing to old file paths

Expected Behavior

  • Find References: Should discover ALL references across the entire project, regardless of whether files are open in buffers
  • Rename Symbol: Should rename all occurrences project-wide, including in unopened files
  • File Rename: Should automatically update all import statements that reference the renamed/moved file

Steps to Reproduce

  1. Clone a large Python monorepo
  2. Open Neovim with Pyrefly LSP configured
  3. Navigate to any function/class definition
  4. Try to find all references using LSP references command
  5. Observe that only references in open buffers are shown
  6. Try renaming a symbol that's used across multiple files (with most files closed)
  7. Observe that rename only affects open buffers

Additional Context

  • This issue does NOT occur in smaller repositories - LSP features work as expected in smaller Python projects
  • The project uses standard Python import patterns and Django structure
  • The repository structure includes:
    • Multiple Django apps
    • Plugin architecture with client/territory specific code
    • Extensive test suite
    • Complex import hierarchy
  • This issue does NOT occur with other LSPs - LSP features like find references or symbol renaming do work as expected.

Impact

This issue severely impacts developer productivity in large codebases, making refactoring operations risky and time-consuming as developers cannot rely on automated tools to find all usages or update references correctly.

Relevant conversation in Discord

Metadata

Metadata

Assignees

No one assigned

    Labels

    language-serverIssues specific to our IDE integration rather than type checkingneeds-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions