* MeTTaLog Language server **Currently a fork of prolog Language server. Will update this README later.** 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 [[https://github.com/SWI-Prolog/swipl-devel/commit/303f6430de5c9d7e225d8eb6fb8bb8b59e7c5f8f][303f6430de5c]]). Installable as a pack like ~?- pack_install(lsp_server).~ * Emacs ** [[https://github.com/emacs-lsp/lsp-mode][lsp-mode]]: #+begin_src emacs-lisp (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)) #+end_src * Vim/Neovim ** [[https://github.com/autozimu/LanguageClient-neovim][LanguageClient]]: #+begin_src viml let g:LanguageClient_serverCommands = { \ 'prolog': ['swipl', \ '-g', 'use_module(library(lsp_server)).', \ '-g', 'lsp_server:main', \ '-t', 'halt', \ '--', 'stdio'] \ } #+end_src * Neovim ** [[https://github.com/neoclide/coc.nvim][CoC]] Put the following in ~coc-settings.json~ (which you can access by using the command ~:CocConfig~). #+begin_src json {"languageserver": { "prolog-lsp": { "command": "swipl", "args": ["-g", "use_module(library(lsp_server)).", "-g", "lsp_server:main", "-t", "halt", "--", "stdio" ], "filetypes": ["prolog"] }} } #+end_src ** Native LSP (for Neovim >= 0.5) Install the [[https://github.com/neovim/nvim-lspconfig][neovim/nvim-lspconfig]] package Put the following in ~$XDG_CONFIG_DIR/nvim/lua/lspconfig/prolog_lsp.lua~: #+begin_src lua local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' configs.prolog_lsp = { default_config = { cmd = {"swipl", "-g", "use_module(library(lsp_server)).", "-g", "lsp_server:main", "-t", "halt", "--", "stdio"}; filetypes = {"prolog"}; root_dir = util.root_pattern("pack.pl"); }; docs = { description = [[ https://github.com/jamesnvc/prolog_lsp Prolog Language Server ]]; } } -- vim:et ts=2 sw=2 #+end_src Then add the following to ~init.vim~: #+begin_src viml lua << EOF require('lspconfig/prolog_lsp') require('lspconfig').prolog_lsp.setup{} EOF #+end_src * VSCode - download the latest ~.vsix~ file from the [[https://github.com/jamesnvc/lsp_server/releases][releases page]] - clone this repo and copy/symlink the ~vscode/~ directory to ~~/.vscode/extensions/~ - clone and build the ~.vsix~ file yourself by the follwing steps: 1. install ~vsce~ (~npm install -g vsce~) 2. run ~vsce publish~ from the ~vscode/~ directory 3. add the resulting ~.vsix~ to VSCode.