Skip to content

Commit a506ce1

Browse files
committed
Merge branch 'main' into refactor-custom-actions
* main: fix "Error rewriting command" warning triggered on startup (#2277) Take font style of sighelp active parameter from color scheme (#2279) Add argument "include_declaration" to "lsp_symbol_references" (#2275) fix crash on checking excluded folders with missing project data (#2276) Fix tagged diagnostics flickering on document changes (#2274) Cut 1.24.0 use class for diagnostic info instead of hardcoding color (#2257) Fix package storage path in a docstring description (#2256) Use regular font style in sighelp popup if already highlighted by color scheme (#2259) update note about custom color scheme rule used for diagnostics (#2254)
2 parents 5046fbe + 33c6497 commit a506ce1

19 files changed

+173
-104
lines changed

Default.sublime-keymap

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
{
6464
"keys": ["shift+f12"],
6565
"command": "lsp_symbol_references",
66-
"args": {"side_by_side": false, "force_group": true, "fallback": false, "group": -1},
66+
"args": {"side_by_side": false, "force_group": true, "fallback": false, "group": -1, "include_declaration": false},
6767
"context": [{"key": "lsp.session_with_capability", "operand": "referencesProvider"}]
6868
},
6969
// Find References (side-by-side)

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.23.0
1+
1.24.0

boot.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from .plugin.core.registry import LspNextDiagnosticCommand
2626
from .plugin.core.registry import LspOpenLocationCommand
2727
from .plugin.core.registry import LspPrevDiagnosticCommand
28-
from .plugin.core.registry import LspRecheckSessionsCommand
2928
from .plugin.core.registry import LspRestartServerCommand
3029
from .plugin.core.registry import windows
3130
from .plugin.core.sessions import AbstractPlugin

docs/src/customization.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If you want to bind some action to a mouse, open `Preferences / Browser Packages
3737
| Linux | `/User/Default (Linux).sublime-mousemap` |
3838
| Mac | `/User/Default (OSX).sublime-mousemap` |
3939

40-
Here is an example mouse binding that triggers LSP's "go to symbol definition" command on pressing the <kbd>ctrl</kbd>+<kbd>left click</kbd>:
40+
Here is an example of a mouse binding that triggers LSP's "go to symbol definition" command on pressing the <kbd>ctrl</kbd>+<kbd>left click</kbd>:
4141

4242
```js
4343
[
@@ -68,23 +68,23 @@ See the [mdpopups documentation](http://facelessuser.github.io/sublime-markdown-
6868

6969
## Inlay Hints
7070

71-
The style for inlay hints is defined in a [`inlay_hints.css`](https://github.com/sublimelsp/LSP/blob/main/inlay_hints.css) file in the root directory of the LSP package.
71+
The styles for inlay hints are defined in the [`inlay_hints.css`](https://github.com/sublimelsp/LSP/blob/main/inlay_hints.css) file in the root directory of the LSP package.
7272
If you would like to adjust the inlay hints style, you can create an [override](https://www.sublimetext.com/docs/packages.html#overriding-files-from-a-zipped-package) for this file (a restart of Sublime Text is required to apply the changes).
73-
But be aware that by doing this, you might miss out future changes in this file, in case of updates in a new release of the LSP package.
74-
So consider to use a package like [OverrideAudit](https://packagecontrol.io/packages/OverrideAudit) in order to get a notification when that happens.
73+
But be aware that by doing this, you might miss out on future changes in this file, in case of updates in a new release of the LSP package.
74+
So consider using a package like [OverrideAudit](https://packagecontrol.io/packages/OverrideAudit) to get a notification when that happens.
7575

7676
## Color scheme customizations
7777

7878
Some features use TextMate scopes to control the colors (underline, background or text color) of styled regions in a document or popup.
7979
Colors can be customized by adding a rule for these scopes into your color scheme.
8080
There is an example in the [official ST documentation](https://www.sublimetext.com/docs/color_schemes.html#customization) which explains how to do that.
8181

82-
The following tables give an overview about the scope names used by LSP.
82+
The following tables give an overview of the scope names used by LSP.
8383

8484
### Semantic Highlighting
8585

8686
!!! info "This feature is only available if the server has the *semanticTokensProvider* capability."
87-
Language servers which support semantic highlighting are for example *clangd* and *rust-analyzer*.
87+
Language servers that support semantic highlighting are for example *clangd* and *rust-analyzer*.
8888

8989
In order to support semantic highlighting, the color scheme requires a special rule with a background color set for semantic tokens, which is (marginally) different from the original background.
9090
LSP automatically adds such a rule to the built-in color schemes from Sublime Text.
@@ -101,7 +101,7 @@ If you use a custom color scheme, select `UI: Customize Color Scheme` from the C
101101
}
102102
```
103103

104-
Furthermore it is possible to adjust the colors for semantic tokens by applying a foreground color to the individual token types:
104+
Furthermore, it is possible to adjust the colors for semantic tokens by applying a foreground color to the individual token types:
105105

106106
| scope | [Semantic Token Type](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#semanticTokenTypes) |
107107
| ----- | ------------------ |
@@ -130,10 +130,10 @@ Furthermore it is possible to adjust the colors for semantic tokens by applying
130130

131131
By default, LSP will assign scopes based on the [scope naming guideline](https://www.sublimetext.com/docs/scope_naming.html) to each of these token types, but if you define color scheme rules for the scopes specified above, the latter will take precedence.
132132

133-
Language servers can also add their own custom token types, which are not defined in the protocol.
134-
A "LSP-*" helper package (or user) can provide a "semantic_tokens" mapping in the server configuration for such additional token types, or to override the scopes used for the predefined tokens from the table above.
135-
Keys of this mapping should be the token types and values should be the corresponding scopes.
136-
Semantic tokens with exactly one [token modifier](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#semanticTokenModifiers) can be addressed by apending the modifier after a dot.
133+
Language servers can also add their custom token types, which are not defined in the protocol.
134+
An "LSP-\*" helper package (or user) can provide a `semantic_tokens` mapping in the server configuration for such additional token types, or to override the scopes used for the predefined tokens from the table above.
135+
The keys of this mapping should be the token types and values should be the corresponding scopes.
136+
Semantic tokens with exactly one [token modifier](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#semanticTokenModifiers) can be addressed by appending the modifier after a dot.
137137

138138
```json
139139
{
@@ -146,10 +146,10 @@ Semantic tokens with exactly one [token modifier](https://microsoft.github.io/la
146146
```
147147

148148
The color for custom token types can also be adjusted via a color scheme rule for the scope `meta.semantic-token.<token-type>`, where `<token-type>` is the name of the custom token type, but with all letters lowercased (similar to the listed scopes in the table above).
149-
To target tokens with one modifier, use the scope `meta.semantic-token.<token-type>.<token-modifier>` (all lowercased).
149+
To target tokens with one modifier, use the scope `meta.semantic-token.<token-type>.<token-modifier>` (all lowercase).
150150
Currently, semantic tokens with more than one modifier cannot be styled reliably.
151151

152-
If neither a scope for a custom token type is defined, nor a color scheme rule for this token type exists, then it will only be highlighted via the regular syntax highlighting.
152+
If neither a scope for a custom token type is defined, nor a color scheme rule for this token type exists, then it will only be highlighted via regular syntax highlighting.
153153

154154
### Document Highlights
155155

@@ -194,7 +194,7 @@ Diagnostics will also optionally include the following scopes:
194194
| `markup.unnecessary.lsp` | Unnecessary | Unused or unnecessary code |
195195
| `markup.deprecated.lsp` | Deprecated | Deprecated or obsolete code |
196196

197-
Those scopes can be used to, for example, gray-out the text color of unused code, if the server supports that.
197+
Those scopes can be used to, for example, gray out the text color of unused code, if the server supports that.
198198

199199
For example, to add a custom rule for `Mariana` color scheme, select `UI: Customize Color Scheme` from the Command Palette and add the following rule:
200200

@@ -204,13 +204,13 @@ For example, to add a custom rule for `Mariana` color scheme, select `UI: Custom
204204
{
205205
"scope": "markup.unnecessary.lsp",
206206
"foreground": "color(rgb(255, 255, 255) alpha(0.4))",
207-
"background": "color(var(blue3) alpha(0.9))"
207+
"background": "#00000101"
208208
}
209209
]
210210
}
211211
```
212212

213-
The color scheme rule only works if the "background" color is different from the global background of the scheme. So for other color schemes, ideally pick a background color that is as close as possible, but marginally different from the original background.
213+
The color scheme rule only works if the "background" color is (marginally) different from the original color scheme background.
214214

215215
### Signature Help
216216

@@ -220,6 +220,10 @@ The color scheme rule only works if the "background" color is different from the
220220
| `variable.parameter.sighelp.lsp` | Function argument in the signature help popup |
221221
| `variable.parameter.sighelp.active.lsp` | Function argument which is currently highlighted in the signature help popup |
222222

223+
!!! note
224+
If there is no special rule for the active parameter in the color scheme, it will be rendered with bold and underlined font style.
225+
But if the color scheme defines a different `"foreground"` color for the active parameter, the style follows the `"font_style"` property from the color scheme rule.
226+
223227
### Annotations
224228

225229
| scope | description |

docs/src/keyboard_shortcuts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin
99
| ------- | -------- | ------- |
1010
| Auto Complete | <kbd>ctrl</kbd> <kbd>space</kbd> (also on macOS) | `auto_complete`
1111
| Expand Selection | unbound | `lsp_expand_selection`
12-
| Find References | <kbd>shift</kbd> <kbd>f12</kbd> | `lsp_symbol_references`
12+
| Find References | <kbd>shift</kbd> <kbd>f12</kbd> | `lsp_symbol_references` (supports optional args: `{"include_declaration": true/false}`)
1313
| Follow Link | unbound | `lsp_open_link`
1414
| Format File | unbound | `lsp_format_document`
1515
| Format Selection | unbound | `lsp_format_document_range`

messages.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"1.21.0": "messages/1.21.0.txt",
2222
"1.22.0": "messages/1.22.0.txt",
2323
"1.23.0": "messages/1.23.0.txt",
24+
"1.24.0": "messages/1.24.0.txt",
2425
"1.3.0": "messages/1.3.0.txt",
2526
"1.3.1": "messages/1.3.1.txt",
2627
"1.4.0": "messages/1.4.0.txt",

messages/1.24.0.txt

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=> 1.23.0
1+
=> 1.24.0
22

33
⚠️ To ensure that everything works properly after LSP package is updated, it's strongly recommended to restart
44
Sublime Text once it finishes updating all packages. ⚠️
@@ -7,3 +7,27 @@ Sublime Text once it finishes updating all packages. ⚠️
77

88
- Diagnostics for files that are not within the project folders are no longer ignored.
99
You can set `"diagnostics_mode": "workspace"` in server-specific configuration to enable old behavior.
10+
11+
# New features
12+
13+
- Add support for pull diagnostics (#2221) (jwortmann)
14+
- Add "outline" as an option for "document_highlight_style" (#2234) (Terminal)
15+
- add "show_multiline_document_highlights" setting (#2247) (Tito)
16+
17+
# Fixes
18+
19+
- Fix handling of folder_exclude_patterns in projects (#2237) (Rafał Chłodnicki)
20+
- html-escape diagnostic-related strings (#2228) (Rafał Chłodnicki)
21+
- Fix exception for null response id (#2233) (jwortmann)
22+
- Fix some features might not work with dynamical registration (#2222) (jwortmann)
23+
24+
# Improvements
25+
26+
- use class for diagnostic info instead of hardcoding color (#2257) (Rafał Chłodnicki)
27+
- Use regular font style in sighelp popup if already highlighted by color scheme (#2259) (jwortmann)
28+
- Add support and mode for workspace pull diagnostics (#2225) (jwortmann)
29+
- don't send params for requests/notifications that don't expect them (#2240) (Rafał Chłodnicki)
30+
- optimize creation of code actions annotation region (#2239) (Rafał Chłodnicki)
31+
- Allow style overrides for inlay_hints.css (#2232) (jwortmann)
32+
- Improve label detail support in completions (#2212) (ryuukk)
33+
- Update clojure-lsp docs (#2226) (Raffael Stein)

plugin/core/configurations.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
from .types import ClientConfig
55
from .typing import Generator, List, Optional, Set, Dict, Deque
66
from .workspace import enable_in_project, disable_in_project
7+
from abc import ABCMeta
8+
from abc import abstractmethod
79
from collections import deque
810
from datetime import datetime, timedelta
11+
from weakref import WeakSet
912
import sublime
1013
import urllib.parse
1114

@@ -14,14 +17,25 @@
1417
RETRY_COUNT_TIMEDELTA = timedelta(minutes=3)
1518

1619

20+
class WindowConfigChangeListener(metaclass=ABCMeta):
21+
22+
@abstractmethod
23+
def on_configs_changed(self, config_name: Optional[str] = None) -> None:
24+
raise NotImplementedError()
25+
26+
1727
class WindowConfigManager(object):
1828
def __init__(self, window: sublime.Window, global_configs: Dict[str, ClientConfig]) -> None:
1929
self._window = window
2030
self._global_configs = global_configs
2131
self._disabled_for_session = set() # type: Set[str]
2232
self._crashes = {} # type: Dict[str, Deque[datetime]]
2333
self.all = {} # type: Dict[str, ClientConfig]
24-
self.update()
34+
self._change_listeners = WeakSet() # type: WeakSet[WindowConfigChangeListener]
35+
self._reload_configs()
36+
37+
def add_change_listener(self, listener: WindowConfigChangeListener) -> None:
38+
self._change_listeners.add(listener)
2539

2640
def get_configs(self) -> List[ClientConfig]:
2741
return sorted(self.all.values(), key=lambda config: config.name)
@@ -44,7 +58,7 @@ def match_view(self, view: sublime.View, include_disabled: bool = False) -> Gene
4458
except (IndexError, RuntimeError):
4559
pass
4660

47-
def update(self, updated_config_name: Optional[str] = None) -> None:
61+
def _reload_configs(self, updated_config_name: Optional[str] = None) -> None:
4862
project_settings = (self._window.project_data() or {}).get("settings", {}).get("LSP", {})
4963
if updated_config_name is None:
5064
self.all.clear()
@@ -67,7 +81,11 @@ def update(self, updated_config_name: Optional[str] = None) -> None:
6781
self.all[name] = ClientConfig.from_dict(name, c)
6882
except Exception as ex:
6983
exception_log("failed to load project-only configuration {}".format(name), ex)
70-
self._window.run_command("lsp_recheck_sessions", {'config_name': updated_config_name})
84+
85+
def update(self, updated_config_name: Optional[str] = None) -> None:
86+
self._reload_configs(updated_config_name)
87+
for listener in self._change_listeners:
88+
listener.on_configs_changed(updated_config_name)
7189

7290
def enable_config(self, config_name: str) -> None:
7391
if not self._reenable_disabled_for_session(config_name):
@@ -76,7 +94,7 @@ def enable_config(self, config_name: str) -> None:
7694

7795
def disable_config(self, config_name: str, only_for_session: bool = False) -> None:
7896
if only_for_session:
79-
self._disable_for_session(config_name)
97+
self._disabled_for_session.add(config_name)
8098
else:
8199
disable_in_project(self._window, config_name)
82100
self.update(config_name)
@@ -97,9 +115,6 @@ def record_crash(self, config_name: str, exit_code: int, exception: Optional[Exc
97115
config_name, crash_count, RETRY_MAX_COUNT, RETRY_COUNT_TIMEDELTA.total_seconds(), exit_code, exception))
98116
return crash_count < RETRY_MAX_COUNT
99117

100-
def _disable_for_session(self, config_name: str) -> None:
101-
self._disabled_for_session.add(config_name)
102-
103118
def _reenable_disabled_for_session(self, config_name: str) -> bool:
104119
try:
105120
self._disabled_for_session.remove(config_name)

plugin/core/registry.py

-11
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,6 @@ def run_async() -> None:
276276
sublime.set_timeout_async(run_async)
277277

278278

279-
class LspRecheckSessionsCommand(sublime_plugin.WindowCommand):
280-
def run(self, config_name: Optional[str] = None) -> None:
281-
282-
def run_async() -> None:
283-
wm = windows.lookup(self.window)
284-
if wm:
285-
wm.restart_sessions_async(config_name)
286-
287-
sublime.set_timeout_async(run_async)
288-
289-
290279
def navigate_diagnostics(view: sublime.View, point: Optional[int], forward: bool = True) -> None:
291280
try:
292281
uri = uri_from_view(view)

0 commit comments

Comments
 (0)