Skip to content

Commit

Permalink
LS: Proc macros support
Browse files Browse the repository at this point in the history
closes #6141

commit-id:7ea22adb
  • Loading branch information
Draggu committed Nov 12, 2024
1 parent 3874879 commit 3709348
Show file tree
Hide file tree
Showing 19 changed files with 981 additions and 29 deletions.
175 changes: 161 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/cairo-lang-language-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ cairo-lang-starknet = { path = "../cairo-lang-starknet", version = "~2.8.4" }
cairo-lang-syntax = { path = "../cairo-lang-syntax", version = "~2.8.4" }
cairo-lang-test-plugin = { path = "../cairo-lang-test-plugin", version = "~2.8.4" }
cairo-lang-utils = { path = "../cairo-lang-utils", version = "~2.8.4" }
cairo-lang-macro = { git = "https://github.com/software-mansion/scarb", rev = "fc99b54" } # not registry version because conflict with scarb-proc-macro-server-types local version
crossbeam = "0.8.4"
governor = { version = "0.7.0", default-features = false, features = ["std", "quanta"]}
indent.workspace = true
indoc.workspace = true
itertools.workspace = true
Expand All @@ -35,6 +37,7 @@ lsp-types = "=0.95.0"
rustc-hash = "1.1.0"
salsa.workspace = true
scarb-metadata = "1.13"
scarb-proc-macro-server-types = { git = "https://github.com/software-mansion/scarb", rev = "fc99b54" }
serde = { workspace = true, default-features = true }
serde_json.workspace = true
smol_str.workspace = true
Expand Down
15 changes: 15 additions & 0 deletions crates/cairo-lang-language-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub struct Config {
/// The property is set by the user under the `cairo1.traceMacroDiagnostics` key in client
/// configuration.
pub trace_macro_diagnostics: bool,
/// Whether to resolve procedural macros or ignore them.
///
/// The property is set by the user under the `cairo1.disableProcMacros` key in client
/// configuration.
/// [`None`] means that config has not yet been loaded from client.
/// We want to default it to `false`, but to prevent proc-macro-server from starting
/// immediately even if client want to set it to `true` we uses this 3rd value.
pub disable_proc_macros: Option<bool>,
}

impl Config {
Expand All @@ -61,6 +69,10 @@ impl Config {
scope_uri: None,
section: Some("cairo1.traceMacroDiagnostics".to_owned()),
},
ConfigurationItem {
scope_uri: None,
section: Some("cairo1.disableProcMacros".to_owned()),
},
];
let expected_len = items.len();

Expand All @@ -86,6 +98,9 @@ impl Config {
.map(Into::into);
state.config.trace_macro_diagnostics =
response.pop_front().as_ref().and_then(Value::as_bool).unwrap_or_default();
state.config.disable_proc_macros = Some(
response.pop_front().as_ref().and_then(Value::as_bool).unwrap_or_default(),
);

debug!("reloaded configuration: {:#?}", state.config);
})
Expand Down
Loading

0 comments on commit 3709348

Please sign in to comment.