Skip to main content

Language server for Vyper, a pythonic smart contract language

Project description

Vyper Language Server

A language server for Vyper, a pythonic smart contract language for the EVM.

Forked from vyperlang/vyper-lsp.

Requirements

  • Python >= 3.12
  • Vyper >= 0.4.1

The Vyper version installed in your virtual environment must be capable of compiling your contract for full support.

Installation

This language server imports Vyper as a library, so it should be installed in the same environment as your project's Vyper.

As a project dev dependency (recommended)

# pyproject.toml
[dependency-groups]
dev = [
    "vyper-language-server",
]

[tool.uv.sources]
vyper-language-server = { git = "https://github.com/latticafi/vyper-language-server" }

Then uv sync.

Via pipx (global)

pipx install git+https://github.com/latticafi/vyper-language-server.git

Note: when installed globally, the server will use whatever Vyper version is in its own environment, which may not match your project.

Verify

which vyper-language-server

Editor Setup

Neovim

Add to ~/.config/nvim/init.lua:

vim.api.nvim_create_autocmd({ "BufEnter" }, {
  pattern = { "*.vy" },
  callback = function()
    vim.lsp.start({
      name = "vyper-language-server",
      cmd = { "vyper-language-server" },
      root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
    })
  end,
})

If installed as a project dep, point to the venv binary:

vim.api.nvim_create_autocmd({ "BufEnter" }, {
  pattern = { "*.vy" },
  callback = function()
    local venv = vim.fs.find({ ".venv" }, { upward = true })[1]
    local cmd = venv and (venv .. "/bin/vyper-language-server") or "vyper-language-server"
    vim.lsp.start({
      name = "vyper-language-server",
      cmd = { cmd },
      root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
    })
  end,
})

Emacs

(define-derived-mode vyper-mode python-mode "Vyper" "Major mode for editing Vyper.")

(add-to-list 'auto-mode-alist '("\\.vy\\'" . vyper-mode))

(with-eval-after-load 'lsp-mode
  (add-to-list 'lsp-language-id-configuration
               '(vyper-mode . "vyper"))
  (lsp-register-client
   (make-lsp-client :new-connection
                    (lsp-stdio-connection `(,(executable-find "vyper-language-server")))
                    :activation-fn (lsp-activate-on "vyper")
                    :server-id 'vyper-language-server)))

Features

  • Diagnostics (compile errors and warnings)
  • Completions (state variables, functions, decorators, types, imports)
  • Hover information
  • Go to definition / declaration
  • Find references
  • Signature help

Development

Setup

  1. Install uv (Fast Python package installer and resolver)
   pip install uv
   # Or on macOS with Homebrew
   brew install uv
  1. Clone and install
   git clone https://github.com/latticafi/vyper-language-server.git
   cd vyper-language-server
   uv sync

Commands

uv run pytest                  # run tests
uv run ruff check .            # lint
uv run ruff format .           # format
uv run coverage run -m pytest  # test with coverage
uv run coverage report         # view coverage

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vyper_language_server-0.2.2.tar.gz (62.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vyper_language_server-0.2.2-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file vyper_language_server-0.2.2.tar.gz.

File metadata

  • Download URL: vyper_language_server-0.2.2.tar.gz
  • Upload date:
  • Size: 62.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vyper_language_server-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6ed62d99cc0c3de6753436d731c03300da9d1569aab85bcd2df21866710a2bcc
MD5 2e931399af4984f0e03c590ecdf022d8
BLAKE2b-256 37fe8a0425304dc584891bcdd20f7a85e39389c4bae188b2a790a61ad50ce337

See more details on using hashes here.

File details

Details for the file vyper_language_server-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: vyper_language_server-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vyper_language_server-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35509d2a654043e71a429ee2d9e6d6f533a6a860eb968e261bbb3ed9905bbf99
MD5 208dabafae946d399f1265e847c37ba5
BLAKE2b-256 3bd6efce25da8b35fd88c9c68c6c7b54841800e8d4dd5fc9b4df610c31d6bdba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page