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

Add "enter-to-leave" on root node feature by default #497

Closed
wants to merge 1 commit into from

Conversation

lambdalisue
Copy link
Owner

@lambdalisue lambdalisue commented Mar 16, 2024

Close #496

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option to control the "enter to leave" behavior on the root node of the tree, enhancing navigation flexibility.
  • Documentation

    • Documented the addition of a global variable for controlling tree navigation behavior.

Copy link

coderabbitai bot commented Mar 16, 2024

Walkthrough

The update introduces a new configuration option that allows users to toggle the behavior of the Enter key at the root node within the Fern file explorer. This change enables users to either exit the tree or reload the tree when pressing Enter at the root node, enhancing navigation flexibility based on user preference.

Changes

File Path Change Summary
autoload/fern.vim Added the 'disable_enter_to_leave_on_root' configuration option with a default value of 0.
autoload/fern/mapping/... Modified s:map_enter to conditionally enter or leave a tree based on the new global variable.
doc/fern.txt Documented the new g:fern#disable_enter_to_leave_on_root global variable.

Assessment against linked issues

Objective Addressed Explanation
Add a way to go up a directory with Return (#496)

Poem

In the vast digital wood, a rabbit hopped,
Tweaking the Fern, it never stopped.
"With a tap," it said, "you choose your fate,
To climb up high or through folders navigate."
🌿🐇💻
"Fear not the root, for now, you see,
A way to stay or leave, as free as can be."

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@lambdalisue lambdalisue mentioned this pull request Mar 16, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 24

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 56f8e4c and 3e9fc83.
Files selected for processing (3)
  • autoload/fern.vim (1 hunks)
  • autoload/fern/mapping/node.vim (1 hunks)
  • doc/fern.txt (1 hunks)
Additional comments: 16
autoload/fern.vim (1)
  • 27-27: The addition of the 'disable_enter_to_leave_on_root' configuration option is well-integrated within the existing configuration setup. Ensure that the documentation for this new option is clear and comprehensive, helping users understand how to use it and the implications of enabling/disabling this feature.
autoload/fern/mapping/node.vim (1)
  • 176-180: The conditional logic in the s:map_enter function correctly implements the feature's intended behavior. Consider adding a comment to clarify the use of !empty(node.__owner) in the condition, explaining its role in determining whether the current node is at the root level. This will enhance code readability and maintainability.
doc/fern.txt (14)
  • 570-574: The documentation for the new global variable g:fern#disable_enter_to_leave_on_root is clear and concise. It effectively explains the purpose and default behavior of the variable.
  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [58-58]

The term "netrw" might be incorrectly spelled or unclear to some readers. Consider clarifying if this refers to a specific plugin or feature.

Please verify if "netrw" refers to a specific Vim plugin or feature and consider adding a brief explanation or reference link for clarity.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [72-72]

Possible typo in "t9md/vim-choosewin". Verify if the repository name is correct.

Verification successful

The repository t9md/vim-choosewin exists on GitHub, as confirmed by the HTTP status code "HTTP/2 200". Therefore, the mention of the repository name in the documentation is correct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if the repository t9md/vim-choosewin exists
curl -I https://github.com/t9md/vim-choosewin 2>/dev/null | head -n 1 | grep "HTTP/2 200"

Length of output: 91

* 567-577: > 📝 **NOTE** > This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [79-79]

The term "exrename" might be unfamiliar to some readers. Consider adding a brief explanation or reference link.

Please verify the term "exrename" and consider adding a brief explanation or reference link for clarity.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [95-95]

The term "osascript" might be unfamiliar to some readers. Consider adding a brief explanation that it is a utility available on macOS for running AppleScript commands.

Consider adding a brief explanation for "osascript" to clarify that it is a utility available on macOS for running AppleScript commands.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [110-110]

The term "Netrw" might be incorrectly spelled or unclear to some readers. Consider clarifying if this refers to a specific plugin or feature.

Please verify if "Netrw" refers to a specific Vim plugin or feature and consider adding a brief explanation or reference link for clarity.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [173-173]

The term "autocmd" might be unfamiliar to some readers. Consider adding a brief explanation that it refers to Vim's "autocommand" feature.

Consider adding a brief explanation for "autocmd" to clarify that it refers to Vim's "autocommand" feature.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [203-203]

The term "tcd:root" might be unfamiliar to some readers. Consider adding a brief explanation or reference link.

Please verify the term "tcd:root" and consider adding a brief explanation or reference link for clarity.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [330-330]

The phrase "thus faint vertical bar is used instead" could be rephrased for clarity.

Consider rephrasing to "therefore, a faint vertical bar is used as an alternative".

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [339-339]

The term "keepalt_on_edit" should be more descriptive and use snake case for readability.

Consider renaming to "keep_alt_on_edit" for better readability and consistency with naming conventions.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [361-361]

The term "keepjumps_on_edit" should be more descriptive and use snake case for readability.

Consider renaming to "keep_jumps_on_edit" for better readability and consistency with naming conventions.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [399-399]

Clarify that "CUI Vim" refers to "Console User Interface for Vim".

Consider adding a brief explanation for "CUI Vim" to clarify that it refers to "Console User Interface for Vim".

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [404-404]

The term "WinEnter" might be unfamiliar to some readers. Consider adding a brief explanation that it refers to a Vim autocommand event.

Consider adding a brief explanation for "WinEnter" to clarify that it refers to a Vim autocommand event.

  • 567-577: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [528-528]

The term "textprop_support" should be more descriptive and use snake case for readability.

Consider renaming to "text_prop_support" for better readability and consistency with naming conventions.

Comment on lines 567 to 577
A |Number| value that specifies whether to synchronize file renames to the buffer
Default: 0

*g:fern#disable_enter_to_leave_on_root*
A |Boolean| to disable "enter to leave" behavior on the root node.
If set to 1, "enter" on the root node will reload the tree instead.
Default: 0

*g:fern#window_selector_use_popup*
A |Boolean| which use popup/float window to select window.
See |fern-glossary-window-selector|
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [3-3]

There's an extra whitespace between "Author:" and "Alisue".

- Author:  Alisue <[email protected]>
+ Author: Alisue <[email protected]>

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [44-44]

The word "Exception" starting a sentence should be preceded by a period or be part of the previous sentence.

- itself. 	Exception: "trash" feature in Linux.
+ itself. Exception: "trash" feature in Linux.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [49-49]

Consider rephrasing "most of operations" to "most operations" for better readability.

- Fern uses asynchronous technique to perform most of operations so Vim
+ Fern uses asynchronous technique to perform most operations so Vim

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [55-55]

There's an extra space before "NERDTree".

- drawer (e.g.  NERDTree); officially.
+ drawer (e.g. NERDTree); officially.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [91-91]

The phrase "quite easy" could be replaced with a more formal term like "straightforward".

- So it's quite easy to open a directory with Explorer
+ So it's straightforward to open a directory with Explorer

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [102-102]

The phrase "Most of functionalities" should be corrected to "Most functionalities" for grammatical accuracy.

- Most of functionalities are provided as plugins in fern.
+ Most functionalities are provided as plugins in fern.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [140-140]

The word "where" starting a sentence should be capitalized.

- where {name} is a name of the action.
+ Where {name} is a name of the action.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [188-188]

There's an extra space before "e".

- you may found entries like below by "?": > 	e
+ you may found entries like below by "?": > e

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [225-225]

There's an extra space after the opening parenthesis.

- nmap <buffer><expr> <Plug>(fern-my-open-or-expand)
+ nmap <buffer><expr><Plug>(fern-my-open-or-expand)

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [248-248]

There's an extra space at the beginning of the line.

- 	fern.vim
+ fern.vim

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [268-268]

The term "String" should not be capitalized unless it's at the beginning of a sentence or part of a title.

- A |String| used as leading space unit (one indentation level.)
+ A |string| used as leading space unit (one indentation level.)

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [287-287]

The term "pre-defeined" is misspelled. It should be "pre-defined".

- to change pre-defeined |highlight|.
+ to change pre-defined |highlight|.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [307-307]

The term "logfile" should be two words: "log file".

- A path |String| to log messages or |v:null| to log messages via |echomsg|.
+ A path |string| to log messages or |v:null| to log messages via |echomsg|.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [335-335]

The term "cursorline" should be two words: "cursor line".

- Set 1 to forcibly disable |cursorline| for the fern window
+ Set 1 to forcibly disable |cursor line| for the fern window

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [426-426]

The term "win_execute" should be two words: "win execute".

- Note that this feature is required the |win_execute| and popup/floatwin features.
+ Note that this feature requires the |win execute| and popup/floatwin features.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [434-434]

There's an extra whitespace before "If disabled".

- Set 1 to disable the drawer tabpage isolation.          If disabled, there is only one left or right drawer across all the windows and tabs for a given VIM instance.
+ Set 1 to disable the drawer tabpage isolation. If disabled, there is only one left or right drawer across all the windows and tabs for a given VIM instance.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [445-445]

Don't put a space before the full stop.

- g:fern#disable_drawer_smart_quit = 0
+ g:fern#disable_drawer_smart_quit = 0.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [479-479]

This sentence does not start with an uppercase letter.

- g:fern#disable_drawer_auto_restore_focus = 0
+ G:fern#disable_drawer_auto_restore_focus = 0

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [516-516]

The term "String" should not be capitalized unless it's at the beginning of a sentence or part of a title.

- A default |String| pattern used to filter nodes (include).
+ A default |string| pattern used to filter nodes (include).

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [553-553]

The term "String" should not be capitalized unless it's at the beginning of a sentence or part of a title.

- A |String| which is used as a mark symbol text.
+ A |string| which is used as a mark symbol text.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [588-588]

Use "the" before "the superlative" for grammatical accuracy.

- If {reveal} is specified, parent nodes of the node which is identified
+ If {reveal} is specified, the parent nodes of the node which is identified

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [620-620]

The verb "is" doesn't seem to fit in this context, "are" is probably more formally correct.

- If the {width} is specified, the width of the window is regulated to
+ If the {width} are specified, the width of the window is regulated to

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [662-662]

Is an article like 'a' or 'an' missing?

- If the node is leaf, the {leaf} is returned.
+ If the node is a leaf, the {leaf} is returned.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [689-689]

Use "the" before "the superlative" for grammatical accuracy.

- "anchor"		A nearest suitable window from a drawer style fern
+ "anchor"		The nearest suitable window from a drawer style fern

@ubaldot
Copy link

ubaldot commented Mar 16, 2024

I gave it a shot but for some reason it does not work on MacVim. I posted a small video, see below.

Screen.Recording.2024-03-16.at.11.20.41.mov

@lambdalisue
Copy link
Owner Author

I didn't recall what the default was, but it seems your <CR> is remapped to the expand action. What this pull request changed is the behavior of the enter action. So the expected behavior is something like:

CleanShot.2024-03-17.at.19.20.19.mp4

Is your desired behavior "Expand the branch node with Enter and go up to the root node with Enter"? Is that correct?

@ubaldot
Copy link

ubaldot commented Mar 17, 2024

Is your desired behavior "Expand the branch node with Enter and go up to the root node with Enter"? Is that correct?

Yes, exactly. For changing dire I have the following mapping:

nmap <buffer><nowait> cd <Plug>(fern-action-enter)<Plug>(fern-action-cd:cursor)<Cmd>pwd<cr>

@lambdalisue
Copy link
Owner Author

@ubaldot Got it. While everyone has different preferences, I think we should add a smart mapping helper function instead. Could you try #498 and see if that addresses your desired behavior?

@lambdalisue lambdalisue deleted the enter-to-leave-on-root branch March 17, 2024 22:52
@ubaldot
Copy link

ubaldot commented Mar 19, 2024

Hectic period... I will try to give it a shot tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to go up a directory with Return
2 participants