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

Use box-style for multiline doc highlights #1712

Merged
merged 5 commits into from
Jun 4, 2021
Merged

Conversation

rwols
Copy link
Member

@rwols rwols commented Jun 1, 2021

Related: #1710

I've removed the "squiggly", "dotted" and "box" options for single-line highlights. "fill" and "underline" are possible. When set to "fill", "fill" is used for multi-line as well.

@rchl
Copy link
Member

rchl commented Jun 2, 2021

The comment above the document_highlight_style should be updated also.

@rchl
Copy link
Member

rchl commented Jun 2, 2021

The fill style looks bad but it was like that before also:

Screenshot 2021-06-02 at 09 06 29

@rchl
Copy link
Member

rchl commented Jun 2, 2021

In on_selection_modified_async there should also be a user pref check added.

plugin/documents.py Outdated Show resolved Hide resolved
plugin/core/types.py Outdated Show resolved Hide resolved
plugin/documents.py Outdated Show resolved Hide resolved
@rwols rwols requested a review from rchl June 2, 2021 21:36
@rchl
Copy link
Member

rchl commented Jun 3, 2021

In on_selection_modified_async there should also be a user pref check added.

Still not addressed.

And also:

The comment above the document_highlight_style setting in the LSP.sublime-settings should be updated also.

Otherwise looks very good.

@rwols rwols requested review from rchl and removed request for rchl June 3, 2021 21:30
Copy link
Member

@rchl rchl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

@rchl rchl merged commit 940c918 into main Jun 4, 2021
@rchl rchl deleted the feat/refine-highlights branch June 4, 2021 07:12
@agnivade
Copy link

I am very surprised with this change. I would be totally fine with changing the default to underline, but removing the other settings altogether seems like an extreme step, and is affecting my setup choices.

I do not like underline at all, and want to use stippled. What choice do I have as an user apart from directly hot-wiring the code?

@rwols
Copy link
Member Author

rwols commented Jun 13, 2021

Thanks for actually looking at possible customization points. The vast majority of users don't actually do that.

We traded settings-maintenance-burden complexity with overall better default behavior here. This project is maintained by volunteers in their free time so if you really need stippled customizability, feel free to make a pull request and maintain the behavior in the long run.

What you can also do is use fill and set up your color scheme overrides (by running UI: Customize Color Scheme from the command palette) so that it'll behave somewhat like VSCode.

So for instance for my Mariana color scheme I have this override file:

{
    "rules": [
        {
            "scope": "markup.error",
            "foreground": "hsl(357, 79%, 65%)"
        },
        {
            "scope": "markup.warning",
            "foreground": "hsl(32, 93%, 66%)"
        },
        {
            "scope": "markup.info",
            "foreground": "hsl(0, 0%, 100%)"
        },
        {
            "scope": "markup.info.hint",
            "foreground": "hsl(0, 0%, 97%)"
        },
        {
            "scope": "markup.highlight.text",
            "background": "color(var(white2) alpha(0.2))"
        },
        {
            "scope": "markup.highlight.read",
            "background": "color(var(green) alpha(0.2))"
        },
        {
            "scope": "markup.highlight.write",
            "background": "color(var(red2) alpha(0.2))"
        },
        {
            "scope": "markup.unnecessary.lsp",
            "foreground": "color(rgb(255, 255, 255) alpha(0.4))",
            "background": "color(var(blue3) alpha(0.9))"
        }
    ],
}

resulting in:

image

See: https://lsp.sublimetext.io/customization/#document-highlights

@agnivade
Copy link

Thanks, yep totally with you on the burdens of open source. Doesn't look like I can do a stippled line via a color scheme override, so I'll have to maintain my own git patch.

Thanks for all your work!

@jwortmann
Copy link
Member

You could for example set the underline color to 50% opacity via "foreground" in the color scheme rule, then it doesn't look much different from the dotted style:

stippled

underline

But I must say I actually considered to suggest keeping the "stippled" style option when I saw this PR, but then I changed my mind because I don't need it personally and the default has been "underline" even before iirc. I guess the motivation was that "stippled" is now used for the diagnostics with severity info and hint, so currently it's ensured that the document highlights are not only distinguishable by color, but also by the drawing style.

However, the "settings maintenance burden" is only two lines of code (plus re-adding that option in the settings description and .sublime-package schema). Maybe it's reasonable to keep that style option?

diff --git a/plugin/core/types.py b/plugin/core/types.py
index 49fdd3b..512bdcb 100644
--- a/plugin/core/types.py
+++ b/plugin/core/types.py
@@ -235,6 +235,8 @@ class Settings:
     def document_highlight_style_region_flags(self) -> Tuple[int, int]:
         if self.document_highlight_style == "fill":
             return sublime.DRAW_NO_OUTLINE, sublime.DRAW_NO_OUTLINE
+        elif self.document_highlight_style == "stippled":
+            return sublime.DRAW_NO_FILL, sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE
         else:
             return sublime.DRAW_NO_FILL, sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE

@agnivade
Copy link

I guess the motivation was that "stippled" is now used for the diagnostics with severity info and hint, so currently it's ensured that the document highlights are not only distinguishable by color, but also by the drawing style.

Yep I get that. But 99% of the time, I place my cursor under a symbol to get a feeling of other symbols around it. That overshadows my workflow far more than the times I need diagnostics for info and hint. (And if needed, I'd want to be able to customize it).

However, the "settings maintenance burden" is only two lines of code (plus re-adding that option in the settings description and .sublime-package schema). Maybe it's reasonable to keep that style option?

I'd really like that. However, I think I might fall into the 1% here, so I'd let you guys take the call. Thanks for pasting the snippet btw!

@thewchan
Copy link

I'd like to add myself to the 1% here, it was kinda confusing and disappointing to see those appearance customization options disappeared.

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 this pull request may close these issues.

5 participants