Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable uri schemes #15

Merged
merged 5 commits into from
Aug 17, 2021
Merged
Changes from 1 commit
Commits
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
21 changes: 19 additions & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from LSP.plugin import unregister_plugin
from LSP.plugin import Request
from LSP.plugin.core.typing import Optional, Any, List, Dict, Mapping, Callable
from LSP.plugin.core.registry import LspTextCommand
from LSP.plugin.core.protocol import ExecuteCommandParams, Notification

import os
import sublime
from urllib.request import urlopen
Expand All @@ -18,6 +17,10 @@
# TODO: Not part of the public API :(
from LSP.plugin.core.edit import apply_workspace_edit
from LSP.plugin.core.edit import parse_workspace_edit
from LSP.plugin.core.protocol import DocumentUri
from LSP.plugin.core.protocol import ExecuteCommandParams
from LSP.plugin.core.protocol import Notification
from LSP.plugin.core.registry import LspTextCommand
from LSP.plugin.core.views import location_to_encoded_filename, text_document_identifier


Expand Down Expand Up @@ -156,6 +159,20 @@ def install_or_update(cls) -> None:
if os.path.isdir(absdir):
shutil.move(absdir, serverdir(cls.storage_subpath()))

def on_open_uri_async(self, uri: DocumentUri, callback: Callable[[str, str, str], None]) -> bool:
if not uri.startswith("jdt:"):
return False
session = self.weaksession()
if not session:
return False
view = session.window.active_view()
session.send_request_async(
Request("java/classFileContents", text_document_identifier(uri), view, progress=True),
lambda resp: callback(uri, resp, "Packages/Java/Java.sublime-syntax"),
lambda err: callback("ERROR", str(err), "Packages/Text/Plain text.tmLanguage")
)
return True

def on_pre_server_command(self, command: Mapping[str, Any], done: Callable[[], None]) -> bool:
session = self.weaksession()
if not session:
Expand Down