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

Help Developing Plugin: How can I show integrated documentation of a Pin added by a Convention? #636

Open
brettimus opened this issue Feb 22, 2023 · 0 comments

Comments

@brettimus
Copy link

brettimus commented Feb 22, 2023

Hi! I am developing a plugin, and I'm not sure if I'm doing things the correct way.

Mainly, I just want to provide additional documentation for certain methods or symbols.

As a first step, I was trying to simply show a tooltip on hover. I created a pin for a token in the AST, and added a random doc string.

I couldn't seem to get anything to show up in the VS Code extension.

I verified that

  • The plugin was loaded properly
  • The plugin was adding a valid pin

Whenever solargraph looked for definitions given a cursor position, I noticed that the source_map pins that it looked for did not include the pin that my plugin added.

I was able to resolve this by having SourceMap::Clip#define also consider the pins of the source_map's environment: source_map.environ.pins.

More specifically, I changed the line that I linked to above to be the following:

        result.concat((source_map.pins + source_map.environ.pins + source_map.locals).select{ |p| p.name == cursor.word && p.location.range.contain?(cursor.position) }) if result.empty?

I made this change since all the Pins added by Conventions are stored on the source_map's environ property, but not on the source_map's pins attr. (See: here)

To me, this seems like expected behavior. If my plugin creates a Pin with additional documentation for something in the file, then it should be able to be picked up by the language server, right?

Thanks for reading!

@brettimus brettimus changed the title Help Developing Plugin: How can I show integration documentation of a pin added by a Convention? Help Developing Plugin: How can I show integrated documentation of a Pin added by a Convention? Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant