Reputation: 41
Firtsble solidity-ls installed by mason via neovim command
:LspInstall solidity-ls
wasn't executable from terminal, altough it was shown as an executable one when typing :LspInfo in .sol file. After I installed it manually via npm
npm i solidity-ls -g
This is configuration for solidity-ls
require'lspconfig'.solidity.setup({
on_attach = on_attach,
})
With this empty configuration however root directory is not found, also solidity-ls is not attached to the file which I guess is just a consequence.
After adding root_dir manually in a following way and checking the file via luafile %
require'lspconfig'.solidity.setup({
on_attach = on_attach,
root_dir = function(fname)
return vim.fn.getcwd()
end,
})
I get this error
LSP[solidity]: Error SERVER_REQUEST_HANDLER_ERROR: "/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:86: bad argument #1 to 'ipairs' (table expected, got nil)"
Although :LspInfo shows root_dir is set up solidity-ls still is not attached
LspInfo from .sol file after
Any suggestion how to solve this?
Ubuntu 20.04.3 LTS NVIM v0.7.2
I am new in vim, neovim and lua programming so apologizes in advance in case the question is too silly. Thanks.
Upvotes: 1
Views: 443
Reputation: 1
First, "solidity-ls" should be installed using the command :
:LspInstall solidity
You can find a complete mapping for mason.lsp-config here.
:LspInstall solidity-ls
Doesn't exist so i assume you used this command instead :
:LspInstall solidity_ls
In that case, you actually installed "vscode-solidity-server" and thus you should had the correct cmd configuration in your setup.
require("lspconfig")["solidity"].setup {
cmd = { 'vscode-solidity-server', '--stdio' },
}
There is probably another way that consist of configuring the default solidity lsp server to solidity_ls instead of solidity that I am not aware of.
Also, you have to be aware of the fact that "vscode-solidity-server" doesn't provide you with a solc compiler. I recommend you to install solc-select to install the last version of solc.
Upvotes: 0