From 752ed8eb15b7366ef0c9e835b261189141e38630 Mon Sep 17 00:00:00 2001 From: Luv-Ray <1357065654@qq.com> Date: Tue, 30 Apr 2024 12:13:27 +0800 Subject: [PATCH 1/4] add `try` keyword to rust highlights (#10641) --- runtime/queries/rust/highlights.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 1c0f799b1..7997c5ea0 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -125,6 +125,7 @@ "match" "if" "else" + "try" ] @keyword.control.conditional [ From 31273c69e0be3b2d14f0c76d3f6a735e1d332e63 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 2 May 2024 06:25:15 -0400 Subject: [PATCH 2/4] Add completion/signature bindings to keymap.md (#10654) * Add completion/signature bindings to keymap.md PR #9974 added alt-p/alt-n keybindings to scroll through signatures. This wasn't very discoverable, as it's not in the docs or the command palette. This also removes a broken link for "comment mode" in the table of contents. * Update keymap.md --- book/src/keymap.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/book/src/keymap.md b/book/src/keymap.md index 65a223efb..55b467a0e 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -12,8 +12,9 @@ - [Match mode](#match-mode) - [Window mode](#window-mode) - [Space mode](#space-mode) - - [Comment mode](#comment-mode) - [Popup](#popup) + - [Completion Menu](#completion-menu) + - [Signature-help Popup](#signature-help-popup) - [Unimpaired](#unimpaired) - [Insert mode](#insert-mode) - [Select / extend mode](#select--extend-mode) @@ -309,13 +310,31 @@ This layer is a kludge of mappings, mostly pickers. ##### Popup -Displays documentation for item under cursor. +Displays documentation for item under cursor. Remapping currently not supported. | Key | Description | | ---- | ----------- | | `Ctrl-u` | Scroll up | | `Ctrl-d` | Scroll down | +##### Completion Menu + +Displays documentation for the selected completion item. Remapping currently not supported. + +| Key | Description | +| ---- | ----------- | +| `Shift-Tab`, `Ctrl-p`, `Up` | Previous entry | +| `Tab`, `Ctrl-n`, `Down` | Next entry | + +##### Signature-help Popup + +Displays the signature of the selected completion item. Remapping currently not supported. + +| Key | Description | +| ---- | ----------- | +| `Alt-p` | Previous signature | +| `Alt-n` | Next signature | + #### Unimpaired These mappings are in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaired). From cfca30887cd4df53af3086c51ab5480cdb3604d5 Mon Sep 17 00:00:00 2001 From: Hichem Date: Fri, 3 May 2024 03:53:07 +0200 Subject: [PATCH 3/4] signature: use the suggested LSP signature when changed (#10655) some LSPs does update the active signature and some not. To make both worlds happy, make the active signature more intelligent. 1. SignatureHelp store now the suggested lsp_signature 2. if the lsp_signature changes then use it 3. otherwise use the last signature from the old popup 4. in case the old signature doesn't exist anymore, show the last signature Signed-off-by: Ben Fekih, Hichem --- helix-term/src/handlers/signature_help.rs | 28 +++++++++++++++++------ helix-term/src/ui/lsp.rs | 7 ++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/helix-term/src/handlers/signature_help.rs b/helix-term/src/handlers/signature_help.rs index 0bb1d3d16..4fc008118 100644 --- a/helix-term/src/handlers/signature_help.rs +++ b/helix-term/src/handlers/signature_help.rs @@ -238,19 +238,33 @@ pub fn show_signature_help( .collect(); let old_popup = compositor.find_id::>(SignatureHelp::ID); - let mut active_signature = old_popup - .as_ref() - .map(|popup| popup.contents().active_signature()) - .unwrap_or_else(|| response.active_signature.unwrap_or_default() as usize); + let lsp_signature = response.active_signature.map(|s| s as usize); - if active_signature >= signatures.len() { - active_signature = signatures.len() - 1; - } + // take the new suggested lsp signature if changed + // otherwise take the old signature if possible + // otherwise the last one (in case there is less signatures than before) + let active_signature = old_popup + .as_ref() + .map(|popup| { + let old_lsp_sig = popup.contents().lsp_signature(); + let old_sig = popup + .contents() + .active_signature() + .min(signatures.len() - 1); + + if old_lsp_sig != lsp_signature { + lsp_signature.unwrap_or(old_sig) + } else { + old_sig + } + }) + .unwrap_or(lsp_signature.unwrap_or_default()); let contents = SignatureHelp::new( language.to_string(), Arc::clone(&editor.syn_loader), active_signature, + lsp_signature, signatures, ); diff --git a/helix-term/src/ui/lsp.rs b/helix-term/src/ui/lsp.rs index b82f7be29..d845be4a7 100644 --- a/helix-term/src/ui/lsp.rs +++ b/helix-term/src/ui/lsp.rs @@ -27,6 +27,7 @@ pub struct SignatureHelp { language: String, config_loader: Arc>, active_signature: usize, + lsp_signature: Option, signatures: Vec, } @@ -37,12 +38,14 @@ impl SignatureHelp { language: String, config_loader: Arc>, active_signature: usize, + lsp_signature: Option, signatures: Vec, ) -> Self { Self { language, config_loader, active_signature, + lsp_signature, signatures, } } @@ -51,6 +54,10 @@ impl SignatureHelp { self.active_signature } + pub fn lsp_signature(&self) -> Option { + self.lsp_signature + } + pub fn visible_popup(compositor: &mut Compositor) -> Option<&mut Popup> { compositor.find_id::>(Self::ID) } From 7e13213e7430c95cbad210994cecbfadc52c0714 Mon Sep 17 00:00:00 2001 From: Matthew Pomes Date: Fri, 3 May 2024 05:39:02 -0500 Subject: [PATCH 4/4] Add `is not` and `not in` to python syntax (#10647) --- runtime/queries/python/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm index 0a082f2fd..9f7d2790c 100644 --- a/runtime/queries/python/highlights.scm +++ b/runtime/queries/python/highlights.scm @@ -215,9 +215,11 @@ [ "and" "or" + "not in" "in" "not" "del" + "is not" "is" ] @keyword.operator