diff --git a/core/src/data.rs b/core/src/data.rs index df50ca21..0837b236 100644 --- a/core/src/data.rs +++ b/core/src/data.rs @@ -1521,45 +1521,45 @@ pub fn get_code_actions(&mut self, ctx: &mut EventCtx) { } } - fn move_command( - &self, - count: Option, - cmd: &LapceCommand, - ) -> Option { - match cmd { - LapceCommand::Left => Some(Movement::Left), - LapceCommand::Right => Some(Movement::Right), - LapceCommand::Up => Some(Movement::Up), - LapceCommand::Down => Some(Movement::Down), - LapceCommand::LineStart => Some(Movement::StartOfLine), - LapceCommand::LineEnd => Some(Movement::EndOfLine), - LapceCommand::GotoLineDefaultFirst => Some(match count { - Some(n) => Movement::Line(LinePosition::Line(n)), - None => Movement::Line(LinePosition::First), - }), - LapceCommand::GotoLineDefaultLast => Some(match count { - Some(n) => Movement::Line(LinePosition::Line(n)), - None => Movement::Line(LinePosition::Last), - }), - LapceCommand::WordBackward => Some(Movement::WordBackward), - LapceCommand::WordFoward => Some(Movement::WordForward), - LapceCommand::WordEndForward => Some(Movement::WordEndForward), - LapceCommand::MatchPairs => Some(Movement::MatchPairs), - LapceCommand::NextUnmatchedRightBracket => { - Some(Movement::NextUnmatched(')')) - } - LapceCommand::PreviousUnmatchedLeftBracket => { - Some(Movement::PreviousUnmatched('(')) - } - LapceCommand::NextUnmatchedRightCurlyBracket => { - Some(Movement::NextUnmatched('}')) - } - LapceCommand::PreviousUnmatchedLeftCurlyBracket => { - Some(Movement::PreviousUnmatched('{')) - } - _ => None, - } - } + // fn move_command( + // &self, + // count: Option, + // cmd: &LapceCommand, + // ) -> Option { + // match cmd { + // LapceCommand::Left => Some(Movement::Left), + // LapceCommand::Right => Some(Movement::Right), + // LapceCommand::Up => Some(Movement::Up), + // LapceCommand::Down => Some(Movement::Down), + // LapceCommand::LineStart => Some(Movement::StartOfLine), + // LapceCommand::LineEnd => Some(Movement::EndOfLine), + // LapceCommand::GotoLineDefaultFirst => Some(match count { + // Some(n) => Movement::Line(LinePosition::Line(n)), + // None => Movement::Line(LinePosition::First), + // }), + // LapceCommand::GotoLineDefaultLast => Some(match count { + // Some(n) => Movement::Line(LinePosition::Line(n)), + // None => Movement::Line(LinePosition::Last), + // }), + // LapceCommand::WordBackward => Some(Movement::WordBackward), + // LapceCommand::WordFoward => Some(Movement::WordForward), + // LapceCommand::WordEndForward => Some(Movement::WordEndForward), + // LapceCommand::MatchPairs => Some(Movement::MatchPairs), + // LapceCommand::NextUnmatchedRightBracket => { + // Some(Movement::NextUnmatched(')')) + // } + // LapceCommand::PreviousUnmatchedLeftBracket => { + // Some(Movement::PreviousUnmatched('(')) + // } + // LapceCommand::NextUnmatchedRightCurlyBracket => { + // Some(Movement::NextUnmatched('}')) + // } + // LapceCommand::PreviousUnmatchedLeftCurlyBracket => { + // Some(Movement::PreviousUnmatched('{')) + // } + // _ => None, + // } + // } fn toggle_visual(&mut self, visual_mode: VisualMode) { if !self.config.lapce.modal { @@ -2238,99 +2238,99 @@ pub fn cancel_completion(&mut self) { completion.cancel(); } - fn update_completion(&mut self, ctx: &mut EventCtx) { - if self.get_mode() != Mode::Insert { - return; - } - if !self.buffer.loaded { - return; - } - if self.buffer.local { - return; - } - let offset = self.editor.cursor.offset(); - let start_offset = self.buffer.prev_code_boundary(offset); - let end_offset = self.buffer.next_code_boundary(offset); - let input = self - .buffer - .slice_to_cow(start_offset..end_offset) - .to_string(); - let char = if start_offset == 0 { - "".to_string() - } else { - self.buffer - .slice_to_cow(start_offset - 1..start_offset) - .to_string() - }; - let completion = Arc::make_mut(&mut self.completion); - if input == "" && char != "." && char != ":" { - completion.cancel(); - return; - } + // fn update_completion(&mut self, ctx: &mut EventCtx) { + // if self.get_mode() != Mode::Insert { + // return; + // } + // if !self.buffer.loaded { + // return; + // } + // if self.buffer.local { + // return; + // } + // let offset = self.editor.cursor.offset(); + // let start_offset = self.buffer.prev_code_boundary(offset); + // let end_offset = self.buffer.next_code_boundary(offset); + // let input = self + // .buffer + // .slice_to_cow(start_offset..end_offset) + // .to_string(); + // let char = if start_offset == 0 { + // "".to_string() + // } else { + // self.buffer + // .slice_to_cow(start_offset - 1..start_offset) + // .to_string() + // }; + // let completion = Arc::make_mut(&mut self.completion); + // if input == "" && char != "." && char != ":" { + // completion.cancel(); + // return; + // } - if completion.status != CompletionStatus::Inactive - && completion.offset == start_offset - && completion.buffer_id == self.buffer.id - { - completion.update_input(input.clone()); + // if completion.status != CompletionStatus::Inactive + // && completion.offset == start_offset + // && completion.buffer_id == self.buffer.id + // { + // completion.update_input(input.clone()); - if !completion.input_items.contains_key("") { - let event_sink = ctx.get_external_handle(); - completion.request( - self.proxy.clone(), - completion.request_id, - self.buffer.id, - "".to_string(), - self.buffer.offset_to_position(start_offset), - completion.id, - event_sink, - ); - } + // if !completion.input_items.contains_key("") { + // let event_sink = ctx.get_external_handle(); + // completion.request( + // self.proxy.clone(), + // completion.request_id, + // self.buffer.id, + // "".to_string(), + // self.buffer.offset_to_position(start_offset), + // completion.id, + // event_sink, + // ); + // } - if !completion.input_items.contains_key(&input) { - let event_sink = ctx.get_external_handle(); - completion.request( - self.proxy.clone(), - completion.request_id, - self.buffer.id, - input, - self.buffer.offset_to_position(offset), - completion.id, - event_sink, - ); - } + // if !completion.input_items.contains_key(&input) { + // let event_sink = ctx.get_external_handle(); + // completion.request( + // self.proxy.clone(), + // completion.request_id, + // self.buffer.id, + // input, + // self.buffer.offset_to_position(offset), + // completion.id, + // event_sink, + // ); + // } - return; - } + // return; + // } - completion.buffer_id = self.buffer.id; - completion.offset = start_offset; - completion.input = input.clone(); - completion.status = CompletionStatus::Started; - completion.input_items.clear(); - completion.request_id += 1; - let event_sink = ctx.get_external_handle(); - completion.request( - self.proxy.clone(), - completion.request_id, - self.buffer.id, - "".to_string(), - self.buffer.offset_to_position(start_offset), - completion.id, - event_sink.clone(), - ); - if input != "" { - completion.request( - self.proxy.clone(), - completion.request_id, - self.buffer.id, - input, - self.buffer.offset_to_position(offset), - completion.id, - event_sink, - ); - } - } + // completion.buffer_id = self.buffer.id; + // completion.offset = start_offset; + // completion.input = input.clone(); + // completion.status = CompletionStatus::Started; + // completion.input_items.clear(); + // completion.request_id += 1; + // let event_sink = ctx.get_external_handle(); + // completion.request( + // self.proxy.clone(), + // completion.request_id, + // self.buffer.id, + // "".to_string(), + // self.buffer.offset_to_position(start_offset), + // completion.id, + // event_sink.clone(), + // ); + // if input != "" { + // completion.request( + // self.proxy.clone(), + // completion.request_id, + // self.buffer.id, + // input, + // self.buffer.offset_to_position(offset), + // completion.id, + // event_sink, + // ); + // } + // } } // pub struct LapceEditorLens(pub WidgetId); @@ -2421,890 +2421,890 @@ fn update_completion(&mut self, ctx: &mut EventCtx) { // } // } -impl KeyPressFocus for LapceEditorViewData { - fn get_mode(&self) -> Mode { - self.editor.cursor.get_mode() - } +// impl KeyPressFocus for LapceEditorViewData { +// fn get_mode(&self) -> Mode { +// self.editor.cursor.get_mode() +// } +// +// fn check_condition(&self, condition: &str) -> bool { +// match condition { +// "editor_focus" => true, +// "source_control_focus" => { +// self.editor.editor_type == EditorType::SourceControl +// } +// "in_snippet" => self.editor.snippet.is_some(), +// "list_focus" => { +// self.completion.status != CompletionStatus::Inactive +// && self.completion.len() > 0 +// } +// _ => false, +// } +// } - fn check_condition(&self, condition: &str) -> bool { - match condition { - "editor_focus" => true, - "source_control_focus" => { - self.editor.editor_type == EditorType::SourceControl - } - "in_snippet" => self.editor.snippet.is_some(), - "list_focus" => { - self.completion.status != CompletionStatus::Inactive - && self.completion.len() > 0 - } - _ => false, - } - } +// fn run_command( +// &mut self, +// ctx: &mut EventCtx, +// cmd: &LapceCommand, +// count: Option, +// env: &Env, +// ) { +// if let Some(movement) = self.move_command(count, cmd) { +// self.do_move(&movement, count.unwrap_or(1)); +// if let Some(snippet) = self.editor.snippet.as_ref() { +// let offset = self.editor.cursor.offset(); +// let mut within_region = false; +// for (_, (start, end)) in snippet { +// if offset >= *start && offset <= *end { +// within_region = true; +// break; +// } +// } +// if !within_region { +// Arc::make_mut(&mut self.editor).snippet = None; +// } +// } +// self.cancel_completion(); +// return; +// } +// match cmd { +// LapceCommand::SplitLeft => { +// if let Some(split_id) = self.editor.split_id.clone() { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditorMove( +// SplitMoveDirection::Left, +// self.editor.view_id, +// ), +// Target::Widget(split_id), +// )); +// } +// } +// LapceCommand::SplitRight => { +// if let Some(split_id) = self.editor.split_id.clone() { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditorMove( +// SplitMoveDirection::Right, +// self.editor.view_id, +// ), +// Target::Widget(split_id), +// )); +// } +// } +// LapceCommand::SplitUp => { +// if let Some(split_id) = self.editor.split_id.clone() { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditorMove( +// SplitMoveDirection::Up, +// self.editor.view_id, +// ), +// Target::Widget(split_id), +// )); +// } +// } +// LapceCommand::SplitDown => { +// if let Some(split_id) = self.editor.split_id.clone() { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditorMove( +// SplitMoveDirection::Down, +// self.editor.view_id, +// ), +// Target::Widget(split_id), +// )); +// } +// } +// LapceCommand::SplitExchange => { +// if let Some(split_id) = self.editor.split_id.clone() { +// if self.editor.editor_type == EditorType::Normal { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditorExchange(self.editor.view_id), +// Target::Widget(split_id), +// )); +// } +// } +// } +// LapceCommand::SplitVertical => { +// if let Some(split_id) = self.editor.split_id.clone() { +// if self.editor.editor_type == EditorType::Normal { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditor(true, self.editor.view_id), +// Target::Widget(split_id), +// )); +// } +// } +// } +// LapceCommand::SplitClose => { +// if let Some(split_id) = self.editor.split_id.clone() { +// if self.editor.editor_type == EditorType::Normal { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::SplitEditorClose(self.editor.view_id), +// Target::Widget(split_id), +// )); +// } +// } +// } +// LapceCommand::Undo => { +// self.initiate_diagnositcs_offset(); +// let proxy = self.proxy.clone(); +// let buffer = self.buffer_mut(); +// if let Some(delta) = buffer.do_undo(proxy) { +// let (iv, _) = delta.summary(); +// let line = self.buffer.line_of_offset(iv.start); +// let offset = self.buffer.first_non_blank_character_on_line(line); +// let selection = Selection::caret(offset); +// self.set_cursor_after_change(selection); +// self.update_diagnositcs_offset(&delta); +// } +// } +// LapceCommand::Redo => { +// self.initiate_diagnositcs_offset(); +// let proxy = self.proxy.clone(); +// let buffer = self.buffer_mut(); +// if let Some(delta) = buffer.do_redo(proxy) { +// let (iv, _) = delta.summary(); +// let line = self.buffer.line_of_offset(iv.start); +// let offset = self.buffer.first_non_blank_character_on_line(line); +// let selection = Selection::caret(offset); +// self.set_cursor_after_change(selection); +// self.update_diagnositcs_offset(&delta); +// } +// } +// LapceCommand::Append => { +// let offset = self +// .buffer +// .move_offset( +// self.editor.cursor.offset(), +// None, +// 1, +// &Movement::Right, +// Mode::Insert, +// ) +// .0; +// self.buffer_mut().update_edit_type(); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(Selection::caret(offset)), +// None, +// )); +// } +// LapceCommand::AppendEndOfLine => { +// let (offset, horiz) = self.buffer.move_offset( +// self.editor.cursor.offset(), +// None, +// 1, +// &Movement::EndOfLine, +// Mode::Insert, +// ); +// self.buffer_mut().update_edit_type(); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(Selection::caret(offset)), +// Some(horiz), +// )); +// } +// LapceCommand::InsertMode => { +// Arc::make_mut(&mut self.editor).cursor.mode = CursorMode::Insert( +// Selection::caret(self.editor.cursor.offset()), +// ); +// self.buffer_mut().update_edit_type(); +// } +// LapceCommand::InsertFirstNonBlank => { +// match &self.editor.cursor.mode { +// CursorMode::Normal(offset) => { +// let (offset, horiz) = self.buffer.move_offset( +// *offset, +// None, +// 1, +// &Movement::FirstNonBlank, +// Mode::Normal, +// ); +// self.buffer_mut().update_edit_type(); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(Selection::caret(offset)), +// Some(horiz), +// )); +// } +// CursorMode::Visual { start, end, mode } => { +// let mut selection = Selection::new(); +// for region in +// self.editor.cursor.edit_selection(&self.buffer).regions() +// { +// selection.add_region(SelRegion::caret(region.min())); +// } +// self.buffer_mut().update_edit_type(); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(selection), +// None, +// )); +// } +// CursorMode::Insert(_) => {} +// }; +// } +// LapceCommand::NewLineAbove => { +// let line = self.editor.cursor.current_line(&self.buffer); +// let offset = if line > 0 { +// self.buffer.line_end_offset(line - 1, true) +// } else { +// self.buffer.first_non_blank_character_on_line(line) +// }; +// self.insert_new_line(ctx, offset); +// } +// LapceCommand::NewLineBelow => { +// let offset = self.editor.cursor.offset(); +// let offset = self.buffer.offset_line_end(offset, true); +// self.insert_new_line(ctx, offset); +// } +// LapceCommand::DeleteToBeginningOfLine => { +// let selection = match self.editor.cursor.mode { +// CursorMode::Normal(_) | CursorMode::Visual { .. } => { +// self.editor.cursor.edit_selection(&self.buffer) +// } +// CursorMode::Insert(_) => { +// let selection = +// self.editor.cursor.edit_selection(&self.buffer); +// let selection = self.buffer.update_selection( +// &selection, +// 1, +// &Movement::StartOfLine, +// Mode::Insert, +// true, +// ); +// selection +// } +// }; +// let (selection, _) = +// self.edit(ctx, &selection, "", None, true, EditType::Delete); +// match self.editor.cursor.mode { +// CursorMode::Normal(_) | CursorMode::Visual { .. } => { +// let offset = selection.min_offset(); +// let offset = +// self.buffer.offset_line_end(offset, false).min(offset); +// self.set_cursor(Cursor::new( +// CursorMode::Normal(offset), +// None, +// )); +// } +// CursorMode::Insert(_) => { +// self.set_cursor(Cursor::new( +// CursorMode::Insert(selection), +// None, +// )); +// } +// } +// } +// LapceCommand::Yank => { +// let data = self.editor.cursor.yank(&self.buffer); +// let register = Arc::make_mut(&mut self.main_split.register); +// register.add_yank(data); +// match &self.editor.cursor.mode { +// CursorMode::Visual { start, end, mode } => { +// let offset = *start.min(end); +// let offset = +// self.buffer.offset_line_end(offset, false).min(offset); +// self.set_cursor(Cursor::new( +// CursorMode::Normal(offset), +// None, +// )); +// } +// CursorMode::Normal(_) => {} +// CursorMode::Insert(_) => {} +// } +// } +// LapceCommand::ClipboardCopy => { +// let data = self.editor.cursor.yank(&self.buffer); +// Application::global().clipboard().put_string(data.content); +// match &self.editor.cursor.mode { +// CursorMode::Visual { start, end, mode } => { +// let offset = *start.min(end); +// let offset = +// self.buffer.offset_line_end(offset, false).min(offset); +// self.set_cursor(Cursor::new( +// CursorMode::Normal(offset), +// None, +// )); +// } +// CursorMode::Normal(_) => {} +// CursorMode::Insert(_) => {} +// } +// } +// LapceCommand::ClipboardPaste => { +// if let Some(s) = Application::global().clipboard().get_string() { +// let data = RegisterData { +// content: s.to_string(), +// mode: VisualMode::Normal, +// }; +// self.paste(ctx, &data); +// } +// } +// LapceCommand::Paste => { +// let data = self.main_split.register.unamed.clone(); +// self.paste(ctx, &data); +// } +// LapceCommand::DeleteWordBackward => { +// let selection = match self.editor.cursor.mode { +// CursorMode::Normal(_) | CursorMode::Visual { .. } => { +// self.editor.cursor.edit_selection(&self.buffer) +// } +// CursorMode::Insert(_) => { +// let selection = +// self.editor.cursor.edit_selection(&self.buffer); +// let selection = self.buffer.update_selection( +// &selection, +// 1, +// &Movement::WordBackward, +// Mode::Insert, +// true, +// ); +// selection +// } +// }; +// let (selection, _) = +// self.edit(ctx, &selection, "", None, true, EditType::Delete); +// self.set_cursor_after_change(selection); +// self.update_completion(ctx); +// } +// LapceCommand::DeleteBackward => { +// let selection = match self.editor.cursor.mode { +// CursorMode::Normal(_) | CursorMode::Visual { .. } => { +// self.editor.cursor.edit_selection(&self.buffer) +// } +// CursorMode::Insert(_) => { +// let selection = +// self.editor.cursor.edit_selection(&self.buffer); +// let mut selection = self.buffer.update_selection( +// &selection, +// 1, +// &Movement::Left, +// Mode::Insert, +// true, +// ); +// if selection.regions().len() == 1 { +// let delete_str = self +// .buffer +// .slice_to_cow( +// selection.min_offset()..selection.max_offset(), +// ) +// .to_string(); +// if str_is_pair_left(&delete_str) { +// if let Some(c) = str_matching_pair(&delete_str) { +// let offset = selection.max_offset(); +// let line = self.buffer.line_of_offset(offset); +// let line_end = +// self.buffer.line_end_offset(line, true); +// let content = self +// .buffer +// .slice_to_cow(offset..line_end) +// .to_string(); +// if content.trim().starts_with(&c.to_string()) { +// let index = content +// .match_indices(c) +// .next() +// .unwrap() +// .0; +// selection = Selection::region( +// selection.min_offset(), +// offset + index + 1, +// ); +// } +// } +// } +// } +// selection +// } +// }; +// let (selection, _) = +// self.edit(ctx, &selection, "", None, true, EditType::Delete); +// self.set_cursor_after_change(selection); +// self.update_completion(ctx); +// } +// LapceCommand::DeleteForeward => { +// let selection = self.editor.cursor.edit_selection(&self.buffer); +// let (selection, _) = +// self.edit(ctx, &selection, "", None, true, EditType::Delete); +// self.set_cursor_after_change(selection); +// self.update_completion(ctx); +// } +// LapceCommand::DeleteForewardAndInsert => { +// let selection = self.editor.cursor.edit_selection(&self.buffer); +// let (selection, _) = +// self.edit(ctx, &selection, "", None, true, EditType::Delete); +// self.set_cursor(Cursor::new(CursorMode::Insert(selection), None)); +// self.update_completion(ctx); +// } +// LapceCommand::InsertNewLine => { +// let selection = self.editor.cursor.edit_selection(&self.buffer); +// if selection.regions().len() > 1 { +// let (selection, _) = self.edit( +// ctx, +// &selection, +// "\n", +// None, +// true, +// EditType::InsertNewline, +// ); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(selection), +// None, +// )); +// return; +// }; +// self.insert_new_line(ctx, self.editor.cursor.offset()); +// self.update_completion(ctx); +// } +// LapceCommand::ToggleVisualMode => { +// self.toggle_visual(VisualMode::Normal); +// } +// LapceCommand::ToggleLinewiseVisualMode => { +// self.toggle_visual(VisualMode::Linewise); +// } +// LapceCommand::ToggleBlockwiseVisualMode => { +// self.toggle_visual(VisualMode::Blockwise); +// } +// LapceCommand::CenterOfWindow => { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::EnsureCursorCenter, +// Target::Widget(self.editor.view_id), +// )); +// } +// LapceCommand::ScrollDown => { +// self.scroll(ctx, true, count.unwrap_or(1), env); +// } +// LapceCommand::ScrollUp => { +// self.scroll(ctx, false, count.unwrap_or(1), env); +// } +// LapceCommand::PageDown => { +// self.page_move(ctx, true, env); +// } +// LapceCommand::PageUp => { +// self.page_move(ctx, false, env); +// } +// LapceCommand::JumpLocationBackward => { +// self.jump_location_backward(ctx, env); +// } +// LapceCommand::JumpLocationForward => { +// self.jump_location_forward(ctx, env); +// } +// LapceCommand::NextError => { +// self.next_error(ctx, env); +// } +// LapceCommand::PreviousError => {} +// LapceCommand::ListNext => { +// let completion = Arc::make_mut(&mut self.completion); +// completion.next(); +// } +// LapceCommand::ListPrevious => { +// let completion = Arc::make_mut(&mut self.completion); +// completion.previous(); +// } +// LapceCommand::JumpToNextSnippetPlaceholder => { +// if let Some(snippet) = self.editor.snippet.as_ref() { +// let mut current = 0; +// let offset = self.editor.cursor.offset(); +// for (i, (_, (start, end))) in snippet.iter().enumerate() { +// if *start <= offset && offset <= *end { +// current = i; +// break; +// } +// } - fn run_command( - &mut self, - ctx: &mut EventCtx, - cmd: &LapceCommand, - count: Option, - env: &Env, - ) { - if let Some(movement) = self.move_command(count, cmd) { - self.do_move(&movement, count.unwrap_or(1)); - if let Some(snippet) = self.editor.snippet.as_ref() { - let offset = self.editor.cursor.offset(); - let mut within_region = false; - for (_, (start, end)) in snippet { - if offset >= *start && offset <= *end { - within_region = true; - break; - } - } - if !within_region { - Arc::make_mut(&mut self.editor).snippet = None; - } - } - self.cancel_completion(); - return; - } - match cmd { - LapceCommand::SplitLeft => { - if let Some(split_id) = self.editor.split_id.clone() { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditorMove( - SplitMoveDirection::Left, - self.editor.view_id, - ), - Target::Widget(split_id), - )); - } - } - LapceCommand::SplitRight => { - if let Some(split_id) = self.editor.split_id.clone() { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditorMove( - SplitMoveDirection::Right, - self.editor.view_id, - ), - Target::Widget(split_id), - )); - } - } - LapceCommand::SplitUp => { - if let Some(split_id) = self.editor.split_id.clone() { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditorMove( - SplitMoveDirection::Up, - self.editor.view_id, - ), - Target::Widget(split_id), - )); - } - } - LapceCommand::SplitDown => { - if let Some(split_id) = self.editor.split_id.clone() { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditorMove( - SplitMoveDirection::Down, - self.editor.view_id, - ), - Target::Widget(split_id), - )); - } - } - LapceCommand::SplitExchange => { - if let Some(split_id) = self.editor.split_id.clone() { - if self.editor.editor_type == EditorType::Normal { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditorExchange(self.editor.view_id), - Target::Widget(split_id), - )); - } - } - } - LapceCommand::SplitVertical => { - if let Some(split_id) = self.editor.split_id.clone() { - if self.editor.editor_type == EditorType::Normal { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditor(true, self.editor.view_id), - Target::Widget(split_id), - )); - } - } - } - LapceCommand::SplitClose => { - if let Some(split_id) = self.editor.split_id.clone() { - if self.editor.editor_type == EditorType::Normal { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::SplitEditorClose(self.editor.view_id), - Target::Widget(split_id), - )); - } - } - } - LapceCommand::Undo => { - self.initiate_diagnositcs_offset(); - let proxy = self.proxy.clone(); - let buffer = self.buffer_mut(); - if let Some(delta) = buffer.do_undo(proxy) { - let (iv, _) = delta.summary(); - let line = self.buffer.line_of_offset(iv.start); - let offset = self.buffer.first_non_blank_character_on_line(line); - let selection = Selection::caret(offset); - self.set_cursor_after_change(selection); - self.update_diagnositcs_offset(&delta); - } - } - LapceCommand::Redo => { - self.initiate_diagnositcs_offset(); - let proxy = self.proxy.clone(); - let buffer = self.buffer_mut(); - if let Some(delta) = buffer.do_redo(proxy) { - let (iv, _) = delta.summary(); - let line = self.buffer.line_of_offset(iv.start); - let offset = self.buffer.first_non_blank_character_on_line(line); - let selection = Selection::caret(offset); - self.set_cursor_after_change(selection); - self.update_diagnositcs_offset(&delta); - } - } - LapceCommand::Append => { - let offset = self - .buffer - .move_offset( - self.editor.cursor.offset(), - None, - 1, - &Movement::Right, - Mode::Insert, - ) - .0; - self.buffer_mut().update_edit_type(); - self.set_cursor(Cursor::new( - CursorMode::Insert(Selection::caret(offset)), - None, - )); - } - LapceCommand::AppendEndOfLine => { - let (offset, horiz) = self.buffer.move_offset( - self.editor.cursor.offset(), - None, - 1, - &Movement::EndOfLine, - Mode::Insert, - ); - self.buffer_mut().update_edit_type(); - self.set_cursor(Cursor::new( - CursorMode::Insert(Selection::caret(offset)), - Some(horiz), - )); - } - LapceCommand::InsertMode => { - Arc::make_mut(&mut self.editor).cursor.mode = CursorMode::Insert( - Selection::caret(self.editor.cursor.offset()), - ); - self.buffer_mut().update_edit_type(); - } - LapceCommand::InsertFirstNonBlank => { - match &self.editor.cursor.mode { - CursorMode::Normal(offset) => { - let (offset, horiz) = self.buffer.move_offset( - *offset, - None, - 1, - &Movement::FirstNonBlank, - Mode::Normal, - ); - self.buffer_mut().update_edit_type(); - self.set_cursor(Cursor::new( - CursorMode::Insert(Selection::caret(offset)), - Some(horiz), - )); - } - CursorMode::Visual { start, end, mode } => { - let mut selection = Selection::new(); - for region in - self.editor.cursor.edit_selection(&self.buffer).regions() - { - selection.add_region(SelRegion::caret(region.min())); - } - self.buffer_mut().update_edit_type(); - self.set_cursor(Cursor::new( - CursorMode::Insert(selection), - None, - )); - } - CursorMode::Insert(_) => {} - }; - } - LapceCommand::NewLineAbove => { - let line = self.editor.cursor.current_line(&self.buffer); - let offset = if line > 0 { - self.buffer.line_end_offset(line - 1, true) - } else { - self.buffer.first_non_blank_character_on_line(line) - }; - self.insert_new_line(ctx, offset); - } - LapceCommand::NewLineBelow => { - let offset = self.editor.cursor.offset(); - let offset = self.buffer.offset_line_end(offset, true); - self.insert_new_line(ctx, offset); - } - LapceCommand::DeleteToBeginningOfLine => { - let selection = match self.editor.cursor.mode { - CursorMode::Normal(_) | CursorMode::Visual { .. } => { - self.editor.cursor.edit_selection(&self.buffer) - } - CursorMode::Insert(_) => { - let selection = - self.editor.cursor.edit_selection(&self.buffer); - let selection = self.buffer.update_selection( - &selection, - 1, - &Movement::StartOfLine, - Mode::Insert, - true, - ); - selection - } - }; - let (selection, _) = - self.edit(ctx, &selection, "", None, true, EditType::Delete); - match self.editor.cursor.mode { - CursorMode::Normal(_) | CursorMode::Visual { .. } => { - let offset = selection.min_offset(); - let offset = - self.buffer.offset_line_end(offset, false).min(offset); - self.set_cursor(Cursor::new( - CursorMode::Normal(offset), - None, - )); - } - CursorMode::Insert(_) => { - self.set_cursor(Cursor::new( - CursorMode::Insert(selection), - None, - )); - } - } - } - LapceCommand::Yank => { - let data = self.editor.cursor.yank(&self.buffer); - let register = Arc::make_mut(&mut self.main_split.register); - register.add_yank(data); - match &self.editor.cursor.mode { - CursorMode::Visual { start, end, mode } => { - let offset = *start.min(end); - let offset = - self.buffer.offset_line_end(offset, false).min(offset); - self.set_cursor(Cursor::new( - CursorMode::Normal(offset), - None, - )); - } - CursorMode::Normal(_) => {} - CursorMode::Insert(_) => {} - } - } - LapceCommand::ClipboardCopy => { - let data = self.editor.cursor.yank(&self.buffer); - Application::global().clipboard().put_string(data.content); - match &self.editor.cursor.mode { - CursorMode::Visual { start, end, mode } => { - let offset = *start.min(end); - let offset = - self.buffer.offset_line_end(offset, false).min(offset); - self.set_cursor(Cursor::new( - CursorMode::Normal(offset), - None, - )); - } - CursorMode::Normal(_) => {} - CursorMode::Insert(_) => {} - } - } - LapceCommand::ClipboardPaste => { - if let Some(s) = Application::global().clipboard().get_string() { - let data = RegisterData { - content: s.to_string(), - mode: VisualMode::Normal, - }; - self.paste(ctx, &data); - } - } - LapceCommand::Paste => { - let data = self.main_split.register.unamed.clone(); - self.paste(ctx, &data); - } - LapceCommand::DeleteWordBackward => { - let selection = match self.editor.cursor.mode { - CursorMode::Normal(_) | CursorMode::Visual { .. } => { - self.editor.cursor.edit_selection(&self.buffer) - } - CursorMode::Insert(_) => { - let selection = - self.editor.cursor.edit_selection(&self.buffer); - let selection = self.buffer.update_selection( - &selection, - 1, - &Movement::WordBackward, - Mode::Insert, - true, - ); - selection - } - }; - let (selection, _) = - self.edit(ctx, &selection, "", None, true, EditType::Delete); - self.set_cursor_after_change(selection); - self.update_completion(ctx); - } - LapceCommand::DeleteBackward => { - let selection = match self.editor.cursor.mode { - CursorMode::Normal(_) | CursorMode::Visual { .. } => { - self.editor.cursor.edit_selection(&self.buffer) - } - CursorMode::Insert(_) => { - let selection = - self.editor.cursor.edit_selection(&self.buffer); - let mut selection = self.buffer.update_selection( - &selection, - 1, - &Movement::Left, - Mode::Insert, - true, - ); - if selection.regions().len() == 1 { - let delete_str = self - .buffer - .slice_to_cow( - selection.min_offset()..selection.max_offset(), - ) - .to_string(); - if str_is_pair_left(&delete_str) { - if let Some(c) = str_matching_pair(&delete_str) { - let offset = selection.max_offset(); - let line = self.buffer.line_of_offset(offset); - let line_end = - self.buffer.line_end_offset(line, true); - let content = self - .buffer - .slice_to_cow(offset..line_end) - .to_string(); - if content.trim().starts_with(&c.to_string()) { - let index = content - .match_indices(c) - .next() - .unwrap() - .0; - selection = Selection::region( - selection.min_offset(), - offset + index + 1, - ); - } - } - } - } - selection - } - }; - let (selection, _) = - self.edit(ctx, &selection, "", None, true, EditType::Delete); - self.set_cursor_after_change(selection); - self.update_completion(ctx); - } - LapceCommand::DeleteForeward => { - let selection = self.editor.cursor.edit_selection(&self.buffer); - let (selection, _) = - self.edit(ctx, &selection, "", None, true, EditType::Delete); - self.set_cursor_after_change(selection); - self.update_completion(ctx); - } - LapceCommand::DeleteForewardAndInsert => { - let selection = self.editor.cursor.edit_selection(&self.buffer); - let (selection, _) = - self.edit(ctx, &selection, "", None, true, EditType::Delete); - self.set_cursor(Cursor::new(CursorMode::Insert(selection), None)); - self.update_completion(ctx); - } - LapceCommand::InsertNewLine => { - let selection = self.editor.cursor.edit_selection(&self.buffer); - if selection.regions().len() > 1 { - let (selection, _) = self.edit( - ctx, - &selection, - "\n", - None, - true, - EditType::InsertNewline, - ); - self.set_cursor(Cursor::new( - CursorMode::Insert(selection), - None, - )); - return; - }; - self.insert_new_line(ctx, self.editor.cursor.offset()); - self.update_completion(ctx); - } - LapceCommand::ToggleVisualMode => { - self.toggle_visual(VisualMode::Normal); - } - LapceCommand::ToggleLinewiseVisualMode => { - self.toggle_visual(VisualMode::Linewise); - } - LapceCommand::ToggleBlockwiseVisualMode => { - self.toggle_visual(VisualMode::Blockwise); - } - LapceCommand::CenterOfWindow => { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::EnsureCursorCenter, - Target::Widget(self.editor.view_id), - )); - } - LapceCommand::ScrollDown => { - self.scroll(ctx, true, count.unwrap_or(1), env); - } - LapceCommand::ScrollUp => { - self.scroll(ctx, false, count.unwrap_or(1), env); - } - LapceCommand::PageDown => { - self.page_move(ctx, true, env); - } - LapceCommand::PageUp => { - self.page_move(ctx, false, env); - } - LapceCommand::JumpLocationBackward => { - self.jump_location_backward(ctx, env); - } - LapceCommand::JumpLocationForward => { - self.jump_location_forward(ctx, env); - } - LapceCommand::NextError => { - self.next_error(ctx, env); - } - LapceCommand::PreviousError => {} - LapceCommand::ListNext => { - let completion = Arc::make_mut(&mut self.completion); - completion.next(); - } - LapceCommand::ListPrevious => { - let completion = Arc::make_mut(&mut self.completion); - completion.previous(); - } - LapceCommand::JumpToNextSnippetPlaceholder => { - if let Some(snippet) = self.editor.snippet.as_ref() { - let mut current = 0; - let offset = self.editor.cursor.offset(); - for (i, (_, (start, end))) in snippet.iter().enumerate() { - if *start <= offset && offset <= *end { - current = i; - break; - } - } +// let last_placeholder = current + 1 >= snippet.len() - 1; - let last_placeholder = current + 1 >= snippet.len() - 1; +// if let Some((_, (start, end))) = snippet.get(current + 1) { +// let mut selection = Selection::new(); +// let region = SelRegion::new(*start, *end, None); +// selection.add_region(region); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(selection), +// None, +// )); +// } - if let Some((_, (start, end))) = snippet.get(current + 1) { - let mut selection = Selection::new(); - let region = SelRegion::new(*start, *end, None); - selection.add_region(region); - self.set_cursor(Cursor::new( - CursorMode::Insert(selection), - None, - )); - } +// if last_placeholder { +// Arc::make_mut(&mut self.editor).snippet = None; +// } +// self.cancel_completion(); +// } +// } +// LapceCommand::JumpToPrevSnippetPlaceholder => { +// if let Some(snippet) = self.editor.snippet.as_ref() { +// let mut current = 0; +// let offset = self.editor.cursor.offset(); +// for (i, (_, (start, end))) in snippet.iter().enumerate() { +// if *start <= offset && offset <= *end { +// current = i; +// break; +// } +// } - if last_placeholder { - Arc::make_mut(&mut self.editor).snippet = None; - } - self.cancel_completion(); - } - } - LapceCommand::JumpToPrevSnippetPlaceholder => { - if let Some(snippet) = self.editor.snippet.as_ref() { - let mut current = 0; - let offset = self.editor.cursor.offset(); - for (i, (_, (start, end))) in snippet.iter().enumerate() { - if *start <= offset && offset <= *end { - current = i; - break; - } - } +// if current > 0 { +// if let Some((_, (start, end))) = snippet.get(current - 1) { +// let mut selection = Selection::new(); +// let region = SelRegion::new(*start, *end, None); +// selection.add_region(region); +// self.set_cursor(Cursor::new( +// CursorMode::Insert(selection), +// None, +// )); +// } +// self.cancel_completion(); +// } +// } +// } +// LapceCommand::ListSelect => { +// let selection = self.editor.cursor.edit_selection(&self.buffer); - if current > 0 { - if let Some((_, (start, end))) = snippet.get(current - 1) { - let mut selection = Selection::new(); - let region = SelRegion::new(*start, *end, None); - selection.add_region(region); - self.set_cursor(Cursor::new( - CursorMode::Insert(selection), - None, - )); - } - self.cancel_completion(); - } - } - } - LapceCommand::ListSelect => { - let selection = self.editor.cursor.edit_selection(&self.buffer); +// let count = self.completion.input.len(); +// let selection = if count > 0 { +// self.buffer.update_selection( +// &selection, +// count, +// &Movement::Left, +// Mode::Insert, +// true, +// ) +// } else { +// selection +// }; - let count = self.completion.input.len(); - let selection = if count > 0 { - self.buffer.update_selection( - &selection, - count, - &Movement::Left, - Mode::Insert, - true, - ) - } else { - selection - }; +// let item = self.completion.current_item().to_owned(); +// self.cancel_completion(); +// if item.data.is_some() { +// let view_id = self.editor.view_id; +// let buffer_id = self.buffer.id; +// let rev = self.buffer.rev; +// let offset = self.editor.cursor.offset(); +// let event_sink = ctx.get_external_handle(); +// self.proxy.completion_resolve( +// buffer_id, +// item.clone(), +// Box::new(move |result| { +// println!("completion resolve result {:?}", result); +// let mut item = item.clone(); +// if let Ok(res) = result { +// if let Ok(i) = +// serde_json::from_value::(res) +// { +// item = i; +// } +// }; +// event_sink.submit_command( +// LAPCE_UI_COMMAND, +// LapceUICommand::ResolveCompletion( +// buffer_id, rev, offset, item, +// ), +// Target::Widget(view_id), +// ); +// }), +// ); +// } else { +// self.apply_completion_item(ctx, &item); +// } +// } +// LapceCommand::NormalMode => { +// if !self.config.lapce.modal { +// return; +// } - let item = self.completion.current_item().to_owned(); - self.cancel_completion(); - if item.data.is_some() { - let view_id = self.editor.view_id; - let buffer_id = self.buffer.id; - let rev = self.buffer.rev; - let offset = self.editor.cursor.offset(); - let event_sink = ctx.get_external_handle(); - self.proxy.completion_resolve( - buffer_id, - item.clone(), - Box::new(move |result| { - println!("completion resolve result {:?}", result); - let mut item = item.clone(); - if let Ok(res) = result { - if let Ok(i) = - serde_json::from_value::(res) - { - item = i; - } - }; - event_sink.submit_command( - LAPCE_UI_COMMAND, - LapceUICommand::ResolveCompletion( - buffer_id, rev, offset, item, - ), - Target::Widget(view_id), - ); - }), - ); - } else { - self.apply_completion_item(ctx, &item); - } - } - LapceCommand::NormalMode => { - if !self.config.lapce.modal { - return; - } +// let offset = match &self.editor.cursor.mode { +// CursorMode::Insert(selection) => { +// self.buffer +// .move_offset( +// selection.get_cursor_offset(), +// None, +// 1, +// &Movement::Left, +// Mode::Normal, +// ) +// .0 +// } +// CursorMode::Visual { start, end, mode } => { +// self.buffer.offset_line_end(*end, false).min(*end) +// } +// CursorMode::Normal(offset) => *offset, +// }; +// self.buffer_mut().update_edit_type(); +// let mut cursor = &mut Arc::make_mut(&mut self.editor).cursor; +// cursor.mode = CursorMode::Normal(offset); +// cursor.horiz = None; +// Arc::make_mut(&mut self.editor).snippet = None; +// self.cancel_completion(); +// } +// LapceCommand::GotoDefinition => { +// let offset = self.editor.cursor.offset(); +// let start_offset = self.buffer.prev_code_boundary(offset); +// let start_position = self.buffer.offset_to_position(start_offset); +// let event_sink = ctx.get_external_handle(); +// let buffer_id = self.buffer.id; +// let position = self.buffer.offset_to_position(offset); +// let proxy = self.proxy.clone(); +// let editor_view_id = self.editor.view_id; +// self.proxy.get_definition( +// offset, +// buffer_id, +// position, +// Box::new(move |result| { +// if let Ok(res) = result { +// if let Ok(resp) = +// serde_json::from_value::(res) +// { +// if let Some(location) = match resp { +// GotoDefinitionResponse::Scalar(location) => { +// Some(location) +// } +// GotoDefinitionResponse::Array(locations) => { +// if locations.len() > 0 { +// Some(locations[0].clone()) +// } else { +// None +// } +// } +// GotoDefinitionResponse::Link(location_links) => { +// None +// } +// } { +// if location.range.start == start_position { +// proxy.get_references( +// buffer_id, +// position, +// Box::new(move |result| { +// process_get_references( +// editor_view_id, +// offset, +// result, +// event_sink, +// ); +// }), +// ); +// } else { +// event_sink.submit_command( +// LAPCE_UI_COMMAND, +// LapceUICommand::GotoDefinition( +// editor_view_id, +// offset, +// EditorLocationNew { +// path: PathBuf::from( +// location.uri.path(), +// ), +// position: Some( +// location.range.start, +// ), +// scroll_offset: None, +// }, +// ), +// Target::Auto, +// ); +// } +// } +// } +// } +// }), +// ); +// } +// LapceCommand::SourceControl => { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::FocusSourceControl, +// Target::Auto, +// )); +// } +// LapceCommand::SourceControlCancel => { +// if self.editor.editor_type == EditorType::SourceControl { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::FocusEditor, +// Target::Auto, +// )); +// println!("source control cancel"); +// } +// } +// LapceCommand::ShowCodeActions => { +// if let Some(actions) = self.current_code_actions() { +// if actions.len() > 0 { +// ctx.submit_command(Command::new( +// LAPCE_UI_COMMAND, +// LapceUICommand::ShowCodeActions, +// Target::Auto, +// )); +// } +// } +// } +// LapceCommand::SearchWholeWordForward => { +// let offset = self.editor.cursor.offset(); +// let (start, end) = self.buffer.select_word(offset); +// let word = self.buffer.slice_to_cow(start..end).to_string(); +// Arc::make_mut(&mut self.main_split.find) +// .set_find(&word, false, false, true); +// let next = self.main_split.find.next( +// &self.buffer.rope, +// offset, +// false, +// true, +// ); +// if let Some((start, end)) = next { +// self.do_move(&Movement::Offset(start), 1); +// } +// } +// LapceCommand::SearchForward => { +// let offset = self.editor.cursor.offset(); +// let next = self.main_split.find.next( +// &self.buffer.rope, +// offset, +// false, +// true, +// ); +// if let Some((start, end)) = next { +// self.do_move(&Movement::Offset(start), 1); +// } +// } +// LapceCommand::SearchBackward => { +// let offset = self.editor.cursor.offset(); +// let next = +// self.main_split +// .find +// .next(&self.buffer.rope, offset, true, true); +// if let Some((start, end)) = next { +// self.do_move(&Movement::Offset(start), 1); +// } +// } +// LapceCommand::JoinLines => { +// let offset = self.editor.cursor.offset(); +// let (line, col) = self.buffer.offset_to_line_col(offset); +// if line < self.buffer.last_line() { +// let start = self.buffer.line_end_offset(line, true); +// let end = +// self.buffer.first_non_blank_character_on_line(line + 1); +// self.edit( +// ctx, +// &Selection::region(start, end), +// " ", +// None, +// false, +// EditType::Other, +// ); +// } +// } +// LapceCommand::Save => { +// if !self.buffer.dirty { +// return; +// } - let offset = match &self.editor.cursor.mode { - CursorMode::Insert(selection) => { - self.buffer - .move_offset( - selection.get_cursor_offset(), - None, - 1, - &Movement::Left, - Mode::Normal, - ) - .0 - } - CursorMode::Visual { start, end, mode } => { - self.buffer.offset_line_end(*end, false).min(*end) - } - CursorMode::Normal(offset) => *offset, - }; - self.buffer_mut().update_edit_type(); - let mut cursor = &mut Arc::make_mut(&mut self.editor).cursor; - cursor.mode = CursorMode::Normal(offset); - cursor.horiz = None; - Arc::make_mut(&mut self.editor).snippet = None; - self.cancel_completion(); - } - LapceCommand::GotoDefinition => { - let offset = self.editor.cursor.offset(); - let start_offset = self.buffer.prev_code_boundary(offset); - let start_position = self.buffer.offset_to_position(start_offset); - let event_sink = ctx.get_external_handle(); - let buffer_id = self.buffer.id; - let position = self.buffer.offset_to_position(offset); - let proxy = self.proxy.clone(); - let editor_view_id = self.editor.view_id; - self.proxy.get_definition( - offset, - buffer_id, - position, - Box::new(move |result| { - if let Ok(res) = result { - if let Ok(resp) = - serde_json::from_value::(res) - { - if let Some(location) = match resp { - GotoDefinitionResponse::Scalar(location) => { - Some(location) - } - GotoDefinitionResponse::Array(locations) => { - if locations.len() > 0 { - Some(locations[0].clone()) - } else { - None - } - } - GotoDefinitionResponse::Link(location_links) => { - None - } - } { - if location.range.start == start_position { - proxy.get_references( - buffer_id, - position, - Box::new(move |result| { - process_get_references( - editor_view_id, - offset, - result, - event_sink, - ); - }), - ); - } else { - event_sink.submit_command( - LAPCE_UI_COMMAND, - LapceUICommand::GotoDefinition( - editor_view_id, - offset, - EditorLocationNew { - path: PathBuf::from( - location.uri.path(), - ), - position: Some( - location.range.start, - ), - scroll_offset: None, - }, - ), - Target::Auto, - ); - } - } - } - } - }), - ); - } - LapceCommand::SourceControl => { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::FocusSourceControl, - Target::Auto, - )); - } - LapceCommand::SourceControlCancel => { - if self.editor.editor_type == EditorType::SourceControl { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::FocusEditor, - Target::Auto, - )); - println!("source control cancel"); - } - } - LapceCommand::ShowCodeActions => { - if let Some(actions) = self.current_code_actions() { - if actions.len() > 0 { - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::ShowCodeActions, - Target::Auto, - )); - } - } - } - LapceCommand::SearchWholeWordForward => { - let offset = self.editor.cursor.offset(); - let (start, end) = self.buffer.select_word(offset); - let word = self.buffer.slice_to_cow(start..end).to_string(); - Arc::make_mut(&mut self.main_split.find) - .set_find(&word, false, false, true); - let next = self.main_split.find.next( - &self.buffer.rope, - offset, - false, - true, - ); - if let Some((start, end)) = next { - self.do_move(&Movement::Offset(start), 1); - } - } - LapceCommand::SearchForward => { - let offset = self.editor.cursor.offset(); - let next = self.main_split.find.next( - &self.buffer.rope, - offset, - false, - true, - ); - if let Some((start, end)) = next { - self.do_move(&Movement::Offset(start), 1); - } - } - LapceCommand::SearchBackward => { - let offset = self.editor.cursor.offset(); - let next = - self.main_split - .find - .next(&self.buffer.rope, offset, true, true); - if let Some((start, end)) = next { - self.do_move(&Movement::Offset(start), 1); - } - } - LapceCommand::JoinLines => { - let offset = self.editor.cursor.offset(); - let (line, col) = self.buffer.offset_to_line_col(offset); - if line < self.buffer.last_line() { - let start = self.buffer.line_end_offset(line, true); - let end = - self.buffer.first_non_blank_character_on_line(line + 1); - self.edit( - ctx, - &Selection::region(start, end), - " ", - None, - false, - EditType::Other, - ); - } - } - LapceCommand::Save => { - if !self.buffer.dirty { - return; - } +// let proxy = self.proxy.clone(); +// let buffer_id = self.buffer.id; +// let rev = self.buffer.rev; +// let path = self.buffer.path.clone(); +// let event_sink = ctx.get_external_handle(); +// let (sender, receiver) = bounded(1); +// thread::spawn(move || { +// proxy.get_document_formatting( +// buffer_id, +// Box::new(move |result| { +// sender.send(result); +// }), +// ); - let proxy = self.proxy.clone(); - let buffer_id = self.buffer.id; - let rev = self.buffer.rev; - let path = self.buffer.path.clone(); - let event_sink = ctx.get_external_handle(); - let (sender, receiver) = bounded(1); - thread::spawn(move || { - proxy.get_document_formatting( - buffer_id, - Box::new(move |result| { - sender.send(result); - }), - ); +// let result = +// receiver.recv_timeout(Duration::from_secs(1)).map_or_else( +// |e| Err(anyhow!("{}", e)), +// |v| v.map_err(|e| anyhow!("{:?}", e)), +// ); +// event_sink.submit_command( +// LAPCE_UI_COMMAND, +// LapceUICommand::DocumentFormatAndSave(path, rev, result), +// Target::Auto, +// ); +// }); +// } +// _ => { +// ctx.submit_command(Command::new( +// LAPCE_COMMAND, +// cmd.clone(), +// Target::Auto, +// )); +// } +// } +// } - let result = - receiver.recv_timeout(Duration::from_secs(1)).map_or_else( - |e| Err(anyhow!("{}", e)), - |v| v.map_err(|e| anyhow!("{:?}", e)), - ); - event_sink.submit_command( - LAPCE_UI_COMMAND, - LapceUICommand::DocumentFormatAndSave(path, rev, result), - Target::Auto, - ); - }); - } - _ => { - ctx.submit_command(Command::new( - LAPCE_COMMAND, - cmd.clone(), - Target::Auto, - )); - } - } - } - - fn insert(&mut self, ctx: &mut EventCtx, c: &str) { - if self.get_mode() == Mode::Insert { - let mut selection = self.editor.cursor.edit_selection(&self.buffer); - let cursor_char = - self.buffer.char_at_offset(selection.get_cursor_offset()); - - let mut content = c.to_string(); - if c.chars().count() == 1 { - let c = c.chars().next().unwrap(); - if !matching_pair_direction(c).unwrap_or(true) { - if cursor_char == Some(c) { - self.do_move(&Movement::Right, 1); - return; - } else { - let offset = selection.get_cursor_offset(); - let line = self.buffer.line_of_offset(offset); - let line_start = self.buffer.offset_of_line(line); - if self.buffer.slice_to_cow(line_start..offset).trim() == "" - { - if let Some(c) = matching_char(c) { - if let Some(previous_offset) = - self.buffer.previous_unmatched(c, offset) - { - let previous_line = - self.buffer.line_of_offset(previous_offset); - let line_indent = - self.buffer.indent_on_line(previous_line); - content = line_indent + &content; - selection = - Selection::region(line_start, offset); - } - } - }; - } - } - } - - let (selection, _) = self.edit( - ctx, - &selection, - &content, - None, - true, - EditType::InsertChars, - ); - let editor = Arc::make_mut(&mut self.editor); - editor.cursor.mode = CursorMode::Insert(selection.clone()); - editor.cursor.horiz = None; - if c.chars().count() == 1 { - let c = c.chars().next().unwrap(); - if matching_pair_direction(c).unwrap_or(false) { - if cursor_char - .map(|c| { - let prop = get_word_property(c); - prop == WordProperty::Lf - || prop == WordProperty::Space - || prop == WordProperty::Punctuation - }) - .unwrap_or(true) - { - if let Some(c) = matching_char(c) { - self.edit( - ctx, - &selection, - &c.to_string(), - None, - false, - EditType::InsertChars, - ); - } - } - } - } - self.update_completion(ctx); - } - } -} +// fn insert(&mut self, ctx: &mut EventCtx, c: &str) { +// if self.get_mode() == Mode::Insert { +// let mut selection = self.editor.cursor.edit_selection(&self.buffer); +// let cursor_char = +// self.buffer.char_at_offset(selection.get_cursor_offset()); +// +// let mut content = c.to_string(); +// if c.chars().count() == 1 { +// let c = c.chars().next().unwrap(); +// if !matching_pair_direction(c).unwrap_or(true) { +// if cursor_char == Some(c) { +// self.do_move(&Movement::Right, 1); +// return; +// } else { +// let offset = selection.get_cursor_offset(); +// let line = self.buffer.line_of_offset(offset); +// let line_start = self.buffer.offset_of_line(line); +// if self.buffer.slice_to_cow(line_start..offset).trim() == "" +// { +// if let Some(c) = matching_char(c) { +// if let Some(previous_offset) = +// self.buffer.previous_unmatched(c, offset) +// { +// let previous_line = +// self.buffer.line_of_offset(previous_offset); +// let line_indent = +// self.buffer.indent_on_line(previous_line); +// content = line_indent + &content; +// selection = +// Selection::region(line_start, offset); +// } +// } +// }; +// } +// } +// } +// +// let (selection, _) = self.edit( +// ctx, +// &selection, +// &content, +// None, +// true, +// EditType::InsertChars, +// ); +// let editor = Arc::make_mut(&mut self.editor); +// editor.cursor.mode = CursorMode::Insert(selection.clone()); +// editor.cursor.horiz = None; +// if c.chars().count() == 1 { +// let c = c.chars().next().unwrap(); +// if matching_pair_direction(c).unwrap_or(false) { +// if cursor_char +// .map(|c| { +// let prop = get_word_property(c); +// prop == WordProperty::Lf +// || prop == WordProperty::Space +// || prop == WordProperty::Punctuation +// }) +// .unwrap_or(true) +// { +// if let Some(c) = matching_char(c) { +// self.edit( +// ctx, +// &selection, +// &c.to_string(), +// None, +// false, +// EditType::InsertChars, +// ); +// } +// } +// } +// } +// self.update_completion(ctx); +// } +// } +// } fn next_in_file_errors_offset( position: Position, diff --git a/core/src/editor.rs b/core/src/editor.rs index a9b5cd8a..049cf5dd 100644 --- a/core/src/editor.rs +++ b/core/src/editor.rs @@ -9,7 +9,7 @@ LapceMainSplitData, LapceTabData, RegisterData, }; use crate::find::Find; -use crate::keypress::{KeyMap, KeyPressFocus}; +use crate::keypress::{KeyMap, KeyPress, KeyPressFocus}; use crate::proxy::LapceProxy; use crate::scroll::LapceIdentityWrapper; use crate::signature::SignatureState; @@ -4027,11 +4027,11 @@ fn layout( for keymap in keymaps { if keymap.command == cmd.cmd { let mut keymap_str = "".to_string(); - for (mods, key) in &keymap.key { + for keypress in &keymap.key { if keymap_str != "" { keymap_str += " " } - keymap_str += &keybinding_to_string(mods, key); + keymap_str += &keybinding_to_string(keypress); } key = Some(keymap_str); break; @@ -4340,18 +4340,15 @@ fn empty_editor_commands(modal: bool, has_workspace: bool) -> Vec String { +fn keybinding_to_string(keypress: &KeyPress) -> String { let mut keymap_str = "".to_string(); - if mods.ctrl() { + if keypress.mods.ctrl() { keymap_str += "Ctrl+"; } - if mods.alt() { + if keypress.mods.alt() { keymap_str += "Alt+"; } - if mods.meta() { + if keypress.mods.meta() { let keyname = match std::env::consts::OS { "macos" => "Cmd", "windows" => "Win", @@ -4360,9 +4357,9 @@ fn keybinding_to_string( keymap_str += &keyname; keymap_str += "+"; } - if mods.shift() { + if keypress.mods.shift() { keymap_str += "Shift+"; } - keymap_str += &code.to_string(); + keymap_str += &keypress.key.to_string(); keymap_str } diff --git a/core/src/keypress.rs b/core/src/keypress.rs index 48df2d8d..9dc14a7a 100644 --- a/core/src/keypress.rs +++ b/core/src/keypress.rs @@ -36,16 +36,15 @@ enum KeymapMatch { None, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct KeyPress { - pub code: druid::keyboard_types::Code, pub key: druid::keyboard_types::Key, pub mods: Modifiers, } #[derive(PartialEq, Eq, Hash, Clone, Debug)] pub struct KeyMap { - pub key: Vec<(Modifiers, druid::keyboard_types::Code)>, + pub key: Vec, pub modes: Vec, pub when: Option, pub command: String, @@ -67,8 +66,7 @@ fn run_command( #[derive(Clone, Debug)] pub struct KeyPressData { pending_keypress: Vec, - pub keymaps: - Arc, Vec>>, + pub keymaps: Arc, Vec>>, pub commands: Arc>, count: Option, } @@ -139,25 +137,24 @@ pub fn key_down( focus: &mut T, env: &Env, ) -> bool { - let code = match key_event.code { - druid::keyboard_types::Code::AltRight => { - druid::keyboard_types::Code::AltLeft + if key_event.key == druid::keyboard_types::Key::Shift { + let mut mods = key_event.mods.clone(); + mods.set(Modifiers::SHIFT, false); + if mods.is_empty() { + return false; } - druid::keyboard_types::Code::ShiftRight => { - druid::keyboard_types::Code::ShiftLeft + } + let mut mods = key_event.mods.clone(); + match &key_event.key { + druid::keyboard_types::Key::Character(c) => { + mods.set(Modifiers::SHIFT, false); } - druid::keyboard_types::Code::MetaRight => { - druid::keyboard_types::Code::MetaLeft - } - druid::keyboard_types::Code::ControlRight => { - druid::keyboard_types::Code::ControlLeft - } - _ => key_event.code, - }; + _ => (), + } + let keypress = KeyPress { - code, key: key_event.key.clone(), - mods: key_event.mods.clone(), + mods, }; let mode = focus.get_mode(); @@ -165,12 +162,8 @@ pub fn key_down( return false; } - let mut keypresses: Vec<(Modifiers, druid::keyboard_types::Code)> = self - .pending_keypress - .iter() - .map(|k| (k.mods.clone(), k.code.clone())) - .collect(); - keypresses.push((keypress.mods.clone(), keypress.code.clone())); + let mut keypresses: Vec = self.pending_keypress.clone(); + keypresses.push(keypress.clone()); let matches = self.match_keymap(&keypresses, focus); let keymatch = if matches.len() == 0 { @@ -233,7 +226,7 @@ pub fn key_down( fn match_keymap( &self, - keypresses: &Vec<(Modifiers, druid::keyboard_types::Code)>, + keypresses: &Vec, check: &T, ) -> Vec<&KeyMap> { self.keymaps @@ -316,20 +309,14 @@ fn check_condition(&self, condition: &str, check: &T) -> bool } } - fn keymaps_from_str( - s: &str, - ) -> Result, Vec>> - { + fn keymaps_from_str(s: &str) -> Result, Vec>> { let toml_keymaps: toml::Value = toml::from_str(s)?; let toml_keymaps = toml_keymaps .get("keymaps") .and_then(|v| v.as_array()) .ok_or(anyhow!("no keymaps"))?; - let mut keymaps: IndexMap< - Vec<(Modifiers, druid::keyboard_types::Code)>, - Vec, - > = IndexMap::new(); + let mut keymaps: IndexMap, Vec> = IndexMap::new(); for toml_keymap in toml_keymaps { if let Ok(keymap) = Self::get_keymap(toml_keymap) { for i in 1..keymap.key.len() + 1 { @@ -347,9 +334,7 @@ fn keymaps_from_str( Ok(keymaps) } - fn get_keymaps( - ) -> Result, Vec>> - { + fn get_keymaps() -> Result, Vec>> { let mut keymaps_str = if std::env::consts::OS == "macos" { default_keymaps_macos } else if std::env::consts::OS == "linux" { @@ -375,7 +360,7 @@ fn get_keymaps( Self::keymaps_from_str(&keymaps_str) } - fn get_keypress(key: &str) -> Vec<(Modifiers, druid::keyboard_types::Code)> { + fn get_keypress(key: &str) -> Vec { let mut keypresses = Vec::new(); for k in key.split(" ") { let mut mods = Modifiers::default(); @@ -384,88 +369,26 @@ fn get_keypress(key: &str) -> Vec<(Modifiers, druid::keyboard_types::Code)> { if parts.len() == 0 { continue; } - let code = match parts[parts.len() - 1].to_lowercase().as_ref() { - "escape" => druid::keyboard_types::Code::Escape, - "esc" => druid::keyboard_types::Code::Escape, - "backspace" => druid::keyboard_types::Code::Backspace, - "bs" => druid::keyboard_types::Code::Backspace, - "arrowup" => druid::keyboard_types::Code::ArrowUp, - "arrowdown" => druid::keyboard_types::Code::ArrowDown, - "arrowright" => druid::keyboard_types::Code::ArrowRight, - "arrowleft" => druid::keyboard_types::Code::ArrowLeft, - "up" => druid::keyboard_types::Code::ArrowUp, - "down" => druid::keyboard_types::Code::ArrowDown, - "right" => druid::keyboard_types::Code::ArrowRight, - "left" => druid::keyboard_types::Code::ArrowLeft, - "tab" => druid::keyboard_types::Code::Tab, - "enter" => druid::keyboard_types::Code::Enter, - "delete" => druid::keyboard_types::Code::Delete, - "del" => druid::keyboard_types::Code::Delete, - "ctrl" => druid::keyboard_types::Code::ControlLeft, - "meta" => druid::keyboard_types::Code::MetaLeft, - "shift" => druid::keyboard_types::Code::ShiftLeft, - "alt" => druid::keyboard_types::Code::AltLeft, - "f1" => druid::keyboard_types::Code::F1, - "f2" => druid::keyboard_types::Code::F2, - "f3" => druid::keyboard_types::Code::F3, - "f4" => druid::keyboard_types::Code::F4, - "f5" => druid::keyboard_types::Code::F5, - "f6" => druid::keyboard_types::Code::F6, - "f7" => druid::keyboard_types::Code::F7, - "f8" => druid::keyboard_types::Code::F8, - "f9" => druid::keyboard_types::Code::F9, - "f10" => druid::keyboard_types::Code::F10, - "f11" => druid::keyboard_types::Code::F11, - "f12" => druid::keyboard_types::Code::F12, - "a" => druid::keyboard_types::Code::KeyA, - "b" => druid::keyboard_types::Code::KeyB, - "c" => druid::keyboard_types::Code::KeyC, - "d" => druid::keyboard_types::Code::KeyD, - "e" => druid::keyboard_types::Code::KeyE, - "f" => druid::keyboard_types::Code::KeyF, - "g" => druid::keyboard_types::Code::KeyG, - "h" => druid::keyboard_types::Code::KeyH, - "i" => druid::keyboard_types::Code::KeyI, - "j" => druid::keyboard_types::Code::KeyJ, - "k" => druid::keyboard_types::Code::KeyK, - "l" => druid::keyboard_types::Code::KeyL, - "m" => druid::keyboard_types::Code::KeyM, - "n" => druid::keyboard_types::Code::KeyN, - "o" => druid::keyboard_types::Code::KeyO, - "p" => druid::keyboard_types::Code::KeyP, - "q" => druid::keyboard_types::Code::KeyQ, - "r" => druid::keyboard_types::Code::KeyR, - "s" => druid::keyboard_types::Code::KeyS, - "t" => druid::keyboard_types::Code::KeyT, - "u" => druid::keyboard_types::Code::KeyU, - "v" => druid::keyboard_types::Code::KeyV, - "w" => druid::keyboard_types::Code::KeyW, - "x" => druid::keyboard_types::Code::KeyX, - "y" => druid::keyboard_types::Code::KeyY, - "z" => druid::keyboard_types::Code::KeyZ, - "1" => druid::keyboard_types::Code::Digit1, - "2" => druid::keyboard_types::Code::Digit2, - "3" => druid::keyboard_types::Code::Digit3, - "4" => druid::keyboard_types::Code::Digit4, - "5" => druid::keyboard_types::Code::Digit5, - "6" => druid::keyboard_types::Code::Digit6, - "7" => druid::keyboard_types::Code::Digit7, - "8" => druid::keyboard_types::Code::Digit8, - "9" => druid::keyboard_types::Code::Digit9, - "0" => druid::keyboard_types::Code::Digit0, - "=" => druid::keyboard_types::Code::Equal, - "-" => druid::keyboard_types::Code::Minus, - "]" => druid::keyboard_types::Code::BracketRight, - "[" => druid::keyboard_types::Code::BracketLeft, - "'" => druid::keyboard_types::Code::Quote, - ";" => druid::keyboard_types::Code::Semicolon, - "\\" => druid::keyboard_types::Code::Backslash, - "," => druid::keyboard_types::Code::Comma, - "/" => druid::keyboard_types::Code::Slash, - "." => druid::keyboard_types::Code::Period, - "`" => druid::keyboard_types::Code::Backquote, - - _ => druid::keyboard_types::Code::Unidentified, + let key = match parts[parts.len() - 1].to_lowercase().as_str() { + "escape" => druid::keyboard_types::Key::Escape, + "esc" => druid::keyboard_types::Key::Escape, + "backspace" => druid::keyboard_types::Key::Backspace, + "bs" => druid::keyboard_types::Key::Backspace, + "arrowup" => druid::keyboard_types::Key::ArrowUp, + "arrowdown" => druid::keyboard_types::Key::ArrowDown, + "arrowright" => druid::keyboard_types::Key::ArrowRight, + "arrowleft" => druid::keyboard_types::Key::ArrowLeft, + "up" => druid::keyboard_types::Key::ArrowUp, + "down" => druid::keyboard_types::Key::ArrowDown, + "right" => druid::keyboard_types::Key::ArrowRight, + "left" => druid::keyboard_types::Key::ArrowLeft, + "tab" => druid::keyboard_types::Key::Tab, + "enter" => druid::keyboard_types::Key::Enter, + "delete" => druid::keyboard_types::Key::Delete, + "del" => druid::keyboard_types::Key::Delete, + _ => druid::keyboard_types::Key::Character( + parts[parts.len() - 1].to_string(), + ), }; for part in &parts[..parts.len() - 1] { match part.to_lowercase().as_ref() { @@ -477,41 +400,8 @@ fn get_keypress(key: &str) -> Vec<(Modifiers, druid::keyboard_types::Code)> { } } - keypresses.push((mods, code)); - // for (i, part) in - // k.split("+").collect::>().iter().rev().enumerate() - // { - // if i == 0 { - // keypress.key = match part.to_lowercase().as_ref() { - // "escape" => druid::keyboard_types::Key::Escape, - // "esc" => druid::keyboard_types::Key::Escape, - // "backspace" => druid::keyboard_types::Key::Backspace, - // "bs" => druid::keyboard_types::Key::Backspace, - // "arrowup" => druid::keyboard_types::Key::ArrowUp, - // "arrowdown" => druid::keyboard_types::Key::ArrowDown, - // "arrowright" => druid::keyboard_types::Key::ArrowRight, - // "arrowleft" => druid::keyboard_types::Key::ArrowLeft, - // "up" => druid::keyboard_types::Key::ArrowUp, - // "down" => druid::keyboard_types::Key::ArrowDown, - // "right" => druid::keyboard_types::Key::ArrowRight, - // "left" => druid::keyboard_types::Key::ArrowLeft, - // "tab" => druid::keyboard_types::Key::Tab, - // "enter" => druid::keyboard_types::Key::Enter, - // "delete" => druid::keyboard_types::Key::Delete, - // "del" => druid::keyboard_types::Key::Delete, - // _ => druid::keyboard_types::Key::Character(part.to_string()), - // } - // } else { - // match part.to_lowercase().as_ref() { - // "ctrl" => keypress.mods.set(Modifiers::CONTROL, true), - // "meta" => keypress.mods.set(Modifiers::META, true), - // "shift" => keypress.mods.set(Modifiers::SHIFT, true), - // "alt" => keypress.mods.set(Modifiers::ALT, true), - // _ => (), - // } - // } - // } - // keypresses.push(keypress); + let keypress = KeyPress { mods, key }; + keypresses.push(keypress); } keypresses } diff --git a/defaults/keymaps-macos.toml b/defaults/keymaps-macos.toml index 17620652..95c1755c 100644 --- a/defaults/keymaps-macos.toml +++ b/defaults/keymaps-macos.toml @@ -5,7 +5,7 @@ key = "meta+p" command = "palette" [[keymaps]] -key = "shift+meta+p" +key = "meta+P" command = "palette.command" [[keymaps]] @@ -13,7 +13,7 @@ key = "F1" command = "palette.command" [[keymaps]] -key = "shift+;" +key = ":" command = "palette.command" mode = "n" @@ -213,7 +213,7 @@ mode = "i" when = "in_snippet" [[keymaps]] -key = "shift+g" +key = "G" command = "go_to_line_deault_last" mode = "nv" @@ -248,7 +248,7 @@ command = "append" mode = "n" [[keymaps]] -key = "shift+a" +key = "A" command = "append_end_of_line" mode = "n" @@ -318,7 +318,7 @@ command = "paste" mode = "nv" [[keymaps]] -key = "shift+j" +key = "J" command = "join_lines" mode = "n" @@ -338,7 +338,7 @@ command = "delete_foreward_and_insert" mode = "nv" [[keymaps]] -key = "shift+i" +key = "I" command = "insert_first_non_blank" mode = "nv" @@ -353,7 +353,7 @@ command = "line_start" mode = "nv" [[keymaps]] -key = "shift+4" +key = "$" command = "line_end" mode = "nv" @@ -373,7 +373,7 @@ command = "word_backward" mode = "nv" [[keymaps]] -key = "shift+o" +key = "O" command = "new_line_above" mode = "nv" @@ -418,7 +418,7 @@ command = "delete_line" mode = "n" [[keymaps]] -key = "shift+8" +key = "*" command = "search_whole_word_forward" mode = "nv" @@ -428,32 +428,32 @@ command = "search_forward" mode = "nv" [[keymaps]] -key = "shift+n" +key = "N" command = "search_backward" mode = "nv" [[keymaps]] -key = "shift+5" +key = "%" command = "match_pairs" mode = "nv" [[keymaps]] -key = "] shift+0" +key = "] )" command = "next_unmatched_right_bracket" mode = "nv" [[keymaps]] -key = "[ shift+9" +key = "[ (" command = "previous_unmatched_left_bracket" mode = "nv" [[keymaps]] -key = "] shift+]" +key = "] }" command = "next_unmatched_right_curly_bracket" mode = "nv" [[keymaps]] -key = "[ shift+[" +key = "[ {" command = "previous_unmatched_left_curly_bracket" mode = "nv" @@ -463,7 +463,7 @@ command = "toggle_visual_mode" mode = "nv" [[keymaps]] -key = "shift+v" +key = "V" command = "toggle_linewise_visual_mode" mode = "nv" diff --git a/defaults/keymaps-windows.toml b/defaults/keymaps-windows.toml index 54da93be..e2e58a9b 100644 --- a/defaults/keymaps-windows.toml +++ b/defaults/keymaps-windows.toml @@ -5,7 +5,7 @@ key = "ctrl+p" command = "palette" [[keymaps]] -key = "shift+ctrl+p" +key = "Ctrl+P" command = "palette.command" [[keymaps]] @@ -213,7 +213,7 @@ mode = "i" when = "in_snippet" [[keymaps]] -key = "shift+g" +key = "G" command = "go_to_line_deault_last" mode = "nv" @@ -248,7 +248,7 @@ command = "append" mode = "n" [[keymaps]] -key = "shift+a" +key = "A" command = "append_end_of_line" mode = "n" @@ -318,7 +318,7 @@ command = "paste" mode = "nv" [[keymaps]] -key = "shift+j" +key = "J" command = "join_lines" mode = "n" @@ -338,7 +338,7 @@ command = "delete_foreward_and_insert" mode = "nv" [[keymaps]] -key = "shift+i" +key = "I" command = "insert_first_non_blank" mode = "nv" @@ -353,7 +353,7 @@ command = "line_start" mode = "nv" [[keymaps]] -key = "shift+4" +key = "$" command = "line_end" mode = "nv" @@ -373,7 +373,7 @@ command = "word_backward" mode = "nv" [[keymaps]] -key = "shift+o" +key = "O" command = "new_line_above" mode = "nv" @@ -428,32 +428,32 @@ command = "search_forward" mode = "nv" [[keymaps]] -key = "shift+n" +key = "N" command = "search_backward" mode = "nv" [[keymaps]] -key = "shift+5" +key = "%" command = "match_pairs" mode = "nv" [[keymaps]] -key = "] shift+0" +key = "] )" command = "next_unmatched_right_bracket" mode = "nv" [[keymaps]] -key = "[ shift+9" +key = "[ (" command = "previous_unmatched_left_bracket" mode = "nv" [[keymaps]] -key = "] shift+]" +key = "] }" command = "next_unmatched_right_curly_bracket" mode = "nv" [[keymaps]] -key = "[ shift+[" +key = "[ {" command = "previous_unmatched_left_curly_bracket" mode = "nv" @@ -463,7 +463,7 @@ command = "toggle_visual_mode" mode = "nv" [[keymaps]] -key = "shift+v" +key = "V" command = "toggle_linewise_visual_mode" mode = "nv"