LSP: `textDocument/definition` always returns "result":[]
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Description
## Environment
- Compiler version: Version: 0.8.14+commit.80d49f37.Windows.msvc
- Target EVM version (as per compiler settings): default
- Framework/IDE (e.g. Truffle or Remix): Notepad++ 8.3.3. 64bit & https://github.com/Ekopalypse/NppLspClient V0.0.9 64 bits
- EVM execution environment / backend / blockchain client: default
- Operating system: Windows
## Steps to Reproduce
### setup
Install `solc-windows.exe` in `C:\tmp\solidity\`
Install `Notepad++`
Setup a language definition for Solidity in `Notepad++` (for example via `https://github.com/alin1popa/solidity-notepadplusplus-userdefined-highlight`)
Download `https://github.com/Ekopalypse/NppLspClient/releases/download/v.0.0.9-alpha/NppLspClient_x64.zip`
Install `NppLspClient.dll` in `C:\Program Files\Notepad++\plugins\NppLspClient`
Edit config file via menu `open configuration file` (`NppLspClientConfig.toml`) to contain:
```
[lspservers.solidity]
executable = 'C:\tmp\solidity\solc-windows.exe'
args = '--lsp'
mode = "io"
auto_start_server = true
```
Have some sample soldity files in `C:\tmp\solidity\`
test.sol:
```solidity
// SPDX-License-Identifier: MIT
import "test2.sol";
contract test() {
uint x=1;
uint y=x;
}
```
test2.sol
```solidity
// SPDX-License-Identifier: MIT
```
### test in Notepad++
Open file `test.sol` in `Notepad++`
In menu option `Plugins/NppLspClient_x64` choose `Toggle Console` to see debug output.
Put the cursor on `import`
In menu option `Plugins/NppLspClient_x64` choose `Goto Definition`
Now nothing happens in the editor main screen.
The LSP output console shows: `{"id":4,"jsonrpc":"2.0","result":[]}`
So somehow the lookup doesn't work.
The same happens with anything else I select.
Note: the detection of syntax errors does work and is shown in the editor, so the LSP interaction does work.
### full log
```
checking current lexer
checking language server status: solidity
trying to start C:\tmp\solidity\solc-windows.exe
running
on_initialize: 15908
write_to_stdin: Content-Length: 2128
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":15908,"clientInfo":{"name":"NppLspClient","version":"0.0.1"},"rootUri":"file:///C%3A/tmp/solidity","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":false,"workspaceEdit":{"documentChanges":false},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"configuration":false,"workspaceFolders":false},"textDocument":{"publishDiagnostics":{"relatedInformation":false},"synchronization":{"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false,"didSave":true},"completion":{"dynamicRegistration":false,"contextSupport":false,"completionItem":{"snippetSupport":false,"commitCharactersSupport":false,"documentationFormat":["plaintext"],"deprecatedSupport":false},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"]}},"definition":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"codeAction":{"dynamicRegistration":false},"codeLens":{"dynamicRegistration":false},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"onTypeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"foldingRange":{"dynamicRegistration":false,"rangeLimit":100,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
on_message_received: Content-Length: 205
{"id":0,"jsonrpc":"2.0","result":{"capabilities":{"definitionProvider":true,"implementationProvider":true,"textDocumentSync":{"change":2,"openClose":true}},"serverInfo":{"name":"solc","version":"0.8.14"}}}
initialized response received
write_to_stdin: Content-Length: 52
{"jsonrpc":"2.0","method":"initialized","params":{}}
on_file_opened:: solidity: C:\tmp\solidity\test.sol
on_file_opened: initialized=true
write_to_stdin: Content-Length: 291
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///C%3A/tmp/solidity/test.sol","languageId":"solidity","version":0,"text":"// SPDX-License-Identifier: MIT\r\nimport \"test2.sol\";\r\n\r\ncontract test() {\r\n uint x=1;\r\n uint y=x;\r\n} \r\n"}}}
on_message_received: Content-Length: 299
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":2314,"message":"ParserError: Expected '{' but got '('","range":{"end":{"character":14,"line":3},"start":{"character":13,"line":3}},"severity":1,"source":"solc"}],"uri":"file:///C%3A/tmp/solidity/test.sol"}}
write_to_stdin: Content-Length: 166
{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///C%3A/tmp/solidity/test.sol"},"position":{"character":0,"line":1}}}
on_message_received: Content-Length: 36
{"id":1,"jsonrpc":"2.0","result":[]}
```
Contributor guide
Research direction
Start with the provided test.sol and test2.sol files and reproduce the logged textDocument/definition request using solc-windows.exe with --lsp. Compare the response for the import and selected symbols with the diagnostics that already work; done means definition lookups return the expected locations instead of an empty result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100