nvim-pytrize.lua icon indicating copy to clipboard operation
nvim-pytrize.lua copied to clipboard

PytrizeJumpFixture: provide as a language server feature that responds to "go to definition" requests?

Open fnune opened this issue 1 year ago • 2 comments

I love PytrizeJumpFixture, but it would be great if it integrated with (e.g.) https://github.com/microsoft/pyright or other LSPs. Ideally, I'd just use my "go to definition" keybinding, and the result of PytrizeJumpFixture would be available among the results.

I don't know how one would go about doing this without further investigation, but I think the issue is relevant.

Thank you for your plugin!

fnune avatar Apr 29 '23 12:04 fnune

Would be cool if it's indeed more similar to normal go-to-definition. I doubt that pyright would integrate this though since its related to an external package and I guess cannot really be resolved statically (ie you have to run pytest --fixture.

Anyway, maybe one can somehow write a standalone LSP (not sure how much work that is), or hook into the LSP client of neovim. For example, we could make our own handler for sending the request and check (eg using treesitter) if the node under the cursor is an argument of a function in a test-file. If so we call out to PytrizeJumpFixture instead of sending the request to pyright or other LSP.

If useful I shared a snippet sometime ago on how to for example get notified when the LSP has no response: https://www.reddit.com/r/neovim/comments/12fburw/feedback_when_lsp_dont_find_definition/

Any thoughts?

AckslD avatar May 01 '23 16:05 AckslD

Anyway, maybe one can somehow write a standalone LSP (not sure how much work that is)

An LSP that provides just this for pytest would certainly be useful to all editors/IDEs that support multiple completion providers for one buffer (which I guess is all of them?). Then I could have pyright alongside that other thing, and the client could just disambiguate between the "go to definition" sources.

I'll see whether I have some time to give this a go.

fnune avatar May 02 '23 08:05 fnune