saevarb / lsp_server

Language Server Protocol server for SWI-Prolog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prolog Language server

Still a work-in-progress – please open an issue if you have any issues or feature requests!.

Currently supports showing documentation on hover, go to definition, go to callers, listing defined symbols in the file, and showing a limited number of diagnostics.

Only tested with SWI-Prolog, as it heavily uses its introspection facilities to do its stuff. It should work with any relatively-recent version of SWI-Prolog, but for best results (for “find references” in particular), use a version with xref_called/5 (8.1.5 or newer; past commit 303f6430de5c).

Installable as a pack like ?- pack_install(lsp_server).

To use with Emacs, via lsp-mode:

(lsp-register-client
  (make-lsp-client
   :new-connection
   (lsp-stdio-connection (list "swipl"
                               "-g" "use_module(library(lsp_server))."
                               "-g" "lsp_server:main"
                               "-t" "halt"
                               "--" "stdio"))
   :major-modes '(prolog-mode)
   :priority 1
   :multi-root t
   :server-id 'prolog-ls))

To use with Vim/Neovim, via LanguageClient:

let g:LanguageClient_serverCommands = {
\ 'prolog': ['swipl',
\            '-g', 'use_module(library(lsp_server)).',
\            '-g', 'lsp_server:main',
\            '-t', 'halt',
\            '--', 'stdio']
\ }

To use with Neovim, via CoC, put the following in coc-settings.json (which you can access by using the command :CocConfig).

{"languageserver": {
  "prolog-lsp": {
    "command": "swipl",
    "args": ["-g", "use_module(library(lsp_server)).",
             "-g", "lsp_server:main",
             "-t", "halt",
             "--", "stdio"
            ],
    "filetypes": ["prolog"]
  }}
}

About

Language Server Protocol server for SWI-Prolog

License:BSD 2-Clause "Simplified" License


Languages

Language:Prolog 98.9%Language:Gnuplot 1.1%