AckslD / nvim-pytrize.lua

Easily navigate pytest parametrize entries and fixtures with neovim
26 stars 1 forks source link

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

Open fnune opened 1 year ago

fnune commented 1 year ago

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!

AckslD commented 1 year ago

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?

fnune commented 1 year ago

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.