Skip to content
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
699dad3
Test both TCP modes
rwols Apr 13, 2026
908c849
Use enum for 'Mode' in server.py
rwols Apr 18, 2026
b4f0420
Make init_options optional
rwols Apr 18, 2026
76f3c3f
WIP add asyncio to transports
rwols Apr 18, 2026
45d7ea6
Test both TCP modes
rwols Apr 13, 2026
e8fae30
Use enum for 'Mode' in server.py
rwols Apr 18, 2026
c511cec
Make init_options optional
rwols Apr 18, 2026
7438d4a
Use StrEnum
rwols Apr 18, 2026
6a104b0
Merge branch 'chore/add-tests' into feat/asyncio
rwols Apr 19, 2026
d59bb1c
More work on adding asyncio
rwols Apr 20, 2026
c0bea09
Merge branch 'main' into feat/asyncio
rwols Apr 20, 2026
c1fc59c
More work towards asyncio
rwols Apr 22, 2026
e35b611
Remove accidental merge conflict changes
rwols Apr 22, 2026
6cad098
Remove code in server.py, I really screwed up the merge but will reba…
rwols Apr 22, 2026
1597782
refactor Promise.__await__
rwols Apr 22, 2026
cc642f4
Add more comments to _SetTimeoutAsyncExecutor
rwols Apr 22, 2026
cea0e99
Rename Session._invoke_views -> Session._invoke_views_async
rwols Apr 22, 2026
3d30ad4
More work towards asyncio
rwols Apr 28, 2026
472705b
debugging sublime_aio.ViewEventListener
rwols Apr 28, 2026
ea34714
Merge branch 'main' into feat/asyncio
rwols May 2, 2026
069ed50
Fix calls
rwols May 2, 2026
776749a
More fix calls
rwols May 2, 2026
0227877
More work. Some diagnostics show intermittently. Request logic is not…
rwols May 3, 2026
2649a6f
Tweaks to pull diagnostics handling
rwols May 3, 2026
54af917
Restore method names
rwols May 5, 2026
1a4589c
Forgot import
rwols May 5, 2026
900f721
Restore more method names
rwols May 5, 2026
35621cf
ResponseException is not needed, we already have Error
rwols May 8, 2026
dbf4d7d
Merge branch 'main' into feat/asyncio
rwols May 8, 2026
f3b2f84
More rename reverts
rwols May 8, 2026
a9c1692
Add more tracing for understanding why requests are not resolving
rwols May 8, 2026
7004df5
Start fixing up 'goto' functionality
rwols May 9, 2026
a876949
Fix:
rwols May 10, 2026
d27aa93
debugging
rwols May 10, 2026
341ff99
We have something working
rwols May 10, 2026
4ed4e3f
Start fixing diagnostic errors because diagnostics work
rwols May 11, 2026
7aba65e
Remove trace() calls
rwols May 12, 2026
e3ccba2
Remove trace() calls
rwols May 12, 2026
c2c2a8c
Remove trace() calls
rwols May 12, 2026
af561a8
Fixups
rwols May 12, 2026
7260c90
Remove trace() calls and fixup type hints
rwols May 12, 2026
a60ddd2
Reintroduce request_code_actions_async for SessionBuffer
rwols May 12, 2026
23210e3
Consolidate sublime_aio & asyncio functions/classes in plugin/core/ai…
rwols May 12, 2026
73ed644
get_session_buffer_for_uri -> get_session_buffer_for_uri_async
rwols May 12, 2026
6d6e772
Session.session_buffers -> Session.session_buffers_async
rwols May 12, 2026
a84f3dd
_invoke_views_async -> _invoke_views
rwols May 12, 2026
f7702c2
Fix notifications being logged twice
rwols May 12, 2026
bb51929
Fix LspCheckApplicableCommand... I think
rwols May 12, 2026
7d58862
Fix errors in WindowManager.start, and allow async version of LspPlug…
rwols May 12, 2026
e2119a1
Print exceptions from coroutines started from `run_coroutine_threadsafe`
rwols May 13, 2026
ce27231
Ensure plugin_unloaded works as expected
rwols May 13, 2026
a4aba53
Merge branch 'main' into feat/asyncio
rwols May 13, 2026
c215234
Fixup incorrect (old) usage of Session.send_request_async
rwols May 13, 2026
ae081e3
Remove trace() calls from sessions.py
rwols May 13, 2026
e4d3324
Merge branch 'main' into feat/asyncio
rwols May 14, 2026
6e5ca85
Fix type errors in sessions.py
rwols May 14, 2026
4866feb
Review all sublime.set_timeout_async call sites
rwols May 14, 2026
73a658a
Merge branch 'main' into feat/asyncio
rwols May 14, 2026
8a6de63
asyncio.Future, async functions, and Promises are all just Awaitables
rwols May 14, 2026
fcb8717
Fix process args
rwols May 14, 2026
8997d51
Fix most type errors, except for tooling.py
rwols May 14, 2026
5943571
Fix: document link was requested before didOpen
rwols May 14, 2026
7485b90
Rename Files: open files sequentially, as it as before
rwols May 14, 2026
edd3ccd
apply_text_edits: wait at least one UI frame
rwols May 14, 2026
91af0e0
LspPlugin.prefer_async_on_pre_start -> LspPlugin.use_asyncio
rwols May 14, 2026
da1fc1d
Invoke LspPlugin.on_initialize after the `initialized` notification
rwols May 14, 2026
34697be
Update tooling.py for asyncio
rwols May 15, 2026
aa37898
Remove unused imports
rwols May 15, 2026
9335c7d
Fix 'TCP client' mode
rwols May 15, 2026
afde9fb
Compatibility with python 3.8
rwols May 15, 2026
0795ee4
Fix missing import for type checking
rwols May 15, 2026
4659e8d
Add stubs/sublime_aio.pyi
rwols May 15, 2026
76aeba1
Fix formatting
rwols May 15, 2026
66bd43a
Fix all remaining lint errors
rwols May 15, 2026
a143bdf
Fix interface method (why isn't this reported as an error by either p…
rwols May 15, 2026
69fd44d
Fixup interface method of `Manager` (why isn't this reported by eithe…
rwols May 15, 2026
c2a9e30
Fixup wm.handle_show_message: it's not async
rwols May 15, 2026
8835214
Add @override to all methods in WindowManager that implement an inter…
rwols May 15, 2026
668846c
Turn off @deprecation warnings
rwols May 15, 2026
c6a89b1
Fix lint warnings
rwols May 15, 2026
9d8c1b3
The return type of the `Window.handle_show_message` interface method …
rwols May 15, 2026
d271624
Fix reference to task object
rwols May 16, 2026
68b8945
Add function: exceptions_log
rwols May 16, 2026
a3c88ec
Catch possible exception when draining the stream writer
rwols May 16, 2026
3915ca6
Add functions aclosing, gather_and_flatten_exceptions, TaskContainer.…
rwols May 16, 2026
82973a5
Fix for python 3.8 runtime regarding opening files lock
rwols May 16, 2026
1ae40fe
Fixes for python 3.8 runtime, better CancellableInflightStreamingRequ…
rwols May 16, 2026
45bbb05
Fix LSP: Rename
rwols May 16, 2026
998ac1c
Comment out the debug print in the tranports.py because I'm feeling c…
rwols May 16, 2026
9c761d1
Merge branch 'main' into feat/asyncio
rwols May 16, 2026
056359b
LspPlugin.use_asyncio() -> LspPlugin.use_asyncio
rwols May 16, 2026
aca3b34
Fixup incorrect merge resolution in api.py
rwols May 16, 2026
1a6448b
I don't know how this got here.
rwols May 16, 2026
dd2b791
Odds and ends in sessions.py
rwols May 16, 2026
ff9cfd7
Odds and ends: make `@requires_session` compatible with coroutine fun…
rwols May 16, 2026
5e3af9c
WIP refactor tests
rwols May 17, 2026
d91eeda
Convert unit/integration tests to asyncio
rwols May 18, 2026
8676dc4
Fix bugs revealed by tests
rwols May 18, 2026
c6efba4
Merge branch 'main' into feat/asyncio
rwols May 18, 2026
2c2e7b3
Merge branch 'main' into feat/asyncio
rwols May 18, 2026
119fa99
Add runtime check for accidental coroutine continuations
rwols May 18, 2026
9e35cc4
In the process of fixing bugs due to tests revealing bugs
rwols May 19, 2026
8c83c96
Re-introduce classSetUp and classTearDown
rwols May 20, 2026
691d8ea
Fixes for macOS
rwols May 21, 2026
0aa553b
Merge branch 'main' into feat/asyncio
rwols May 21, 2026
e9d65dd
Fixes after merge
rwols May 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"bracex",
"mdpopups",
"orjson",
"sublime_aio",
"typing_extensions",
"wcmatch"
]
Expand Down
46 changes: 46 additions & 0 deletions plugin/core/executors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import concurrent.futures
import threading
from typing import Any, Callable, TypeVar

import sublime


class _SetTimeoutAsyncExecutor(concurrent.futures.Executor):
"""
An Executor that wraps sublime.set_timeout_async.
"""

def __init__(self) -> None:
self._running = 0
self._shuttingdown = False
self._lock = threading.Lock()
self._cv = threading.Condition(self._lock)

def submit(self, fn: Callable[..., Any], *args: Any, **kwargs: Any) -> concurrent.futures.Future:
if self._shuttingdown:
raise RuntimeError("Executor is shutting down")
future: concurrent.futures.Future = concurrent.futures.Future()
with self._cv:
self._running += 1

def run() -> None:
try:
future.set_result(fn(*args, **kwargs))
except BaseException as ex:
future.set_exception(ex)
with self._cv:
self._running -= 1
if self._running == 0:
self._cv.notify()

sublime.set_timeout_async(run)
return future

def shutdown(self, wait: bool = True, *, cancel_futures: bool = False) -> None:
self._shuttingdown = True
if wait:
with self._cv:
self._cv.wait_for(lambda: self._running == 0)


executor = _SetTimeoutAsyncExecutor()
17 changes: 17 additions & 0 deletions plugin/core/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Tuple
from typing import TypeVar
from typing import Union
import asyncio
import functools
import threading

Expand Down Expand Up @@ -207,6 +208,22 @@ def async_wrapper(resolve_fn: ResolveFunc[TResult]) -> None:
return Promise(sync_wrapper)
return Promise(async_wrapper)

def __await__(self):
"""You can `await` a Promise."""
loop = asyncio.get_running_loop()
future = loop.create_future()

def resolve_callback(value: T) -> None:
if not future.done():
future.set_result(value)

if self._is_resolved():
resolve_callback(self._get_value())
else:
self._add_callback(resolve_callback)

return future.__await__()

def _do_resolve(self, new_value: T) -> None:
# No need to block as we can't change from resolved to unresolved.
if self.resolved:
Expand Down
7 changes: 7 additions & 0 deletions plugin/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ class ResponseError(TypedDict):
data: NotRequired[LSPAny]


class ResponseException(Exception):
error: ResponseError

def __init__(error: ResponseError) -> None:
self.error = error
Comment thread
rchl marked this conversation as resolved.
Outdated


class ResolvedCodeLens(TypedDict):
range: Range
command: Command
Expand Down
Loading
Loading