From 31ce84fef2d13d7323e5cc3a6da288a333c8920a Mon Sep 17 00:00:00 2001 From: Daniel <101683475+Koranir@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:38:31 +1100 Subject: [PATCH] Works --- helix-term/src/commands/lsp.rs | 17 ++++++++++++----- helix-view/src/editor.rs | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index df9ad3b00..b47a01263 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -1654,11 +1654,17 @@ fn compute_inlay_hints_for_view( }); }; - vimmise_inlays(&mut type_inlay_hints, " => "); - vimmise_inlays(&mut parameter_inlay_hints, " <= "); - vimmise_inlays(&mut other_inlay_hints, " == "); - padding_after_inlay_hints = vec![]; - padding_before_inlay_hints = vec![]; + { + let cfg = doc.config.load(); + let vim_cfg = &cfg.lsp.vim_inlay_hints; + if vim_cfg.enable { + vimmise_inlays(&mut type_inlay_hints, vim_cfg.type_inlay_prefix.as_str()); + vimmise_inlays(&mut parameter_inlay_hints, vim_cfg.parameter_inlay_prefix.as_str()); + vimmise_inlays(&mut other_inlay_hints, vim_cfg.other_inlay_prefix.as_str()); + padding_after_inlay_hints = vec![]; + padding_before_inlay_hints = vec![]; + } + } doc.set_inlay_hints( view_id, @@ -1671,6 +1677,7 @@ fn compute_inlay_hints_for_view( padding_after_inlay_hints: padding_after_inlay_hints.into(), }, ); + doc.inlay_hints_oudated = false; }, ); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index f2e853071..5c0e49174 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -365,6 +365,25 @@ pub fn get_terminal_provider() -> Option { None } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default, rename_all = "kebab-case", deny_unknown_fields)] +pub struct VimInlayConfig { + pub enable: bool, + pub type_inlay_prefix: String, + pub parameter_inlay_prefix: String, + pub other_inlay_prefix: String, +} +impl Default for VimInlayConfig { + fn default() -> Self { + Self { + enable: false, + type_inlay_prefix: String::from(" => "), + parameter_inlay_prefix: String::from(" <= "), + other_inlay_prefix: String::from(" == "), + } + } +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(default, rename_all = "kebab-case", deny_unknown_fields)] pub struct LspConfig { @@ -378,6 +397,8 @@ pub struct LspConfig { pub display_signature_help_docs: bool, /// Display inlay hints pub display_inlay_hints: bool, + /// Vim-style inlay hints + pub vim_inlay_hints: VimInlayConfig, /// Whether to enable snippet support pub snippets: bool, /// Whether to include declaration in the goto reference query @@ -392,6 +413,7 @@ impl Default for LspConfig { auto_signature_help: true, display_signature_help_docs: true, display_inlay_hints: false, + vim_inlay_hints: VimInlayConfig::default(), snippets: true, goto_reference_include_declaration: true, }