gpui: Store action documentation (#33809)
Closes #ISSUE Adds a new `documentation` method to actions, that is extracted from doc comments when using the `actions!` or derive macros. Additionally, this PR adds doc comments to as many action definitions in Zed as possible. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
parent
def8bab5a8
commit
6cd4dbdea1
96 changed files with 1467 additions and 78 deletions
|
@ -3,7 +3,15 @@ use gpui::{Context, Window, actions};
|
|||
|
||||
use crate::{Vim, state::Mode};
|
||||
|
||||
actions!(vim, [ChangeListOlder, ChangeListNewer]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Navigates to an older position in the change list.
|
||||
ChangeListOlder,
|
||||
/// Navigates to a newer position in the change list.
|
||||
ChangeListNewer
|
||||
]
|
||||
);
|
||||
|
||||
pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, |vim, _: &ChangeListOlder, window, cx| {
|
||||
|
|
|
@ -44,18 +44,21 @@ use crate::{
|
|||
visual::VisualDeleteLine,
|
||||
};
|
||||
|
||||
/// Goes to the specified line number in the editor.
|
||||
#[derive(Clone, Debug, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct GoToLine {
|
||||
range: CommandRange,
|
||||
}
|
||||
|
||||
/// Yanks (copies) text based on the specified range.
|
||||
#[derive(Clone, Debug, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct YankCommand {
|
||||
range: CommandRange,
|
||||
}
|
||||
|
||||
/// Executes a command with the specified range.
|
||||
#[derive(Clone, Debug, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct WithRange {
|
||||
|
@ -64,6 +67,7 @@ pub struct WithRange {
|
|||
action: WrappedAction,
|
||||
}
|
||||
|
||||
/// Executes a command with the specified count.
|
||||
#[derive(Clone, Debug, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct WithCount {
|
||||
|
@ -155,12 +159,14 @@ impl VimOption {
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets vim options and configuration values.
|
||||
#[derive(Clone, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct VimSet {
|
||||
options: Vec<VimOption>,
|
||||
}
|
||||
|
||||
/// Saves the current file with optional save intent.
|
||||
#[derive(Clone, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
struct VimSave {
|
||||
|
@ -168,6 +174,7 @@ struct VimSave {
|
|||
pub filename: String,
|
||||
}
|
||||
|
||||
/// Deletes the specified marks from the editor.
|
||||
#[derive(Clone, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
enum DeleteMarks {
|
||||
|
@ -177,8 +184,18 @@ enum DeleteMarks {
|
|||
|
||||
actions!(
|
||||
vim,
|
||||
[VisualCommand, CountCommand, ShellCommand, ArgumentRequired]
|
||||
[
|
||||
/// Executes a command in visual mode.
|
||||
VisualCommand,
|
||||
/// Executes a command with a count prefix.
|
||||
CountCommand,
|
||||
/// Executes a shell command.
|
||||
ShellCommand,
|
||||
/// Indicates that an argument is required for the command.
|
||||
ArgumentRequired
|
||||
]
|
||||
);
|
||||
/// Opens the specified file for editing.
|
||||
#[derive(Clone, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
struct VimEdit {
|
||||
|
@ -1282,6 +1299,7 @@ fn generate_positions(string: &str, query: &str) -> Vec<usize> {
|
|||
positions
|
||||
}
|
||||
|
||||
/// Applies a command to all lines matching a pattern.
|
||||
#[derive(Debug, PartialEq, Clone, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub(crate) struct OnMatchingLines {
|
||||
|
@ -1480,6 +1498,7 @@ impl OnMatchingLines {
|
|||
}
|
||||
}
|
||||
|
||||
/// Executes a shell command and returns the output.
|
||||
#[derive(Clone, Debug, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct ShellExec {
|
||||
|
|
|
@ -6,7 +6,13 @@ use text::SelectionGoal;
|
|||
|
||||
use crate::{Vim, motion::Motion, state::Mode};
|
||||
|
||||
actions!(vim, [HelixNormalAfter]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Switches to normal mode after the cursor (Helix-style).
|
||||
HelixNormalAfter
|
||||
]
|
||||
);
|
||||
|
||||
pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, Vim::helix_normal_after);
|
||||
|
|
|
@ -13,7 +13,17 @@ pub(crate) enum IndentDirection {
|
|||
Auto,
|
||||
}
|
||||
|
||||
actions!(vim, [Indent, Outdent, AutoIndent]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Increases indentation of selected lines.
|
||||
Indent,
|
||||
/// Decreases indentation of selected lines.
|
||||
Outdent,
|
||||
/// Automatically adjusts indentation based on syntax.
|
||||
AutoIndent
|
||||
]
|
||||
);
|
||||
|
||||
pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, |vim, _: &Indent, window, cx| {
|
||||
|
|
|
@ -5,7 +5,15 @@ use language::SelectionGoal;
|
|||
use settings::Settings;
|
||||
use vim_mode_setting::HelixModeSetting;
|
||||
|
||||
actions!(vim, [NormalBefore, TemporaryNormal]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Switches to normal mode with cursor positioned before the current character.
|
||||
NormalBefore,
|
||||
/// Temporarily switches to normal mode for one command.
|
||||
TemporaryNormal
|
||||
]
|
||||
);
|
||||
|
||||
pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, Vim::normal_before);
|
||||
|
|
|
@ -176,6 +176,7 @@ enum IndentType {
|
|||
Same,
|
||||
}
|
||||
|
||||
/// Moves to the start of the next word.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -184,6 +185,7 @@ struct NextWordStart {
|
|||
ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the end of the next word.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -192,6 +194,7 @@ struct NextWordEnd {
|
|||
ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the start of the previous word.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -200,6 +203,7 @@ struct PreviousWordStart {
|
|||
ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the end of the previous word.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -208,6 +212,7 @@ struct PreviousWordEnd {
|
|||
ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the start of the next subword.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -216,6 +221,7 @@ pub(crate) struct NextSubwordStart {
|
|||
pub(crate) ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the end of the next subword.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -224,6 +230,7 @@ pub(crate) struct NextSubwordEnd {
|
|||
pub(crate) ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the start of the previous subword.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -232,6 +239,7 @@ pub(crate) struct PreviousSubwordStart {
|
|||
pub(crate) ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves to the end of the previous subword.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -240,6 +248,7 @@ pub(crate) struct PreviousSubwordEnd {
|
|||
pub(crate) ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Moves cursor up by the specified number of lines.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -248,6 +257,7 @@ pub(crate) struct Up {
|
|||
pub(crate) display_lines: bool,
|
||||
}
|
||||
|
||||
/// Moves cursor down by the specified number of lines.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -256,6 +266,7 @@ pub(crate) struct Down {
|
|||
pub(crate) display_lines: bool,
|
||||
}
|
||||
|
||||
/// Moves to the first non-whitespace character on the current line.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -264,6 +275,7 @@ struct FirstNonWhitespace {
|
|||
display_lines: bool,
|
||||
}
|
||||
|
||||
/// Moves to the end of the current line.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -272,6 +284,7 @@ struct EndOfLine {
|
|||
display_lines: bool,
|
||||
}
|
||||
|
||||
/// Moves to the start of the current line.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -280,6 +293,7 @@ pub struct StartOfLine {
|
|||
pub(crate) display_lines: bool,
|
||||
}
|
||||
|
||||
/// Moves to the middle of the current line.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -288,6 +302,7 @@ struct MiddleOfLine {
|
|||
display_lines: bool,
|
||||
}
|
||||
|
||||
/// Finds the next unmatched bracket or delimiter.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -296,6 +311,7 @@ struct UnmatchedForward {
|
|||
char: char,
|
||||
}
|
||||
|
||||
/// Finds the previous unmatched bracket or delimiter.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -307,46 +323,85 @@ struct UnmatchedBackward {
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Moves cursor left one character.
|
||||
Left,
|
||||
/// Moves cursor left one character, wrapping to previous line.
|
||||
#[action(deprecated_aliases = ["vim::Backspace"])]
|
||||
WrappingLeft,
|
||||
/// Moves cursor right one character.
|
||||
Right,
|
||||
/// Moves cursor right one character, wrapping to next line.
|
||||
#[action(deprecated_aliases = ["vim::Space"])]
|
||||
WrappingRight,
|
||||
/// Selects the current line.
|
||||
CurrentLine,
|
||||
/// Moves to the start of the next sentence.
|
||||
SentenceForward,
|
||||
/// Moves to the start of the previous sentence.
|
||||
SentenceBackward,
|
||||
/// Moves to the start of the paragraph.
|
||||
StartOfParagraph,
|
||||
/// Moves to the end of the paragraph.
|
||||
EndOfParagraph,
|
||||
/// Moves to the start of the document.
|
||||
StartOfDocument,
|
||||
/// Moves to the end of the document.
|
||||
EndOfDocument,
|
||||
/// Moves to the matching bracket or delimiter.
|
||||
Matching,
|
||||
/// Goes to a percentage position in the file.
|
||||
GoToPercentage,
|
||||
/// Moves to the start of the next line.
|
||||
NextLineStart,
|
||||
/// Moves to the start of the previous line.
|
||||
PreviousLineStart,
|
||||
/// Moves to the start of a line downward.
|
||||
StartOfLineDownward,
|
||||
/// Moves to the end of a line downward.
|
||||
EndOfLineDownward,
|
||||
/// Goes to a specific column number.
|
||||
GoToColumn,
|
||||
/// Repeats the last character find.
|
||||
RepeatFind,
|
||||
/// Repeats the last character find in reverse.
|
||||
RepeatFindReversed,
|
||||
/// Moves to the top of the window.
|
||||
WindowTop,
|
||||
/// Moves to the middle of the window.
|
||||
WindowMiddle,
|
||||
/// Moves to the bottom of the window.
|
||||
WindowBottom,
|
||||
/// Moves to the start of the next section.
|
||||
NextSectionStart,
|
||||
/// Moves to the end of the next section.
|
||||
NextSectionEnd,
|
||||
/// Moves to the start of the previous section.
|
||||
PreviousSectionStart,
|
||||
/// Moves to the end of the previous section.
|
||||
PreviousSectionEnd,
|
||||
/// Moves to the start of the next method.
|
||||
NextMethodStart,
|
||||
/// Moves to the end of the next method.
|
||||
NextMethodEnd,
|
||||
/// Moves to the start of the previous method.
|
||||
PreviousMethodStart,
|
||||
/// Moves to the end of the previous method.
|
||||
PreviousMethodEnd,
|
||||
/// Moves to the next comment.
|
||||
NextComment,
|
||||
/// Moves to the previous comment.
|
||||
PreviousComment,
|
||||
/// Moves to the previous line with lesser indentation.
|
||||
PreviousLesserIndent,
|
||||
/// Moves to the previous line with greater indentation.
|
||||
PreviousGreaterIndent,
|
||||
/// Moves to the previous line with the same indentation.
|
||||
PreviousSameIndent,
|
||||
/// Moves to the next line with lesser indentation.
|
||||
NextLesserIndent,
|
||||
/// Moves to the next line with greater indentation.
|
||||
NextGreaterIndent,
|
||||
/// Moves to the next line with the same indentation.
|
||||
NextSameIndent,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -36,32 +36,59 @@ use multi_buffer::MultiBufferRow;
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Inserts text after the cursor.
|
||||
InsertAfter,
|
||||
/// Inserts text before the cursor.
|
||||
InsertBefore,
|
||||
/// Inserts at the first non-whitespace character.
|
||||
InsertFirstNonWhitespace,
|
||||
/// Inserts at the end of the line.
|
||||
InsertEndOfLine,
|
||||
/// Inserts a new line above the current line.
|
||||
InsertLineAbove,
|
||||
/// Inserts a new line below the current line.
|
||||
InsertLineBelow,
|
||||
/// Inserts an empty line above without entering insert mode.
|
||||
InsertEmptyLineAbove,
|
||||
/// Inserts an empty line below without entering insert mode.
|
||||
InsertEmptyLineBelow,
|
||||
/// Inserts at the previous insert position.
|
||||
InsertAtPrevious,
|
||||
/// Joins the current line with the next line.
|
||||
JoinLines,
|
||||
/// Joins lines without adding whitespace.
|
||||
JoinLinesNoWhitespace,
|
||||
/// Deletes character to the left.
|
||||
DeleteLeft,
|
||||
/// Deletes character to the right.
|
||||
DeleteRight,
|
||||
/// Deletes using Helix-style behavior.
|
||||
HelixDelete,
|
||||
/// Changes from cursor to end of line.
|
||||
ChangeToEndOfLine,
|
||||
/// Deletes from cursor to end of line.
|
||||
DeleteToEndOfLine,
|
||||
/// Yanks (copies) the selected text.
|
||||
Yank,
|
||||
/// Yanks the entire line.
|
||||
YankLine,
|
||||
/// Toggles the case of selected text.
|
||||
ChangeCase,
|
||||
/// Converts selected text to uppercase.
|
||||
ConvertToUpperCase,
|
||||
/// Converts selected text to lowercase.
|
||||
ConvertToLowerCase,
|
||||
/// Applies ROT13 cipher to selected text.
|
||||
ConvertToRot13,
|
||||
/// Applies ROT47 cipher to selected text.
|
||||
ConvertToRot47,
|
||||
/// Toggles comments for selected lines.
|
||||
ToggleComments,
|
||||
/// Shows the current location in the file.
|
||||
ShowLocation,
|
||||
/// Undoes the last change.
|
||||
Undo,
|
||||
/// Redoes the last undone change.
|
||||
Redo,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::{Vim, state::Mode};
|
|||
|
||||
const BOOLEAN_PAIRS: &[(&str, &str)] = &[("true", "false"), ("yes", "no"), ("on", "off")];
|
||||
|
||||
/// Increments the number under the cursor or toggles boolean values.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -17,6 +18,7 @@ struct Increment {
|
|||
step: bool,
|
||||
}
|
||||
|
||||
/// Decrements the number under the cursor or toggles boolean values.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
|
|
@ -14,6 +14,7 @@ use crate::{
|
|||
state::{Mode, Register},
|
||||
};
|
||||
|
||||
/// Pastes text from the specified register at the cursor position.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
|
|
@ -11,7 +11,19 @@ use editor::Editor;
|
|||
use gpui::{Action, App, Context, Window, actions};
|
||||
use workspace::Workspace;
|
||||
|
||||
actions!(vim, [Repeat, EndRepeat, ToggleRecord, ReplayLastRecording]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Repeats the last change.
|
||||
Repeat,
|
||||
/// Ends the repeat recording.
|
||||
EndRepeat,
|
||||
/// Toggles macro recording.
|
||||
ToggleRecord,
|
||||
/// Replays the last recorded macro.
|
||||
ReplayLastRecording
|
||||
]
|
||||
);
|
||||
|
||||
fn should_replay(action: &dyn Action) -> bool {
|
||||
// skip so that we don't leave the character palette open
|
||||
|
|
|
@ -11,13 +11,21 @@ use settings::Settings;
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Scrolls up by one line.
|
||||
LineUp,
|
||||
/// Scrolls down by one line.
|
||||
LineDown,
|
||||
/// Scrolls right by one column.
|
||||
ColumnRight,
|
||||
/// Scrolls left by one column.
|
||||
ColumnLeft,
|
||||
/// Scrolls up by half a page.
|
||||
ScrollUp,
|
||||
/// Scrolls down by half a page.
|
||||
ScrollDown,
|
||||
/// Scrolls up by one page.
|
||||
PageUp,
|
||||
/// Scrolls down by one page.
|
||||
PageDown
|
||||
]
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::{
|
|||
state::{Mode, SearchState},
|
||||
};
|
||||
|
||||
/// Moves to the next search match.
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -28,6 +29,7 @@ pub(crate) struct MoveToNext {
|
|||
regex: bool,
|
||||
}
|
||||
|
||||
/// Moves to the previous search match.
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -40,6 +42,7 @@ pub(crate) struct MoveToPrevious {
|
|||
regex: bool,
|
||||
}
|
||||
|
||||
/// Initiates a search operation with the specified parameters.
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -50,6 +53,7 @@ pub(crate) struct Search {
|
|||
regex: bool,
|
||||
}
|
||||
|
||||
/// Executes a find command to search for patterns in the buffer.
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -58,6 +62,7 @@ pub struct FindCommand {
|
|||
pub backwards: bool,
|
||||
}
|
||||
|
||||
/// Executes a search and replace command within the specified range.
|
||||
#[derive(Clone, Debug, PartialEq, Action)]
|
||||
#[action(namespace = vim, no_json, no_register)]
|
||||
pub struct ReplaceCommand {
|
||||
|
@ -73,7 +78,17 @@ pub(crate) struct Replacement {
|
|||
is_case_sensitive: bool,
|
||||
}
|
||||
|
||||
actions!(vim, [SearchSubmit, MoveToNextMatch, MoveToPreviousMatch]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Submits the current search query.
|
||||
SearchSubmit,
|
||||
/// Moves to the next search match.
|
||||
MoveToNextMatch,
|
||||
/// Moves to the previous search match.
|
||||
MoveToPreviousMatch
|
||||
]
|
||||
);
|
||||
|
||||
pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, Vim::move_to_next);
|
||||
|
|
|
@ -7,7 +7,15 @@ use crate::{
|
|||
motion::{Motion, MotionKind},
|
||||
};
|
||||
|
||||
actions!(vim, [Substitute, SubstituteLine]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Substitutes characters in the current selection.
|
||||
Substitute,
|
||||
/// Substitutes the entire line.
|
||||
SubstituteLine
|
||||
]
|
||||
);
|
||||
|
||||
pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, |vim, _: &Substitute, window, cx| {
|
||||
|
|
|
@ -46,6 +46,7 @@ pub enum Object {
|
|||
EntireFile,
|
||||
}
|
||||
|
||||
/// Selects a word text object.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -54,6 +55,7 @@ struct Word {
|
|||
ignore_punctuation: bool,
|
||||
}
|
||||
|
||||
/// Selects a subword text object.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -61,6 +63,7 @@ struct Subword {
|
|||
#[serde(default)]
|
||||
ignore_punctuation: bool,
|
||||
}
|
||||
/// Selects text at the same indentation level.
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
|
||||
#[action(namespace = vim)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
@ -258,25 +261,45 @@ fn find_mini_brackets(
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Selects a sentence text object.
|
||||
Sentence,
|
||||
/// Selects a paragraph text object.
|
||||
Paragraph,
|
||||
/// Selects text within single quotes.
|
||||
Quotes,
|
||||
/// Selects text within backticks.
|
||||
BackQuotes,
|
||||
/// Selects text within the nearest quotes (single or double).
|
||||
MiniQuotes,
|
||||
/// Selects text within any type of quotes.
|
||||
AnyQuotes,
|
||||
/// Selects text within double quotes.
|
||||
DoubleQuotes,
|
||||
/// Selects text within vertical bars (pipes).
|
||||
VerticalBars,
|
||||
/// Selects text within parentheses.
|
||||
Parentheses,
|
||||
/// Selects text within the nearest brackets.
|
||||
MiniBrackets,
|
||||
/// Selects text within any type of brackets.
|
||||
AnyBrackets,
|
||||
/// Selects text within square brackets.
|
||||
SquareBrackets,
|
||||
/// Selects text within curly brackets.
|
||||
CurlyBrackets,
|
||||
/// Selects text within angle brackets.
|
||||
AngleBrackets,
|
||||
/// Selects a function argument.
|
||||
Argument,
|
||||
/// Selects an HTML/XML tag.
|
||||
Tag,
|
||||
/// Selects a method or function.
|
||||
Method,
|
||||
/// Selects a class definition.
|
||||
Class,
|
||||
/// Selects a comment block.
|
||||
Comment,
|
||||
/// Selects the entire file.
|
||||
EntireFile
|
||||
]
|
||||
);
|
||||
|
|
|
@ -13,7 +13,15 @@ use language::{Point, SelectionGoal};
|
|||
use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
|
||||
actions!(vim, [ToggleReplace, UndoReplace]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Toggles replace mode.
|
||||
ToggleReplace,
|
||||
/// Undoes the last replacement.
|
||||
UndoReplace
|
||||
]
|
||||
);
|
||||
|
||||
pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, |vim, _: &ToggleReplace, window, cx| {
|
||||
|
|
|
@ -4,7 +4,13 @@ use editor::{Bias, Editor, RewrapOptions, SelectionEffects, display_map::ToDispl
|
|||
use gpui::{Context, Window, actions};
|
||||
use language::SelectionGoal;
|
||||
|
||||
actions!(vim, [Rewrap]);
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Rewraps the selected text to fit within the line width.
|
||||
Rewrap
|
||||
]
|
||||
);
|
||||
|
||||
pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
||||
Vim::action(editor, cx, |vim, _: &Rewrap, window, cx| {
|
||||
|
|
|
@ -134,55 +134,105 @@ struct PushLiteral {
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Switches to normal mode.
|
||||
SwitchToNormalMode,
|
||||
/// Switches to insert mode.
|
||||
SwitchToInsertMode,
|
||||
/// Switches to replace mode.
|
||||
SwitchToReplaceMode,
|
||||
/// Switches to visual mode.
|
||||
SwitchToVisualMode,
|
||||
/// Switches to visual line mode.
|
||||
SwitchToVisualLineMode,
|
||||
/// Switches to visual block mode.
|
||||
SwitchToVisualBlockMode,
|
||||
/// Switches to Helix-style normal mode.
|
||||
SwitchToHelixNormalMode,
|
||||
/// Clears any pending operators.
|
||||
ClearOperators,
|
||||
/// Clears the exchange register.
|
||||
ClearExchange,
|
||||
/// Inserts a tab character.
|
||||
Tab,
|
||||
/// Inserts a newline.
|
||||
Enter,
|
||||
/// Selects inner text object.
|
||||
InnerObject,
|
||||
/// Maximizes the current pane.
|
||||
MaximizePane,
|
||||
/// Opens the default keymap file.
|
||||
OpenDefaultKeymap,
|
||||
/// Resets all pane sizes to default.
|
||||
ResetPaneSizes,
|
||||
/// Resizes the pane to the right.
|
||||
ResizePaneRight,
|
||||
/// Resizes the pane to the left.
|
||||
ResizePaneLeft,
|
||||
/// Resizes the pane upward.
|
||||
ResizePaneUp,
|
||||
/// Resizes the pane downward.
|
||||
ResizePaneDown,
|
||||
/// Starts a change operation.
|
||||
PushChange,
|
||||
/// Starts a delete operation.
|
||||
PushDelete,
|
||||
/// Exchanges text regions.
|
||||
Exchange,
|
||||
/// Starts a yank operation.
|
||||
PushYank,
|
||||
/// Starts a replace operation.
|
||||
PushReplace,
|
||||
/// Deletes surrounding characters.
|
||||
PushDeleteSurrounds,
|
||||
/// Sets a mark at the current position.
|
||||
PushMark,
|
||||
/// Toggles the marks view.
|
||||
ToggleMarksView,
|
||||
/// Starts a forced motion.
|
||||
PushForcedMotion,
|
||||
/// Starts an indent operation.
|
||||
PushIndent,
|
||||
/// Starts an outdent operation.
|
||||
PushOutdent,
|
||||
/// Starts an auto-indent operation.
|
||||
PushAutoIndent,
|
||||
/// Starts a rewrap operation.
|
||||
PushRewrap,
|
||||
/// Starts a shell command operation.
|
||||
PushShellCommand,
|
||||
/// Converts to lowercase.
|
||||
PushLowercase,
|
||||
/// Converts to uppercase.
|
||||
PushUppercase,
|
||||
/// Toggles case.
|
||||
PushOppositeCase,
|
||||
/// Applies ROT13 encoding.
|
||||
PushRot13,
|
||||
/// Applies ROT47 encoding.
|
||||
PushRot47,
|
||||
/// Toggles the registers view.
|
||||
ToggleRegistersView,
|
||||
/// Selects a register.
|
||||
PushRegister,
|
||||
/// Starts recording to a register.
|
||||
PushRecordRegister,
|
||||
/// Replays a register.
|
||||
PushReplayRegister,
|
||||
/// Replaces with register contents.
|
||||
PushReplaceWithRegister,
|
||||
/// Toggles comments.
|
||||
PushToggleComments,
|
||||
]
|
||||
);
|
||||
|
||||
// in the workspace namespace so it's not filtered out when vim is disabled.
|
||||
actions!(workspace, [ToggleVimMode,]);
|
||||
actions!(
|
||||
workspace,
|
||||
[
|
||||
/// Toggles Vim mode on or off.
|
||||
ToggleVimMode,
|
||||
]
|
||||
);
|
||||
|
||||
/// Initializes the `vim` crate.
|
||||
pub fn init(cx: &mut App) {
|
||||
|
|
|
@ -23,23 +23,41 @@ use crate::{
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
/// Toggles visual mode.
|
||||
ToggleVisual,
|
||||
/// Toggles visual line mode.
|
||||
ToggleVisualLine,
|
||||
/// Toggles visual block mode.
|
||||
ToggleVisualBlock,
|
||||
/// Deletes the visual selection.
|
||||
VisualDelete,
|
||||
/// Deletes entire lines in visual selection.
|
||||
VisualDeleteLine,
|
||||
/// Yanks (copies) the visual selection.
|
||||
VisualYank,
|
||||
/// Yanks entire lines in visual selection.
|
||||
VisualYankLine,
|
||||
/// Moves cursor to the other end of the selection.
|
||||
OtherEnd,
|
||||
/// Moves cursor to the other end of the selection (row-aware).
|
||||
OtherEndRowAware,
|
||||
/// Selects the next occurrence of the current selection.
|
||||
SelectNext,
|
||||
/// Selects the previous occurrence of the current selection.
|
||||
SelectPrevious,
|
||||
/// Selects the next match of the current selection.
|
||||
SelectNextMatch,
|
||||
/// Selects the previous match of the current selection.
|
||||
SelectPreviousMatch,
|
||||
/// Selects the next smaller syntax node.
|
||||
SelectSmallerSyntaxNode,
|
||||
/// Selects the next larger syntax node.
|
||||
SelectLargerSyntaxNode,
|
||||
/// Restores the previous visual selection.
|
||||
RestoreVisualSelection,
|
||||
/// Inserts at the end of each line in visual selection.
|
||||
VisualInsertEndOfLine,
|
||||
/// Inserts at the first non-whitespace character of each line.
|
||||
VisualInsertFirstNonWhiteSpace,
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue