Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:h[elp] command and documentation #997

Open
wants to merge 55 commits into
base: master
Choose a base branch
from

Conversation

Omnikar
Copy link
Contributor

@Omnikar Omnikar commented Nov 6, 2021

Addresses #668.

Each command will have its documentation as a file at runtime/help/command_name.txt. I'm going for an example-driven documentation style (though not all commands need/can have examples).

Todos

  • :h <command> where command is a static command will open documentation for the static command.

  • :h :<command> where command is a typable command will open documentation for the typable command.

  • :h <keybind> where keybind is bound to a specific command will open documentation for the command. Keybind keys will be parsed like a macro.

  • :h <keybind> where keybind branches to multiple other keybinds — like g or z — will collect the sub-keys, their associated commands, and said commands' descriptions into a list which is opened in a buffer for the user.

  • :h topics will open a fuzzy picker with non-command-related help topics.

  • Document static commands

    Command list
    • no_op
    • move_char_left
    • move_char_right
    • move_line_up
    • move_line_down
    • extend_char_left
    • extend_char_right
    • extend_line_up
    • extend_line_down
    • copy_selection_on_next_line
    • copy_selection_on_prev_line
    • move_next_word_start
    • move_prev_word_start
    • move_next_word_end
    • move_next_long_word_start
    • move_prev_long_word_start
    • move_next_long_word_end
    • extend_next_word_start
    • extend_prev_word_start
    • extend_next_word_end
    • extend_next_long_word_start
    • extend_prev_long_word_start
    • extend_next_long_word_end
    • find_till_char
    • find_next_char
    • extend_till_char
    • extend_next_char
    • till_prev_char
    • find_prev_char
    • extend_till_prev_char
    • extend_prev_char
    • repeat_last_motion
    • replace
    • switch_case
    • switch_to_uppercase
    • switch_to_lowercase
    • page_up
    • page_down
    • half_page_up
    • half_page_down
    • select_all
    • select_regex
    • split_selection
    • split_selection_on_newline
    • search
    • rsearch
    • search_next
    • search_prev
    • extend_search_next
    • extend_search_prev
    • search_selection
    • global_search
    • extend_line
    • extend_to_line_bounds
    • delete_selection
    • change_selection
    • collapse_selection
    • flip_selections
    • insert_mode
    • append_mode
    • command_mode
    • file_picker
    • code_action
    • buffer_picker
    • symbol_picker
    • last_picker
    • prepend_to_line
    • append_to_line
    • open_below
    • open_above
    • normal_mode
    • select_mode
    • exit_select_mode
    • goto_definition
    • add_newline_above
    • add_newline_below
    • goto_type_definition
    • goto_implementation
    • goto_file_start
    • goto_file_end
    • goto_reference
    • goto_window_top
    • goto_window_middle
    • goto_window_bottom
    • goto_last_accessed_file
    • goto_line
    • goto_last_line
    • goto_first_diag
    • goto_last_diag
    • goto_next_diag
    • goto_prev_diag
    • goto_line_start
    • goto_line_end
    • goto_next_buffer
    • goto_previous_buffer
    • goto_line_end_newline
    • goto_first_nonwhitespace
    • extend_to_line_start
    • extend_to_line_end
    • extend_to_line_end_newline
    • signature_help
    • insert_tab
    • insert_newline
    • delete_char_backward
    • delete_char_forward
    • delete_word_backward
    • undo
    • redo
    • yank
    • yank_joined_to_clipboard
    • yank_main_selection_to_clipboard
    • yank_joined_to_primary_clipboard
    • yank_main_selection_to_primary_clipboard
    • replace_with_yanked
    • replace_selections_with_clipboard
    • replace_selections_with_primary_clipboard
    • paste_after
    • paste_before
    • paste_clipboard_after
    • paste_clipboard_before
    • paste_primary_clipboard_after
    • paste_primary_clipboard_before
    • indent
    • unindent
    • format_selections
    • join_selections
    • keep_selections
    • keep_primary_selection
    • remove_primary_selection
    • completion
    • hover
    • toggle_comments
    • rotate_selections_forward
    • rotate_selections_backward
    • rotate_selection_contents_forward
    • rotate_selection_contents_backward
    • expand_selection
    • jump_forward
    • jump_backward
    • jump_view_right
    • jump_view_left
    • jump_view_up
    • jump_view_down
    • rotate_view
    • hsplit
    • vsplit
    • wclose
    • select_register
    • align_view_middle
    • align_view_top
    • align_view_center
    • align_view_bottom
    • scroll_up
    • scroll_down
    • match_brackets
    • surround_add
    • surround_replace
    • surround_delete
    • select_textobject_around
    • select_textobject_inner
    • shell_pipe
    • shell_pipe_to
    • shell_insert_output
    • shell_append_output
    • shell_keep_pipe
    • suspend
    • rename_symbol
    • increment
    • decrement
    • record_macro
    • replay_macro
  • Document typable commands

    Command list
    • :quit
    • :quit!
    • :open
    • :buffer-close
    • :buffer-close!
    • :write
    • :new
    • :format
    • :indent-style
    • :line-ending
    • :earlier
    • :later
    • :write-quit
    • :write-quit!
    • :write-all
    • :write-quit-all
    • :write-quit-all!
    • :quit-all
    • :quit-all!
    • :cquit
    • :cquit!
    • :theme
    • :clipboard-yank
    • :clipboard-yank-join
    • :primary-clipboard-yank
    • :primary-clipboard-yank-join
    • :clipboard-paste-after
    • :clipboard-paste-before
    • :clipboard-paste-replace
    • :primary-clipboard-paste-after
    • :primary-clipboard-paste-before
    • :primary-clipboard-paste-replace
    • :show-clipboard-provider
    • :change-current-directory
    • :show-directory
    • :encoding
    • :reload
    • :tree-sitter-scopes
    • :vsplit
    • :hsplit
    • :tutor
    • :goto
    • :set-option
    • :sort
    • :rsort
    • :help

@Omnikar Omnikar changed the title :h[elp] command :h[elp] command and documentation Nov 6, 2021
@archseer
Copy link
Member

archseer commented Nov 7, 2021

I was thinking we could use markdown since it would be possible to highlight it with a tree-sitter grammar. We could also render it using the markdown components we use for LSP docs.

* `copy_selection_on_prev_line`
* `extend_char_left`
* `extend_char_right`
* `extend_line_down`
* `extend_line_up`
* `move_char_left`
* `move_char_right`
* `move_line_down`
* `move_line_up`
* `no_op`
@Omnikar
Copy link
Contributor Author

Omnikar commented Nov 7, 2021

I was thinking we could use markdown since it would be possible to highlight it with a tree-sitter grammar. We could also render it using the markdown components we use for LSP docs.

Would that allow for, in the examples, showing the selections without making the text wider by adding []? Cause that's been bothering me.

@Omnikar
Copy link
Contributor Author

Omnikar commented Nov 8, 2021

Would that allow for, in the examples, showing the selections without making the text wider by adding []? Cause that's been bothering me.

I had an idea to solve this; from Matrix:

What if we were to make some custom tree-sitter grammar solely for Helix help files, and use it to represent selections in examples by actually rendering a selection? It would remove the aforementioned ambiguity, and would be more clear about the fact that they are selections.

"Aforementioned ambiguity" referring to the fact that using brackets to show selections in examples makes no distinction between selection and cursor, and no distinction between primary and non-primary.

One issue I can see with this approach is getting the file to somehow let tree-sitter know what to parse as text that should have a selection displayed on it. Delimiting the example selections with invisible characters won't work since Helix just displays them as 1-column spaces.

Thoughts?

@matoous
Copy link
Contributor

matoous commented Dec 24, 2021

Late to the party but just out of curiosity (and whether it even makes sense): would it be possible to have the docs as a comments for the rust functions and then extract it from there? It would mean that there's only single source of truth that is close to the implementation and it could be easier to keep it up to date. On the other hand, it could get quite messy and maybe harder to write the docs.

@Omnikar
Copy link
Contributor Author

Omnikar commented Dec 24, 2021

Late to the party but just out of curiosity (and whether it even makes sense): would it be possible to have the docs as a comments for the rust functions and then extract it from there? It would mean that there's only single source of truth that is close to the implementation and it could be easier to keep it up to date. On the other hand, it could get quite messy and maybe harder to write the docs.

Hm, interesting idea… but I'm not sure how we'd go about extracting the doc comments into runtime files. Does rustdoc provide an API of some sort that can be used to access the doc comments from build code?

@Omnikar
Copy link
Contributor Author

Omnikar commented Dec 24, 2021

Why is it claiming that typable-cmd.md is conflicted?

@Omnikar
Copy link
Contributor Author

Omnikar commented Dec 24, 2021

OK… I guess I was able to fix it through Github's GUI

@sudormrfbin
Copy link
Member

would it be possible to have the docs as a comments for the rust functions and then extract it from there?

I wanted to do the same for config options and automatically updating the online docs at https://docs.helix-editor.com/configuration.html as a followup to #1119, but couldn't find a way to do it. rustdoc is not available as a separate crate, which would have solved the problem quite neatly.

* `find_till_char`
* `find_next_char`
* `extend_till_char`
* `extend_next_char`
* `till_prev_char`
* `find_prev_char`
* `extend_till_prev_char`
* `extend_prev_char`
@langston-barrett
Copy link

This is really great - Anything I can do to help move it forward?

@archseer
Copy link
Member

@Omnikar could we merge this as is? I think partial documentation is still better than no documentation, and it would make it possible for others to contribute via follow-up PRs.

@the-mikedavis the-mikedavis added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. labels Dec 24, 2022
@6lj6

This comment was marked as off-topic.

Using `:h` with a key that branches into other bindings, such as `g` or
`z` would leave the inputted keys as pending, meaning that any following
keypresses would register as if the looked-up keys had been typed first.
@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. A-command Area: Commands and removed A-helix-term Area: Helix term improvements S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 10, 2024
@pascalkuthe pascalkuthe removed the S-waiting-on-review Status: Awaiting review from a maintainer. label Apr 14, 2024
@shaleh
Copy link
Contributor

shaleh commented Apr 18, 2024

merge conflicts resolved in shaleh/help-command.

@Omnikar Omnikar marked this pull request as ready for review April 21, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-command Area: Commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet