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

Whitespace in popups could be better #105

Closed
braver opened this issue Sep 16, 2017 · 16 comments · Fixed by #176
Closed

Whitespace in popups could be better #105

braver opened this issue Sep 16, 2017 · 16 comments · Fixed by #176

Comments

@braver
Copy link
Contributor

braver commented Sep 16, 2017

Perhaps this is a bit too minor/visual for this stage of the package, but I'm a designer and it's bugging me 😁

screen shot 2017-09-16 at 13 50 24

Text sits too tight too the edge of the popup. At the same time there is an inexplicably large amount of space between the code fragment at the top and the documentation below. It looks worse if there isn't much documentation (e.g. it just says "function").

It would look better if the text aligns and margins are consistent all around.

better

I also noticed the phantoms are missing the little pointer nubbin that the build system phantoms have. This seems to be a function of using the mdpopups library. Are these things we can/should tune here, or should I try to land some enhancements in mdpopups?

@tomv564
Copy link
Contributor

tomv564 commented Sep 16, 2017

Agree absolutely, would love for a PR to fix the left margin and paragraph / code block spacing.
The HTML output may need to change as well?
Perhaps can also apply the sans-serif font ( issue #82 )?

Fixing the pointer on the phantoms is probably a question of taking the right bits of the large style sheet here: https://github.com/twolfson/sublime-files/blob/master/Packages/Default/exec.py#L395

@braver
Copy link
Contributor Author

braver commented Sep 16, 2017

If @rmccue isn't already upto something with this, I could look into this some time next week.

@rwols
Copy link
Member

rwols commented Sep 16, 2017

There's also the issue that we can't browse through other overloads like in VSCode.

@braver
Copy link
Contributor Author

braver commented Sep 16, 2017

@rwols could you point me to a demonstration of that?

@rwols
Copy link
Member

rwols commented Sep 17, 2017

I'm working on that right now, here's a prototype screenshot:

schermafbeelding 2017-09-17 om 10 31 28

I just dump all overloads to the popup box, but ideally, the "active" overload should be displayed, and the up and down arrow keys allow you to browse through the other overloads. The active parameter should be bold. This is how it's done in intelliSense in Visual Studio.

Anyway, this is somewhat of a separate issue but I thought I'd let you know of what I'm up to so you can keep it in mind for when you might change the layout.

@braver
Copy link
Contributor Author

braver commented Sep 17, 2017

@tomv564 How do you feel about the mdpopups dependency? I think if you want to do stuff like @rwols proposes it might not be as flexible as you'd like. I'd prefer having direct access to the HTML that comes out, but then again, I manipulate HTML and CSS all day every day and I can see how someone might not enjoy that 😉 What I'd like to attempt is to set up some basic elements we can re-use and tune it to the purposes at hand. It's not like it will take that much to style up a basic popup.

@rwols
Copy link
Member

rwols commented Sep 17, 2017

My implementation actually doesn't use mdpopups but plain-old HTML+CSS, please wait for the PR!

@braver
Copy link
Contributor Author

braver commented Sep 17, 2017

Well, there you go :)

@tomv564
Copy link
Contributor

tomv564 commented Sep 17, 2017

Agreed, if we're building UI then using markdown is not ideal. But mdpopups supports plain HTML and also provides us with syntax highlighting and user overrides. Are we really discussing replacing all that with code maintained in LSP?

@rwols
Copy link
Member

rwols commented Sep 17, 2017

The syntax highlighting from mdpopups should definitely be reused, that's super useful.

@braver
Copy link
Contributor Author

braver commented Sep 17, 2017

The user overrides are out-of-the-box from Sublime itself, it's no extra effort for us. Edit: not sure what mdpopups offers here, but syntax themes have full control over styling, and IIRC users can override that. Not sure why anyone would want to, but it's there.

The syntax highlight would be cool and useful. It doesn't necessarily work though if you're working with super small snippets.

@rwols
Copy link
Member

rwols commented Sep 17, 2017

Related: #111

@deathaxe
Copy link
Contributor

but syntax themes have full control over styling

mdpopups provides the same kind of flexibility and access to all html/css elements as well.

It's not about styling the mdpopups but syntax highlighting. mdpopups provide a <div class="highlight"> which you can put simple source code into. mdpopups will syntax highlight it the same way the editor does. I find this feature very useful and would like to see the code signatures of all the popups to be highlighted correctly.

LSP does not yet make use of the features mdpopups offers. You don't need to put pure text to the popup to let its markdown engine render it. You can also put normal html code with your own css. This what GitGutter uses for diff popup.

With mdpopups.syntax_highlight(view, source_content, **popup_kwargs) it can be used to highlight a piece of source code and re-use it in ordinary html. By using mdpopups you can ensure the basic elements are styled correctly using its default.css.

But on the other hand I find the syntax style being used by PackageDev to display information about the settings, well enough too. One headline (the signature), one line with a brief description followed by the docstring and maybe the list of arguments. I originally created that popup style for my CNC Sinumerik 840D package to display variable/function tooltips. Same use-case as for LSP.

The only missing thing what I'd like to see LSP to do is highlighting the active argument in the signature, if the cursor is within the argument list.

like def function( arg1, arg2, arg3)

@deathaxe
Copy link
Contributor

Are we really discussing replacing all that with code maintained in LSP?

With or without mdpopups. I think popup rendering needs a separate package as - i don't know in which format the different language servers provide their docstrings - each language might need a little different handling some day to provide a good experience. I already discussed something like that in the Jedi - Autocompletion package. Even in python, you have different styles of docstring. RST, markdown, google, numpy, ... All of them need different parsing to create a commonly styled output. I guess it even becomes worth with other languages. Therefore a kind of plugin infrastructure to handle different languages might be required.

language-server -> response -> popup render plugin -> output

where popup render plugin is an abstract interface for the real rendering plugin provided for a certain language/syntax. Maybe with some kind of format guessing - some day.

That's not so easy.

@tomv564
Copy link
Contributor

tomv564 commented Sep 19, 2017

To summarise the original issues and the new issues discussed in this thread

If I understand your suggestions in this thread, then we can more or less agree on standardising popups with:

  • Structure & Layout: HTML & CSS (through mdpopups if the below cases apply)
  • Code blocks: Use mdpopups (<div> or highlight call if necessary)
  • Server-provided documentation fields: Use mdpopups to render markdown/html.

Issues that this package probably shouldn't fix:

  • Other docstring formats: The protocol dictates only Markdown is allowed.
  • Standardising content in hover popups (there is no guaranteed structure in Hover.contents, language servers could be sending the function name after the documentation if they wanted to)

@deathaxe
Copy link
Contributor

Hover: Vertical spacing inconsistent with editor line spacing

Doesn't really matter in my opinion.

protocol dictates only Markdown

This is good to know, but the issue is markdown can be nearly everything. But this enables us to file an issue at python-language-server to create correct markdown for each kind of docstring. 😆 😈

The rest is 👍

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

Successfully merging a pull request may close this issue.

4 participants