mirror of
https://github.com/helix-editor/helix
synced 2024-05-09 00:06:05 +02:00
Compare commits
9 Commits
5116a3832e
...
7973206efa
Author | SHA1 | Date | |
---|---|---|---|
Daniel | 7973206efa | ||
Diogenesoftoronto | 5ee7411450 | ||
Keir Lawson | 31248d4e2f | ||
David Else | 109f53fb60 | ||
Daniel | 9857b516dc | ||
Daniel | 31ce84fef2 | ||
Daniel | 27aed73abb | ||
Daniel | 73a8622332 | ||
Daniel | 8d231bafd0 |
|
@ -35,7 +35,7 @@
|
|||
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{BTreeMap, HashSet},
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
fmt::Write,
|
||||
future::Future,
|
||||
path::{Path, PathBuf},
|
||||
|
@ -1315,6 +1315,36 @@ fn compute_inlay_hints_for_view(
|
|||
}
|
||||
}
|
||||
|
||||
let vimmise_inlays = |hints: &mut Vec<InlineAnnotation>, prefix| {
|
||||
hints.iter_mut().map(|it| {
|
||||
it.char_idx = helix_core::line_ending::line_end_char_index(&doc_text.slice(..), doc_text.char_to_line(it.char_idx));
|
||||
(it.char_idx, it)
|
||||
}).fold(HashMap::<usize, Vec<&mut InlineAnnotation>>::new(), |mut map, (id, annot)| {
|
||||
match map.get_mut(&id) {
|
||||
Some(v) => v.push(annot),
|
||||
None => {map.insert(id, vec![annot]);}
|
||||
};
|
||||
map
|
||||
}).into_iter().for_each(|(_, mut v)| {
|
||||
v[0].text.insert_str(0, prefix);
|
||||
v.iter_mut().for_each(|s| s.text.push_str(","));
|
||||
let last = v.last_mut().unwrap();
|
||||
last.text.truncate(last.text.len() - 1);
|
||||
});
|
||||
};
|
||||
|
||||
{
|
||||
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,
|
||||
DocumentInlayHints {
|
||||
|
@ -1326,6 +1356,7 @@ fn compute_inlay_hints_for_view(
|
|||
padding_after_inlay_hints,
|
||||
},
|
||||
);
|
||||
|
||||
doc.inlay_hints_oudated = false;
|
||||
},
|
||||
);
|
||||
|
|
|
@ -407,6 +407,25 @@ pub fn get_terminal_provider() -> Option<TerminalConfig> {
|
|||
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 {
|
||||
|
@ -420,6 +439,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
|
||||
|
@ -434,6 +455,7 @@ fn default() -> Self {
|
|||
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,
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ ltex-ls = { command = "ltex-ls" }
|
|||
markdoc-ls = { command = "markdoc-ls", args = ["--stdio"] }
|
||||
markdown-oxide = { command = "markdown-oxide" }
|
||||
marksman = { command = "marksman", args = ["server"] }
|
||||
metals = { command = "metals", config = { "isHttpEnabled" = true } }
|
||||
metals = { command = "metals", config = { "isHttpEnabled" = true, metals = { inlayHints = { typeParameters = {enable = true} , hintsInPatternMatch = {enable = true} } } } }
|
||||
mint = { command = "mint", args = ["ls"] }
|
||||
nil = { command = "nil" }
|
||||
nimlangserver = { command = "nimlangserver" }
|
||||
|
|
|
@ -77,6 +77,9 @@
|
|||
"ui.virtual.indent-guide" = { fg = "dark_gray4" }
|
||||
"ui.virtual.inlay-hint" = { fg = "dark_gray5"}
|
||||
"ui.virtual.jump-label" = { fg = "dark_gray", modifiers = ["bold"] }
|
||||
"ui.highlight.frameline" = { bg = "#4b4b18" }
|
||||
"ui.debug.active" = { fg = "#ffcc00" }
|
||||
"ui.debug.breakpoint" = { fg = "#e51400" }
|
||||
"warning" = { fg = "gold2" }
|
||||
"error" = { fg = "red" }
|
||||
"info" = { fg = "light_blue" }
|
||||
|
|
|
@ -66,6 +66,8 @@ label = "honey"
|
|||
# TODO: namespace ui.cursor as ui.selection.cursor?
|
||||
"ui.cursor.select" = { bg = "delta" }
|
||||
"ui.cursor.insert" = { bg = "white" }
|
||||
"ui.cursor.primary.select" = { bg = "delta" }
|
||||
"ui.cursor.primary.insert" = { bg = "white" }
|
||||
"ui.cursor.match" = { fg = "#212121", bg = "#6C6999" }
|
||||
"ui.cursor" = { modifiers = ["reversed"] }
|
||||
"ui.cursorline.primary" = { bg = "bossanova" }
|
||||
|
|
Loading…
Reference in New Issue