Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Formalise require('treesitter-context.context').get() API #420

Closed
andrewferrier opened this issue Mar 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@andrewferrier
Copy link

andrewferrier commented Mar 19, 2024

Description

Hi, digging into the source for nvim-treesitter-context, I can see an API require('treesitter-context.context').get(bufnr, winnr). I've played with this and can see that it returns the context information as expected and indeed that nvim-treesitter-context obviously uses it for this too.

I'd be really interested in reusing this API in my own plugin debugprint.nvim. debugprint allows the user to add 'poor man' debugging statements into their own code easily. I'd love to offer the option to add context information to help the user correlate the output generated from that with their code, but that's hard to do in a generic sense.

I can see that you've put a lot of the hard effort into supporting this for a variety of languages here, and it would be great to reuse that by making nvim-treesitter-context a soft dependency which allows debugprint to add that information via the API. However, I really only want to do that if you were interested in (at least) semi-formalizing that API by documenting it and keeping it at least reasonably stable.

Is this something you'd be interested in? If you like the principle but don't have the time, I'd be happy to work on a pull request for nvim-treesitter-context to list it out in the README and 'document' it that way - that'd probably be sufficient for my purposes. Thanks.

@andrewferrier andrewferrier added the bug Something isn't working label Mar 19, 2024
@andrewferrier
Copy link
Author

For the record, this was the issue under which I was looking at implementing this capability.

@romgrk
Copy link
Collaborator

romgrk commented Mar 20, 2024

Sounds reasonable, only requires the API to stay stable so there's no effort beyond documenting it. I don't see the implementation needing a substantial refactor anytime soon, so it should stay stable. Feel free to open a PR. Ping @lewis6991, if you have any objection.

@romgrk romgrk added enhancement New feature or request and removed bug Something isn't working labels Mar 20, 2024
@andrewferrier
Copy link
Author

I think this can be closed. I realized this isn't practical for my purposes at least; nvim-treesitter-context is not a generalized "get me the context of where I'm sitting in my code" breadcrumbing tool; the logic of what's in view is also deeply ingrained. I don't want to untangle this too deeply and it could be too complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants