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

Support open from different roots? #77

Open
xaljer opened this issue Sep 20, 2020 · 27 comments
Open

Support open from different roots? #77

xaljer opened this issue Sep 20, 2020 · 27 comments

Comments

@xaljer
Copy link

xaljer commented Sep 20, 2020

  • open from working directory
  • open from root directory of VSC repository
  • open from directory which current file in
@ms-jpq
Copy link
Owner

ms-jpq commented Jan 21, 2021

good idea, this is pretty easy to do

@przepompownia
Copy link

I did not found NERDTreeFocus equivalent (able to focus on each file from different projects in one vim instance, without touching CWD).

I also did not found how to open directory selected by cmdline (CHADOpen /tmp for example).

Both features seems to be related to this issue.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

NERDTreeFocus should be easy to do as well actually i should just do both of these at once

#120

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

:CHADopen will toggle CHADTree open / close

CHADopen <path> will open at <path>

:CHADopen --always-focus will disable toggle if already opened

:CHADopen --nofocus will open CHADTree without giving the sidebar focus

@ms-jpq ms-jpq closed this as completed Jan 26, 2021
@przepompownia
Copy link

przepompownia commented Jan 26, 2021

Thanks for the change. It works but not quite in expected way.

  • CHADopen /tmp executed from buffer opens CHADTree as expected.
  • CHADopen /another/dir executed from chadtree closes CHADTree (at the next CHADopen without arguments /another/dir is visible).
  • expand()ing arguments does not work (CHADopen % for example)
  • CHADopen /regular/file does not focus CHADTree on /regular/file (it opens CWD).
  • if the current file is in dir then CHADopen dir --always-focus makes focus on CHADTree only. Cursor does not land on the file - it happens after wincmd p.
  • completion does not work, both on available options and files

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

  1. is a good point, will fix

  2. was addressed in another issue. need to use &ft == 'CHADTree'. expand has a good chance of conflicting with other plugins that watch the bufnames.

  3. won't do. I think what you are suggesting is worse UX.

  4. need to use --no-focus if you dont want to focus.

  5. maybe, its pretty easy to add, but I kept it out of CHADTree on purpose.

I am happy if people just have something in their clipboard and they want to open it with :CHADTree, I do want to steer people away from using it to open files by manually typing in :CHADTree and then searching for the file they want.

Something like that is strictly inferior than say if they used fzf, or many of the other plugins.


Anyways, thank you very much for the suggestions, I will add them as I see fit. My goal for CHADTree is to make something modern and has a cohesive design, and purposefully eschew doing things the "old way" just because they were done in so and so fashion in the past.

@ms-jpq ms-jpq reopened this Jan 26, 2021
@przepompownia
Copy link

Yet one side effect: CHADopen /tmp/vim.log opens buffer with /tmp/vim.log in the current window (and opens CHADTree on the recently used dir). Expected behiaviour (from NERDTreeFocus user point of view): the buffer window left untouched, CHADTree window puts the cursor on the file selected in command argument.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

I updated my thing above with my reasoning for not copying NERDTree. I understand that muscle memories are hard to develop, but I am not trying to make NeoNERDTree.

My goal is to make something good by adding in things that make sense when put together with the other features, not to match other plugins 1:1 in terms of UX.

If im missing a feature, I will almost always consider adding it, but I have to control how much I add and for what purpose should I add these.

Thank you very much for the list of suggestion tho, I very much appreciate it.

I will tack on the fix for point 2 on #124, since its relatively small

@przepompownia
Copy link

I not suggest you to copy NERDTree UX - I use it as a commonly known example of some practical usages missing there.

@przepompownia
Copy link

1. is a good point, will fix

2. was addressed in another issue. need to use `&ft == 'CHADTree'`. `expand` has a good chance of conflicting with other plugins that watch the bufnames.

3. won't do. I think what you are suggesting is worse UX.

4. need to use `--no-focus` if you dont want to focus.

5. maybe, its pretty easy to add, but I kept it out of CHADTree on purpose.

How expand() of some command argument can conflict with any other tool?

Why the feature of jumping directly to file position on tree is bad? It saves me from manual moving to the file on the tree. It is for me the most often used action on NERDTree. It can be implemented without breaking anything else.

I meant that the cursor does not land on the file item on the tree: CHADTree focuses the cursor only on itself - not on the file item.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

alot of plugins actually check the buffer name via expand, and act on them. For example netrw, the built-in file mananger will just replace the buffer with itself if it sees any path that exists. I have noticed the same thing for other file managers as well. This can be confusing to the users and I do not want them to deal with it.

There is nothing with with &ft == '...', in fact its even shorter.

To your second point, I think I misunderstood you, you are right it is a better default to focus on the sidebar not the file as a default.

@przepompownia
Copy link

My English is still poor and it is very possible that lots of misunderstanigs have source on my side.

I still do not understand the reason for which you want to keep expanding disabled (apart from it could be optional). In most cases I would like to jump to the current file item on the tree using a custom mapping. I can write a custom function that does it if you don't want - this is a secondary issue.

The basic is to can jump directly to given file position on the tree (independently of where the file is placed). Probably we can ask which directory set then as the new root of the tree and how much views of tree we want to keep at once (for two different tabs for example).

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

Oh English is not your first language? that makes sense. I think we both misunderstood each other. Thank you for keep going even if there is some communication issues, thats really awesome.

So I've given it more thought, the root should be placed at a the lowest common ancestor between cwd and path, where path is defined as :CHADopen <path>

@przepompownia
Copy link

The lowest common ancestor policy sounds reasonably.

At the moment, amongst four non-blocking file explorers CHADTree seems to me the most worthy of attention and effort (because of UI and dependencies) - also for breaking misunderstandings. Thank you also for continuing the discussion.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 26, 2021

This PR I think interoperates most of your suggestions #127

@przepompownia
Copy link

Jumping to selected file item seems to work, thank you! 🎉

Side effect mentioned there still exist.

With CHADopen /file I would like to jump to /file item only (usually to browse its neighborhood) and keep the current buffer in window. To replace the current buffer with /file :edit /file is enough.

@przepompownia
Copy link

I also noticed more than one CHADTree view instances 👍

CHADOpen --vcs-toplevel /path (relative to the current buffer if no /path given) would be appreciated as @xaljer suggests. CHADTree is git-aware.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 27, 2021

ohhh I thought u wanted that behaviour so I specifically added it in lol. yeah not having it open the file is more logical.

yes i can add in a vsc top lv. im going to do these after I get windows working. im so close

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 27, 2021

#134

Please check if you still want anything.

@przepompownia
Copy link

  • CHADOpen --version-ctl without arguments opens CHADTree relative to CWD, not to the current file (if such exists). It is still very limited usability especially when I have open files from more than one project at once.
  • CHADOpen --version-ctl /file works as above.

Thanks anyway.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 29, 2021

CHADOpen --version-ctl without arguments opens CHADTree relative to CWD, not to the current file (if such exists). It is still very limited usability especially when I have open files from more than one project at once.

It actually doesn't open with regards to cwd.

Try it under a sub directory of git folder. It opens at the top level where the git root is.

It just happens that most of the time git root is cwd.

I will close this because that's the logical behaviour.

@ms-jpq ms-jpq closed this as completed Jan 29, 2021
@ms-jpq ms-jpq reopened this Jan 29, 2021
@ms-jpq
Copy link
Owner

ms-jpq commented Jan 29, 2021

wait i think I just realized what you meant, you want the top level to be git root but keep focus on same file,

oh...

edit:

its ok communication between two people who speak different languages can be confusing

#138

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 29, 2021

#140

@ms-jpq ms-jpq closed this as completed Jan 29, 2021
@przepompownia
Copy link

przepompownia commented Jan 29, 2021

Now execute 'CHADopen --version-ctl /path/to/file' opens CHADtree focused at /path/to/file as expected. The root of tree is still not set to VCS toplevel.

@ms-jpq
Copy link
Owner

ms-jpq commented Jan 29, 2021

oh right, i just figured i should let /path/to/file pick the top level but I see how you would want both, sigh. so much work LOL

@ms-jpq ms-jpq reopened this Jan 29, 2021
@przepompownia
Copy link

Maybe writing tests would make expectations more precise from my side.

@ms-jpq
Copy link
Owner

ms-jpq commented Feb 24, 2021

ok fixing this next

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

No branches or pull requests

3 participants