Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@

[workspace]
members = ["crates/*", "xtask/"]
resolver = "2"

[workspace.dependencies]
parser = {path = "./crates/parser", version = "0.1.0"}
vfs = {path = "./crates/vfs", version = "0.1.0"}
syntax = {path = './crates/syntax', version = "0.1.0"}
circom-lsp = {path = './crates/lsp', version = "*"}
common = { path = './crates/common', version = "*"}
database = {path = "./crates/database", version = "*"}
# Internal crates
parser = { path = "./crates/parser" }
vfs = { path = "./crates/vfs" }
syntax = { path = "./crates/syntax" }
circom-lsp = { path = "./crates/lsp" }

# External crates
logos = "0.12.0"
rowan = "0.15.13"
lsp-types = "0.94.1"
lsp-server = "0.7.6"

serde = "1.0.216"
serde_json = "1.0.78"

anyhow = "1.0.79"
dashmap = "5.5.3"
path-absolutize = "3.1.1"

# For testing
insta = { version = "1.41.1" }

[profile.dev.package.insta]
opt-level = 3

[profile.dev.package.similar]
opt-level = 3

[workspace.package]
rust-version = "1.71"
74 changes: 65 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,65 @@
# Install
Install follow those commands:

```bash
git clone https://github.com/vuvoth/ccls
cd ccls
cargo xtask install --server
cargo xtask install --client
```
# CCLS

A language server for [Circom](https://docs.circom.io/), built with Rust and TypeScript.

## 🚀 Installation

1. **Clone the repository:**
```bash
git clone https://github.com/vuvoth/ccls.git
cd ccls
```

2. **Install Rust** (if not already installed):
👉 https://www.rust-lang.org/tools/install

3. **Build or test the project:**
```bash
cargo test # Run tests
cargo build # Build the project
```

---

## 🧪 Running Tests (with `insta` snapshots)

Optional, but recommended for snapshot testing.

1. **Install `cargo-insta`:**
```bash
curl -LsSf https://insta.rs/install.sh | sh
```

2. **Run the tests:**
```bash
cargo test
```

3. **Review snapshot changes:**
```bash
cargo insta review
```

📘 More info: [Insta Quickstart](https://insta.rs/docs/quickstart/)

---

## 🐞 Debugging the Extension

1. **Install CCLS server and client:**
```bash
cargo xtask install --server
cargo xtask install --client
npm audit fix --force # optional
```

2. **Run the extension in VSCode:**
- Open the `ccls` project in VSCode.
- Open the *Run and Debug* panel.
- Select `Run Extension (Debug Build)` and start debugging.

3. A new VSCode window will open.
Open a Circom file and try features like **Go to Definition**.

---

11 changes: 0 additions & 11 deletions SNAPSHOT_TEST.md

This file was deleted.

9 changes: 0 additions & 9 deletions crates/common/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion crates/common/src/lib.rs

This file was deleted.

10 changes: 0 additions & 10 deletions crates/database/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion crates/database/src/lib.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/database/src/main.rs

This file was deleted.

37 changes: 12 additions & 25 deletions crates/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,20 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
parser = { workspace = true }
vfs = { workspace = true }
syntax = { workspace = true }

env_logger = "0.9.0"
serde_json = "1.0.78"
serde = { version = "1.0", features = ["derive"] }
log = "0.4.18"
rowan = { workspace = true }
lsp-server = { workspace = true }
lsp-types = { workspace = true, features = ["proposed"] }

lsp-server = "0.7.6"
serde_json = { workspace = true }
serde = { workspace = true, features = ["derive"] }

rowan = "0.15.15"

lsp-types = {version = "0.94.1", features = ["proposed"]}
parser.workspace = true
vfs.workspace = true
syntax.workspace = true

anyhow = "1.0.79"
dashmap = "5.5.3"
path-absolutize = "3.1.1"

[profile]
dev.debug = 2
anyhow = { workspace = true }
dashmap = { workspace = true }
path-absolutize = { workspace = true }

[dev-dependencies]
# for snapshot testing, yaml format
insta = { version = "1.41.1", features = ["yaml"] }

[profile.dev.package]
# compile slightly slower once, but use less memory, have faster diffs
insta.opt-level = 3
similar.opt-level = 3
insta = { workspace = true, features = ["yaml"] }
21 changes: 5 additions & 16 deletions crates/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,10 @@ version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
logos = "0.12.0"
lsp-types = {version = "0.94.1", features = ["proposed"]}
rowan = "0.15.15"
num-traits = "0.2"
num-derive = "0.2"
serde = "1.0.216"

[profile.dev]
debug = 2
logos = { workspace = true }
lsp-types = { workspace = true, features = ["proposed"] }
rowan = { workspace = true }
serde = { workspace = true }

[dev-dependencies]
# for snapshot testing, yaml format
insta = { version = "1.41.1", features = ["yaml"] }

[profile.dev.package]
# compile slightly slower once, but use less memory, have faster diffs
insta.opt-level = 3
similar.opt-level = 3
insta = { workspace = true, features = ["yaml"] }
2 changes: 0 additions & 2 deletions crates/parser/src/grammar/statement.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::token_kind::TokenKind;

use super::{block::block, expression::expression, *};

pub(super) fn statement(p: &mut Parser) {
Expand Down
15 changes: 5 additions & 10 deletions crates/syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rowan = "0.15.13"
parser.workspace = true
lsp-types = {version = "0.94.1", features = ["proposed"]}
parser = { workspace = true }

[dev-dependencies]
# for snapshot testing, yaml format
insta = { version = "1.41.1", features = ["yaml"] }
rowan = { workspace = true }
lsp-types = { workspace = true, features = ["proposed"] }

[profile.dev.package]
# compile slightly slower once, but use less memory, have faster diffs
insta.opt-level = 3
similar.opt-level = 3
[dev-dependencies]
insta = { workspace = true, features = ["yaml"] }
2 changes: 0 additions & 2 deletions crates/syntax/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub mod abstract_syntax_tree;
pub mod syntax;
pub mod syntax_node;
mod utils;
mod view_syntax;
7 changes: 6 additions & 1 deletion crates/syntax/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ pub fn syntax_node_from_source(source: &str, scope: Scope) -> SyntaxNode {
syntax
}

#[cfg(test)]
mod test_utils;

#[cfg(test)]
mod tests {
use crate::test_syntax;
use parser::grammar::entry::Scope;

use crate::syntax::test_utils::view_ast;
use crate::test_syntax;

#[test]
fn pragma_happy_test() {
test_syntax!("/src/test_files/happy/pragma.circom", Scope::Pragma);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
use crate::syntax_node::SyntaxNode;

pub use rowan::{NodeOrToken, WalkEvent};

fn level_str(level: u32) -> String {
let mut ans = String::from("");
use crate::syntax_node::SyntaxNode;

for _i in 0..level {
ans.push_str("| ");
}
ans
#[macro_export]
macro_rules! test_syntax {
($file_path:expr, $scope: expr) => {
let crate_path = std::env::var("CARGO_MANIFEST_DIR").unwrap();

let full_path = format!("{}{}", crate_path, $file_path);
let source = std::fs::read_to_string(full_path).expect("Should not failed");
let syntax = crate::syntax::syntax_node_from_source(&source, $scope);
insta::assert_snapshot!($file_path, view_ast(&syntax));
};
}

pub(crate) fn view_ast(node: &SyntaxNode) -> String {
pub fn view_ast(node: &SyntaxNode) -> String {
let mut level = 0;
let mut result = String::new();
for event in node.preorder_with_tokens() {
Expand Down Expand Up @@ -47,3 +50,12 @@ pub(crate) fn view_ast(node: &SyntaxNode) -> String {
}
return result;
}

fn level_str(level: u32) -> String {
let mut ans = String::from("");

for _i in 0..level {
ans.push_str("| ");
}
ans
}
10 changes: 0 additions & 10 deletions crates/syntax/src/utils.rs

This file was deleted.

8 changes: 2 additions & 6 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ edition = "2021"
rust-version.workspace = true

[dependencies]
anyhow = "1.0.62"
flate2 = "1.0.24"
write-json = "0.1.2"
anyhow = { workspace = true }
xshell = "0.2.2"
xflags = "0.3.0"
time = { version = "0.3", default-features = false }
zip = { version = "0.6", default-features = false, features = ["deflate", "time"] }
# Avoid adding more dependencies to this crate
# Avoid adding more dependencies to this crate