alephium / ralph-lsp

Ralph language server
6 stars 1 forks source link

ralph-lsp

Language server for Ralph.

Features

Requirements

Java 11 or higher.

Install VSCode plugin

Ralph LSP is available on the VSCode Marketplace.

Manual Installation

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.

vim-plug

  Plug 'alephium/ralph-lsp', {'rtp': 'plugin-nvim'}

lazy

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

Configurations in alephium.config.ts are the primary source for build settings, and ralph.json is secondary. Any settings defined in alephium.config.ts will be mirrored in ralph.json.

alephium.config.ts

Refer to the documentation for more details about the alephium.config.ts.

ralph.json

Once your IDE has booted up, a config file named ralph.json will be generated in your project's root directory under the folder .ralph-lsp/ralph.json. This file reflects the sourceDir and compilerOptions settings defined in alephium.config.ts. If alephium.config.ts is not present or if the settings are missing, default settings will be used.

The dependencyPath setting is specific to Ralph-LSP and configures the directory for dependencies. If dependencyPath is not specified, the default path (<user.home>/.ralph-lsp/dependencies/) will be used.

Here’s an example of the ralph.json file with all configurations set:

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

Configure trace (VSCode)

image

Release VSCode plugin