-
Notifications
You must be signed in to change notification settings - Fork 23
Feat/vscode enhance #199
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: master
Are you sure you want to change the base?
Feat/vscode enhance #199
Conversation
|
Thanks @Patotking12 ! Could you please run rustfmt and eslint, see the CI jobs |
|
Done! Fixed the eslint issue. CI should pass now. @delta1 |
vscode/src/compile.ts
Outdated
| } | ||
|
|
||
| throw new Error( | ||
| "simc compiler not found. Install it with: cargo install --path . " + |
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.
It's better to leave a link to SimplicityHL readme, because cargo install --path . don't do anything on it's own
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.
Updated to link to the README instead
lsp/src/backend.rs
Outdated
| if !value_str.starts_with("0x") { | ||
| if let Some(pos) = find_value_position(text, name, "value") { | ||
| diagnostics.push(Diagnostic::new_simple( | ||
| Range::new(pos, pos), | ||
| format!("Witness '{}' value must start with '0x' (hex format)", name), | ||
| )); | ||
| } | ||
| } |
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.
The witness is not required to be a hex number
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.
Good catch, totally slipped my mind to remove that
The witness validation was added as a basic example to show we can validate .wit files in real-time (checking JSON structure, required fields)
| ) | ||
| } | ||
|
|
||
| /// Validate a witness (.wit) file and return diagnostics. |
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.
It would be nice if the functions below could be moved into utils.rs
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.
Good suggestion, moved the helper functions to utils.rs for better organization
Also moved the related tests to utils.rs since the functions they test now live there
vscode/src/compile.ts
Outdated
| // Parse simc error output into VSCode diagnostics. | ||
| // Error format: | ||
| // | | ||
| // 1 | let a1: List<u32, 5> = None; | ||
| // | ^^^^^^ Expected a power of two... | ||
| public parseErrors(output: string): vscode.Diagnostic[] { | ||
| const diagnostics: vscode.Diagnostic[] = []; |
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.
Don't we already have diagnostics via LSP?
The language server output matches simc, so it's essentially showing the same problem twice.
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.
The compiler diagnostics are intentional, they show the actual simc output when you run a build command
The LSP provides real-time feedback while editing, but the compiler is the source of truth
There is some overlap when both report the same error, but the compiler output is useful for the build workflow as it shows exactly what simc says. Happy to remove if you think it's too redundant
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.
I like having the idea of diagnostics from simc, as it is really helpful for testing; however, I don't think that we need it right now for three reasons:
- In most cases, it overlaps with LSP diagnostics.
- In cases where it doesn't overlap (like errors for missing witnesses or params), it doesn't show the position of the problem, so it isn't very helpful.
- If the display of errors changes, we would be required to rewrite this part, making it harder to maintain.
So, for now, I think we should not parse errors from the simc output, but in the future we could look into implementing this differently.
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.
Ok, will proceed to remove it
|
I don't think we need to add more examples to |
|
Also deleted the examples folder I added |
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.
Thank you for your PR and fixes! These are really great features for the development experience.
Could you please resolve these issues and squash or restructure the later commits so the final history looks like your first three commits?
| const action = await vscode.window.showInformationMessage( | ||
| "SimplicityHL compiled successfully!", | ||
| "Copy Program", | ||
| "Copy Both", | ||
| "Dismiss" | ||
| ); |
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.
I think we should remove "Copy Both" and the related code for this action, as it compiles without a witness. We should also create a similar action prompt for the "simplicityhl.compileWithWitness" command to handle this functionality.
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.
Removed "Copy Both" from basic compile
Added "Copy Program" and "Copy Witness" options to the witness compile command instead
vscode/src/tasks.ts
Outdated
| // Locate simc compiler, fallback to cargo run if not installed | ||
| private async getSimcPath(): Promise<string> { | ||
| const config = vscode.workspace.getConfiguration("simplicityhl"); | ||
| const configuredPath = config.get<string>("compiler.path"); | ||
| if (configuredPath?.trim()) { | ||
| return configuredPath; | ||
| } | ||
|
|
||
| const simcPath = findExecutable("simc"); | ||
| if (simcPath) { | ||
| return simcPath; | ||
| } | ||
|
|
||
| // Fallback: run via cargo (useful during development) | ||
| return "cargo run --release --"; | ||
| } | ||
| } |
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.
Can we import getSimcPath from compile.ts instead of redefining it here?
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.
Done, now imports from compile.ts
lsp/src/backend.rs
Outdated
| #[allow(dead_code)] | ||
| mod semantic_token_types { | ||
| pub const FUNCTION: u32 = 0; | ||
| pub const PARAMETER: u32 = 1; | ||
| pub const VARIABLE: u32 = 2; | ||
| pub const TYPE: u32 = 3; | ||
| pub const KEYWORD: u32 = 4; | ||
| pub const NAMESPACE: u32 = 5; | ||
| } | ||
|
|
||
| /// Get the semantic token legend for this server | ||
| fn get_semantic_token_legend() -> SemanticTokensLegend { | ||
| SemanticTokensLegend { | ||
| token_types: vec![ | ||
| SemanticTokenType::FUNCTION, | ||
| SemanticTokenType::PARAMETER, | ||
| SemanticTokenType::VARIABLE, | ||
| SemanticTokenType::TYPE, | ||
| SemanticTokenType::KEYWORD, | ||
| SemanticTokenType::NAMESPACE, | ||
| ], |
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.
Could you remove #[allow(dead_code)] and delete unused semantic token types?
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.
Removed and deleted the unused
vscode/docs/updates.md
Outdated
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.
I think it might be better suited for the PR description rather than the docs/ folder, which is usually for actual documentation.
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.
Deleted the file
665dce8 to
dc3e43e
Compare
|
Done, squashed everything into 3 clean commits |
|
ACK |
Added build integration to the VSCode extension with a task provider that runs simc and shows output in a dedicated channel. Also added code snippets for common patterns and custom file icons for .simf and .wit files.
On the LSP side, implemented document symbols for the outline view, signature help for function parameter hints, semantic tokens for AST-based highlighting of functions and namespaces, and witness file validation that checks types and reports missing or extra fields in real-time.