https://github.com/deathaxe/sublime-asyncio
Show case how to use asyncio to drive Sublime Text plugins
https://github.com/deathaxe/sublime-asyncio
Last synced: about 1 year ago
JSON representation
Show case how to use asyncio to drive Sublime Text plugins
- Host: GitHub
- URL: https://github.com/deathaxe/sublime-asyncio
- Owner: deathaxe
- Created: 2025-01-26T18:28:51.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-23T18:16:46.000Z (about 1 year ago)
- Last Synced: 2025-03-23T18:34:30.403Z (about 1 year ago)
- Language: Python
- Size: 290 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AsyncIO for Sublime Text
This package demonstrates power of asyncio and [simdjson](https://pypi.org/project/pysimdjson/)
to handle hundrets of thousands of completions smoothly,
without blocking Sublime Text's UI in any way.
It also show cases how to turn any ST event handler
into an asyncio coroutine by just decorating it.
```py
from __future__ import annotations
import simdjson
import sublime_plugin
from .vendor import aio_sublime
def plugin_loaded():
aio_sublime.setup_event_loop()
def plugin_unloaded():
aio_sublime.shutdown_event_loop()
class CompletionListener(sublime_plugin.ViewEventListener):
parser = simdjson.Parser()
@aio_sublime.asyncio_completions
async def on_query_completions(self, prefix, locations):
doc = self.parser.parse(data)
return (i["label"] for i in doc["items"])
@aio_sublime.asyncio_event
async def on_modified(self):
print(f"{self.view!r} got modified on io loop!")
```