Skip to content

Commit

Permalink
Merge branch 'main' into workspace-edit-preserve-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann committed Apr 20, 2024
2 parents 7b71db2 + c5321ad commit 572638e
Show file tree
Hide file tree
Showing 82 changed files with 623 additions and 514 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- if: ${{ matrix.os == 'macOS-latest' }}
run: brew unlink openssl
- uses: SublimeText/UnitTesting/actions/setup@v1
- uses: SublimeText/UnitTesting/actions/run-tests@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.29.0
2.0.0
4 changes: 2 additions & 2 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from .plugin.core.transports import kill_all_subprocesses
from .plugin.core.tree_view import LspCollapseTreeItemCommand
from .plugin.core.tree_view import LspExpandTreeItemCommand
from .plugin.core.typing import Any, Optional, List, Type, Dict
from .plugin.core.views import LspRunTextCommandHelperCommand
from .plugin.document_link import LspOpenLinkCommand
from .plugin.documents import DocumentSyncListener
Expand Down Expand Up @@ -86,6 +85,7 @@
from .plugin.tooling import LspOnDoubleClickCommand
from .plugin.tooling import LspParseVscodePackageJson
from .plugin.tooling import LspTroubleshootServerCommand
from typing import Any, Dict, List, Optional, Type


def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:
Expand All @@ -98,7 +98,7 @@ def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:


def _register_all_plugins() -> None:
plugin_classes = [] # type: List[Type[AbstractPlugin]]
plugin_classes: List[Type[AbstractPlugin]] = []
_get_final_subclasses(AbstractPlugin.__subclasses__(), plugin_classes)
for plugin_class in plugin_classes:
try:
Expand Down
2 changes: 1 addition & 1 deletion dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
">=4096": [
"bracex",
"mdpopups",
"pathlib",
"typing_extensions",
"wcmatch"
]
}
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ nav:
extra:
social:
- icon: fontawesome/brands/discord
link: https://discordapp.com/channels/280102180189634562/645268178397560865
link: https://discord.gg/TZ5WN8t
20 changes: 19 additions & 1 deletion docs/src/language_servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Follow installation instructions on [LSP-gopls](https://github.com/sublimelsp/LS
"godot-lsp": {
"enabled": true,
"command": ["/PATH/TO/godot-editor.exe"], // Update the PATH
"tcp_port": 6008,
"tcp_port": 6005, // Older versions of Godot(3.x) use port 6008
"selector": "source.gdscript",
}
}
Expand Down Expand Up @@ -673,6 +673,24 @@ Follow installation instructions on [LSP-metals](https://github.com/scalameta/me
}
```

## Solidity

1. Install the [Ethereum](https://packagecontrol.io/packages/Ethereum) package from Package Control for syntax highlighting.
2. Install the [github:NomicFoundation/hardhat-vscode](https://github.com/NomicFoundation/hardhat-vscode/tree/development/server) language server.
3. Open `Preferences > Package Settings > LSP > Settings` and add the `"solidity"` client configuration to the `"clients"`:

```jsonc
{
"clients": {
"solidity": {
"enabled": true,
"command": ["nomicfoundation-solidity-language-server", "--stdio"],
"selector": "source.solidity"
}
}
}
```

## Stylelint

Follow installation instructions on [LSP-stylelint](https://github.com/sublimelsp/LSP-stylelint).
Expand Down
2 changes: 2 additions & 0 deletions messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
"1.29.0": "messages/1.29.0.txt",
"1.3.0": "messages/1.3.0.txt",
"1.3.1": "messages/1.3.1.txt",
"1.30.0": "messages/1.30.0.txt",
"1.4.0": "messages/1.4.0.txt",
"1.5.0": "messages/1.5.0.txt",
"1.6.0": "messages/1.6.0.txt",
"1.6.1": "messages/1.6.1.txt",
"1.7.0": "messages/1.7.0.txt",
"1.8.0": "messages/1.8.0.txt",
"1.9.0": "messages/1.9.0.txt",
"2.0.0": "messages/2.0.0.txt",
"install": "messages/install.txt"
}
21 changes: 21 additions & 0 deletions messages/1.30.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
=> 1.30.0

# Breaking changes

- [godot-editor](https://lsp.sublimetext.io/language_servers/#gdscript-godot-engine) client configuration default `tcp_port` value is now `6005` instead of `6008`. Older versions of Godot(3.x) use port `6008`. (#2447) (Предраг Николић)

# Fixes and Improvements

- Keep tab selection and focus when applying WorkspaceEdit (#2431) (Janos Wortmann)
- Enhancements for the rename panel (#2428) (Janos Wortmann)
- Fix URI format for res scheme (#2432) (Janos Wortmann)
- If `"log_debug"` is enabled, `window/logMessage` will be printed to the Sublime Text Console instead of LSP log panel (#2444) (Janos Wortmann)

# Documentation

- docs: Add Toit (#2425) (Serjan Nasredin)
- docs: Add Solidity (#2383) (Nikita Kozlov)

# Plugin API changes

- Allow plugins to ignore certain views (#2410) (Janos Wortmann)
32 changes: 32 additions & 0 deletions messages/2.0.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
=> 2.0.0

⚠️ Sublime Text will need to be restarted **more than once** for things to work properly. ⚠️

# Breaking changes

- LSP and LSP-* packages are transitioning from Python 3.3 to Python 3.8.

# FAQ

### What are the most significant improvements that stem from the 3.3 to 3.8 change?

There are no new features.
This is an internal LSP codebase change that affects all LSP-* packages.

### LSP is broken after the update even if Sublime Text is restarted many times

If that is the case, follow these steps:

- ##### Check if `"index_files"` is set to `false` in `Preferences.sublime-settings`

From the command palette open `Preferences: Settings` and see if `"index_files": false` exists.
If yes, remove that setting.

- ##### Check if `"LSP"` is put in `"ignored_packages"` in `Preferences.sublime-settings`

Ensure that LSP hasn't been added to the "ignored_packages" list during the update. If it has, remove it.

- ##### Reach for help

Feel free to [open an issue](https://github.com/sublimelsp/LSP/issues/new?assignees=&labels=&projects=&template=bug_report.md&title=) or reach out to us on [Discord](https://discord.gg/TZ5WN8t) if you encounter any problems during the update.
Please provide logs from the Sublime Text console.
26 changes: 14 additions & 12 deletions plugin/code_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from .core.sessions import AbstractViewListener
from .core.sessions import SessionBufferProtocol
from .core.settings import userprefs
from .core.typing import Any, List, Dict, Callable, Optional, Tuple, TypeGuard, Union, cast
from .core.views import entire_content_region
from .core.views import first_selection_region
from .core.views import format_code_actions_for_quick_panel
Expand All @@ -21,6 +20,9 @@
from abc import ABCMeta
from abc import abstractmethod
from functools import partial
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from typing import cast
from typing_extensions import TypeGuard
import sublime

ConfigName = str
Expand All @@ -37,10 +39,10 @@ class CodeActionsManager:
"""Manager for per-location caching of code action responses."""

def __init__(self) -> None:
self._response_cache = None # type: Optional[Tuple[str, Promise[List[CodeActionsByConfigName]]]]
self.menu_actions_cache_key = None # type: Optional[str]
self.refactor_actions_cache = [] # type: List[Tuple[str, CodeAction]]
self.source_actions_cache = [] # type: List[Tuple[str, CodeAction]]
self._response_cache: Optional[Tuple[str, Promise[List[CodeActionsByConfigName]]]] = None
self.menu_actions_cache_key: Optional[str] = None
self.refactor_actions_cache: List[Tuple[str, CodeAction]] = []
self.source_actions_cache: List[Tuple[str, CodeAction]] = []

def request_for_region_async(
self,
Expand Down Expand Up @@ -74,7 +76,7 @@ def request_for_region_async(
self.source_actions_cache.clear()

def request_factory(sb: SessionBufferProtocol) -> Optional[Request]:
diagnostics = [] # type: List[Diagnostic]
diagnostics: List[Diagnostic] = []
for diag_sb, diags in session_buffer_diagnostics:
if diag_sb == sb:
diagnostics = diags
Expand Down Expand Up @@ -122,7 +124,7 @@ def request_factory(sb: SessionBufferProtocol) -> Optional[Request]:
matching_kinds = get_matching_on_save_kinds(on_save_actions, session_kinds)
if not matching_kinds:
return None
diagnostics = [] # type: List[Diagnostic]
diagnostics: List[Diagnostic] = []
for diag_sb, diags in session_buffer_diagnostics:
if diag_sb == sb:
diagnostics = diags
Expand Down Expand Up @@ -155,13 +157,13 @@ def on_response(
actions = response_filter(sb, response)
return (sb.session.config.name, actions)

tasks = [] # type: List[Promise[CodeActionsByConfigName]]
tasks: List[Promise[CodeActionsByConfigName]] = []
for sb in listener.session_buffers_async('codeActionProvider'):
session = sb.session
request = request_factory(sb)
if request:
response_handler = partial(on_response, sb)
task = session.send_request_task(request) # type: Promise[Optional[List[CodeActionOrCommand]]]
task: Promise[Optional[List[CodeActionOrCommand]]] = session.send_request_task(request)
tasks.append(task.then(response_handler))
# Return only results for non-empty lists.
return Promise.all(tasks) \
Expand All @@ -172,7 +174,7 @@ def on_response(


def get_session_kinds(sb: SessionBufferProtocol) -> List[CodeActionKind]:
session_kinds = sb.get_capability('codeActionProvider.codeActionKinds') # type: Optional[List[CodeActionKind]]
session_kinds: Optional[List[CodeActionKind]] = sb.get_capability('codeActionProvider.codeActionKinds')
return session_kinds or []


Expand Down Expand Up @@ -254,7 +256,7 @@ def _handle_response_async(self, responses: List[CodeActionsByConfigName]) -> No
if self._cancelled:
return
view = self._task_runner.view
tasks = [] # type: List[Promise]
tasks: List[Promise] = []
for config_name, code_actions in responses:
session = self._task_runner.session_by_name(config_name, 'codeActionProvider')
if session:
Expand Down Expand Up @@ -308,7 +310,7 @@ def _run_async(self, only_kinds: Optional[List[CodeActionKind]] = None) -> None:

def _handle_code_actions(self, response: List[CodeActionsByConfigName], run_first: bool = False) -> None:
# Flatten response to a list of (config_name, code_action) tuples.
actions = [] # type: List[Tuple[ConfigName, CodeActionOrCommand]]
actions: List[Tuple[ConfigName, CodeActionOrCommand]] = []
for config_name, session_actions in response:
actions.extend([(config_name, action) for action in session_actions])
if actions:
Expand Down
11 changes: 6 additions & 5 deletions plugin/code_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from .core.protocol import CodeLens
from .core.protocol import CodeLensExtended
from .core.protocol import Error
from .core.typing import List, Tuple, Dict, Iterable, Optional, Generator, Union, cast
from .core.registry import LspTextCommand
from .core.registry import LspWindowCommand
from .core.registry import windows
from .core.views import make_command_link
from .core.views import range_to_region
from html import escape as html_escape
from functools import partial
from typing import Dict, Generator, Iterable, List, Optional, Tuple, Union
from typing import cast
import itertools
import sublime

Expand Down Expand Up @@ -108,7 +109,7 @@ def __init__(self, view: sublime.View) -> None:
self.view = view
self._init = False
self._phantom = sublime.PhantomSet(view, self.CODE_LENS_KEY)
self._code_lenses = {} # type: Dict[Tuple[int, int], List[CodeLensData]]
self._code_lenses: Dict[Tuple[int, int], List[CodeLensData]] = {}

def clear(self) -> None:
self._code_lenses.clear()
Expand All @@ -134,10 +135,10 @@ def handle_response(self, session_name: str, response: List[CodeLens]) -> None:
self._init = True
responses = [CodeLensData(data, self.view, session_name) for data in response]
responses.sort(key=lambda c: c.region)
result = {
result: Dict[Tuple[int, int], List[CodeLensData]] = {
region.to_tuple(): list(groups)
for region, groups in itertools.groupby(responses, key=lambda c: c.region)
} # type: Dict[Tuple[int, int], List[CodeLensData]]
}

# Fast path: no extra work to do
if self.is_empty():
Expand Down Expand Up @@ -215,7 +216,7 @@ def run(self, edit: sublime.Edit) -> None:
listener = windows.listener_for_view(self.view)
if not listener:
return
code_lenses = [] # type: List[CodeLensExtended]
code_lenses: List[CodeLensExtended] = []
for region in self.view.sel():
for sv in listener.session_views_async():
code_lenses.extend(sv.get_resolved_code_lenses_for_region(region))
Expand Down
8 changes: 4 additions & 4 deletions plugin/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from .core.protocol import ColorPresentationParams
from .core.protocol import Request
from .core.registry import LspTextCommand
from .core.typing import List
from .core.views import range_to_region
from .core.views import text_document_identifier
from typing import List
import sublime


Expand All @@ -19,11 +19,11 @@ def run(self, edit: sublime.Edit, color_information: ColorInformation) -> None:
if session:
self._version = self.view.change_count()
self._range = color_information['range']
params = {
params: ColorPresentationParams = {
'textDocument': text_document_identifier(self.view),
'color': color_information['color'],
'range': self._range
} # type: ColorPresentationParams
}
session.send_request_async(Request.colorPresentation(params, self.view), self._handle_response_async)

def want_event(self) -> bool:
Expand All @@ -38,7 +38,7 @@ def _handle_response_async(self, response: List[ColorPresentation]) -> None:
if self._version != self.view.change_count():
return
old_text = self.view.substr(range_to_region(self._range, self.view))
self._filtered_response = [] # type: List[ColorPresentation]
self._filtered_response: List[ColorPresentation] = []
for item in response:
# Filter out items that would apply no change
text_edit = item.get('textEdit')
Expand Down
Loading

0 comments on commit 572638e

Please sign in to comment.