Skip to content

Adds document_symbol support for pyrefly#78

Open
jackd wants to merge 2 commits intobug-ops:mainfrom
jackd:pyrefly-document-symbol
Open

Adds document_symbol support for pyrefly#78
jackd wants to merge 2 commits intobug-ops:mainfrom
jackd:pyrefly-document-symbol

Conversation

@jackd
Copy link
Copy Markdown

@jackd jackd commented Mar 27, 2026

Adds document_symbol support for pyrefly

I originally wrote this as an issue, but since I had the fix I thought I might as well offer it. I want to be completely up front and admit I'm not a rust person, this was agent-authored, and I'm not going to pretend to understand it. I hope that doesn't offend anybody, and I similarly won't be offended if this PR is promptly rejected on that basis.

I could have added tests, but given I wouldn't understand them either I don't see the value of including that to that project.

What I can say is the document_symbol didn't work with pyrefly before the change, and it did afterwards.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Checklist

  • I have read the CONTRIBUTING guide
  • My code follows the project's coding style
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass
  • I have updated the documentation accordingly
  • I have updated the CHANGELOG.md (for user-facing changes)

Additional Notes

Config that works with it:

[[workspace.language_extensions]]
extensions = ["py", "pyw", "pyi"]
language_id = "python"

[[lsp_servers]]
language_id = "python"
command = "pyrefly"
args = ["lsp"]
file_patterns = ["**/*.py"]

@github-actions github-actions bot added rust Rust code changes mcpls-core mcpls-core crate changes labels Mar 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the LSP client initialization handshake to advertise textDocument/documentSymbol support, improving compatibility with servers like pyrefly that may gate symbol responses on declared client capabilities.

Changes:

  • Add text_document.document_symbol client capabilities during LSP initialize.
  • Enable hierarchical document symbol support (hierarchical_document_symbol_support: true).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 293 to +298
text_document: Some(lsp_types::TextDocumentClientCapabilities {
document_symbol: Some(lsp_types::DocumentSymbolClientCapabilities {
dynamic_registration: Some(false),
hierarchical_document_symbol_support: Some(true),
..Default::default()
}),
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds document_symbol to the client capabilities, but there’s no test asserting that the initialize request includes this capability. Since this module already has unit tests, consider adding a small unit test (or factoring out capability construction) to prevent regressions where document_symbol support is accidentally dropped again.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcpls-core mcpls-core crate changes rust Rust code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants