Repository: sublimelsp/LSP

Issue:
Additional gutter icons for diagnostics severities
I want to ask what you think about an additional gutter icon set for the different diagnostics severities. I adjusted a few lines of the code and added another option value for the "diagnostics_gutter_marker" setting (e.g. "symbols") for it. Here is how it looks like in the Monokai, Mariana and Brackets schemes (f.l.t.r.):

![icons](https://user-images.githubusercontent.com/6579999/81484120-8597be80-9243-11ea-8adc-47be6f5b90cf.png)

The icons source are colored [SVG icons](https://github.com/microsoft/vscode-codicons) from VS Code. I removed the color and converted them to PNG for use in Sublime.

I didn't made a pull request yet because I wanted to hear some opinions first, and want to be sure to have no license violation. The original icons are released under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode), so I believe we could use them as long as we give attribution and include the license file.

What do you think about it?


Discussion:
I feel they are kinda big. I'd think they should be no higher than the height of the line number.
That should also give it a bit more padding horizontally.
But I like the idea.
SublimeLinter also has many, many icons.
https://github.com/SublimeLinter/SublimeLinter/tree/master/gutter-themes
> SublimeLinter also has many, many icons.

Interesting reference, but it looks like they have only `error` and `warning`, and all of them (but one simple circle) are colored images. I rather would prefer not to use predefined colors, so that the actual icon color is determined by the color scheme instead. Just like the icons from the adaptive theme that we already use ("dot", etc.).

> I feel they are kinda big. I'd think they should be no higher than the height of the line number.
> That should also give it a bit more padding horizontally.

I've experimented a bit, and the problem is that the gutter icons don't scale with the "font_size" setting. That means the relative size compared to the line hight strongly depends on the used font and font size, so it is a bit difficult to find the optimal size for all users. And vertical alignment depends on the font as well. If I make them too small, they will lose details pretty quickly, because they are only a few pixels wide anyway (at least with default "ui_scale" setting and 16x16 pixel icons).

There is also a recent issue on the Sublime issue tracker about blurry rescaled icons with small font sizes: https://github.com/sublimehq/sublime_text/issues/3320

https://github.com/sublimehq/sublime_text/issues/3320#issuecomment-623162351 suggests 15x15 pixel size for better quality, however I am oddly experiencing the exact opposite here. For me 16x16 pixel icons look sharp, and when I use 15x15 icons they get rescaled to 16x16 pixel and become blurry (see images below).

I've made some more images with default "ui_scale", Full HD display, on Windows, ST 3211, and different font sizes. Click on images for bigger view. Personally I use Fira Code with font size `10.5`. I made the icons a tiny bit (1px) smaller now, in comparison with the image from the first post.

### 16x16 pixel icons

![icons_16x16](https://user-images.githubusercontent.com/6579999/81621236-30e47700-93ee-11ea-9fda-e2b4497f2953.png)
![icons_16x16_consolas](https://user-images.githubusercontent.com/6579999/81621247-3477fe00-93ee-11ea-94bf-60b34f6a6197.png)

### 15x15 pixel icons (same icons as before, just 1 pixel cut off from the 16x16 version - looks blurry for me)

![icons_15x15](https://user-images.githubusercontent.com/6579999/81621276-4b1e5500-93ee-11ea-9f84-a8c9dd759cb5.png)

### 32x32 or 48x48 pixel icons with "ui_scale": 1.25 and 1.5

![icons_ui_scale](https://user-images.githubusercontent.com/6579999/81621290-56718080-93ee-11ea-9b5b-0002c8d59790.png)

I guess I could make the 32x32 and 48x48 pixel versions a bit smaller if desired. But again, the actual size strongly depends on the font size, so feedback from high DPI displays and your own used font sizes would be welcome. I will make a pull request shortly.

Note to myself for conversion settings used here: 

| scale | icon size | canvas size svg import | added margin left+top (px) | added margin right+bottom (px) |
| ----- | --------- | ---------------------- | -------------------------- | ------------------------------ |
| 1x | 16x16 | 14x14 | 0 | 2 |
| 2x | 32x32 | 28x28 | 1 | 3 |
| 3x | 48x48 | 42x42 | 2 | 4 |
I have QHD and 15' Retina here so could test on those if you prepare PR.
We could pick whatever works in most cases.
(I wish SVGs would be supported...)

Resolving patch:
diff --git a/plugin/diagnostics.py b/plugin/diagnostics.py
--- a/plugin/diagnostics.py
+++ b/plugin/diagnostics.py
@@ -257,8 +257,18 @@ def end(self) -> None:
             if severity in self._regions:
                 regions = self._regions[severity]
                 scope_name = diagnostic_severity_scopes[severity]
+                if settings.diagnostics_gutter_marker == "sign":
+                    diagnostic_severity_icons = {
+                        DiagnosticSeverity.Error: "Packages/LSP/icons/error.png",
+                        DiagnosticSeverity.Warning: "Packages/LSP/icons/warning.png",
+                        DiagnosticSeverity.Information: "Packages/LSP/icons/info.png",
+                        DiagnosticSeverity.Hint: "Packages/LSP/icons/info.png"
+                    }
+                    icon = diagnostic_severity_icons[severity]
+                else:
+                    icon = settings.diagnostics_gutter_marker
                 self._view.add_regions(
-                    region_name, regions, scope_name, settings.diagnostics_gutter_marker,
+                    region_name, regions, scope_name, icon,
                     UNDERLINE_FLAGS if settings.diagnostics_highlight_style == "underline" else BOX_FLAGS)
             else:
                 self._view.erase_regions(region_name)


Test patch: