Open rwols opened 3 years ago
If the scheme of the URI is not file
, res
, http
, https
or buffer
, then ST should look for a "view provider", much like how it searches for a "key binding handler" with on_query_context
. There should be a new async callback that can signal to ST that it can "handle" a certain scheme. So maybe a new callback for sublime_plugin.EventListener
:
async def on_query_uri(
self,
window: sublime.Window,
uri: str
) -> Optional[Tuple[str, str, Optional[str]]]:
...
If you define this method in a plugin, then you must return a tuple of three elements:
view.file_name()
, although I guess this should be None.If you don't know how to handle the provided URI then you must return None
.
This would allow plugins to extend the behavior of opening URIs for custom schemes.
For instance, the Deno language server uses a deno
scheme. This scheme requires custom handling to fetch the remote content (and again, it must all be asynchronous).
Of course I didn't think of this myself. VSCode already has this mechanism.
I'm learning this idea has consequences for various other features:
Nevertheless I still think this would be a nice feature to have as a basis for, for instance, remote SSH file viewing, or translating paths for inspecting files in a docker container.
Another use case is resolving URIs with a jdt
scheme for Debugger + Eclipse language server integration: https://github.com/daveleroy/sublime_debugger/pull/106#issuecomment-795747917
Problem description
Development is moving more and more towards web-based tooling. Sublime is lacking in this area.
Preferred solution
A new async method for the
sublime.Window
class:It should have the following behavior:
file
orres
, delegates to #3172.http
orhttps
, downloads the file asynchronously, puts the content into a scratch buffer. Theview.uri()
should return theuri
passed inopen_uri
.buffer
, find an existing view with that buffer ID.The return type should be an
Optional[View]
if the URI can be represented as a single file. It may beNone
because it might have been closed/cancelled by the user while opening it.Alternatives
N/A
Additional Information (optional)
https://github.com/sublimelsp/LSP/issues/1605
The Deno language server has the "goto definition" capability. When the user wants to jump to the definition of a module that is not in the workspace, it will report back a resource on the web. The editor is expected to open that web resource.
EDIT: Contrary to what you might expect, Deno doesn't use http:// schemes but rather deno:// schemes (see below).