Skip to content

Installing

Build from Source

# Clone the repository
git clone https://github.com/hudson-trading/slang-server.git
cd slang-server

# Pull dependencies (slang and reflect-cpp)
git submodule update --init --recursive

# Build with cmake using a C++20 compliant compiler
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j --target slang_server

On certain systems (Arch, etc), you may need to have the project use its vendored copy of the fmt library, rather than the one on your system. This can be achieved by appending -DCMAKE_DISABLE_FIND_PACKAGE_fmt=TRUE to the CMake configuration step, e.g.:

cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_DISABLE_FIND_PACKAGE_fmt=TRUE

In the future there will be pre-built binaries released for common platforms. The editor clients will auto-install these, similar to what clangd and others do.

Windows: At the moment there are issues running on windows; See #115 and related issues.

Vscode

Install the extension here, then set slang.path to the slang-server binary. (at build/bin/slang-server)

See VSCode Options

Vscode Forks (Cursor, Antigravity, VSCodium, etc.)

Install from your editor, or download from the OpenVSX Marketplace

Neovim

Once Slang Server is more actively used (you can help by starring the project!), it will be added to nvim-lspconfig and mason.nvim and no additional configuration will be required. Until then, follow one of the methods below to manually add the server configuration.

For newer versions of Neovim (≥ v0.11), the new vim.lsp API is the preferred, simpler way to configure language servers:

vim.lsp.config("slang-server", {
  cmd = { "slang-server" },
  root_markers = { ".git", ".slang" },
  filetypes = {
    "systemverilog",
    "verilog",
  },
})

vim.lsp.enable("slang-server")

For older versions of Neovim (< v0.11) with nvim-lspconfig, the server can be configured with:

local configs = require("lspconfig.configs")
local util = require("lspconfig.util")

if not configs.slang_server then
  configs.slang_server = {
    default_config = {
      cmd = {
        "slang-server",
      },
      filetypes = {
        "systemverilog",
        "verilog",
      },
      single_file_support = true,
      root_dir = function(fname)
        return util.root_pattern(".git", ".slang")(fname)
      end,
    },
  }
end

For users of lazy.nvim, the above could be added to their nvim-lspconfig spec at ~/.config/nvim/lua/plugins/nvim-lspconfig.lua like this:

return {
  "neovim/nvim-lspconfig",
  opts = {
    setup = {
      slang_server = function(_, opts)
        local configs = require("lspconfig.configs")
        local util = require("lspconfig.util")

        if not configs.slang_server then
          configs.slang_server = {
            default_config = {
              cmd = {
                "slang-server",
              },
              filetypes = {
                "systemverilog",
                "verilog",
              },
              single_file_support = true,
              root_dir = function(fname)
                return util.root_pattern(".git", ".slang")(fname)
              end,
            },
          }
        end
      end,
    },
    servers = {
      slang_server = {
        enabled = true,
        mason = false,
      },
    },
  },
}

Pointing at the binary is all you need for standard language features, however a plugin is provided to enable some client-side features which extend the LSP (e.g. the hierarchy view, waveform integration). The plugin can be found in clients/neovim/ and is also mirrored in slang-server.nvim for ease of use with Neovim plugin managers.

Other editors

Most modern editors can at least point to a language server binary for specific file types. This will provide standard LSP features, but not HDL specific features.

If the editor also allows for executing LSP commands, HDL features like setting a compilation should be available.