Skip to content

parmanuxyz/solidity-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solidity-analyzer

Telegram

Goal is to create and provide improved devex over current extensions for foundry projects with maybe hardhat support(through foundry) in future.

Features

  • Formatting (with foundry, same as forge fmt while respecting configs)
  • Diagnostics (compiler errors and warnings on standard dapptools/foundry structure projects work. Optimizations, configurations, perf, etc. yet to come)
  • Outline (could add more details)

Installation

  1. Install the language server:
    # ensure that ~/.cargo/bin is in your path for the extension to be able to find it
    cargo +nightly install --git https://github.com/parmanuxyz/solidity-analyzer --bin solidity-analyzer-ls
  2. Install the companion vscode prerelease extension from the marketplace

Language Server

$ cargo b

Check the configuration path below. Logs are located in ~/solidity-analyzer.log

VSCode Extension Development/Debug

Open extension.ts in VSCode and run in debug mode with F5.

Install the pre-release from VSCode marketplace here.

Configuration

VSCode

The extension will try to run the language server from the paths in following order:

  1. solidity-analyzer.languageServerPath configuration value if it exists
  2. SOLIDITY_ANALYZER_SERVER_PATH environment variable if it exists
  3. Will search the folders in PATH to see if solidity-analyzer-ls exists in any of them. Will run the first entry it'd find.
  4. If it doesn't even exist in the PATH it will try ~/bin/solidity-analyzer-ls.
  5. If found nowhere it'd show an error and exit.

neovim

Configure neovim to use solidity-analyzer-ls as follows:

local configs = require 'lspconfig.configs'
local lspconfig = require 'lspconfig'

-- Check if the config is already defined (useful when reloading this file)
if not configs.solidity_analyer_lsp then
  configs.solidity_analyzer_lsp = {
    default_config = {
      cmd = {vim.fn.expand('$HOME/.cargo/bin/solidity-analyzer-ls')},
      filetypes = {'solidity'},
      root_dir = lspconfig.util.root_pattern('foundry.toml') or function(fname)
        return lspconfig.util.find_git_ancestor(fname)
      end,
      settings = {},
    },
  }
end

lspconfig.solidity_analyzer_lsp.setup{}