openlawlibrary / pygls

A pythonic generic language server
https://pygls.readthedocs.io/en/latest/
Apache License 2.0
546 stars 101 forks source link

Add example server for `textDocument/rename` and `textDocument/prepareRename` #452

Closed alcarney closed 2 months ago

alcarney commented 2 months ago

Description (e.g. "Related to ...", etc.)

Continuing the trend of adding example servers and end-to-end tests, this PR tackles the textDocument/rename and textDocument/prepareRename requests.

The implementation is no smarter than a naive search and replace (ideally the server should take into account language semantics), but it's enough to demonstrate the expected interaction with the client.

Screenshot_20240503_193708

This also includes a fix to ensure the ServerCapabilitiesBuilder correctly computes capabilities when defining a textDocument/prepareRename handler

Code review checklist (for code reviewer to complete)

alcarney commented 2 months ago

I think it'd be nice to have a brief description at the top of examples/servers/rename.py

Good point, the end user perspective could be a little tricky as it will vary between clients, though I suppose we could just say "in VSCode this does X". I'll try to do a proper documentation pass on these at some point - there's plenty that can be expanded upon (user experience, client capabilities etc.), I'm focusing on the test suite side of things atm as it's the main thing blocking me making progress on #418

That said, I'll make sure to include a description with the next one! :)

But it's minor, so approving ✅

Thanks!