From f99bea404f43ea0e373fd9fe54616d3282e8364b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 22 Aug 2021 15:28:45 +0900 Subject: [PATCH 01/31] idle timer wip --- helix-term/src/application.rs | 5 +++++ helix-term/src/ui/editor.rs | 1 + helix-view/src/editor.rs | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 6206e6f2d..dbd8755d8 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -199,6 +199,11 @@ impl Application { self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback); self.render(); } + _ = &mut self.editor.idle_timer => { + self.editor.clear_idle_timer(); + println!("idle!") + // idle timeout + } } } } diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 0605e2c7c..aa2d66360 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -901,6 +901,7 @@ impl Component for EditorView { EventResult::Consumed(None) } Event::Key(key) => { + cxt.editor.reset_idle_timer(); let mut key = KeyEvent::from(key); canonicalize_key(&mut key); // clear status diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index b08a2df20..5362acc81 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -9,10 +9,12 @@ use crate::{ use futures_util::future; use std::{ path::{Path, PathBuf}, + pin::Pin, sync::Arc, - time::Duration, }; +use tokio::time::{sleep, Duration, Instant, Sleep}; + use slotmap::SlotMap; use anyhow::Error; @@ -91,6 +93,8 @@ pub struct Editor { pub status_msg: Option<(String, Severity)>, pub config: Config, + + pub idle_timer: Pin>, } #[derive(Debug, Copy, Clone)] @@ -125,10 +129,24 @@ impl Editor { registers: Registers::default(), clipboard_provider: get_clipboard_provider(), status_msg: None, + idle_timer: Box::pin(sleep(Duration::from_millis(500))), config, } } + pub fn clear_idle_timer(&mut self) { + // equivalent to internal Instant::far_future() (30 years) + self.idle_timer + .as_mut() + .reset(Instant::now() + Duration::from_secs(86400 * 365 * 30)); + } + + pub fn reset_idle_timer(&mut self) { + self.idle_timer + .as_mut() + .reset(Instant::now() + Duration::from_millis(500)); + } + pub fn clear_status(&mut self) { self.status_msg = None; } From 40abec80e1062503d70055ed9e968cd4b31411a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 26 Aug 2021 11:14:46 +0900 Subject: [PATCH 02/31] Experiment with autocompletion on idle --- helix-term/src/application.rs | 38 +++++++++++++++++++++++++++++++++-- helix-term/src/commands.rs | 2 +- helix-term/src/ui/editor.rs | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index dbd8755d8..ab268041b 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -200,9 +200,9 @@ impl Application { self.render(); } _ = &mut self.editor.idle_timer => { + // idle timeout self.editor.clear_idle_timer(); - println!("idle!") - // idle timeout + self.handle_idle_timeout(); } } } @@ -233,6 +233,40 @@ impl Application { } } + pub fn handle_idle_timeout(&mut self) { + use helix_view::document::Mode; + use crate::commands::{Context, completion}; + + + if doc_mut!(self.editor).mode != Mode::Insert { + return; + } + let editor_view = self + .compositor + .find(std::any::type_name::()) + .expect("expected at least one EditorView"); + let editor_view = editor_view + .as_any_mut() + .downcast_mut::() + .unwrap(); + + if editor_view.completion.is_some() { + return; + } + + let mut cx = Context { + selected_register: helix_view::RegisterSelection::default(), + editor: &mut self.editor, + jobs: &mut self.jobs, + count: None, + callback: None, + on_next_key_callback: None, + }; + completion(&mut cx); + // TODO: scan backwards for trigger and filter the box + self.render(); + } + pub fn handle_terminal_events(&mut self, event: Option>) { let mut cx = crate::compositor::Context { editor: &mut self.editor, diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index ec76c81dc..1dbb56168 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4045,7 +4045,7 @@ fn remove_primary_selection(cx: &mut Context) { doc.set_selection(view.id, selection); } -fn completion(cx: &mut Context) { +pub fn completion(cx: &mut Context) { // trigger on trigger char, or if user calls it // (or on word char typing??) // after it's triggered, if response marked is_incomplete, update on every subsequent keypress diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index aa2d66360..ee3b3c65a 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -33,7 +33,7 @@ pub struct EditorView { keymaps: Keymaps, on_next_key: Option>, last_insert: (commands::Command, Vec), - completion: Option, + pub(crate) completion: Option, spinners: ProgressSpinners, autoinfo: Option, } From 66f26e82ceaf4b81dfeb429dcb840a3242e8f254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 27 Aug 2021 10:44:12 +0900 Subject: [PATCH 03/31] Filter the initial completion --- helix-term/src/application.rs | 11 ++++++----- helix-term/src/commands.rs | 17 ++++++++++++----- helix-term/src/ui/completion.rs | 25 +++++++++++++++++++------ helix-term/src/ui/editor.rs | 5 ++++- helix-view/src/macros.rs | 16 ++++++++++++++++ 5 files changed, 57 insertions(+), 17 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index ab268041b..79921268b 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -234,9 +234,8 @@ impl Application { } pub fn handle_idle_timeout(&mut self) { + use crate::commands::{completion, Context}; use helix_view::document::Mode; - use crate::commands::{Context, completion}; - if doc_mut!(self.editor).mode != Mode::Insert { return; @@ -254,6 +253,8 @@ impl Application { return; } + // TODO: if completion window was closed with enter (and no selection) we shouldn't retrigger + let mut cx = Context { selected_register: helix_view::RegisterSelection::default(), editor: &mut self.editor, @@ -262,9 +263,9 @@ impl Application { callback: None, on_next_key_callback: None, }; - completion(&mut cx); - // TODO: scan backwards for trigger and filter the box - self.render(); + completion(&mut cx); + // TODO: scan backwards for trigger and filter the box + self.render(); } pub fn handle_terminal_events(&mut self, event: Option>) { diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 1dbb56168..3798c99a2 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4090,10 +4090,8 @@ pub fn completion(cx: &mut Context) { }; let offset_encoding = language_server.offset_encoding(); - let cursor = doc - .selection(view.id) - .primary() - .cursor(doc.text().slice(..)); + let text = doc.text().slice(..); + let cursor = doc.selection(view.id).primary().cursor(text); let pos = pos_to_lsp_pos(doc.text(), cursor, offset_encoding); @@ -4101,6 +4099,15 @@ pub fn completion(cx: &mut Context) { let trigger_offset = cursor; + // TODO: trigger_offset should be the cursor offset but we also need a starting offset from where we want to apply + // completion filtering. For example logger.te| should filter the initial suggestion list with "te". + + use helix_core::chars; + let mut iter = text.chars_at(cursor); + iter.reverse(); + let offset = iter.take_while(|ch| chars::char_is_word(*ch)).count(); + let start_offset = cursor.saturating_sub(offset); + cx.callback( future, move |editor: &mut Editor, @@ -4131,7 +4138,7 @@ pub fn completion(cx: &mut Context) { .find(std::any::type_name::()) .unwrap(); if let Some(ui) = ui.as_any_mut().downcast_mut::() { - ui.set_completion(items, offset_encoding, trigger_offset, size); + ui.set_completion(editor, items, offset_encoding, start_offset, trigger_offset, size); }; }, ); diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index 6c9e3a808..72b032741 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -69,14 +69,17 @@ impl menu::Item for CompletionItem { /// Wraps a Menu. pub struct Completion { popup: Popup>, + start_offset: usize, trigger_offset: usize, // TODO: maintain a completioncontext with trigger kind & trigger char } impl Completion { pub fn new( + editor: &Editor, items: Vec, offset_encoding: helix_lsp::OffsetEncoding, + start_offset: usize, trigger_offset: usize, ) -> Self { // let items: Vec = Vec::new(); @@ -175,16 +178,22 @@ impl Completion { }; }); let popup = Popup::new(menu); - Self { + let mut completion = Self { popup, + start_offset, trigger_offset, - } + }; + + // need to recompute immediately in case start_offset != trigger_offset + completion.recompute_filter(editor); + + completion } - pub fn update(&mut self, cx: &mut commands::Context) { + pub fn recompute_filter(&mut self, editor: &Editor) { // recompute menu based on matches let menu = self.popup.contents_mut(); - let (view, doc) = current!(cx.editor); + let (view, doc) = current_ref!(editor); // cx.hooks() // cx.add_hook(enum type, ||) @@ -200,14 +209,18 @@ impl Completion { .selection(view.id) .primary() .cursor(doc.text().slice(..)); - if self.trigger_offset <= cursor { - let fragment = doc.text().slice(self.trigger_offset..cursor); + if self.start_offset <= cursor { + let fragment = doc.text().slice(self.start_offset..cursor); let text = Cow::from(fragment); // TODO: logic is same as ui/picker menu.score(&text); } } + pub fn update(&mut self, cx: &mut commands::Context) { + self.recompute_filter(cx.editor) + } + pub fn is_empty(&self) -> bool { self.popup.contents().is_empty() } diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index ee3b3c65a..fda6a6d3a 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -721,12 +721,15 @@ impl EditorView { pub fn set_completion( &mut self, + editor: &Editor, items: Vec, offset_encoding: helix_lsp::OffsetEncoding, + start_offset: usize, trigger_offset: usize, size: Rect, ) { - let mut completion = Completion::new(items, offset_encoding, trigger_offset); + let mut completion = + Completion::new(editor, items, offset_encoding, start_offset, trigger_offset); // TODO : propagate required size on resize to completion too completion.required_size((size.width, size.height)); self.completion = Some(completion); diff --git a/helix-view/src/macros.rs b/helix-view/src/macros.rs index c9a042701..0bebd02fc 100644 --- a/helix-view/src/macros.rs +++ b/helix-view/src/macros.rs @@ -44,3 +44,19 @@ macro_rules! view { $( $editor ).+ .tree.get($( $editor ).+ .tree.focus) }}; } + +#[macro_export] +macro_rules! doc { + ( $( $editor:ident ).+ ) => {{ + $crate::current_ref!( $( $editor ).+ ).1 + }}; +} + +#[macro_export] +macro_rules! current_ref { + ( $( $editor:ident ).+ ) => {{ + let view = $( $editor ).+ .tree.get($( $editor ).+ .tree.focus); + let doc = &$( $editor ).+ .documents[view.doc]; + (view, doc) + }}; +} From 8ca91891d1f8f6df8073a4cc4af4132f8c6695ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 5 Oct 2021 22:35:38 +0900 Subject: [PATCH 04/31] fix compilation --- helix-term/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 79921268b..8019b8395 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -256,7 +256,7 @@ impl Application { // TODO: if completion window was closed with enter (and no selection) we shouldn't retrigger let mut cx = Context { - selected_register: helix_view::RegisterSelection::default(), + register: None, editor: &mut self.editor, jobs: &mut self.jobs, count: None, From f692ede2b7af9ee3c0a83642c0e169ac2db90ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 7 Oct 2021 10:37:35 +0900 Subject: [PATCH 05/31] fix: Don't crash on empty completion, don't retrigger on close --- helix-term/src/ui/editor.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index fda6a6d3a..9234bb964 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -730,6 +730,12 @@ impl EditorView { ) { let mut completion = Completion::new(editor, items, offset_encoding, start_offset, trigger_offset); + + if completion.is_empty() { + // skip if we got no completion results + return; + } + // TODO : propagate required size on resize to completion too completion.required_size((size.width, size.height)); self.completion = Some(completion); @@ -939,6 +945,7 @@ impl Component for EditorView { if callback.is_some() { // assume close_fn self.completion = None; + cxt.editor.clear_idle_timer(); // don't retrigger } } } @@ -952,6 +959,7 @@ impl Component for EditorView { completion.update(&mut cxt); if completion.is_empty() { self.completion = None; + cxt.editor.clear_idle_timer(); // don't retrigger } } } From 2e692dc184d86c674da9e77afe93896743f67ebd Mon Sep 17 00:00:00 2001 From: James Cash Date: Thu, 7 Oct 2021 22:05:30 -0400 Subject: [PATCH 06/31] Add (SWI-)Prolog LSP support (#816) As discussed in #809 ; I also have a [tree-sitter implementation](https://github.com/jamesnvc/tree-sitter-prolog), but for reasons discussed in the linked post, I kind of gave up on that sort of static approach for making a general-purpose Prolog grammar (since it has a very flexible syntax and allows defining new operators with new precedences dynamically). That being said, the LSP implementation here at least shows documentation and does support the semantic token API, so when Helix supports that, this should also provide highlighting. --- languages.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/languages.toml b/languages.toml index fe473f89f..e7d4075c8 100644 --- a/languages.toml +++ b/languages.toml @@ -315,3 +315,15 @@ comment-token = "//" language-server = { command = "zls" } indent = { tab-width = 4, unit = " " } + +[[language]] +name = "prolog" +scope = "source.prolog" +roots = [] +file-types = ["pl", "prolog"] +comment-token = "%" + +language-server = { command = "swipl", args = [ + "-g", "use_module(library(lsp_server))", + "-g", "lsp_server:main", + "-t", "halt", "--", "stdio"] } From 9f27be429d0b4848a01876cd0eb192f2db8a830b Mon Sep 17 00:00:00 2001 From: Ethan Frei Date: Thu, 7 Oct 2021 21:08:10 -0500 Subject: [PATCH 07/31] relative paths showing active file in global search (#803) --- helix-term/src/commands.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index ec76c81dc..c1fd7bfec 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1291,7 +1291,8 @@ fn global_search(cx: &mut Context) { cx.push_layer(Box::new(prompt)); - let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); + let current_path = doc_mut!(cx.editor).path().cloned(); + let show_picker = async move { let all_matches: Vec<(usize, PathBuf)> = UnboundedReceiverStream::new(all_matches_rx).collect().await; @@ -1301,14 +1302,19 @@ fn global_search(cx: &mut Context) { editor.set_status("No matches found".to_string()); return; } + let picker = FilePicker::new( all_matches, move |(_line_num, path)| { - path.strip_prefix(&root) - .unwrap_or(path) + let relative_path = helix_core::path::get_relative_path(path) .to_str() .unwrap() - .into() + .to_owned(); + if current_path.as_ref().map(|p| p == path).unwrap_or(false) { + format!("{} (*)", relative_path).into() + } else { + relative_path.into() + } }, move |editor: &mut Editor, (line_num, path), action| { match editor.open(path.into(), action) { From eedcea7e6bdae7d18610ae8d035e7f732099e619 Mon Sep 17 00:00:00 2001 From: Midnight Exigent <36641328+midnightexigent@users.noreply.github.com> Date: Fri, 8 Oct 2021 04:14:12 +0200 Subject: [PATCH 08/31] Allow `language.config` (in languages.toml) to be passed in as a toml object (#807) * allow language.config (in languages.toml) to be passed in as a toml object * Change config field for languages from json string to toml object * remove indents on languages.toml config * fix: remove patch version from serde_json import in helix-core * Use same tree-sitter-zig as upstream/master --- Cargo.lock | 49 ++++++++++++++++++++-------------------- helix-core/Cargo.toml | 1 + helix-core/src/syntax.rs | 13 ++++++++++- helix-lsp/src/lib.rs | 10 +------- languages.toml | 14 +++--------- 5 files changed, 42 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3f7ff8f9..cc92c5e1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,9 +37,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bstr" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", @@ -54,9 +54,9 @@ checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" [[package]] name = "bytes" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cassowary" @@ -368,6 +368,7 @@ dependencies = [ "regex", "ropey", "serde", + "serde_json", "similar", "smallvec", "tendril", @@ -514,18 +515,18 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" dependencies = [ "cfg-if", ] [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "jsonrpc-core" @@ -548,9 +549,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.99" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" [[package]] name = "libloading" @@ -564,9 +565,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ "scopeguard", ] @@ -694,9 +695,9 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", @@ -705,9 +706,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ "cfg-if", "instant", @@ -737,9 +738,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] @@ -982,9 +983,9 @@ checksum = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" [[package]] name = "syn" -version = "1.0.74" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +checksum = "a4eac2e6c19f5c3abc0c229bea31ff0b9b091c7b14990e8924b92902a303a0c0" dependencies = [ "proc-macro2", "quote", @@ -1042,9 +1043,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" +checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" dependencies = [ "tinyvec_macros", ] @@ -1077,9 +1078,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.3.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" +checksum = "154794c8f499c2619acd19e839294703e9e32e7630ef5f46ea80d4ef0fbee5eb" dependencies = [ "proc-macro2", "quote", diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index 34cbba9fd..510964536 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -28,6 +28,7 @@ arc-swap = "1" regex = "1" serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" toml = "0.5" similar = "2.1" diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 547b25726..9c433f3db 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -30,6 +30,15 @@ where .transpose() } +fn deserialize_lsp_config<'de, D>(deserializer: D) -> Result, D::Error> +where + D: serde::Deserializer<'de>, +{ + Option::::deserialize(deserializer)? + .map(|toml| toml.try_into().map_err(serde::de::Error::custom)) + .transpose() +} + #[derive(Debug, Serialize, Deserialize)] pub struct Configuration { pub language: Vec, @@ -45,7 +54,9 @@ pub struct LanguageConfiguration { pub file_types: Vec, // filename ends_with? pub roots: Vec, // these indicate project roots <.git, Cargo.toml> pub comment_token: Option, - pub config: Option, + + #[serde(default, skip_serializing, deserialize_with = "deserialize_lsp_config")] + pub config: Option, #[serde(default)] pub auto_format: bool, diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 35cff7548..7fa65928b 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -318,15 +318,7 @@ impl Registry { let (client, incoming, initialize_notify) = Client::start( &config.command, &config.args, - serde_json::from_str(language_config.config.as_deref().unwrap_or("")) - .map_err(|e| { - log::error!( - "LSP Config, {}, in `languages.toml` for `{}`", - e, - language_config.scope() - ) - }) - .ok(), + language_config.config.clone(), id, )?; self.incoming.push(UnboundedReceiverStream::new(incoming)); diff --git a/languages.toml b/languages.toml index e7d4075c8..509100e74 100644 --- a/languages.toml +++ b/languages.toml @@ -6,19 +6,11 @@ file-types = ["rs"] roots = [] auto-format = true comment-token = "//" -config = """ -{ - "cargo": { - "loadOutDirsFromCheck": true - }, - "procMacro": { - "enable": false - } -} -""" - language-server = { command = "rust-analyzer" } indent = { tab-width = 4, unit = " " } +[language.config] +cargo = { loadOutDirsFromCheck = true } +procMacro = { enable = false } [[language]] name = "toml" From a6852fb88f72ea6bb41b19e65b531c17662ba57d Mon Sep 17 00:00:00 2001 From: Leoi Hung Kin Date: Sat, 9 Oct 2021 19:34:10 +0800 Subject: [PATCH 09/31] Picker: Don't panick at move_up/move_down when matches is empty (#818) --- helix-term/src/ui/picker.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index c5b90a9ca..9be2a73e2 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -270,12 +270,18 @@ impl Picker { } pub fn move_up(&mut self) { + if self.matches.is_empty() { + return; + } let len = self.matches.len(); let pos = ((self.cursor + len.saturating_sub(1)) % len) % len; self.cursor = pos; } pub fn move_down(&mut self) { + if self.matches.is_empty() { + return; + } let len = self.matches.len(); let pos = (self.cursor + 1) % len; self.cursor = pos; From 4260b31ec059ffa2207f8f2541af1c3996b00cf9 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 9 Oct 2021 19:35:27 +0800 Subject: [PATCH 10/31] Update mdbook style and fix unreadable table head (#806) The styles are now pulled from upstream styles, some of the changes I submitted it back to upstream. Fix #796 --- book/theme/css/chrome.css | 2 +- book/theme/css/general.css | 5 ++++- book/theme/css/variables.css | 14 ++++---------- helix-core/src/selection.rs | 8 ++++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/book/theme/css/chrome.css b/book/theme/css/chrome.css index 72b7f1880..aba8a417b 100644 --- a/book/theme/css/chrome.css +++ b/book/theme/css/chrome.css @@ -196,7 +196,7 @@ a > .hljs { border-radius: 3px; } -:not(pre):not(a) > .hljs { +:not(pre):not(a):not(td):not(p) > .hljs { color: var(--inline-code-color); overflow-x: initial; } diff --git a/book/theme/css/general.css b/book/theme/css/general.css index ddc2387a0..9b280d08a 100644 --- a/book/theme/css/general.css +++ b/book/theme/css/general.css @@ -162,7 +162,6 @@ table thead td { table thead th { padding: .75rem; text-align: left; - color: var(--table-border-color); font-weight: 500; line-height: 1.5; width: auto; @@ -228,3 +227,7 @@ blockquote *:last-child { margin: 5px 0px; font-weight: bold; } + +.result-no-output { + font-style: italic; +} diff --git a/book/theme/css/variables.css b/book/theme/css/variables.css index db1a11b85..b62c75581 100644 --- a/book/theme/css/variables.css +++ b/book/theme/css/variables.css @@ -13,7 +13,6 @@ .ayu { --bg: hsl(210, 25%, 8%); --fg: #c5c5c5; - --heading-fg: #c5c5c5; --sidebar-bg: #14191f; --sidebar-fg: #c8c9db; @@ -54,7 +53,6 @@ .coal { --bg: hsl(200, 7%, 8%); --fg: #98a3ad; - --heading-fg: #98a3ad; --sidebar-bg: #292c2f; --sidebar-fg: #a1adb8; @@ -95,7 +93,6 @@ .light { --bg: hsl(0, 0%, 100%); --fg: hsl(0, 0%, 0%); - --heading-fg: hsl(0, 0%, 0%); --sidebar-bg: #fafafa; --sidebar-fg: hsl(0, 0%, 0%); @@ -110,7 +107,7 @@ --links: #20609f; - --inline-code-color: #a39e9b; + --inline-code-color: #301900; --theme-popup-bg: #fafafa; --theme-popup-border: #cccccc; @@ -136,7 +133,6 @@ .navy { --bg: hsl(226, 23%, 11%); --fg: #bcbdd0; - --heading-fg: #bcbdd0; --sidebar-bg: #282d3f; --sidebar-fg: #c8c9db; @@ -177,7 +173,6 @@ .rust { --bg: hsl(60, 9%, 87%); --fg: #262625; - --heading-fg: #262625; --sidebar-bg: #3b2e2a; --sidebar-fg: #c8c9db; @@ -192,7 +187,7 @@ --links: #2b79a2; - --inline-code-color: #c5c8c6; + --inline-code-color: #6e6b5e; --theme-popup-bg: #e1e1db; --theme-popup-border: #b38f6b; @@ -218,8 +213,7 @@ @media (prefers-color-scheme: dark) { .light.no-js { --bg: hsl(200, 7%, 8%); - --fg: #ebeafa; - --heading-fg: #ebeafa; + --fg: #98a3ad; --sidebar-bg: #292c2f; --sidebar-fg: #a1adb8; @@ -234,7 +228,7 @@ --links: #2b79a2; - --inline-code-color: #6e6b5e; + --inline-code-color: #c5c8c6; --theme-popup-bg: #141617; --theme-popup-border: #43484d; diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs index 755ee679a..18af4d089 100644 --- a/helix-core/src/selection.rs +++ b/helix-core/src/selection.rs @@ -29,10 +29,10 @@ use std::borrow::Cow; /// "(anchor, head)", followed by example text with "[" and "]" /// inserted to represent the anchor and head positions: /// -/// - (0, 3): [Som]e text. -/// - (3, 0): ]Som[e text. -/// - (2, 7): So[me te]xt. -/// - (1, 1): S[]ome text. +/// - (0, 3): `[Som]e text`. +/// - (3, 0): `]Som[e text`. +/// - (2, 7): `So[me te]xt`. +/// - (1, 1): `S[]ome text`. /// /// Ranges are considered to be inclusive on the left and /// exclusive on the right, regardless of anchor-head ordering. From c7f3a971c0e42d1ecb8b91f075b2300040b656fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 10 Oct 2021 12:22:11 +0900 Subject: [PATCH 11/31] Remove resolved TODOs --- helix-term/src/application.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 8019b8395..c39a9173e 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -253,8 +253,6 @@ impl Application { return; } - // TODO: if completion window was closed with enter (and no selection) we shouldn't retrigger - let mut cx = Context { register: None, editor: &mut self.editor, @@ -264,7 +262,6 @@ impl Application { on_next_key_callback: None, }; completion(&mut cx); - // TODO: scan backwards for trigger and filter the box self.render(); } From 633b981db22bb30c601b838eaaeb814a64156125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 10 Oct 2021 12:32:06 +0900 Subject: [PATCH 12/31] Make idle-timeout configurable --- book/src/configuration.md | 1 + helix-term/src/commands.rs | 11 +++++++++-- helix-view/src/editor.rs | 12 ++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 60b12bfd4..f30146dd4 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -19,6 +19,7 @@ To override global configuration parameters, create a `config.toml` file located | `line-number` | Line number display (`absolute`, `relative`) | `absolute` | | `smart-case` | Enable smart case regex searching (case insensitive unless pattern contains upper case characters) | `true` | | `auto-pairs` | Enable automatic insertion of pairs to parenthese, brackets, etc. | `true` | +| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | ## LSP diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3798c99a2..f005e376c 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4130,7 +4130,7 @@ pub fn completion(cx: &mut Context) { }; if items.is_empty() { - editor.set_error("No completion available".to_string()); + // editor.set_error("No completion available".to_string()); return; } let size = compositor.size(); @@ -4138,7 +4138,14 @@ pub fn completion(cx: &mut Context) { .find(std::any::type_name::()) .unwrap(); if let Some(ui) = ui.as_any_mut().downcast_mut::() { - ui.set_completion(editor, items, offset_encoding, start_offset, trigger_offset, size); + ui.set_completion( + editor, + items, + offset_encoding, + start_offset, + trigger_offset, + size, + ); }; }, ); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 5362acc81..5af6dbf3c 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -26,6 +26,14 @@ use helix_core::Position; use serde::Deserialize; +fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + let millis = u64::deserialize(deserializer)?; + Ok(Duration::from_millis(millis)) +} + #[derive(Debug, Clone, PartialEq, Deserialize)] #[serde(rename_all = "kebab-case", default)] pub struct Config { @@ -45,6 +53,9 @@ pub struct Config { pub smart_case: bool, /// Automatic insertion of pairs to parentheses, brackets, etc. Defaults to true. pub auto_pairs: bool, + /// Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. Defaults to 400ms. + #[serde(skip_serializing, deserialize_with = "deserialize_duration_millis")] + pub idle_timeout: Duration, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize)] @@ -72,6 +83,7 @@ impl Default for Config { middle_click_paste: true, smart_case: true, auto_pairs: true, + idle_timeout: Duration::from_millis(400), } } } From 76b1bbc23ad5fc47765472cd9e83727a43c97ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 10 Oct 2021 12:33:22 +0900 Subject: [PATCH 13/31] Allow trigger_offset to be unused for now --- helix-term/src/ui/completion.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index 72b032741..ba009c505 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -70,6 +70,7 @@ impl menu::Item for CompletionItem { pub struct Completion { popup: Popup>, start_offset: usize, + #[allow(dead_code)] trigger_offset: usize, // TODO: maintain a completioncontext with trigger kind & trigger char } From a7f49fa56fecd7f44efca7e6074e5cd9e5d91c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wehm=C3=B6ller?= Date: Sun, 10 Oct 2021 15:09:17 +0200 Subject: [PATCH 14/31] Add Vue tree sitter grammar (#787) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Add vue tree sitter support * Update .gitmodules Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 ++++ helix-syntax/languages/tree-sitter-vue | 1 + languages.toml | 9 +++++++++ runtime/queries/vue/highlights.scm | 21 +++++++++++++++++++++ runtime/queries/vue/injections.scm | 17 +++++++++++++++++ 5 files changed, 52 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-vue create mode 100644 runtime/queries/vue/highlights.scm create mode 100644 runtime/queries/vue/injections.scm diff --git a/.gitmodules b/.gitmodules index d1fc15179..95b3670b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -122,3 +122,7 @@ path = helix-syntax/languages/tree-sitter-svelte url = https://github.com/Himujjal/tree-sitter-svelte shallow = true +[submodule "helix-syntax/languages/tree-sitter-vue"] + path = helix-syntax/languages/tree-sitter-vue + url = https://github.com/ikatyang/tree-sitter-vue + shallow = true diff --git a/helix-syntax/languages/tree-sitter-vue b/helix-syntax/languages/tree-sitter-vue new file mode 160000 index 000000000..91fe27547 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-vue @@ -0,0 +1 @@ +Subproject commit 91fe2754796cd8fba5f229505a23fa08f3546c06 diff --git a/languages.toml b/languages.toml index 509100e74..e716b3dca 100644 --- a/languages.toml +++ b/languages.toml @@ -278,6 +278,15 @@ roots = [] indent = { tab-width = 2, unit = " " } language-server = { command = "svelteserver", args = ["--stdio"] } + +[[language]] +name = "vue" +scope = "source.vue" +injection-regex = "vue" +file-types = ["vue"] +roots = [] +indent = { tab-width = 2, unit = " " } + [[language]] name = "yaml" scope = "source.yaml" diff --git a/runtime/queries/vue/highlights.scm b/runtime/queries/vue/highlights.scm new file mode 100644 index 000000000..f90ae4297 --- /dev/null +++ b/runtime/queries/vue/highlights.scm @@ -0,0 +1,21 @@ +(tag_name) @tag +(end_tag) @tag + +(directive_name) @keyword +(directive_argument) @constant + +(attribute + (attribute_name) @attribute + (quoted_attribute_value + (attribute_value) @string) +) + +(comment) @comment + +[ + "<" + ">" + " Date: Sun, 10 Oct 2021 22:39:47 +0900 Subject: [PATCH 15/31] fix: Make sure to actually use idle_timeout config value for the timers --- helix-view/src/editor.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 5af6dbf3c..d0ea6653b 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -141,7 +141,7 @@ impl Editor { registers: Registers::default(), clipboard_provider: get_clipboard_provider(), status_msg: None, - idle_timer: Box::pin(sleep(Duration::from_millis(500))), + idle_timer: Box::pin(sleep(config.idle_timeout)), config, } } @@ -156,7 +156,7 @@ impl Editor { pub fn reset_idle_timer(&mut self) { self.idle_timer .as_mut() - .reset(Instant::now() + Duration::from_millis(500)); + .reset(Instant::now() + self.config.idle_timeout); } pub fn clear_status(&mut self) { From c15e3b32d6f96be7b5f3045bfbcbe00c9fe224cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:39:48 +0900 Subject: [PATCH 16/31] build(deps): bump cc from 1.0.70 to 1.0.71 (#826) Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.70 to 1.0.71. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.70...1.0.71) --- updated-dependencies: - dependency-name: cc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc92c5e1e..6d355ade4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,9 +66,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" [[package]] name = "cfg-if" From 6cb0d1c4e47c610937454c03f7ca83bb79e93cdc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:39:56 +0900 Subject: [PATCH 17/31] build(deps): bump libloading from 0.7.0 to 0.7.1 (#827) Bumps [libloading](https://github.com/nagisa/rust_libloading) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/nagisa/rust_libloading/releases) - [Commits](https://github.com/nagisa/rust_libloading/commits) --- updated-dependencies: - dependency-name: libloading dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d355ade4..fc640cd88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -555,9 +555,9 @@ checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" [[package]] name = "libloading" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +checksum = "c0cf036d15402bea3c5d4de17b3fce76b3e4a56ebc1f577be0e7a72f7c607cf0" dependencies = [ "cfg-if", "winapi", From a6b393f59840fc126dfcf1980d82808cc1505a20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:40:06 +0900 Subject: [PATCH 18/31] build(deps): bump thiserror from 1.0.29 to 1.0.30 (#828) Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.29 to 1.0.30. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.29...1.0.30) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc640cd88..841af25c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1005,18 +1005,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", From 933db94f2ff116d3194d4de95c1f6ff287ecb150 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:40:19 +0900 Subject: [PATCH 19/31] build(deps): bump lsp-types from 0.90.0 to 0.90.1 (#829) Bumps [lsp-types](https://github.com/gluon-lang/lsp-types) from 0.90.0 to 0.90.1. - [Release notes](https://github.com/gluon-lang/lsp-types/releases) - [Changelog](https://github.com/gluon-lang/lsp-types/blob/master/CHANGELOG.md) - [Commits](https://github.com/gluon-lang/lsp-types/compare/v0.90.0...v0.90.1) --- updated-dependencies: - dependency-name: lsp-types dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 841af25c8..3b4c14669 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,9 +583,9 @@ dependencies = [ [[package]] name = "lsp-types" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7404037aab080771c90b0a499836d9d8a10336ecd07badf969567b65c6d51a1" +checksum = "6f3734ab1d7d157fc0c45110e06b587c31cd82bea2ccfd6b563cbff0aaeeb1d3" dependencies = [ "bitflags", "serde", From b42ef0e028c91d8afb85898aeed04a0a8207f0c8 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Wed, 13 Oct 2021 10:24:37 +0800 Subject: [PATCH 20/31] Using pylsp instead of pyls (#834) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index e716b3dca..7715425bf 100644 --- a/languages.toml +++ b/languages.toml @@ -146,7 +146,7 @@ file-types = ["py"] roots = [] comment-token = "#" -language-server = { command = "pyls" } +language-server = { command = "pylsp" } # TODO: pyls needs utf-8 offsets indent = { tab-width = 4, unit = " " } From 47208b990b159b37d9b1a55df908d2cb27eea896 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Thu, 14 Oct 2021 17:03:35 +0800 Subject: [PATCH 21/31] improve contract on nord comment color (#842) --- runtime/themes/nord.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/themes/nord.toml b/runtime/themes/nord.toml index c6a0e1728..990d5a4aa 100644 --- a/runtime/themes/nord.toml +++ b/runtime/themes/nord.toml @@ -24,8 +24,8 @@ "ui.cursor.match" = { bg = "434c5e" } # nord3 - comments -"comment" = "#4c566a" -"ui.linenr" = { fg = "#4c566a" } +"comment" = "#616E88" +"ui.linenr" = { fg = "#616E88" } # Snow Storm # nord4 - cursor, variables, constants, attributes, fields From ef3f78b6ce79ab17d85780ec02af12ed1459b971 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Fri, 15 Oct 2021 16:36:01 +0800 Subject: [PATCH 22/31] fix nord ui focus color (#844) --- runtime/themes/nord.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/themes/nord.toml b/runtime/themes/nord.toml index 990d5a4aa..ee7c88650 100644 --- a/runtime/themes/nord.toml +++ b/runtime/themes/nord.toml @@ -1,7 +1,7 @@ # Author : RayGervais # "ui.linenr.selected" = { fg = "#d8dee9" } -# "ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] } +"ui.text.focus" = { fg = "#88c0d0", modifiers= ["bold"] } # "ui.menu.selected" = { fg = "#e5ded6", bg = "#313f4e" } # "info" = "#b48ead" From 4d07eaa48bc4fc0c75e0346406fb6dedfc7db743 Mon Sep 17 00:00:00 2001 From: Leoi Hung Kin Date: Fri, 15 Oct 2021 16:36:39 +0800 Subject: [PATCH 23/31] Prevent LSP Messages from displaying when a prompt is presented (#824) * Prevent LSP Messages from displaying when a prompt is presented * use match guard --- helix-term/src/application.rs | 33 ++++++++++++++++++++++++--------- helix-term/src/compositor.rs | 6 ++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c39a9173e..7667441b2 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -295,14 +295,6 @@ impl Application { server_id: usize, ) { use helix_lsp::{Call, MethodCall, Notification}; - let editor_view = self - .compositor - .find(std::any::type_name::()) - .expect("expected at least one EditorView"); - let editor_view = editor_view - .as_any_mut() - .downcast_mut::() - .unwrap(); match call { Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => { @@ -412,7 +404,19 @@ impl Application { Notification::LogMessage(params) => { log::info!("window/logMessage: {:?}", params); } - Notification::ProgressMessage(params) => { + Notification::ProgressMessage(params) + if !self + .compositor + .has_component(std::any::type_name::()) => + { + let editor_view = self + .compositor + .find(std::any::type_name::()) + .expect("expected at least one EditorView"); + let editor_view = editor_view + .as_any_mut() + .downcast_mut::() + .unwrap(); let lsp::ProgressParams { token, value } = params; let lsp::ProgressParamsValue::WorkDone(work) = value; @@ -487,6 +491,9 @@ impl Application { self.editor.set_status(status); } } + Notification::ProgressMessage(_params) => { + // do nothing + } } } Call::MethodCall(helix_lsp::jsonrpc::MethodCall { @@ -521,6 +528,14 @@ impl Application { MethodCall::WorkDoneProgressCreate(params) => { self.lsp_progress.create(server_id, params.token); + let editor_view = self + .compositor + .find(std::any::type_name::()) + .expect("expected at least one EditorView"); + let editor_view = editor_view + .as_any_mut() + .downcast_mut::() + .unwrap(); let spinner = editor_view.spinners_mut().get_or_create(server_id); if spinner.is_stopped() { spinner.start(); diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs index 36e54eded..cad1df054 100644 --- a/helix-term/src/compositor.rs +++ b/helix-term/src/compositor.rs @@ -171,6 +171,12 @@ impl Compositor { (None, CursorKind::Hidden) } + pub fn has_component(&self, type_name: &str) -> bool { + self.layers + .iter() + .any(|component| component.type_name() == type_name) + } + pub fn find(&mut self, type_name: &str) -> Option<&mut dyn Component> { self.layers .iter_mut() From c71b49497d8fc8ee487b7cfeafb7392b71a13d17 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Fri, 15 Oct 2021 21:04:26 -0400 Subject: [PATCH 24/31] Set CWD when editor is started with a directory (#849) --- helix-term/src/application.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 7667441b2..b3fa79eee 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -100,6 +100,7 @@ impl Application { if !args.files.is_empty() { let first = &args.files[0]; // we know it's not empty if first.is_dir() { + std::env::set_current_dir(&first)?; editor.new_file(Action::VerticalSplit); compositor.push(Box::new(ui::file_picker(first.clone()))); } else { From 6063ecf3b44b6b3b6ae0d96375c7485bb47cf716 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Fri, 15 Oct 2021 21:05:29 -0400 Subject: [PATCH 25/31] Add note about FAQ to `README.md` (#848) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d596c83d0..7cd58d590 100644 --- a/README.md +++ b/README.md @@ -83,4 +83,6 @@ a good overview of the internals. # Getting help +Your question might already be answered on the [FAQ](https://github.com/helix-editor/helix/wiki/FAQ). + Discuss the project on the community [Matrix Space](https://matrix.to/#/#helix-community:matrix.org) (make sure to join `#helix-editor:matrix.org` if you're on a client that doesn't support Matrix Spaces yet). From 43465926be77e6890203fe6a4942f674bfb2a8f4 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Fri, 15 Oct 2021 23:47:45 -0400 Subject: [PATCH 26/31] Continue tutor (#737) * Add sections * `COUNTS WITH MOTIONS` * `SELECTING LINES` * `UNDOING` * Adjust lesson spacing to conform to page-wise scrolling Vertical length of lessons reduced by 1 line so that page-up and page-down move cleanly between lessons. * Add sections * `THE CHANGE COMMAND` * `RECAP` * `MULTIPLE CURSORS` * Fix height of `RECAP` section * Fix typo in `MULTIPLE CURSORS` * Add additional information about space mode to `MULTIPLE CURSORS` * Change `` to `,` * Add sections * `THE SELECT COMMAND` * `SELECTING VIA REGEX` * `COLLAPSING SELECTIONS` * Fix quote inconsistency --- runtime/tutor.txt | 208 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 198 insertions(+), 10 deletions(-) diff --git a/runtime/tutor.txt b/runtime/tutor.txt index 07b888848..b6f600d02 100644 --- a/runtime/tutor.txt +++ b/runtime/tutor.txt @@ -20,7 +20,6 @@ _________________________________________________________________ the first lesson. - ================================================================= = BASIC CURSOR MOVEMENT = ================================================================= @@ -43,7 +42,6 @@ _________________________________________________________________ - ================================================================= = EXITING HELIX = ================================================================= @@ -66,7 +64,6 @@ _________________________________________________________________ - ================================================================= = DELETION = ================================================================= @@ -89,7 +86,6 @@ _________________________________________________________________ - ================================================================= = INSERT MODE = ================================================================= @@ -112,7 +108,6 @@ _________________________________________________________________ Note: The status bar will display your current mode. Notice that when you press i, 'NOR' changes to 'INS'. - ================================================================= = MORE ON INSERT MODE = ================================================================= @@ -123,7 +118,7 @@ _________________________________________________________________ Common examples of insertion commands include: i - Insert before the selection. - a - Insert after the selection. (a means "append") + a - Insert after the selection. (a means 'append') I - Insert at the start of the line. A - Insert at the end of the line. @@ -135,7 +130,6 @@ _________________________________________________________________ --> This sentence is miss This sentence is missing some text. - ================================================================= = SAVING A FILE = ================================================================= @@ -158,7 +152,6 @@ _________________________________________________________________ - ================================================================= = RECAP = ================================================================= @@ -181,7 +174,6 @@ _________________________________________________________________ - ================================================================= = MOTIONS AND SELECTIONS = ================================================================= @@ -204,7 +196,6 @@ _________________________________________________________________ - ================================================================= = MORE ON MOTIONS = ================================================================= @@ -227,6 +218,203 @@ _________________________________________________________________ +================================================================= += THE CHANGE COMMAND = +================================================================= + + Press c to change the current selection. + + The change command deletes the current selection and enters + Insert mode, so it is a very common shorthand for di. + + 1. Move the cursor to the line below marked -->. + 2. Move to the start of an incorrect word and press w to + select it. + 3. Press c to delete the word and enter Insert mode. + 4. Type the correct word. + 5. Repeat until the line matches the line below it. + + --> This paper has heavy words behind it. + This sentence has incorrect words in it. + + + + +================================================================= += COUNTS WITH MOTIONS = +================================================================= + + Type a number before a motion to repeat it that many times. + + 1. Move the cursor to the line below marked -->. + + 2. Type 2w to move 2 words forward. + + 3. Type 3e to move to the end of the third word forward. + + 4. Type 2b to move 2 words backwards + + 5. Try the above with different numbers. + + --> This is just a line with words you can move around in. + + + + + +================================================================= += SELECTING LINES = +================================================================= + + Press x to select a whole line. Press again to select the next. + + 1. Move the cursor to the second line below marked -->. + 2. Press x to select the line, and d to delete it. + 3. Move to the fourth line. + 4. Press x twice or type 2x to select 2 lines, and d to delete. + + --> 1) Roses are red, + --> 2) Mud is fun, + --> 3) Violets are blue, + --> 4) I have a car, + --> 5) Clocks tell time, + --> 6) Sugar is sweet, + --> 7) And so are you. + + + + +================================================================= += UNDOING = +================================================================= + + Type u to undo. Type U to redo. + + 1. Move the cursor to the line below marked -->. + 2. Move to the first error, and press d to delete it. + 3. Type u to undo your deletion. + 4. Fix all the errors on the line. + 5. Type u several times to undo your fixes. + 6. Type U ( + u) several times to redo your fixes. + + --> Fiix the errors on thhis line and reeplace them witth undo. + + + + + + + + +================================================================= += RECAP = +================================================================= + + * Type w to select forward until the next word. + * Type e to select to the end of the current word. + * Type b to select backward to the start of the current word. + * Use uppercase counterparts, W,E,B, to traverse WORDS. + + * Typing d deletes the entire selection, so you can delete a + word forward by typing wd. + + * Type c to delete the selection and enter Insert mode. + + * Type a number before a motion to repeat it that many times. + + * Type x to select the entire current line. Type x again to + select the next line. + + * Type u to undo. Type U to redo. + + +================================================================= += MULTIPLE CURSORS = +================================================================= + + Type C to duplicate the cursor to the next line. + + 1. Move the cursor to the first line below marked -->. + 2. Type C to duplicate the cursor to the next line. Keys you + press will now affect both cursors. + 3. Use Insert mode to correct the lines. The two cursors will + fix both lines simultaneously. + 4. Type , to remove the second cursor. + + --> Fix th two nes at same ime. + --> Fix th two nes at same ime. + + Fix these two lines at the same time. + + + + + +================================================================= += THE SELECT COMMAND = +================================================================= + + Type s to select matches in the selection. + + 1. Move the cursor to the line below marked -->. + 2. Press x to select the line. + 3. Press s. A prompt will appear. + 4. Type 'apples' and press . Both occurrences of + 'apples' in the line will be selected. + 5. You can now press c and change 'apples' to something else, + like 'oranges'. + 6. Type , to remove the second cursor. + + --> I like to eat apples since my favorite fruit is apples. + + + + + + +================================================================= += SELECTING VIA REGEX = +================================================================= + + The select command selects regular expressions, not just exact + matches, allowing you to target more complex patterns. + + 1. Move the cursor to the line below marked -->. + 2. Select the line with x and then press s. + 3. Enter ' +' to select any amount of consecutive spaces >1. + 4. Press c and change the matches to single spaces. + + --> This sentence has some extra spaces. + + Note: If you want to perform find-and-replace, the select + command is the way to do it. Select the text you want + to replace in — type % to select the whole file — and + then perform the steps explained above. + + + + +================================================================= += COLLAPSING SELECTIONS = +================================================================= + + Type ; to collapse selections to single cursors. + + Sometimes, you want to deselect without having to move the + cursor(s). This can be done using the ; key. + + 1. Move the cursor to the line below marked -->. + + 2. Use the motions you have learned to move around the line, + and try using ; to deselect the text after it is selected + by the motions. + + --> This is an error-free line with words to move around in. + + + + + ================================================================= This tutorial is still a work-in-progress. From e069fb9dea0d41eedb9257050f2231b7b0b88d0e Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 16 Oct 2021 03:58:04 -0500 Subject: [PATCH 27/31] Add highlight support for tree-sitter-query language (tsq) (#845) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add submodule on tree-sitter/tree-sitter-tsq mark tsq submodule as shallow * add tree-sitter-tsq to languages * add highlight queries for tsq * Update .gitmodules Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 +++ helix-syntax/languages/tree-sitter-tsq | 1 + languages.toml | 8 +++++ runtime/queries/tsq/highlights.scm | 46 ++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-tsq create mode 100644 runtime/queries/tsq/highlights.scm diff --git a/.gitmodules b/.gitmodules index 95b3670b6..a8e6481ea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -126,3 +126,7 @@ path = helix-syntax/languages/tree-sitter-vue url = https://github.com/ikatyang/tree-sitter-vue shallow = true +[submodule "helix-syntax/languages/tree-sitter-tsq"] + path = helix-syntax/languages/tree-sitter-tsq + url = https://github.com/tree-sitter/tree-sitter-tsq + shallow = true diff --git a/helix-syntax/languages/tree-sitter-tsq b/helix-syntax/languages/tree-sitter-tsq new file mode 160000 index 000000000..b665659d3 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-tsq @@ -0,0 +1 @@ +Subproject commit b665659d3238e6036e22ed0e24935e60efb39415 diff --git a/languages.toml b/languages.toml index 7715425bf..60b996c05 100644 --- a/languages.toml +++ b/languages.toml @@ -328,3 +328,11 @@ language-server = { command = "swipl", args = [ "-g", "use_module(library(lsp_server))", "-g", "lsp_server:main", "-t", "halt", "--", "stdio"] } + +[[language]] +name = "tsq" +scope = "source.tsq" +file-types = ["scm"] +roots = [] +comment-token = ";" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/tsq/highlights.scm b/runtime/queries/tsq/highlights.scm new file mode 100644 index 000000000..9ba5699a8 --- /dev/null +++ b/runtime/queries/tsq/highlights.scm @@ -0,0 +1,46 @@ +; mark the string passed #match? as a regex +(((predicate_name) @function + (capture) + (string) @string.regexp) + (#eq? @function "#match?")) + +; highlight inheritance comments +((query . (comment) @keyword.directive) + (#match? @keyword.directive "^;\ +inherits *:")) + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +":" @punctuation.delimiter + +[ + (one_or_more) + (zero_or_one) + (zero_or_more) +] @operator + +[ + (wildcard_node) + (anchor) +] @constant.builtin + +[ + (anonymous_leaf) + (string) +] @string + +(comment) @comment + +(field_name) @property + +(capture) @label + +(predicate_name) @function + +(escape_sequence) @escape + +(node_name) @variable From be428a295a0884ed0523a8a995e913ee1c863b60 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 16 Oct 2021 04:02:06 -0500 Subject: [PATCH 28/31] fix digit escapes in java & php highlights (#846) --- runtime/queries/java/highlights.scm | 2 +- runtime/queries/php/highlights.scm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/queries/java/highlights.scm b/runtime/queries/java/highlights.scm index 3f8ae0d50..e7d793df9 100644 --- a/runtime/queries/java/highlights.scm +++ b/runtime/queries/java/highlights.scm @@ -47,7 +47,7 @@ ; Variables ((identifier) @constant - (#match? @constant "^_*[A-Z][A-Z\d_]+")) + (#match? @constant "^_*[A-Z][A-Z\\d_]+$")) (identifier) @variable diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 838504035..029045558 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -42,7 +42,7 @@ (relative_scope) @variable.builtin ((name) @constant - (#match? @constant "^_?[A-Z][A-Z\d_]+$")) + (#match? @constant "^_?[A-Z][A-Z\\d_]+$")) ((name) @constructor (#match? @constructor "^[A-Z]")) From 2c0468ffd16de1f835ac9c4e39692a682273fb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sat, 16 Oct 2021 18:43:07 +0900 Subject: [PATCH 29/31] fix: If backspacing past the start offset, cancel completion Refs #822 --- helix-term/src/ui/completion.rs | 4 ++++ helix-term/src/ui/menu.rs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index ba009c505..c75b24f1a 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -215,6 +215,10 @@ impl Completion { let text = Cow::from(fragment); // TODO: logic is same as ui/picker menu.score(&text); + } else { + // we backspaced before the start offset, clear the menu + // this will cause the editor to remove the completion popup + menu.clear(); } } diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index dab0c34f1..055593fda 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -90,6 +90,14 @@ impl Menu { self.recalculate = true; } + pub fn clear(&mut self) { + self.matches.clear(); + + // reset cursor position + self.cursor = None; + self.scroll = 0; + } + pub fn move_up(&mut self) { let len = self.matches.len(); let pos = self.cursor.map_or(0, |i| (i + len.saturating_sub(1)) % len) % len; From 89707a858f593c99d44af173e9fb2c0d72b8697e Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 16 Oct 2021 21:57:41 +0800 Subject: [PATCH 30/31] Make auto-completion a config (#853) --- book/src/configuration.md | 1 + helix-term/src/application.rs | 2 +- helix-view/src/editor.rs | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index f30146dd4..d47f95d91 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -19,6 +19,7 @@ To override global configuration parameters, create a `config.toml` file located | `line-number` | Line number display (`absolute`, `relative`) | `absolute` | | `smart-case` | Enable smart case regex searching (case insensitive unless pattern contains upper case characters) | `true` | | `auto-pairs` | Enable automatic insertion of pairs to parenthese, brackets, etc. | `true` | +| `auto-completion` | Enable automatic pop up of auto-completion. | `true` | | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | ## LSP diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index b3fa79eee..0e7d0e558 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -238,7 +238,7 @@ impl Application { use crate::commands::{completion, Context}; use helix_view::document::Mode; - if doc_mut!(self.editor).mode != Mode::Insert { + if doc_mut!(self.editor).mode != Mode::Insert || !self.config.editor.auto_completion { return; } let editor_view = self diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index d0ea6653b..90e3bf471 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -47,12 +47,14 @@ pub struct Config { pub shell: Vec, /// Line number mode. pub line_number: LineNumber, - /// Middle click paste support. Defaults to true + /// Middle click paste support. Defaults to true. pub middle_click_paste: bool, /// Smart case: Case insensitive searching unless pattern contains upper case characters. Defaults to true. pub smart_case: bool, /// Automatic insertion of pairs to parentheses, brackets, etc. Defaults to true. pub auto_pairs: bool, + /// Automatic auto-completion, automatically pop up without user trigger. Defaults to true. + pub auto_completion: bool, /// Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. Defaults to 400ms. #[serde(skip_serializing, deserialize_with = "deserialize_duration_millis")] pub idle_timeout: Duration, @@ -83,6 +85,7 @@ impl Default for Config { middle_click_paste: true, smart_case: true, auto_pairs: true, + auto_completion: true, idle_timeout: Duration::from_millis(400), } } From e216e9621e73cda1968632cd20595231af5e07be Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 16 Oct 2021 23:45:09 -0500 Subject: [PATCH 31/31] Enable c-sharp language and highlights (#861) --- languages.toml | 10 ++ runtime/queries/c-sharp/highlights.scm | 238 +++++++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 runtime/queries/c-sharp/highlights.scm diff --git a/languages.toml b/languages.toml index 60b996c05..67f4d3d6f 100644 --- a/languages.toml +++ b/languages.toml @@ -74,6 +74,16 @@ comment-token = "//" language-server = { command = "clangd" } indent = { tab-width = 2, unit = " " } +[[language]] +name = "c-sharp" +scope = "source.csharp" +injection-regex = "c-?sharp" +file-types = ["cs"] +roots = [] +comment-token = "//" + +indent = { tab-width = 4, unit = "\t" } + [[language]] name = "go" scope = "source.go" diff --git a/runtime/queries/c-sharp/highlights.scm b/runtime/queries/c-sharp/highlights.scm new file mode 100644 index 000000000..b76f4e601 --- /dev/null +++ b/runtime/queries/c-sharp/highlights.scm @@ -0,0 +1,238 @@ +;; Methods +(method_declaration (identifier) @type (identifier) @function) + +;; Types +(interface_declaration name: (identifier) @type) +(class_declaration name: (identifier) @type) +(enum_declaration name: (identifier) @type) +(struct_declaration (identifier) @type) +(record_declaration (identifier) @type) +(namespace_declaration name: (identifier) @type) + +(constructor_declaration name: (identifier) @type) + +[ + (implicit_type) + (nullable_type) + (pointer_type) + (function_pointer_type) + (predefined_type) +] @type.builtin + +;; Enum +(enum_member_declaration (identifier) @variable.property) + +;; Literals +[ + (real_literal) + (integer_literal) +] @number + +[ + (character_literal) + (string_literal) + (verbatim_string_literal) + (interpolated_string_text) + (interpolated_verbatim_string_text) + "\"" + "$\"" + "@$\"" + "$@\"" + ] @string + +[ + (boolean_literal) + (null_literal) + (void_keyword) +] @constant.builtin + +;; Comments +(comment) @comment + +;; Tokens +[ + ";" + "." + "," +] @punctuation.delimiter + +[ + "--" + "-" + "-=" + "&" + "&&" + "+" + "++" + "+=" + "<" + "<<" + "=" + "==" + "!" + "!=" + "=>" + ">" + ">>" + "|" + "||" + "?" + "??" + "^" + "~" + "*" + "/" + "%" + ":" +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +;; Keywords +(modifier) @keyword +(this_expression) @keyword +(escape_sequence) @keyword + +[ + "as" + "base" + "break" + "case" + "catch" + "checked" + "class" + "continue" + "default" + "delegate" + "do" + "else" + "enum" + "event" + "explicit" + "finally" + "for" + "foreach" + "goto" + "if" + "implicit" + "interface" + "is" + "lock" + "namespace" + "operator" + "params" + "return" + "sizeof" + "stackalloc" + "struct" + "switch" + "throw" + "try" + "typeof" + "unchecked" + "using" + "while" + "new" + "await" + "in" + "yield" + "get" + "set" + "when" + "out" + "ref" + "from" + "where" + "select" + "record" + "init" + "with" + "let" +] @keyword + + +;; Linq +(from_clause (identifier) @variable) +(group_clause) +(order_by_clause) +(select_clause (identifier) @variable) +(query_continuation (identifier) @variable) @keyword + +;; Record +(with_expression + (with_initializer_expression + (simple_assignment_expression + (identifier) @variable))) + +;; Exprs +(binary_expression (identifier) @variable (identifier) @variable) +(binary_expression (identifier)* @variable) +(conditional_expression (identifier) @variable) +(prefix_unary_expression (identifier) @variable) +(postfix_unary_expression (identifier)* @variable) +(assignment_expression (identifier) @variable) +(cast_expression (identifier) @type (identifier) @variable) + +;; Class +(base_list (identifier) @type) +(property_declaration (generic_name)) +(property_declaration + type: (nullable_type) @type + name: (identifier) @variable) +(property_declaration + type: (predefined_type) @type + name: (identifier) @variable) +(property_declaration + type: (identifier) @type + name: (identifier) @variable) + +;; Lambda +(lambda_expression) @variable + +;; Attribute +(attribute) @type + +;; Parameter +(parameter + type: (identifier) @type + name: (identifier) @variable.parameter) +(parameter (identifier) @variable.parameter) +(parameter_modifier) @keyword + +;; Typeof +(type_of_expression (identifier) @type) + +;; Variable +(variable_declaration (identifier) @type) +(variable_declarator (identifier) @variable) + +;; Return +(return_statement (identifier) @variable) +(yield_statement (identifier) @variable) + +;; Type +(generic_name (identifier) @type) +(type_parameter (identifier) @variable.parameter) +(type_argument_list (identifier) @type) + +;; Type constraints +(type_parameter_constraints_clause (identifier) @variable.parameter) +(type_constraint (identifier) @type) + +;; Exception +(catch_declaration (identifier) @type (identifier) @variable) +(catch_declaration (identifier) @type) + +;; Switch +(switch_statement (identifier) @variable) +(switch_expression (identifier) @variable) + +;; Lock statement +(lock_statement (identifier) @variable)