Skip to content

Conversation

@Patotking12
Copy link

@Patotking12 Patotking12 commented Jan 22, 2026

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.

@Patotking12 Patotking12 requested a review from delta1 as a code owner January 22, 2026 23:15
@delta1
Copy link
Collaborator

delta1 commented Jan 23, 2026

Thanks @Patotking12 ! Could you please run rustfmt and eslint, see the CI jobs

@Patotking12
Copy link
Author

Done! Fixed the eslint issue. CI should pass now. @delta1

}

throw new Error(
"simc compiler not found. Install it with: cargo install --path . " +
Copy link
Contributor

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

Copy link
Author

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

Comment on lines 843 to 850
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),
));
}
}
Copy link
Contributor

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

Copy link
Author

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.
Copy link
Contributor

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

Copy link
Author

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

Comment on lines 137 to 143
// 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[] = [];
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Contributor

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:

  1. In most cases, it overlaps with LSP diagnostics.
  2. 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.
  3. 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.

Copy link
Author

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

@gerau
Copy link
Contributor

gerau commented Jan 23, 2026

I don't think we need to add more examples to vscode/examples. While it's good to showcase the extension's capabilities, we already have examples in this repo.

@Patotking12
Copy link
Author

Also deleted the examples folder I added

Copy link
Contributor

@gerau gerau left a 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?

Comment on lines 46 to 50
const action = await vscode.window.showInformationMessage(
"SimplicityHL compiled successfully!",
"Copy Program",
"Copy Both",
"Dismiss"
);
Copy link
Contributor

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.

Copy link
Author

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

Comment on lines 111 to 127
// 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 --";
}
}
Copy link
Contributor

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?

Copy link
Author

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

Comment on lines 45 to 65
#[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,
],
Copy link
Contributor

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?

Copy link
Author

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

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the file

@Patotking12
Copy link
Author

Done, squashed everything into 3 clean commits

@Patotking12 Patotking12 requested a review from gerau January 27, 2026 14:22
@gerau
Copy link
Contributor

gerau commented Jan 27, 2026

ACK dc3e43e

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

Successfully merging this pull request may close these issues.

3 participants