trueagi-io / metta-wam

A Hyperon MeTTa Interpreter/Transpilier that targets the Warren Abstract Machine
8 stars 11 forks source link

Create Installation Instructions for LSP Server in NeoVIM, Emacs, and Other Environments #104

Open TeamSPoon opened 1 month ago

TeamSPoon commented 1 month ago

We need comprehensive instructions for installing the LSP Server in various environments, with a focus on NeoVIM, Emacs, and other platforms where the original LSP server is commonly used. The goal is to provide clear, accurate, and easy-to-follow guidance that enables users to get the LSP server running with MeTTa's XREF information.

Instructions:

  1. Emacs

    Use the lsp-mode package:

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

    Use the LanguageClient-neovim plugin:

    let g:LanguageClient_serverCommands = {
    \ 'metta': ['swipl',
    \            '-g', 'use_module(library(lsp_server_metta)).',
    \            '-g', 'lsp_server_metta:main',
    \            '-t', 'halt',
    \            '--', 'stdio']
    \ }
  3. Neovim (CoC Plugin)

    Add the following to coc-settings.json:

    {
     "languageserver": {
       "metta-lsp": {
         "command": "swipl",
         "args": ["-g", "use_module(library(lsp_server_metta)).",
                  "-g", "lsp_server_metta:main",
                  "-t", "halt",
                  "--", "stdio"],
         "filetypes": ["metta"]
       }
     }
    }
  4. Neovim (Native LSP for Neovim >= 0.5)

    Install the neovim/nvim-lspconfig package, then create the following configuration file at $XDG_CONFIG_DIR/nvim/lua/lspconfig/metta_lsp.lua:

    local configs = require 'lspconfig/configs'
    local util = require 'lspconfig/util'
    
    configs.metta_lsp = {
     default_config = {
       cmd = {"swipl",
              "-g", "use_module(library(lsp_server_metta)).",
              "-g", "lsp_server_metta:main",
              "-t", "halt",
              "--", "stdio"};
       filetypes = {"metta"};
       root_dir = util.root_pattern("pack.pl");
     };
     docs = {
        description = [[
     https://github.com/xxxx/xxxx
    
     Metta Language Server
     ]];
     }
    }

    Then add the following to init.vim:

    lua << EOF
    require('lspconfig/metta_lsp')
    require('lspconfig').metta_lsp.setup{}
    EOF
  5. VSCode

    • Download the latest .vsix file from the releases page.
    • Clone this repo and copy/symlink the vscode/ directory to ~/.vscode/extensions/.
    • Alternatively, clone and build the .vsix file yourself:
      1. Install vsce (npm install -g vsce).
      2. Run vsce publish from the vscode/ directory.
      3. Add the resulting .vsix to VSCode.

Additional Notes: