Merge remote-tracking branch 'helix-pull/pull-diagnostics'

This commit is contained in:
Kalle Carlbark 2025-01-09 17:39:40 +01:00
commit 0f2fbd2b6f
12 changed files with 1045 additions and 695 deletions

View file

@ -336,5 +336,6 @@ These scopes are used for theming the editor interface:
| `diagnostic.error` | Diagnostics error (editing area) |
| `diagnostic.unnecessary` | Diagnostics with unnecessary tag (editing area) |
| `diagnostic.deprecated` | Diagnostics with deprecated tag (editing area) |
| `tabstop` | Snippet placeholder |
[editor-section]: ./configuration.md#editor-section

File diff suppressed because it is too large Load diff

View file

@ -30,7 +30,9 @@ use helix_core::{
object, pos_at_coords,
regex::{self, Regex},
search::{self, CharMatcher},
selection, shellwords, surround,
selection,
shellwords::{self, Args},
surround,
syntax::{BlockCommentToken, LanguageServerFeature},
text_annotations::{Overlay, TextAnnotations},
textobject,
@ -207,7 +209,7 @@ use helix_view::{align_view, Align};
pub enum MappableCommand {
Typable {
name: String,
args: Vec<String>,
args: String,
doc: String,
},
Static {
@ -242,15 +244,17 @@ impl MappableCommand {
pub fn execute(&self, cx: &mut Context) {
match &self {
Self::Typable { name, args, doc: _ } => {
let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect();
if let Some(command) = typed::TYPABLE_COMMAND_MAP.get(name.as_str()) {
let mut cx = compositor::Context {
editor: cx.editor,
jobs: cx.jobs,
scroll: None,
};
if let Err(e) = (command.fun)(&mut cx, &args[..], PromptEvent::Validate) {
cx.editor.set_error(format!("{}", e));
if let Err(err) =
(command.fun)(&mut cx, Args::from(args), PromptEvent::Validate)
{
cx.editor.set_error(format!("{err}"));
}
}
}
@ -624,21 +628,15 @@ impl std::str::FromStr for MappableCommand {
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some(suffix) = s.strip_prefix(':') {
let mut typable_command = suffix.split(' ').map(|arg| arg.trim());
let name = typable_command
.next()
.ok_or_else(|| anyhow!("Expected typable command name"))?;
let args = typable_command
.map(|s| s.to_owned())
.collect::<Vec<String>>();
let (name, args) = suffix.split_once(' ').unwrap_or((suffix, ""));
typed::TYPABLE_COMMAND_MAP
.get(name)
.map(|cmd| MappableCommand::Typable {
name: cmd.name.to_owned(),
doc: format!(":{} {:?}", cmd.name, args),
args,
args: args.to_string(),
})
.ok_or_else(|| anyhow!("No TypableCommand named '{}'", s))
.ok_or_else(|| anyhow!("No TypableCommand named '{}'", name))
} else if let Some(suffix) = s.strip_prefix('@') {
helix_view::input::parse_macro(suffix).map(|keys| Self::Macro {
name: s.to_string(),
@ -3313,7 +3311,7 @@ pub fn command_palette(cx: &mut Context) {
.iter()
.map(|cmd| MappableCommand::Typable {
name: cmd.name.to_owned(),
args: Vec::new(),
args: String::new(),
doc: cmd.doc.to_owned(),
}),
);
@ -4387,13 +4385,19 @@ fn yank_joined_impl(editor: &mut Editor, separator: &str, register: char) {
let (view, doc) = current!(editor);
let text = doc.text().slice(..);
let separator = if separator.is_empty() {
doc.line_ending.as_str()
} else {
separator
};
let selection = doc.selection(view.id);
let selections = selection.len();
let joined = selection
.fragments(text)
.fold(String::new(), |mut acc, fragment| {
if !acc.is_empty() {
acc.push_str(separator);
acc.push_str(&shellwords::unescape(separator));
}
acc.push_str(&fragment);
acc

View file

@ -109,6 +109,7 @@ fn dap_callback<T, F>(
jobs.callback(callback);
}
// TODO: transition to `shellwords::Args` instead of `Option<Vec<Cow>>>`
pub fn dap_start_impl(
cx: &mut compositor::Context,
name: Option<&str>,
@ -312,6 +313,7 @@ pub fn dap_restart(cx: &mut Context) {
);
}
// TODO: transition to `shellwords::Args` instead of `Vec<String>`
fn debug_parameter_prompt(
completions: Vec<DebugConfigCompletion>,
config_name: String,

File diff suppressed because it is too large Load diff

View file

@ -597,18 +597,14 @@ mod tests {
let expectation = KeyTrie::Node(KeyTrieNode::new(
"",
hashmap! {
key => KeyTrie::Sequence(vec!{
key => KeyTrie::Sequence(vec![
MappableCommand::select_all,
MappableCommand::Typable {
name: "pipe".to_string(),
args: vec!{
"sed".to_string(),
"-E".to_string(),
"'s/\\s+$//g'".to_string()
},
doc: "".to_string(),
args: String::from("sed -E 's/\\s+$//g'"),
doc: String::new(),
},
})
])
},
vec![key],
));

View file

@ -113,6 +113,7 @@
"."
";"
","
":"
] @punctuation.delimiter
[

View file

@ -4,7 +4,7 @@
["\\(" ")"] @punctuation.special)
["." ";" ":" "," ] @punctuation.delimiter
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
["(" ")" "[" "]" "{" "}" "<" ">"] @punctuation.bracket
; Identifiers
(attribute) @variable
@ -24,6 +24,7 @@
] @keyword
(function_declaration (simple_identifier) @function.method)
(protocol_function_declaration (simple_identifier) @function.method)
(init_declaration ["init" @constructor])
(deinit_declaration ["deinit" @constructor])
@ -91,6 +92,9 @@
(#match? @type "^[A-Z]"))
(call_expression (simple_identifier) @keyword (#eq? @keyword "defer")) ; defer { ... }
(navigation_suffix
(simple_identifier) @variable.other.member)
(try_operator) @operator
(try_operator ["try" @keyword])
@ -147,7 +151,7 @@
(integer_literal) @constant.numeric.integer
(real_literal) @constant.numeric.float
(boolean_literal) @constant.builtin.boolean
"nil" @variable.builtin
"nil" @constant.builtin
"?" @type
(type_annotation "!" @type)
@ -160,6 +164,7 @@
"?"
"+"
"-"
"\\"
"*"
"/"
"%"

View file

@ -4,3 +4,7 @@
((regex_literal) @injection.content
(#set! injection.language "regex"))
((comment) @injection.content
(#set! injection.language "comment")
(#set! injection.include-children))

View file

@ -1,3 +1,4 @@
# NOTE: For contributors looking to modify the theme, please submit a pull request at https://github.com/catppuccin/helix instead of updating this file. Changes are frequently synchronized from the catppuccin/helix theme repository.
# Syntax highlighting
# -------------------
"attribute" = "yellow"

View file

@ -68,6 +68,7 @@
"ui.cursor.normal" = { bg = "gray" }
"ui.cursor.primary" = { modifiers = ["reversed"] }
"ui.cursor.select" = { bg = "gray" }
"ui.cursorline.primary" = { bg = "linenr_bg" }
"ui.gutter" = { fg = "linenr_fg", bg = "linenr_bg" }
"ui.help" = { fg = "background_fg", bg = "cursorlinenr_bg" }
"ui.linenr" = { fg = "linenr_fg", bg = "linenr_bg" }

View file

@ -91,13 +91,14 @@
"markup.quote" = { fg = "grey" }
"markup.raw" = { fg = "brown" }
"markup.raw.inline" = { fg = "green" }
"markup.raw.block" = { fg = "grey" }
"markup.raw.block" = { fg = "brown" }
"diff" = { fg = "red" }
"diff.plus" = { fg = "green" }
"diff.minus" = { fg = "red" }
"diff.delta" = { fg = "cyan" }
"diff.delta.moved" = { fg = "cyan" }
"diff.delta.conflict" = {fg = "blue"}
"ui.background" = { bg = "white" }
"ui.background.separator" = { bg = "white" }
@ -133,6 +134,7 @@
"ui.text.focus" = { fg = "red", bg = "grey-300", modifiers = ["bold"] }
"ui.text.inactive" = { fg = "grey" }
"ui.text.info" = { fg = "black" }
"ui.text.directory" = { fg = "blue", underline = { style = "line" } }
"ui.virtual" = { fg = "grey-500" }
"ui.virtual.ruler" = { bg = "grey-200" }
@ -159,6 +161,9 @@
"ui.highlight" = { bg = "grey-300" }
"ui.picker.header" = { fg = "purple"}
"ui.picker.header.active" = { fg = "blue"}
"diagnostic.info" = { underline = { color = "blue", style = "dotted" } }
"diagnostic.hint" = { underline = { color = "green", style = "dashed" } }
"diagnostic.warning" = { underline = { color = "yellow", style = "curl" } }
@ -171,6 +176,8 @@
"warning" = { fg = "yellow", modifiers = ["bold"] }
"error" = { fg = "red", modifiers = ["bold"] }
"tabstop" = { modifiers = ["italic"], bg = "grey-300" }
[palette]
white = "#FAFAFA"
yellow = "#FF6F00"