Initial commit

This commit is contained in:
2026-07-05 23:22:38 -04:00
commit dec9313362
9 changed files with 161 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
3.8
+1
View File
@@ -0,0 +1 @@
LSP-prolog implements a Sublime Text package providing support for a Prolog LSP, based off of Scryer Prolog.
+10
View File
@@ -0,0 +1,10 @@
[
{
"caption": "Preferences: LSP-prolog Settings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-prolog/LSP-prolog.sublime-settings",
"default": "// Settings in here override those in \"LSP-prolog/LSP-prolog.sublime-settings\"\n\n{\n\t$0\n}\n"
}
}
]
+15
View File
@@ -0,0 +1,15 @@
{
// The command used to start the Prolog language server. This requires a
// build of scryer-prolog (https://github.com/mthom/scryer-prolog) whose
// "--lsp" flag runs a built-in LSP server communicating over stdio.
// If scryer-prolog is not on your PATH, change this to the absolute path
// of the binary.
"enable": true,
"command": [
"scryer-prolog",
"--lsp"
],
// Which files this language server should be used for.
"selector": "source.prolog",
"settings": {}
}
+34
View File
@@ -0,0 +1,34 @@
[
{
"id": "preferences",
"children": [
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children": [
{
"caption": "LSP",
"id": "lsp-settings",
"children": [
{
"caption": "Servers",
"id": "lsp-servers",
"children": [
{
"caption": "LSP-prolog",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-prolog/LSP-prolog.sublime-settings",
"default": "// Settings in here override those in \"LSP-prolog/LSP-prolog.sublime-settings\"\n\n{\n\t$0\n}\n"
}
}
]
}
]
}
]
}
]
}
]
+30
View File
@@ -0,0 +1,30 @@
# LSP-prolog
Prolog support for Sublime's [LSP](https://packagecontrol.io/packages/LSP) package, via
[scryer-prolog](https://github.com/mthom/scryer-prolog)'s built-in `--lsp` server.
## Requirements
* The [LSP](https://packagecontrol.io/packages/LSP) package.
* A build of scryer-prolog whose `--lsp` flag runs a language server over stdio.
As of this writing that support only exists in a development fork; the flag is
not yet in released/upstream scryer-prolog builds. Make sure `scryer-prolog` is
on your `PATH`, or set the `command` setting below to its full path.
* A Prolog syntax package that assigns the `source.prolog` scope to `.pl`/`.pro` files
(LSP-prolog itself does not ship syntax highlighting).
## Installation
Clone or copy this directory into your Sublime Text `Packages` folder as `LSP-prolog`,
then restart Sublime Text.
## Configuration
Open `Preferences > Package Settings > LSP > Servers > LSP-prolog` to edit settings.
```jsonc
{
"command": ["scryer-prolog", "--lsp"],
"selector": "source.prolog"
}
```
+18
View File
@@ -0,0 +1,18 @@
from __future__ import annotations
def reload_plugin() -> None:
import sys
prefix = "{}.".format(__package__)
for module_name in tuple(
filter(lambda m: m.startswith(prefix) and m != __name__, sys.modules)
):
del sys.modules[module_name]
reload_plugin()
from .plugin import * # noqa: F401, F403, E402
+20
View File
@@ -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)
+32
View File
@@ -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."
)