Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions helix-core/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub mod steel_implementations {
fn equality_hint_general(&self, other: &steel::SteelVal) -> bool {
match other {
SteelVal::StringV(s) => self.to_slice() == s.as_str(),
SteelVal::Custom(c) => Self::equality_hint(&self, c.read().as_ref()),
SteelVal::Custom(c) => Self::equality_hint(self, c.read().as_ref()),

_ => false,
}
Expand Down Expand Up @@ -135,9 +135,9 @@ pub mod steel_implementations {
pub fn line(mut self, cursor: usize) -> Result<Self, RopeyError> {
match self.kind {
RangeKind::Char => {
let slice = self.text.get_slice(self.start..self.end).ok_or_else(|| {
RopeyError(ropey::Error::CharIndexOutOfBounds(self.start, self.end))
})?;
let slice = self.text.get_slice(self.start..self.end).ok_or(RopeyError(
ropey::Error::CharIndexOutOfBounds(self.start, self.end),
))?;

// Move the start range, to wherever this lines up
let index = slice.try_line_to_char(cursor)?;
Expand All @@ -153,9 +153,9 @@ pub mod steel_implementations {
let slice =
self.text
.get_byte_slice(self.start..self.end)
.ok_or_else(|| {
RopeyError(ropey::Error::ByteIndexOutOfBounds(self.start, self.end))
})?;
.ok_or(RopeyError(ropey::Error::ByteIndexOutOfBounds(
self.start, self.end,
)))?;

// Move the start range, to wherever this lines up
let index = slice.try_line_to_byte(cursor)?;
Expand All @@ -176,9 +176,9 @@ pub mod steel_implementations {
self.start += lower;

// Just check that this is legal
self.text.get_slice(self.start..self.end).ok_or_else(|| {
RopeyError(ropey::Error::CharIndexOutOfBounds(self.start, self.end))
})?;
self.text.get_slice(self.start..self.end).ok_or(RopeyError(
ropey::Error::CharIndexOutOfBounds(self.start, self.end),
))?;

Ok(self)
}
Expand All @@ -188,9 +188,9 @@ pub mod steel_implementations {

self.text
.get_byte_slice(self.start..self.end)
.ok_or_else(|| {
RopeyError(ropey::Error::ByteIndexOutOfBounds(self.start, self.end))
})?;
.ok_or(RopeyError(ropey::Error::ByteIndexOutOfBounds(
self.start, self.end,
)))?;

self.kind = RangeKind::Char;
Ok(self)
Expand All @@ -206,9 +206,9 @@ pub mod steel_implementations {
self.kind = RangeKind::Byte;

// Just check that this is legal
self.text.get_slice(self.start..self.end).ok_or_else(|| {
RopeyError(ropey::Error::CharIndexOutOfBounds(self.start, self.end))
})?;
self.text.get_slice(self.start..self.end).ok_or(RopeyError(
ropey::Error::CharIndexOutOfBounds(self.start, self.end),
))?;

Ok(self)
}
Expand All @@ -218,9 +218,9 @@ pub mod steel_implementations {

self.text
.get_byte_slice(self.start..self.end)
.ok_or_else(|| {
RopeyError(ropey::Error::ByteIndexOutOfBounds(self.start, self.end))
})?;
.ok_or(RopeyError(ropey::Error::ByteIndexOutOfBounds(
self.start, self.end,
)))?;

Ok(self)
}
Expand Down
35 changes: 1 addition & 34 deletions helix-core/src/syntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Configuration {
pub language_server: HashMap<String, LanguageServerConfiguration>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
pub struct LanguageConfiguration {
#[serde(skip)]
Expand Down Expand Up @@ -627,36 +627,3 @@ where
pub fn default_timeout() -> u64 {
20
}

impl Clone for LanguageConfiguration {
fn clone(&self) -> Self {
LanguageConfiguration {
language: self.language.clone(),
language_id: self.language_id.clone(),
language_server_language_id: self.language_server_language_id.clone(),
scope: self.scope.clone(),
file_types: self.file_types.clone(),
shebangs: self.shebangs.clone(),
roots: self.roots.clone(),
comment_tokens: self.comment_tokens.clone(),
block_comment_tokens: self.block_comment_tokens.clone(),
text_width: self.text_width.clone(),
soft_wrap: self.soft_wrap.clone(),
auto_format: self.auto_format.clone(),
formatter: self.formatter.clone(),
diagnostic_severity: self.diagnostic_severity.clone(),
grammar: self.grammar.clone(),
injection_regex: self.injection_regex.clone(),
language_servers: self.language_servers.clone(),
indent: self.indent.clone(),
debugger: self.debugger.clone(),
auto_pairs: self.auto_pairs.clone(),
rulers: self.rulers.clone(),
workspace_lsp_roots: self.workspace_lsp_roots.clone(),
persistent_diagnostic_sources: self.persistent_diagnostic_sources.clone(),
path_completion: self.path_completion,
word_completion: self.word_completion.clone(),
rainbow_brackets: self.rainbow_brackets.clone(),
}
}
}
2 changes: 1 addition & 1 deletion helix-lsp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ impl Client {
let request = jsonrpc::MethodCall {
jsonrpc: Some(jsonrpc::Version::V2),
id: id.clone(),
method: (&request.method_name).to_string(),
method: request.method_name,
params: Self::value_into_params(params),
};

Expand Down
4 changes: 0 additions & 4 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,6 @@ impl Application {
self.editor.language_servers.remove_by_id(server_id);
}
Notification::Other(event_name, params) => {
let server_id = server_id;

let mut cx = crate::compositor::Context {
editor: &mut self.editor,
scroll: None,
Expand Down Expand Up @@ -1066,8 +1064,6 @@ impl Application {
Ok(json!(result))
}
Ok(MethodCall::Other(event_name, params)) => {
let server_id = server_id;

let mut cx = crate::compositor::Context {
editor: &mut self.editor,
scroll: None,
Expand Down
16 changes: 7 additions & 9 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,21 +666,19 @@ impl std::str::FromStr for MappableCommand {
if let Some(suffix) = s.strip_prefix(':') {
let (name, args, _) = command_line::split(suffix);
ensure!(!name.is_empty(), "Expected typable command name");
typed::TYPABLE_COMMAND_MAP
let typable = typed::TYPABLE_COMMAND_MAP
.get(name)
.map(|cmd| MappableCommand::Typable {
name: cmd.name.to_owned(),
doc: format!(":{} {:?}", cmd.name, args),
args: args.to_owned(),
})
.or_else(|| {
Some(MappableCommand::Typable {
name: name.to_owned(),
args: args.to_owned(),
doc: "Undocumented plugin command".to_string(),
})
})
.ok_or_else(|| anyhow!("No TypableCommand named '{}'", s))
.unwrap_or_else(|| MappableCommand::Typable {
name: name.to_owned(),
args: args.to_owned(),
doc: "Undocumented plugin command".to_string(),
});
Ok(typable)
} else if let Some(suffix) = s.strip_prefix('@') {
helix_view::input::parse_macro(suffix).map(|keys| Self::Macro {
name: s.to_string(),
Expand Down
3 changes: 2 additions & 1 deletion helix-term/src/commands/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ impl ScriptingEngine {
return Some(value);
}
}
return None;

None
}

pub fn generate_sources() {
Expand Down
23 changes: 12 additions & 11 deletions helix-term/src/commands/engine/steel/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ struct AsyncWriter {

impl std::io::Write for AsyncWriter {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
if let Err(_) = self.channel.send(String::from_utf8_lossy(buf).to_string()) {
if self
.channel
.send(String::from_utf8_lossy(buf).into_owned())
.is_err()
{
Ok(0)
} else {
Ok(buf.len())
Expand All @@ -108,7 +112,7 @@ pub fn helix_component_module(generate_sources: bool) -> BuiltInModule {
let mut module = BuiltInModule::new("helix/components");

let mut builtin_components_module = if generate_sources {
"(require-builtin helix/components as helix.components.)".to_string()
"(require-builtin helix/components as helix.components.)".to_owned()
} else {
String::new()
};
Expand Down Expand Up @@ -1344,7 +1348,7 @@ be popped off of the stack and removed.

register!(
"style",
|| Style::default(),
Style::default,
r#"
Constructs a new default style.

Expand Down Expand Up @@ -1490,7 +1494,7 @@ The key modifier bits associated with the super key modifier.
Event::Key(KeyEvent {
code: KeyCode::F(x),
..
}) if number == x => true,
}) => number == x,
_ => false,
},
r#"Check if this key event is associated with an `F<x>` key, e.g. F1, F2, etc.
Expand Down Expand Up @@ -2017,7 +2021,7 @@ impl Component for SteelDynamicComponent {
)
};

let cursor_call_result = enter_engine(|x| thunk(x));
let cursor_call_result = enter_engine(thunk);

match cursor_call_result {
Ok(c) => match c {
Expand Down Expand Up @@ -2095,18 +2099,15 @@ impl Component for SteelDynamicComponent {
// re-entrant attempting to grab the ENGINE instead mutably, since we have to break the recursion
// somehow. By putting it at the edge, we then say - hey for these functions on this interface,
// call the engine instance. Otherwise, all computation happens inside the engine.
match enter_engine(|x| {
enter_engine(|x| {
x.call_function_with_args_from_mut_slice(
required_size.clone(),
&mut [self.state.clone(), viewport.into_steelval().unwrap()],
)
})
.and_then(|x| Option::<(u16, u16)>::from_steelval(&x))
{
Ok(v) => v,
// TODO: Figure out how to present an error
Err(_e) => None,
}
.ok()
.flatten()
} else {
None
}
Expand Down
Loading