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

with emacs lsp-bridge package, textDocument/definition find contract definition not work #573

Open
getong opened this issue May 26, 2024 · 6 comments

Comments

@getong
Copy link

getong commented May 26, 2024

The code file example contracts/BasicERC20.sol from
https://github.com/protokol/solidity-typescript-hardhat-template

The code sample:

import { ERC20Pausable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";

find ERC20Pausable definition fail:

--- [10:15:13.605713] Send textDocument/definition request (44080) to 'solidity' for project 
{
   "id": 44080,
   "method": "textDocument/definition",
   "params": {
      "position": {
         "line": 6,
         "character": 9
      },
      "textDocument": {
         "uri": "file:///Users/gerald/test/typescript/solidity-typescript-hardhat-template/contracts/BasicERC20.sol"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [10:15:13.606691] Recv textDocument/definition response (44080) from 'solidity' for project 
Eval in Emacs: (lsp-bridge-find-def-fallback '(:line 6 :character 9))
{
   "jsonrpc": "2.0",
   "id": 44080,
   "result": null
}

But find the file definition works, find the "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol", it jump to the right file

--- [10:16:13.605574] Send textDocument/definition request (3315) to 'solidity' for project 
{
   "id": 3315,
   "method": "textDocument/definition",
   "params": {
      "position": {
         "line": 6,
         "character": 95
      },
      "textDocument": {
         "uri": "file:///Users/gerald/test/typescript/solidity-typescript-hardhat-template/contracts/BasicERC20.sol"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [10:16:13.606381] Recv textDocument/definition response (3315) from 'solidity' for project 
Eval in Emacs: (lsp-bridge-define--jump '"/Users/gerald/test/typescript/solidity-typescript-hardhat-template/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol" '"" '(:line 6 :character 0))
{
   "jsonrpc": "2.0",
   "id": 3315,
   "result": {
      "uri": "file:///Users/gerald/test/typescript/solidity-typescript-hardhat-template/node_modules/%40openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol",
      "range": {
         "start": {
            "line": 6,
            "character": 0
         },
         "end": {
            "line": 6,
            "character": 96
         }
      }
   }
}

I also test the code with emacs lsp-mode package, same behaviour, same error.

@kanej
Copy link
Member

kanej commented Jun 3, 2024

I have not been able to reproduce this error when navigating within the vscode extension against the protokol template repo.

Which version of the language server is being used by the emacs package?

@getong
Copy link
Author

getong commented Jun 3, 2024

0.9.0
I know this work with vscode, but it does not work with emacs.
I does not test it with vim, you might take a test with vim.

@kanej
Copy link
Member

kanej commented Jun 4, 2024

0.9.0 I know this work with vscode, but it does not work with emacs. I does not test it with vim, you might take a test with vim.

The latest version of the solidity language server is 0.8.3, is 0.9.0 the version of the emacs package?

Can you try updating to the last language server and retesting?

I initially thought there might be a mapping issue with the line/column numbers coming from the emacs package, but the message shown matches the message that vscode sends for onDefinition for the ERC20Pausable token in BasicERC20.sol. If other messages are give correct responses then is suggests it is not a message encoding issue either.

@getong
Copy link
Author

getong commented Jun 4, 2024

I update it with

npm install @nomicfoundation/solidity-language-server -g

same error

Does it setup with initial setting?

@kanej
Copy link
Member

kanej commented Jun 14, 2024

The defaults should work in this case. The directory that you start the language server might have an effect, if its not able to identify the Hardhat/Foundry project directory.

Can you point me to the emacs package you are using to interact with our Language Server?

@getong
Copy link
Author

getong commented Jun 14, 2024

@kanej kanej moved this to Backlog in hardhat-vscode Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants