-
Notifications
You must be signed in to change notification settings - Fork 373
[circt-verilog-lsp] Add hover support #8304
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
base: dev/hidetou/lsp-features/inlay-hints
Are you sure you want to change the base?
[circt-verilog-lsp] Add hover support #8304
Conversation
Add hover functionality to the CIRCT Verilog LSP server. This includes hover provider capability in server initialization and hover context line configuration option. The implementation adds hover support for Verilog symbols showing type information, definition location with source code, and links to source locations. It also implements hover for external source locations showing context-aware source code snippets and links to external files. The hover feature provides rich information when hovering over Verilog symbols (showing type and definition) and source location annotations (showing external source contents such as MLIR and scala).
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// ----- | ||
// Find definition of `include/test.mlir:2:5` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Find definition of `include/test.mlir:2:5` | |
// Find hover of `include/test.mlir:2:5` |
This has an out of bounds if the definition is on the first line of a file. Reproduction: module thing(input var[2:0] a, output var [2:0] b);
logic [2:0] c;
assign c = a;
assign b = c;
endmodule Hover on Hover on
Minimal solution: diff --git a/lib/Tools/circt-verilog-lsp-server/VerilogServerImpl/VerilogServer.cpp b/lib/Tools/circt-verilog-lsp-server/VerilogServerImpl/VerilogServer.cpp
index 7bd80a6c47..a2933f1eeb 100644
--- a/lib/Tools/circt-verilog-lsp-server/VerilogServerImpl/VerilogServer.cpp
+++ b/lib/Tools/circt-verilog-lsp-server/VerilogServerImpl/VerilogServer.cpp
@@ -1297,6 +1297,9 @@
auto offest = loc.offset();
// Find line boundaries around the location
auto start = text.find_last_of('\n', offest);
+ if (start == text.npos) {
+ start = 0;
+ }
auto end = text.find_first_of('\n', offest);
return StringRef(text.substr(start, end - start)).trim();
} |
Great point, thanks! The fix makes sense, I'll include your fix, thanks! |
Sorry for the delay, I'll rebase the series of the PRs this week! |
Add hover functionality to the CIRCT Verilog LSP server.
The implementation adds hover support for Verilog symbols showing type information, definition location with source code, and links to source locations. It also implements hover for external source locations showing code snippets and links to external files.