Skip to content

Commit

Permalink
README: add neovim config
Browse files Browse the repository at this point in the history
  • Loading branch information
meetmangukiya committed Oct 10, 2023
1 parent 8cfe097 commit 681eb36
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $ cargo b

Check the [configuration path below](#configuration). Logs are located in `~/solidity-analyzer.log`

## Extension
## VSCode Extension

Open [`extension.ts`](./client/src/extension.ts) in VSCode and run in debug mode
with <kbd>F5</kbd>.
Expand All @@ -35,10 +35,37 @@ Install the pre-release from VSCode marketplace [here](https://marketplace.visua

### 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:

```lua
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{}
```

0 comments on commit 681eb36

Please sign in to comment.