Afourcat / treesitter-terraform-doc.nvim

A simple neovim plugin that use treesitter to find resource in context and open the url on your favorite web browser.
MIT License
23 stars 2 forks source link

Support Terraform providers that aren't in the hashicorp namespace #1

Closed andrewferrier closed 2 years ago

andrewferrier commented 2 years ago

Hi - thanks for writing this great plugin. It has the potential to be super-useful.

I did notice, though, that it doesn't work for Terraform providers that aren't in the hashicorp namespace. For example, I'm a fairly frequent user of both of these providers:

Yet, these do not work with this plugin, as it assumes they have a hashicorp namespace, like this:

I assume this may be tricky, as (I think) the only definitive source of that info is in the required_providers block (not necessarily in the same file as the resource I'm trying to look up) - but it would definitely make it a lot more useful, to me at least.

Thanks for your hard work in contributing to the NeoVim community!

Afourcat commented 2 years ago

Hello @andrewferrier, As you said, this seems difficult, but I can think of 2 solutions right now:

  1. Register in the user config prefixes like "ibm_*" redirecting to a specific registry, and fallback on the hashicorp namespace when nothing match.

  2. Use the lsp capabilities to get the nearest required_providers. I'm not sure if this is possible, but, this would be the cleanest implementation I think.

I hope this plugin is helpful to you anyway.

Integralist commented 2 years ago

👋🏻

Yeah I noticed this too just now after installing 🙂

https://registry.terraform.io/providers/hashicorp/fastly/latest/docs/resources/service_vcl

should be

https://registry.terraform.io/providers/fastly/fastly/latest/docs/resources/service_vcl

Afourcat commented 2 years ago

Hello @Integralist, thank you for showing your interest. As said just before, the implementation is not trivial. Have you any insight on which implementation should I work on for you to be the most productive?

andrewferrier commented 2 years ago

@Afourcat I think (1) sounds the simplest to implement. (2) could get very complicated very quickly.

I've been trying to figure out if there is some predictable mapping so you can derive e.g. scottwinkler from shell (i.e. the Terraform resource prefix), but I cannot see a way that's done - it's just in versions.tf as best I can tell.

Suggestion - you maintain in the plugin an internal mapping. Then folks like me can contribute to it over time with pull requests etc. You also support the user adding to this mapping with their own personal config, and encourage people in the README to contribute back.

Integralist commented 2 years ago

This sounds good to me...

Suggestion - you maintain in the plugin an internal mapping. Then folks like me can contribute to it over time with pull requests etc. You also support the user adding to this mapping with their own personal config, and encourage people in the README to contribute back.

Afourcat commented 2 years ago

Hello @andrewferrier @Integralist. I think the feature is ready to be tested. If you want to give it a try, you can switch the branch to this one. Feel free to give a feedback 👍

Integralist commented 2 years ago

Great. Will check it out in my morning. Thanks!

Integralist commented 2 years ago

Can confirm that branch works great now 👍🏻 Thanks!

andrewferrier commented 2 years ago

This works well for me! Thanks.

Afourcat commented 2 years ago

I'm merging into master 🚀