Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from LSP.plugin import register_plugin
|
||||
from LSP.plugin import unregister_plugin
|
||||
|
||||
from .plugin import ScryerProlog
|
||||
|
||||
__all__ = (
|
||||
# ST: Core
|
||||
"plugin_loaded",
|
||||
"plugin_unloaded",
|
||||
)
|
||||
|
||||
|
||||
def plugin_loaded() -> None:
|
||||
register_plugin(ScryerProlog)
|
||||
|
||||
|
||||
def plugin_unloaded() -> None:
|
||||
unregister_plugin(ScryerProlog)
|
||||
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from shutil import which
|
||||
|
||||
from LSP.plugin import AbstractPlugin
|
||||
from LSP.plugin import ClientConfig
|
||||
from LSP.plugin import WorkspaceFolder
|
||||
import sublime
|
||||
|
||||
|
||||
class ScryerProlog(AbstractPlugin):
|
||||
@classmethod
|
||||
def name(cls) -> str:
|
||||
return "prolog"
|
||||
|
||||
@classmethod
|
||||
def can_start(
|
||||
cls,
|
||||
window: sublime.Window,
|
||||
initiating_view: sublime.View,
|
||||
workspace_folders: list[WorkspaceFolder],
|
||||
configuration: ClientConfig,
|
||||
) -> str | None:
|
||||
command = configuration.command[0] if configuration.command else "scryer-prolog"
|
||||
binary = sublime.expand_variables(command, {"packages": sublime.packages_path()})
|
||||
if which(binary):
|
||||
return None
|
||||
return (
|
||||
f'Could not find "{command}" on your PATH. LSP-prolog requires a build of scryer-prolog with '
|
||||
'"--lsp" support (see https://github.com/mthom/scryer-prolog). Install it, or set the "command" '
|
||||
"setting in LSP-prolog.sublime-settings to the full path of the binary."
|
||||
)
|
||||
Reference in New Issue
Block a user