Unnamed repository; edit this file 'description' to name the repository.
hmm
| -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 |
7 files changed, 76 insertions, 16 deletions
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index e0bdf67a1..9bb12f127 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 3dd3b9c3d..477c9e75b 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 f65c32f72..d16cf05b6 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 @@ -1220,7 +1220,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(); @@ -1390,4 +1407,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 7c006bdb6..793252dec 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 afba1f2c7..135bbd447 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 2f3809da1..8a4e65e44 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"] } @@ -85,14 +101,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 13a1416ea..000000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "1.90.0" -components = ["rustfmt", "rust-src", "clippy"] |