I am developing a grafana datasource plugin, I have seen the prometheus/loki datasource source code, and I found they use languageProvider, I can’t understand it by its name, and the official document doesn’t describe it very clearly. So my question is how to understand the languageProvider, what functions it provides?
I’ve recently spent some time digging into this myself. If you want to look at an, arguably, simpler example that Prometheus/Loki, you can check out what I did.
Assuming you’re using the QueryField component from @grafana/ui, really the only thing the language provider does is to provide completion items to the onTypeahead callback. While there’s a LanguageProvider interface in the Grafana packages, I haven’t yet actually found any reason for its existence
You can call it something else if you’d like, you don’t have to extend the interface.
I’ve tried to keep the language provider relatively self-contained and documented. I don’t fully understand it myself yet, but I’ll add docs for it when I learn more.