Skip to main content

Language server for Vyper, a pythonic smart contract language

Project description

Vyper LSP Server

Requirements

Vyper LSP requires a minimum vyper version of 0.3.7. For full support, it is also required that the Vyper version installed in your virtual environment is capable of compiling your contract.

For example, a vyper contract with #pragma version 0.3.8 cannot be compiled with 0.3.10, so you must install vyper==0.3.8 if you want full support while working with this contract.

A contract with #pragma version >=0.3.8 will work fine with any installed vyper version greater than the requirement, so you can get full support while editing this contract if you have the latest vyper version installed.

Install Vyper-LSP

via pipx

I like pipx because it handles creating an isolated env for executables and putting them on your path.

pipx install git+https://github.com/vyperlang/vyper-lsp.git

via pip

You can install using pip if you manage your environments through some other means:

TODO: publish on pypi

pip install git+https://github.com/vyperlang/vyper-lsp.git

Verify installation

Check that vyper-lsp is on your path:

In your terminal, run which vyper-lsp. If installation was succesful, you should see the path to your installed executable.

Editor Setup

Emacs

The following emacs lisp snippet will create a Vyper mode derived from Python Mode, and sets up vyper-lsp.

(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-lsp")))
                    :activation-fn (lsp-activate-on "vyper")
                    :server-id 'vyper-lsp)))

Neovim

Add the following to your neovim lua config.

It should be at ~/.config/nvim/init.lua

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

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

vim.api.nvim_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'gr', '<Cmd>lua vim.lsp.buf.references()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'gi', '<Cmd>lua vim.lsp.buf.implementation()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-k>', '<Cmd>lua vim.lsp.buf.signature_help()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '[d', '<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', ']d', '<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>', { noremap = true, silent = true })

VS Code

See vyper-lsp VS Code extension

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-lsp-0.0.8.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

vyper_lsp-0.0.8-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file vyper-lsp-0.0.8.tar.gz.

File metadata

  • Download URL: vyper-lsp-0.0.8.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.6 Darwin/23.0.0

File hashes

Hashes for vyper-lsp-0.0.8.tar.gz
Algorithm Hash digest
SHA256 1a9af146f6bd71f59bea3e38a2991fd9e8fbdf5313352ee521356690e1b7232a
MD5 c74cd7f20cbdb4e02a4a0227f38c3e64
BLAKE2b-256 a0faf12a07e4dcacca72e430223148d2646c1bc944a3ed653fd9dcc1292ed622

See more details on using hashes here.

File details

Details for the file vyper_lsp-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: vyper_lsp-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.6 Darwin/23.0.0

File hashes

Hashes for vyper_lsp-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 340ae236393e7485aa67b9aa25f412d31000dae0d62fa7e4a14f9ddc82dad806
MD5 8d2fc1aa6de160e8c48ee1fc37c9ffe1
BLAKE2b-256 bd5f5624a57b7c6bf0e08fad84368c16d052dbf944644c74d00e92fb8a56f745

See more details on using hashes here.

Supported by

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