diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 6e1a65802..53bb57022 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3550,9 +3550,8 @@ pub mod insert { indent, ); doc.apply(&transaction, view.id); - } - + pub fn smart_tab(cx: &mut Context) { let (view, doc) = current_ref!(cx.editor); let view_id = view.id; diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 22beddbe4..6a19bf2b1 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2346,594 +2346,594 @@ fn clear_register( } pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ - TypableCommand { - name: "quit", - aliases: &["q"], - doc: "Close the current view.", - fun: quit, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "quit!", - aliases: &["q!"], - doc: "Force close the current view, ignoring unsaved changes.", - fun: force_quit, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "open", - aliases: &["o"], - doc: "Open a file from disk into the current view.", - fun: open, - signature: CommandSignature::all(completers::filename), - }, - TypableCommand { - name: "buffer-close", - aliases: &["bc", "bclose"], - doc: "Close the current buffer.", - fun: buffer_close, - signature: CommandSignature::all(completers::buffer), - }, - TypableCommand { - name: "buffer-close!", - aliases: &["bc!", "bclose!"], - doc: "Close the current buffer forcefully, ignoring unsaved changes.", - fun: force_buffer_close, - signature: CommandSignature::all(completers::buffer) - }, - TypableCommand { - name: "buffer-close-others", - aliases: &["bco", "bcloseother"], - doc: "Close all buffers but the currently focused one.", - fun: buffer_close_others, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "buffer-close-others!", - aliases: &["bco!", "bcloseother!"], - doc: "Force close all buffers but the currently focused one.", - fun: force_buffer_close_others, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "buffer-close-all", - aliases: &["bca", "bcloseall"], - doc: "Close all buffers without quitting.", - fun: buffer_close_all, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "buffer-close-all!", - aliases: &["bca!", "bcloseall!"], - doc: "Force close all buffers ignoring unsaved changes without quitting.", - fun: force_buffer_close_all, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "buffer-next", - aliases: &["bn", "bnext"], - doc: "Goto next buffer.", - fun: buffer_next, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "buffer-previous", - aliases: &["bp", "bprev"], - doc: "Goto previous buffer.", - fun: buffer_previous, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "write", - aliases: &["w"], - doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)", - fun: write, - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "write!", - aliases: &["w!"], - doc: "Force write changes to disk creating necessary subdirectories. Accepts an optional path (:write! some/path.txt)", - fun: force_write, - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "write-buffer-close", - aliases: &["wbc"], - doc: "Write changes to disk and closes the buffer. Accepts an optional path (:write-buffer-close some/path.txt)", - fun: write_buffer_close, - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "write-buffer-close!", - aliases: &["wbc!"], - doc: "Force write changes to disk creating necessary subdirectories and closes the buffer. Accepts an optional path (:write-buffer-close! some/path.txt)", - fun: force_write_buffer_close, - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "new", - aliases: &["n"], - doc: "Create a new scratch buffer.", - fun: new_file, - // TODO: This seems to complete with a filename, but doesn't use that filename to - // set the path of the newly created buffer. - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "format", - aliases: &["fmt"], - doc: "Format the file using the LSP formatter.", - fun: format, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "indent-style", - aliases: &[], - doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)", - fun: set_indent_style, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "line-ending", - aliases: &[], - #[cfg(not(feature = "unicode-lines"))] - doc: "Set the document's default line ending. Options: crlf, lf.", - #[cfg(feature = "unicode-lines")] - doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.", - fun: set_line_ending, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "earlier", - aliases: &["ear"], - doc: "Jump back to an earlier point in edit history. Accepts a number of steps or a time span.", - fun: earlier, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "later", - aliases: &["lat"], - doc: "Jump to a later point in edit history. Accepts a number of steps or a time span.", - fun: later, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "write-quit", - aliases: &["wq", "x"], - doc: "Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt)", - fun: write_quit, - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "write-quit!", - aliases: &["wq!", "x!"], - doc: "Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt)", - fun: force_write_quit, - signature: CommandSignature::positional(&[completers::filename]), - }, - TypableCommand { - name: "write-all", - aliases: &["wa"], - doc: "Write changes from all buffers to disk.", - fun: write_all, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "write-quit-all", - aliases: &["wqa", "xa"], - doc: "Write changes from all buffers to disk and close all views.", - fun: write_all_quit, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "write-quit-all!", - aliases: &["wqa!", "xa!"], - doc: "Write changes from all buffers to disk and close all views forcefully (ignoring unsaved changes).", - fun: force_write_all_quit, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "quit-all", - aliases: &["qa"], - doc: "Close all views.", - fun: quit_all, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "quit-all!", - aliases: &["qa!"], - doc: "Force close all views ignoring unsaved changes.", - fun: force_quit_all, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "cquit", - aliases: &["cq"], - doc: "Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2).", - fun: cquit, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "cquit!", - aliases: &["cq!"], - doc: "Force quit with exit code (default 1) ignoring unsaved changes. Accepts an optional integer exit code (:cq! 2).", - fun: force_cquit, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "theme", - aliases: &[], - doc: "Change the editor theme (show current theme if no name specified).", - fun: theme, - signature: CommandSignature::positional(&[completers::theme]), - }, - TypableCommand { - name: "yank-join", - aliases: &[], - doc: "Yank joined selections. A separator can be provided as first argument. Default value is newline.", - fun: yank_joined, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "clipboard-yank", - aliases: &[], - doc: "Yank main selection into system clipboard.", - fun: yank_main_selection_to_clipboard, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "clipboard-yank-join", - aliases: &[], - doc: "Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc. - fun: yank_joined_to_clipboard, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "primary-clipboard-yank", - aliases: &[], - doc: "Yank main selection into system primary clipboard.", - fun: yank_main_selection_to_primary_clipboard, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "primary-clipboard-yank-join", - aliases: &[], - doc: "Yank joined selections into system primary clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc. - fun: yank_joined_to_primary_clipboard, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "clipboard-paste-after", - aliases: &[], - doc: "Paste system clipboard after selections.", - fun: paste_clipboard_after, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "clipboard-paste-before", - aliases: &[], - doc: "Paste system clipboard before selections.", - fun: paste_clipboard_before, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "clipboard-paste-replace", - aliases: &[], - doc: "Replace selections with content of system clipboard.", - fun: replace_selections_with_clipboard, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "primary-clipboard-paste-after", - aliases: &[], - doc: "Paste primary clipboard after selections.", - fun: paste_primary_clipboard_after, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "primary-clipboard-paste-before", - aliases: &[], - doc: "Paste primary clipboard before selections.", - fun: paste_primary_clipboard_before, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "primary-clipboard-paste-replace", - aliases: &[], - doc: "Replace selections with content of system primary clipboard.", - fun: replace_selections_with_primary_clipboard, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "show-clipboard-provider", - aliases: &[], - doc: "Show clipboard provider name in status bar.", - fun: show_clipboard_provider, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "change-current-directory", - aliases: &["cd"], - doc: "Change the current working directory.", - fun: change_current_directory, - signature: CommandSignature::positional(&[completers::directory]), - }, - TypableCommand { - name: "show-directory", - aliases: &["pwd"], - doc: "Show the current working directory.", - fun: show_current_directory, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "encoding", - aliases: &[], - doc: "Set encoding. Based on `https://encoding.spec.whatwg.org`.", - fun: set_encoding, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "character-info", - aliases: &["char"], - doc: "Get info about the character under the primary cursor.", - fun: get_character_info, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "reload", - aliases: &["rl"], - doc: "Discard changes and reload from the source file.", - fun: reload, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "reload-all", - aliases: &["rla"], - doc: "Discard changes and reload all documents from the source files.", - fun: reload_all, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "update", - aliases: &["u"], - doc: "Write changes only if the file has been modified.", - fun: update, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "lsp-workspace-command", - aliases: &[], - doc: "Open workspace command picker", - fun: lsp_workspace_command, - signature: CommandSignature::positional(&[completers::lsp_workspace_command]), - }, - TypableCommand { - name: "lsp-restart", - aliases: &[], - doc: "Restarts the language servers used by the current doc", - fun: lsp_restart, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "lsp-stop", - aliases: &[], - doc: "Stops the language servers that are used by the current doc", - fun: lsp_stop, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "tree-sitter-scopes", - aliases: &[], - doc: "Display tree sitter scopes, primarily for theming and development.", - fun: tree_sitter_scopes, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "debug-start", - aliases: &["dbg"], - doc: "Start a debug session from a given template with given parameters.", - fun: debug_start, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "debug-remote", - aliases: &["dbg-tcp"], - doc: "Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters.", - fun: debug_remote, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "debug-eval", - aliases: &[], - doc: "Evaluate expression in current debug context.", - fun: debug_eval, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "vsplit", - aliases: &["vs"], - doc: "Open the file in a vertical split.", - fun: vsplit, - signature: CommandSignature::all(completers::filename) - }, - TypableCommand { - name: "vsplit-new", - aliases: &["vnew"], - doc: "Open a scratch buffer in a vertical split.", - fun: vsplit_new, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "hsplit", - aliases: &["hs", "sp"], - doc: "Open the file in a horizontal split.", - fun: hsplit, - signature: CommandSignature::all(completers::filename) - }, - TypableCommand { - name: "hsplit-new", - aliases: &["hnew"], - doc: "Open a scratch buffer in a horizontal split.", - fun: hsplit_new, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "tutor", - aliases: &[], - doc: "Open the tutorial.", - fun: tutor, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "goto", - aliases: &["g"], - doc: "Goto line number.", - fun: goto_line_number, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "set-language", - aliases: &["lang"], - doc: "Set the language of current buffer (show current language if no value specified).", - fun: language, - signature: CommandSignature::positional(&[completers::language]), - }, - TypableCommand { - name: "set-option", - aliases: &["set"], - doc: "Set a config option at runtime.\nFor example to disable smart case search, use `:set search.smart-case false`.", - fun: set_option, - // TODO: Add support for completion of the options value(s), when appropriate. - signature: CommandSignature::positional(&[completers::setting]), - }, - TypableCommand { - name: "toggle-option", - aliases: &["toggle"], - doc: "Toggle a boolean config option at runtime.\nFor example to toggle smart case search, use `:toggle search.smart-case`.", - fun: toggle_option, - signature: CommandSignature::positional(&[completers::setting]), - }, - TypableCommand { - name: "get-option", - aliases: &["get"], - doc: "Get the current value of a config option.", - fun: get_option, - signature: CommandSignature::positional(&[completers::setting]), - }, - TypableCommand { - name: "sort", - aliases: &[], - doc: "Sort ranges in selection.", - fun: sort, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "rsort", - aliases: &[], - doc: "Sort ranges in selection in reverse order.", - fun: sort_reverse, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "reflow", - aliases: &[], - doc: "Hard-wrap the current selection of lines to a given width.", - fun: reflow, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "tree-sitter-subtree", - aliases: &["ts-subtree"], - doc: "Display tree sitter subtree under cursor, primarily for debugging queries.", - fun: tree_sitter_subtree, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "config-reload", - aliases: &[], - doc: "Refresh user config.", - fun: refresh_config, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "config-open", - aliases: &[], - doc: "Open the user config.toml file.", - fun: open_config, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "config-open-workspace", - aliases: &[], - doc: "Open the workspace config.toml file.", - fun: open_workspace_config, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "log-open", - aliases: &[], - doc: "Open the helix log file.", - fun: open_log, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "insert-output", - aliases: &[], - doc: "Run shell command, inserting output before each selection.", - fun: insert_output, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "append-output", - aliases: &[], - doc: "Run shell command, appending output after each selection.", - fun: append_output, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "pipe", - aliases: &[], - doc: "Pipe each selection to the shell command.", - fun: pipe, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "pipe-to", - aliases: &[], - doc: "Pipe each selection to the shell command, ignoring output.", - fun: pipe_to, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "run-shell-command", - aliases: &["sh"], - doc: "Run a shell command", - fun: run_shell_command, - signature: CommandSignature::all(completers::filename) - }, - TypableCommand { - name: "run-shell-command-text", - aliases: &["sh"], - doc: "Run a shell command", - fun: run_shell_command_text, - signature: CommandSignature::all(completers::filename) - }, - TypableCommand { - name: "reset-diff-change", - aliases: &["diffget", "diffg"], - doc: "Reset the diff change at the cursor position.", - fun: reset_diff_change, - signature: CommandSignature::none(), - }, - TypableCommand { - name: "clear-register", - aliases: &[], - doc: "Clear given register. If no argument is provided, clear all registers.", - fun: clear_register, - signature: CommandSignature::none(), - }, - ]; + TypableCommand { + name: "quit", + aliases: &["q"], + doc: "Close the current view.", + fun: quit, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "quit!", + aliases: &["q!"], + doc: "Force close the current view, ignoring unsaved changes.", + fun: force_quit, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "open", + aliases: &["o"], + doc: "Open a file from disk into the current view.", + fun: open, + signature: CommandSignature::all(completers::filename), + }, + TypableCommand { + name: "buffer-close", + aliases: &["bc", "bclose"], + doc: "Close the current buffer.", + fun: buffer_close, + signature: CommandSignature::all(completers::buffer), + }, + TypableCommand { + name: "buffer-close!", + aliases: &["bc!", "bclose!"], + doc: "Close the current buffer forcefully, ignoring unsaved changes.", + fun: force_buffer_close, + signature: CommandSignature::all(completers::buffer) + }, + TypableCommand { + name: "buffer-close-others", + aliases: &["bco", "bcloseother"], + doc: "Close all buffers but the currently focused one.", + fun: buffer_close_others, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "buffer-close-others!", + aliases: &["bco!", "bcloseother!"], + doc: "Force close all buffers but the currently focused one.", + fun: force_buffer_close_others, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "buffer-close-all", + aliases: &["bca", "bcloseall"], + doc: "Close all buffers without quitting.", + fun: buffer_close_all, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "buffer-close-all!", + aliases: &["bca!", "bcloseall!"], + doc: "Force close all buffers ignoring unsaved changes without quitting.", + fun: force_buffer_close_all, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "buffer-next", + aliases: &["bn", "bnext"], + doc: "Goto next buffer.", + fun: buffer_next, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "buffer-previous", + aliases: &["bp", "bprev"], + doc: "Goto previous buffer.", + fun: buffer_previous, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "write", + aliases: &["w"], + doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)", + fun: write, + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "write!", + aliases: &["w!"], + doc: "Force write changes to disk creating necessary subdirectories. Accepts an optional path (:write! some/path.txt)", + fun: force_write, + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "write-buffer-close", + aliases: &["wbc"], + doc: "Write changes to disk and closes the buffer. Accepts an optional path (:write-buffer-close some/path.txt)", + fun: write_buffer_close, + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "write-buffer-close!", + aliases: &["wbc!"], + doc: "Force write changes to disk creating necessary subdirectories and closes the buffer. Accepts an optional path (:write-buffer-close! some/path.txt)", + fun: force_write_buffer_close, + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "new", + aliases: &["n"], + doc: "Create a new scratch buffer.", + fun: new_file, + // TODO: This seems to complete with a filename, but doesn't use that filename to + // set the path of the newly created buffer. + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "format", + aliases: &["fmt"], + doc: "Format the file using the LSP formatter.", + fun: format, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "indent-style", + aliases: &[], + doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)", + fun: set_indent_style, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "line-ending", + aliases: &[], + #[cfg(not(feature = "unicode-lines"))] + doc: "Set the document's default line ending. Options: crlf, lf.", + #[cfg(feature = "unicode-lines")] + doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.", + fun: set_line_ending, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "earlier", + aliases: &["ear"], + doc: "Jump back to an earlier point in edit history. Accepts a number of steps or a time span.", + fun: earlier, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "later", + aliases: &["lat"], + doc: "Jump to a later point in edit history. Accepts a number of steps or a time span.", + fun: later, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "write-quit", + aliases: &["wq", "x"], + doc: "Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt)", + fun: write_quit, + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "write-quit!", + aliases: &["wq!", "x!"], + doc: "Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt)", + fun: force_write_quit, + signature: CommandSignature::positional(&[completers::filename]), + }, + TypableCommand { + name: "write-all", + aliases: &["wa"], + doc: "Write changes from all buffers to disk.", + fun: write_all, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "write-quit-all", + aliases: &["wqa", "xa"], + doc: "Write changes from all buffers to disk and close all views.", + fun: write_all_quit, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "write-quit-all!", + aliases: &["wqa!", "xa!"], + doc: "Write changes from all buffers to disk and close all views forcefully (ignoring unsaved changes).", + fun: force_write_all_quit, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "quit-all", + aliases: &["qa"], + doc: "Close all views.", + fun: quit_all, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "quit-all!", + aliases: &["qa!"], + doc: "Force close all views ignoring unsaved changes.", + fun: force_quit_all, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "cquit", + aliases: &["cq"], + doc: "Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2).", + fun: cquit, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "cquit!", + aliases: &["cq!"], + doc: "Force quit with exit code (default 1) ignoring unsaved changes. Accepts an optional integer exit code (:cq! 2).", + fun: force_cquit, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "theme", + aliases: &[], + doc: "Change the editor theme (show current theme if no name specified).", + fun: theme, + signature: CommandSignature::positional(&[completers::theme]), + }, + TypableCommand { + name: "yank-join", + aliases: &[], + doc: "Yank joined selections. A separator can be provided as first argument. Default value is newline.", + fun: yank_joined, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "clipboard-yank", + aliases: &[], + doc: "Yank main selection into system clipboard.", + fun: yank_main_selection_to_clipboard, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "clipboard-yank-join", + aliases: &[], + doc: "Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc. + fun: yank_joined_to_clipboard, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "primary-clipboard-yank", + aliases: &[], + doc: "Yank main selection into system primary clipboard.", + fun: yank_main_selection_to_primary_clipboard, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "primary-clipboard-yank-join", + aliases: &[], + doc: "Yank joined selections into system primary clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc. + fun: yank_joined_to_primary_clipboard, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "clipboard-paste-after", + aliases: &[], + doc: "Paste system clipboard after selections.", + fun: paste_clipboard_after, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "clipboard-paste-before", + aliases: &[], + doc: "Paste system clipboard before selections.", + fun: paste_clipboard_before, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "clipboard-paste-replace", + aliases: &[], + doc: "Replace selections with content of system clipboard.", + fun: replace_selections_with_clipboard, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "primary-clipboard-paste-after", + aliases: &[], + doc: "Paste primary clipboard after selections.", + fun: paste_primary_clipboard_after, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "primary-clipboard-paste-before", + aliases: &[], + doc: "Paste primary clipboard before selections.", + fun: paste_primary_clipboard_before, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "primary-clipboard-paste-replace", + aliases: &[], + doc: "Replace selections with content of system primary clipboard.", + fun: replace_selections_with_primary_clipboard, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "show-clipboard-provider", + aliases: &[], + doc: "Show clipboard provider name in status bar.", + fun: show_clipboard_provider, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "change-current-directory", + aliases: &["cd"], + doc: "Change the current working directory.", + fun: change_current_directory, + signature: CommandSignature::positional(&[completers::directory]), + }, + TypableCommand { + name: "show-directory", + aliases: &["pwd"], + doc: "Show the current working directory.", + fun: show_current_directory, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "encoding", + aliases: &[], + doc: "Set encoding. Based on `https://encoding.spec.whatwg.org`.", + fun: set_encoding, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "character-info", + aliases: &["char"], + doc: "Get info about the character under the primary cursor.", + fun: get_character_info, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "reload", + aliases: &["rl"], + doc: "Discard changes and reload from the source file.", + fun: reload, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "reload-all", + aliases: &["rla"], + doc: "Discard changes and reload all documents from the source files.", + fun: reload_all, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "update", + aliases: &["u"], + doc: "Write changes only if the file has been modified.", + fun: update, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "lsp-workspace-command", + aliases: &[], + doc: "Open workspace command picker", + fun: lsp_workspace_command, + signature: CommandSignature::positional(&[completers::lsp_workspace_command]), + }, + TypableCommand { + name: "lsp-restart", + aliases: &[], + doc: "Restarts the language servers used by the current doc", + fun: lsp_restart, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "lsp-stop", + aliases: &[], + doc: "Stops the language servers that are used by the current doc", + fun: lsp_stop, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "tree-sitter-scopes", + aliases: &[], + doc: "Display tree sitter scopes, primarily for theming and development.", + fun: tree_sitter_scopes, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "debug-start", + aliases: &["dbg"], + doc: "Start a debug session from a given template with given parameters.", + fun: debug_start, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "debug-remote", + aliases: &["dbg-tcp"], + doc: "Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters.", + fun: debug_remote, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "debug-eval", + aliases: &[], + doc: "Evaluate expression in current debug context.", + fun: debug_eval, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "vsplit", + aliases: &["vs"], + doc: "Open the file in a vertical split.", + fun: vsplit, + signature: CommandSignature::all(completers::filename) + }, + TypableCommand { + name: "vsplit-new", + aliases: &["vnew"], + doc: "Open a scratch buffer in a vertical split.", + fun: vsplit_new, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "hsplit", + aliases: &["hs", "sp"], + doc: "Open the file in a horizontal split.", + fun: hsplit, + signature: CommandSignature::all(completers::filename) + }, + TypableCommand { + name: "hsplit-new", + aliases: &["hnew"], + doc: "Open a scratch buffer in a horizontal split.", + fun: hsplit_new, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "tutor", + aliases: &[], + doc: "Open the tutorial.", + fun: tutor, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "goto", + aliases: &["g"], + doc: "Goto line number.", + fun: goto_line_number, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "set-language", + aliases: &["lang"], + doc: "Set the language of current buffer (show current language if no value specified).", + fun: language, + signature: CommandSignature::positional(&[completers::language]), + }, + TypableCommand { + name: "set-option", + aliases: &["set"], + doc: "Set a config option at runtime.\nFor example to disable smart case search, use `:set search.smart-case false`.", + fun: set_option, + // TODO: Add support for completion of the options value(s), when appropriate. + signature: CommandSignature::positional(&[completers::setting]), + }, + TypableCommand { + name: "toggle-option", + aliases: &["toggle"], + doc: "Toggle a boolean config option at runtime.\nFor example to toggle smart case search, use `:toggle search.smart-case`.", + fun: toggle_option, + signature: CommandSignature::positional(&[completers::setting]), + }, + TypableCommand { + name: "get-option", + aliases: &["get"], + doc: "Get the current value of a config option.", + fun: get_option, + signature: CommandSignature::positional(&[completers::setting]), + }, + TypableCommand { + name: "sort", + aliases: &[], + doc: "Sort ranges in selection.", + fun: sort, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "rsort", + aliases: &[], + doc: "Sort ranges in selection in reverse order.", + fun: sort_reverse, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "reflow", + aliases: &[], + doc: "Hard-wrap the current selection of lines to a given width.", + fun: reflow, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "tree-sitter-subtree", + aliases: &["ts-subtree"], + doc: "Display tree sitter subtree under cursor, primarily for debugging queries.", + fun: tree_sitter_subtree, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "config-reload", + aliases: &[], + doc: "Refresh user config.", + fun: refresh_config, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "config-open", + aliases: &[], + doc: "Open the user config.toml file.", + fun: open_config, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "config-open-workspace", + aliases: &[], + doc: "Open the workspace config.toml file.", + fun: open_workspace_config, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "log-open", + aliases: &[], + doc: "Open the helix log file.", + fun: open_log, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "insert-output", + aliases: &[], + doc: "Run shell command, inserting output before each selection.", + fun: insert_output, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "append-output", + aliases: &[], + doc: "Run shell command, appending output after each selection.", + fun: append_output, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "pipe", + aliases: &[], + doc: "Pipe each selection to the shell command.", + fun: pipe, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "pipe-to", + aliases: &[], + doc: "Pipe each selection to the shell command, ignoring output.", + fun: pipe_to, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "run-shell-command", + aliases: &["sh"], + doc: "Run a shell command", + fun: run_shell_command, + signature: CommandSignature::all(completers::filename) + }, + TypableCommand { + name: "run-shell-command-text", + aliases: &["sh"], + doc: "Run a shell command", + fun: run_shell_command_text, + signature: CommandSignature::all(completers::filename) + }, + TypableCommand { + name: "reset-diff-change", + aliases: &["diffget", "diffg"], + doc: "Reset the diff change at the cursor position.", + fun: reset_diff_change, + signature: CommandSignature::none(), + }, + TypableCommand { + name: "clear-register", + aliases: &[], + doc: "Clear given register. If no argument is provided, clear all registers.", + fun: clear_register, + signature: CommandSignature::none(), + }, +]; pub static TYPABLE_COMMAND_MAP: Lazy> = Lazy::new(|| { diff --git a/helix-term/src/ui/document.rs b/helix-term/src/ui/document.rs index 031326ae9..c521c541a 100644 --- a/helix-term/src/ui/document.rs +++ b/helix-term/src/ui/document.rs @@ -6,7 +6,7 @@ use helix_core::str_utils::char_to_byte_idx; use helix_core::syntax::Highlight; use helix_core::syntax::HighlightEvent; use helix_core::text_annotations::TextAnnotations; -use helix_core::{visual_offset_from_block, Position, RopeSlice, Range}; +use helix_core::{visual_offset_from_block, Position, Range, RopeSlice}; use helix_view::editor::{WhitespaceConfig, WhitespaceRenderValue}; use helix_view::graphics::Rect; use helix_view::theme::Style; @@ -73,7 +73,6 @@ impl> Iterator for StyleIter<'_, H> { } } - /// A wrapper around a HighlightIterator /// that merges the layered highlights to create the final text style /// and yields the active text style and the char_idx where the active @@ -89,33 +88,32 @@ impl> Iterator for RawStyleIter<'_, H> { type Item = (Style, usize); fn next(&mut self) -> Option<(Style, usize)> { while let Some(event) = self.highlight_iter.next() { - // let style = self.active_highlights.iter().fold(self.text_style, |acc, span| { // acc.patch(event.1) // }); - return Some((self.text_style.patch(event.1), event.0.head)) - + return Some((self.text_style.patch(event.1), event.0.head)); + // match event { - // HighlightEvent::HighlightStart(highlights) => { - // self.active_highlights.push(highlights) - // } - // HighlightEvent::HighlightEnd => { - // self.active_highlights.pop(); - // } - // HighlightEvent::Source { start, end } => { - // if start == end { - // continue; - // } - // let style = self - // .active_highlights - // .iter() - // .fold(self.text_style, |acc, span| { - // acc.patch(self.theme.highlight(span.0)) - // }); - - // return Some((style, end)); - // } + // HighlightEvent::HighlightStart(highlights) => { + // self.active_highlights.push(highlights) + // } + // HighlightEvent::HighlightEnd => { + // self.active_highlights.pop(); + // } + // HighlightEvent::Source { start, end } => { + // if start == end { + // continue; + // } + // let style = self + // .active_highlights + // .iter() + // .fold(self.text_style, |acc, span| { + // acc.patch(self.theme.highlight(span.0)) + // }); + + // return Some((style, end)); + // } // } } None @@ -231,7 +229,7 @@ pub fn render_text<'t>( let (mut formatter, mut first_visible_char_idx) = DocumentFormatter::new_at_prev_checkpoint(text, text_fmt, text_annotations, offset.anchor); - + let mut styles = StyleIter { text_style: renderer.text_style, active_highlights: Vec::with_capacity(64), @@ -364,7 +362,7 @@ pub fn render_text<'t>( // } // { - + // let ( // Position { // row: mut row_off, .. @@ -381,7 +379,7 @@ pub fn render_text<'t>( // let (mut formatter, mut first_visible_char_idx) = // DocumentFormatter::new_at_prev_checkpoint(text, text_fmt, text_annotations, offset.anchor); - + // let mut styles = RawStyleIter { // text_style: renderer.text_style, // active_highlights: Vec::with_capacity(64), @@ -433,7 +431,7 @@ pub fn render_text<'t>( // renderer, // last_pos, // ); - // } + // } // break; // }; @@ -518,9 +516,8 @@ pub fn render_text<'t>( // renderer.draw_indent_guides(last_line_indent_level, last_line_pos.visual_line); // for line_decoration in &mut *line_decorations { // line_decoration.render_foreground(renderer, last_line_pos, char_pos); - // } + // } // } - } #[derive(Debug)]