Unnamed repository; edit this file 'description' to name the repository.
hmm
| -rw-r--r-- | Cargo.lock | 25 | ||||
| -rw-r--r-- | helix-core/Cargo.toml | 2 | ||||
| -rw-r--r-- | helix-core/src/snippets.rs | 2 | ||||
| -rw-r--r-- | helix-core/src/syntax.rs | 43 | ||||
| -rw-r--r-- | helix-lsp-types/src/completion.rs | 2 | ||||
| -rw-r--r-- | helix-lsp-types/src/lib.rs | 10 | ||||
| -rw-r--r-- | helix-term/Cargo.toml | 30 | ||||
| -rw-r--r-- | rust-toolchain.toml | 3 |
8 files changed, 101 insertions, 16 deletions
@@ -287,6 +287,12 @@ dependencies = [ ] [[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1703,6 +1709,7 @@ dependencies = [ "tokio", "tokio-stream", "toml", + "tree-house", "url", ] @@ -2345,6 +2352,16 @@ dependencies = [ ] [[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] name = "prettyplease" version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3103,11 +3120,13 @@ dependencies = [ "hashbrown 0.15.5", "kstring", "once_cell", + "pretty_assertions", "regex", "regex-cursor", "ropey", "slab", "tree-house-bindings", + "unicode-width 0.1.12", ] [[package]] @@ -3717,6 +3736,12 @@ dependencies = [ ] [[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] name = "yoke" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index e7e79ea4..4309cc14 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -32,7 +32,7 @@ unicode-segmentation.workspace = true unicode-width = "=0.1.12" unicode-general-category = "1.1" slotmap.workspace = true -tree-house.workspace = true +tree-house = { workspace = true, features = ["fixtures"] } once_cell = "1.21" arc-swap = "1" regex = "1" diff --git a/helix-core/src/snippets.rs b/helix-core/src/snippets.rs index 3dd3b9c3..477c9e75 100644 --- a/helix-core/src/snippets.rs +++ b/helix-core/src/snippets.rs @@ -1,6 +1,6 @@ mod active; mod elaborate; -mod parser; +pub mod parser; mod render; #[derive(PartialEq, Eq, Hash, Debug, PartialOrd, Ord, Clone, Copy)] diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index f1f0e24a..234b6dae 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -90,7 +90,7 @@ impl LanguageData { Ok(Some(config)) } - fn syntax_config(&self, loader: &Loader) -> Option<&SyntaxConfig> { + pub fn syntax_config(&self, loader: &Loader) -> Option<&SyntaxConfig> { self.syntax .get_or_init(|| { Self::compile_syntax_config(&self.config, loader) @@ -238,7 +238,7 @@ impl LanguageData { } } -fn reconfigure_highlights(config: &SyntaxConfig, recognized_names: &[String]) { +pub fn reconfigure_highlights(config: &SyntaxConfig, recognized_names: &[String]) { config.configure(move |capture_name| { let capture_parts: Vec<_> = capture_name.split('.').collect(); @@ -512,7 +512,7 @@ impl FileTypeGlobMatcher { #[derive(Debug)] pub struct Syntax { - inner: tree_house::Syntax, + pub inner: tree_house::Syntax, } const PARSE_TIMEOUT: Duration = Duration::from_millis(500); // half a second is pretty generous @@ -1219,7 +1219,24 @@ mod test { ); let language = LOADER.language_for_name("rust").unwrap(); + dbg!(language); let grammar = LOADER.get_config(language).unwrap().grammar; + dbg!(grammar); + let syntax = Syntax::new(source.slice(..), language, &LOADER).unwrap(); + let mut h = syntax.highlighter( + "fn main() { 4 + 2; }".into(), + &LOADER, + 0.."fn main() { 4 + 2; }".len() as u32, + ); + + for n in 0..5 { + dbg!(h.active_highlights().collect::<Vec<_>>()); + dbg!(h.next_event_offset()); + let (e, h) = h.advance(); + dbg!(h.collect::<Vec<_>>(), e); + // panic!() + } + let query = Query::new(grammar, query_str, |_, _| Ok(())).unwrap(); let textobject = TextObjectQuery::new(query); let syntax = Syntax::new(source.slice(..), language, &LOADER).unwrap(); @@ -1389,4 +1406,24 @@ mod test { source.len(), ); } + #[test] + fn highlight() { + let source = Rope::from_str(r#"assert_eq!(0, Some(0));"#); + let loader = crate::config::default_lang_loader(); + loader.set_scopes(vec!["punctuation".to_string()]); + let language = loader.language_for_name("rust").unwrap(); + + let syntax = Syntax::new(source.slice(..), language, &loader).unwrap(); + println!( + "{}", + tree_house::fixtures::highlighter_fixture( + "", + &loader, + |_| "punct".to_string(), + &syntax.inner, + source.slice(..), + .., + ) + ); + } } diff --git a/helix-lsp-types/src/completion.rs b/helix-lsp-types/src/completion.rs index 7c006bdb..793252de 100644 --- a/helix-lsp-types/src/completion.rs +++ b/helix-lsp-types/src/completion.rs @@ -24,7 +24,7 @@ impl InsertTextFormat { /// The kind of a completion entry. #[derive(Eq, PartialEq, Clone, Copy, Serialize, Deserialize)] #[serde(transparent)] -pub struct CompletionItemKind(i32); +pub struct CompletionItemKind(pub i32); lsp_enum! { impl CompletionItemKind { pub const TEXT: CompletionItemKind = CompletionItemKind(1); diff --git a/helix-lsp-types/src/lib.rs b/helix-lsp-types/src/lib.rs index a1a87e1b..eeb13dec 100644 --- a/helix-lsp-types/src/lib.rs +++ b/helix-lsp-types/src/lib.rs @@ -210,6 +210,16 @@ pub enum NumberOrString { Number(i32), String(String), } +impl From<i32> for NumberOrString { + fn from(v: i32) -> Self { + Self::Number(v) + } +} +impl From<&i32> for NumberOrString { + fn from(&v: &i32) -> Self { + Self::Number(v) + } +} /* ----------------- Cancel support ----------------- */ diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 030bf090..555ee876 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -19,7 +19,7 @@ assets = [ { source = "target/release/hx", dest = "/usr/lib/helix/", mode = "755" }, { source = "../contrib/hx_launcher.sh", dest = "/usr/bin/hx", mode = "755" }, { source = "../runtime/*", dest = "/usr/lib/helix/runtime/", mode = "644" }, - { source = "../runtime/grammars/*", dest = "/usr/lib/helix/runtime/grammars/", mode = "644" }, # to avoid sources/ + { source = "../runtime/grammars/*", dest = "/usr/lib/helix/runtime/grammars/", mode = "644" }, # to avoid sources/ { source = "../runtime/queries/**/*", dest = "/usr/lib/helix/runtime/queries/", mode = "644" }, { source = "../runtime/themes/**/*", dest = "/usr/lib/helix/runtime/themes/", mode = "644" }, { source = "../README.md", dest = "/usr/share/doc/helix/", mode = "644" }, @@ -53,12 +53,28 @@ helix-loader = { path = "../helix-loader" } anyhow = "1" once_cell = "1.21" -tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] } -tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["termina", "crossterm"] } +tokio = { version = "1", features = [ + "rt", + "rt-multi-thread", + "io-util", + "io-std", + "time", + "process", + "macros", + "fs", + "parking_lot", +] } +tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = [ + "termina", + "crossterm", +] } termina = { workspace = true, features = ["event-stream"] } signal-hook = "0.4" tokio-stream = "0.1" -futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false } +futures-util = { version = "0.3", features = [ + "std", + "async-await", +], default-features = false } arc-swap.workspace = true termini = "1" indexmap = { version = "2.14", features = ["serde"] } @@ -90,14 +106,14 @@ toml.workspace = true serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -dashmap = "6.2" - parking_lot.workspace = true +dashmap = "6.0" +tree-house = { workspace = true, features = ["fixtures"] } [target.'cfg(windows)'.dependencies] crossterm = { version = "0.28", features = ["event-stream"] } -[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100 +[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100 signal-hook-tokio = { version = "0.4", features = ["futures-v0_3"] } libc = "0.2.186" diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 13a1416e..00000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "1.90.0" -components = ["rustfmt", "rust-src", "clippy"] |