jamesnvc / lsp_server

Language Server Protocol server for SWI-Prolog
BSD 2-Clause "Simplified" License
90 stars 6 forks source link

Make it Prolog dialect/implementation independent #10

Open XVilka opened 4 years ago

XVilka commented 4 years ago

Apart from SWI Prolog it might be helpful in case of other Prolog implementations. I am more interested in compatibility with Scryer Prolog but maybe some other users will want other different implementations too, e.g. GNU Prolog or XSB:

Scryer Prolog aims to become to ISO Prolog what GHC is to Haskell: an open source industrial strength production environment that is also a testbed for bleeding edge research in logic and constraint programming, which is itself written in a high-level language.

See also https://github.com/mthom/scryer-prolog/issues/161

jamesnvc commented 4 years ago

Excellent idea, I will test with Scryer Prolog & see what I can do to make it work with that as well.

As I see it, there are two ways of looking at this:

  1. Have the language server itself run under SWI but properly handle code written for other Prolog implementations.
  2. Have the language server run under another Prolog implementation for code written to target that.

I suspect 1 will be much easier, as the current implementation leverages some SWI-specific libraries, primarily prolog_xref (for general static analysis of the code) and prolog_colour for semantic highlighting.

However, I've also been considering changing how the server works and, instead of using static analysis, load the code in question in a separate thread & query it to determine things like defined predicates. If I would do that (I have some concerns about how to do some safely & in full generality), presumably that could make approach 2 more feasible, since it could use more of the standard Prolog introspection predicates for most of the work.