Skip to content

includeDeclaration is not respected when enumerating references #2126

Description

@acooper-akamai

Describe the Bug

Most LSPs support a parameter includeDeclaration when enumerating references which informs the LSP to include or exclude the symbol's declaration in its references. I prefer to have it off, but I don't seem to be able to do so with Pyrefly.

As a simple example, in the code

def foo() -> None:
    ...

foo()
foo()

Opening the references in neovim shows the following:

foo.py|1 col 5-8| def foo() -> None:
foo.py|4 col 1-4| foo()
foo.py|5 col 1-4| foo()

I'd prefer it to show just the bottom 2 lines, but passing includeDeclaration = false to the native LSP interface doesn't seem to do it for me. This does work for me with other LSPs like rust-analyzer. The full command to test is

:lua vim.lsp.buf.references({ includeDeclaration = false })

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSImMYABGLrgBQCUNAtAHw0Byu6MiADroaomsQBOEdABdGg8AwXNhw%2BkxXp1LYSAA0IAK4zocEuUQgAxDQCqJqBBmk6h9AGMTfOKqzU6uBIAtqgyAProhkHYMBKM%2BIg00jKsnDRwMhJCImISMDKGEiJgCtxRMVk0wPgAvgq6BmR5YFCkhDK4QVAUNgAKpM2t6Rg4BDTufJAA5oWhEHyEwjYAyjAwNAAWMjLEcIgA9PtN1K2EgVP7MOj7mLjucPsTWhAzEnN8%2BwESNKgAbqjQVDYWDjSYvWZeES4YiQszCMgyDZ8Ni-WJweYiAC8NAUAGZCABGABM9XQIBqBlQnggqIAYtAYBQ0Fg8EQyOSgA

(Only applicable for extension issues) IDE Information

$ nvim --version
NVIM v0.11.4
Build type: Release
LuaJIT 2.1.1741730670

Metadata

Metadata

Assignees

Labels

help wantedLarger than "good first issue", but still well-defined and ready for someone to pick uplanguage-serverIssues specific to our IDE integration rather than type checking

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions