[go: up one dir, main page]

Skip to content

alephium/ralph-lsp

Repository files navigation

ralph-lsp

Language server for Ralph.

Currently supports text document level events and diagnostics.

Install VSCode plugin

Follow these steps:

  1. Download: Get the .vsix plugin file from the latest release.
  2. Install:
    • Open Visual Studio Code.
    • Go to Extensions > Views and More Actions > Install from VSIX...
    • Select the downloaded .vsix file and click "Install".

Install Neovim plugin

Go to the latest release

Download ralph-lsp.zip, extract it and add ralph-lsp/bin to your PATH environment variable.

  Plug 'alephium/ralph-lsp', {'rtp': 'plugin-nvim'}
lazy_opts = {
    performance = {
        rtp = {
            paths = {
                vim.fn.stdpath('data') .. '/lazy/ralph-lsp/plugin-nvim'
            }
        },
    },
}

lazy_plugin_config = {
   "alephium/ralph-lsp",
   init = function()
       -- expose directly from inside nvim
       local path = vim.env.PATH
       path = path .. ":" .. "/path/to/ralph-lsp/bin"
       vim.env.PATH = path
   end
}

The plugin adds file type detection, syntax highlighting and start the LSP server, make sure you have ralph-lsp available in your PATH

Build the JAR

sbt "compile; lsp-server/assembly"

Look in target folder: .../ralph-lsp/lsp-server/target/scala-2.13/ralph-lsp.jar

Build the executable

sbt universal:packageBin

zip file will be generated in target/universal/ralph-lsp.zip

For local development, you can run

sbt stage

This creates the target/universal/stage/bin/ralph-lsp executable

Build the JAR for VSCode

sbt "compile; lsp-server/assembly; copyJARToVSCode"

The JAR file gets generated to plugin-vscode/out/ralph-lsp.jar.

Run LSP in VSCode

Open the plugin directory plugin-vscode in VSCode:

cd plugin-vscode
code .

Run the plugin by selecting the menu option Run -> Run Without Debugging or Run -> Start Debugging.

Configuration

After your IDE has booted up, a config file named ralph.json is generated in your project's root directory under the folder .ralph-lsp/ralph.json. The file contains the following default values:

{
  "compilerOptions": {
    "ignoreUnusedConstantsWarnings": false,
    "ignoreUnusedVariablesWarnings": false,
    "ignoreUnusedFieldsWarnings": false,
    "ignoreUnusedPrivateFunctionsWarnings": false,
    "ignoreUpdateFieldsCheckWarnings": false,
    "ignoreCheckExternalCallerWarnings": false,
    "ignoreUnusedFunctionReturnWarnings": false
  },
  "contractPath": "contracts"
}

The dependencyPath field is optional. If not set, the default path (<user.home>/.ralph-lsp/dependencies/) will be used. If you wish to specify a custom path, add the following to your ralph.json file:

"dependencyPath": "dependencies"

This configuration allows you to customise the behavior of the compiler and define the paths for your contracts, artifacts, and dependencies.

Configure trace (VSCode)

image

  • off - Enables info, warning and error.
  • messages - Enables all the above including debug.
  • verbose - Enables all the above including trace.

Release VSCode plugin