Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file not found error in solidity files when importing from node_modules #9

Open
pchabros opened this issue Jan 25, 2022 · 2 comments
Open

Comments

@pchabros
Copy link

Hi Christian,

Sorry if this is not the best way to ask the question, but
can you please, please help me with those annoying errors? :)

image

I've copied from your config files:

require("lspconfig").solang.setup({
  cmd = { "solang", "--language-server", "--target", "ewasm", "--importpath", "node_modules/" },
})
require("lspconfig").solc.setup({
  cmd = { "solc", "--lsp", "--include-path", "../node_modules" },
})

but I still have those errors :/

@ChristianChiarulli
Copy link
Owner

yea, this was only me testing to see if I could make that work, but I wasn't able to make it work. Doesn't work in VSCode either btw. I would recommend reaching out on the solang and the official solc LSP repos and see if they can help.

Also let me know if you ever solve this.

@JeremyChuaWX
Copy link

JeremyChuaWX commented May 20, 2022

  • For solc, the --lsp mode doesnt support --include-path yet, as per 12994.
  • For now, i have been using solidity ls with these settings:
return {
    root_dir = function (fname)
        local git_root = require("lspconfig").util.find_git_ancestor(fname)
        local pkg_root = require("lspconfig").util.find_package_json_ancestor(fname)

        if git_root then
            return git_root
        elseif pkg_root then
            return pkg_root
        end
    end,
	settings = {
		solidity = {
			packageDefaultDependenciesContractDirectory = "",
			packageDefaultDependenciesDirectory = "node_modules",
			enabledAsYouTypeCompilationErrorCheck = true,
			linter = "solhint",
		},
	},
}
  • I cant seem to get the autocomplete feature for openzeppelin contracts to work, but i can gotoDefinition
  • With solidity ls, it populates cmp with the imported contract's functions though (eg: when importing ERC721, cmp will have completion for methods like _safeMint etc)

[edit]

  • I got the openzeppelin auto completion import working by creating a binding in cmp to open the cmp menu
["<C-y>"] = cmp.mapping({
    i = cmp.mapping.complete(),
}),

alexanderwid pushed a commit to alexanderwid/nvim that referenced this issue Feb 27, 2023
indent_blankline_ part has to be removed from configuration variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants