Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WIP] Add option documentation to :set-option, :get-option. #6174

Closed
wants to merge 2 commits into from
Closed
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
46 changes: 46 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ chrono = { version = "0.4", default-features = false, features = ["alloc", "std"

etcetera = "0.4"
textwrap = "0.16.0"
schemars = { version = "0.8.12", features = ["derive_json_schema"] }

[dev-dependencies]
quickcheck = { version = "1", default-features = false }
39 changes: 38 additions & 1 deletion helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::{
};

use once_cell::sync::{Lazy, OnceCell};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use helix_loader::grammar::{get_language, load_runtime_file};
Expand Down Expand Up @@ -328,6 +329,42 @@ impl FromStr for AutoPairConfig {
}
}

// Allow runtime enable/disable with documentation. Changing the pair mapping at runtime
// is currently not possible.
impl JsonSchema for AutoPairConfig {
fn schema_name() -> String {
"AutoPairConfig".to_owned()
}

fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
#[derive(JsonSchema)]
struct FakeAutoPairsConfig {
/// docs
auto_pairs: bool,
}

impl Default for FakeAutoPairsConfig {
fn default() -> Self {
FakeAutoPairsConfig { auto_pairs: true }
}
}

let schema = FakeAutoPairsConfig::json_schema(gen);
log::debug!("runtime_options: {:#?}", &schema);

schema
.into_object()
.object()
.properties
.to_owned()
.get("auto_pairs")
.unwrap()
.clone()
.into_object()
.into()
}
}

#[derive(Debug)]
pub struct TextObjectQuery {
pub query: Query,
Expand Down Expand Up @@ -547,7 +584,7 @@ impl LanguageConfiguration {
.ok()
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
pub struct SoftWrap {
/// Soft wrap lines that exceed viewport width. Default to off
Expand Down
1 change: 1 addition & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ serde = { version = "1.0", features = ["derive"] }
# ripgrep for global search
grep-regex = "0.1.11"
grep-searcher = "0.1.11"
schemars = { version = "0.8.12", features = ["derive_json_schema"] }

[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
Expand Down
1 change: 1 addition & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub(crate) mod dap;
pub(crate) mod lsp;
pub(crate) mod runtime_options;
pub(crate) mod typed;

pub use dap::*;
Expand Down
Loading