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

Neotree improvements or replacement #29

Closed
syl20bnr opened this issue Oct 24, 2014 · 35 comments
Closed

Neotree improvements or replacement #29

syl20bnr opened this issue Oct 24, 2014 · 35 comments

Comments

@syl20bnr
Copy link
Owner

Discussion started with issue #28.

we have 2 possibilities:

  • we mode it to be usable (proper key bindings, remove mode-line, toggle on and off with automatic focus, make it play nice with window numbering and golden-ratio)
  • we replace it

I lack knowledge for sidebar things since I don't use them (I use ido and helm projectile) so any proposal is welcome.

@trishume
Copy link
Contributor

This evening I added some stuff to my contrib module that allows hiding all the cruft in dired and also expanding sub-directories inline, but I'm not very happy with it. It's better than standard dired but not good enough to be a sidebar.

I'm somewhat unsatisfied with all the emacs file trees, as well as with my console file browser (https://github.com/trishume/MacRanger), and I don't like my GUI file browser either. So I might end up using emacs as a platform for writing my own file browser that is good enough to function as a sidebar, as well as a primary file manager when put in its own frame.

Or I might just end up modifying something like direx or speedbar to suit my wishes.

@syl20bnr
Copy link
Owner Author

OMG I'm a heavy user of ranger, I will try your OS X fork!

What kind of features do you expect in a good sidebar ?

@trishume
Copy link
Contributor

Holy shit you use ranger as well? Wow you use all the coolest/my favourite things: emacs+vim, ranger, ledger, fish, i3, osx, Github ...

Anyways I did some investigating last night and I'm pretty sure the problems I'm having with ranger are probably due to some kind of performance bug in the rendering code of iTerm2. I think I'm gonna try to fix that rather than write a new one, and then I'll write a plugin for ranger that keeps one of its tabs synced up with emacs.

Currently my OSX fork is really hard to set up, you need some extra files to get it to work nice (a patched font and a prefs file for the custom iTerm2 fork), I'm going to try packaging those in an app build, but if you don't want to wait I can just email them to you.

@syl20bnr
Copy link
Owner Author

I'm looking for your project and will try it when the setup is less complicated.
It's true that iTerm is slow with ranger, actually my dev environment in OS X is under XQuartz with i3 and i3ci (a crazy modal configuration for i3 I still have to document and screencast), ranger and emacs.

@trishume
Copy link
Contributor

Progress on ranger integration:

  • Fixed bugs in both iTerm and in Ranger that caused lag
    • Example: Ranger re-outputs everything many times a second all the time, even when nothing changes, iTerm's internal data structures got clogged over many hours of this and became laggy.
    • Solution: Added a sleep mode to Ranger that makes it not redraw when there is no input and no jobs are ongoing.
  • Made ranger responsive: can change to single column when resized
  • Added a control server to ranger that enables emacs to create a special tab that is synced to the current projectile directory.

With this I can add a mode to my window manager that puts ranger in a skinny window next to emacs and it will sync up with what I'm doing. Functioning as a sidebar with the awesomely good file manager powers of Ranger.

Currently everything is in my MacRanger forks but I plan on factoring out the bug fixes into pull requests and the control server and responsiveness into plugins that work with any ranger install.

This doesn't fix the problem that basic emacs doesn't have a good sidebar. But if people don't like neotree they can just install my ranger-control plugin and then enable my ranger-control contrib module (PR coming soon).

@syl20bnr
Copy link
Owner Author

@trishume This looks very promising. If iTerm is not required then maybe it is possible to have the ranger process in a term ?
Is the synchronization bi-directional ? (ie. If I switch the current buffer in Emacs then the ranger sidebar automatically select this buffer)

By the way, did you mean ranger instead of projectile ?

@syl20bnr
Copy link
Owner Author

Oh I see, a ranger tab inside the current projectile project directory. Very clever :-)

@trishume
Copy link
Contributor

Yah currently the synchronization is single direction. When you execute the shortcut <SPC> p c it switches the tab labelled 'e' in ranger to the current projectile root. Ranger actually supports tab labels that aren't numbers and they always sort after the numbers, which is nice, you just have to configure shortcuts to switch to them (I also have the 's' tab synced to my current shell pwd). I also have ranger set up to open text files with emacsclient so that is how I do the direction of ranger->emacs.

I tried to get the projectile project found hooks to work so that it would automatically change to a project when you opened but I couldn't, although I didn't try for very long.

There is nothing iTerm specific about the control and responsive stuff at least, so if the emacs terminal emulator is good enough to run ranger that could work. Popwin with a responsive single column synced ranger window could be cool. I'm just going to have a window manager shortcut to put a skinny MacRanger window next to my emacs though, so that I get the fancy MacRanger features like icons. But an emacs window would require much less configuration for others who wanted to use my stuff.

@punassuming
Copy link
Contributor

You all ever try to go the route of Tpope's vim package vinegar and just try to integrate dired better with the system?

@Olical
Copy link
Contributor

Olical commented Oct 29, 2014

I actually use dired at bit like vinigar. C-x j drops into it I think,
and pressing it again goes up another level. All it takes is binding - in
normal mode to dired, right?
On 29 Oct 2014 20:13, "Rich Alesi" notifications@github.com wrote:

You all ever try to go the route of Tpope's vim package vinegar and just
try to integrate dired better with the system?


Reply to this email directly or view it on GitHub
#29 (comment).

@syl20bnr
Copy link
Owner Author

@Wolfy87 C-j is for next ido item in spacemacs (after <SPC> f f). I don't think original C-j is remapped to something else.

@Olical
Copy link
Contributor

Olical commented Oct 29, 2014

Sorry, I meant C-x C-j. It starts dired in the directory of your current file and will continue to move up the parent directories each time you press the key combination. This is pretty much how vim-vinigar works but it uses the - key in normal mode. I think.

I tried to use markdown in an email response, it didn't work :)

@syl20bnr
Copy link
Owner Author

The recent questions [1] from @tuhdo on Emacs exchange about dired and his comments on /r/emacs show that it is a pretty solid solution. Maybe we should give it a try.

[1] http://emacs.stackexchange.com/users/200/tu-do

@tuhdo
Copy link
Contributor

tuhdo commented Oct 30, 2014

Since this is emailed to me, I have a alternative suggestion for file navigation in replacement of a file browser: How about we browse file by searching files. This can be achieved with Projectile and/or Helm:

You can create a virtual directory that groups files in different physical directories together to form a logical unit. DEMO.

  • First, I create a Dired buffer from the action that contains all my setup files in my .emacs.d.
  • Then, I bookmark the newly created Dired buffer and kill it. As you can see, when I finish creating the bookmark, the bookmark list got updated immediately.
  • Finally, I open that bookmarked Dired buffer again from the bookmark list, so I can reuse it future session.

Personally, I think Dired is really nice already. With dired-x, you can press C-x C-j or C-x 4 C-j to open current directory in current window/other window. I like the way sub-directories in handled in stock Dired better than the typical tree file browsers out there, because I can insert unlimited number of sub-directories without cluttering up the little space I use for a file browser.

@syl20bnr
Copy link
Owner Author

Thank you very much @tuhdo for taking time to reply and link your demos. This is a lot of info so I need some time to study them and testing them in my workflow.

@trishume
Copy link
Contributor

I certainly agree with @tuhdo that search based interfaces can be exceptionally powerful, and he has some cool ideas that could certainly be added to spacemacs' file finding functionality.

However, I also like having a normal browser around. I use search when I'm working with a codebase I know and a file tree when I'm working with a new codebase.

I looked into getting Ranger to run within emacs, but eshell isn't good enough to run curses so ranger crashes. So I'm going to solve my personal problem with MacRanger+window management+ranger-control but that's probably a no-go for most spacemacs users so it would probably be good to include some better dired fanciness by default.

@punassuming
Copy link
Contributor

I would love to get Ranger working within emacs, but I curses support on Windows is abysmal.

@Wolfy87 In terms of emulating vinegar, I have the following keybindings set up:

(define-key dired-mode-map "-" 'dired-up-directory)
(define-key evil-normal-state-map (kbd "-") 'dired-jump)

That way, I only press - regardless of whether I am in dired or not to move around.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

@Ralesi Would be cool to add - to NeoTree configuration if possible.

@tuhdo
Copy link
Contributor

tuhdo commented Nov 4, 2014

How about speedbar and its package sr-speedbar (this package allows speedbar to be in a window instead of a frame)? Here is a speedbar demo. The cool thing about speedbar is that it automatically switches directory tree - when you switch buffer - to the default-directory of current buffer. By default, sr-speedbar is dedicated; that means it will always available even if you press C-x 1, so you don't have to reopen the tree.

Speedbar also gives Semantic content of each file (such as include/import and variable/function definitions), and you can click on those semantic nodes. With all these features, I think it's much better than NeoTree.

EDIT: If the current buffer is in a subdirectory of the directory sr-speedbar currently display, instead of switching the tree, it expands all the way down to the directory that contains the current buffer. It's really nice.

EDIT2: By default, speedbar won't show all files, but only source code files. To show all files:

(setq speedbar-show-unknown-files t)

EDIT3: You can always toggle the speedbar if you like, with sr-speedbar-toggle.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

@tuhdo Interesting that you mentioned it since I had a hard time to make it work with.... helm :-) In spacemacs helm is configured to appear always at the bottom of the screen.
What's your configuration to make them play nice together ?

@tuhdo
Copy link
Contributor

tuhdo commented Nov 4, 2014

I use it fine with Helm out of the box. I'm curious, why do you want Helm always appear at the bottom? Isn't that's a waste of screen estate? Even so, what's the specific problem when you make Helm that way?

@tuhdo
Copy link
Contributor

tuhdo commented Nov 4, 2014

I think I misunderstood what you said earlier. I thought that you said Helm buffer is always visible, and that it conflicts with sr-speedbar. If you don't want Helm to open in sr-speedbar window (my guess), add these configurations:

;; open helm buffer inside current window, not occupy whole other window
(setq helm-split-window-in-side-p t) 

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

The speedbar is duplicated whenever helm buffer appears.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

@tuhdo
Copy link
Contributor

tuhdo commented Nov 4, 2014

Reverse this:

(setq helm-split-window-in-side-p nil
         helm-always-two-windows t)

To:

(setq helm-split-window-in-side-p t
         helm-always-two-windows nil)

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

I cannot succeed in reproducing the duplication, but with both configurations the helm buffer sometimes appear at the bottom, sometimes at the right which is a no go.
I would like to support sr-speedbar but it has first to play nice with helm (always appear at the bottom) and golden-ratio. Which is something we achieved with neotree.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

@tuhdo Other alternative which may be better is to have helm always appear at the right or left depending on the selected buffer but never appear at the bottom (like helm-swoop does).

@tuhdo
Copy link
Contributor

tuhdo commented Nov 4, 2014

@syl20bnr I also use golden-ratio along with Helm and have no such problem. And helm-swoop always appears at the bottom.

What's your helm-split-window-default-side value? If this is configured to 'other, it will always use other window. The default value is 'below, but helm-split-window-in-side-p and helm-always-two-windows always take precedence.

@tuhdo
Copy link
Contributor

tuhdo commented Nov 4, 2014

I've just tried spacemacs with this configuration:

(setq helm-split-window-in-side-p t
helm-always-two-windows nil)

There's no problem at all. I don't see the symptom you described, and helm-swoop is always at the bottom.

Btw, nice distribution. There's some suggestions:

  • You should use the real helm-M-x for M-x as well.
  • You should use helm-find-files for gf. The command can find file at point as well.
  • You can exclude these modes from golden-ratio:
  (setq golden-ratio-exclude-modes '("ediff-mode"
                                     "gud-mode"
                                     "gdb-locals-mode"
                                     "gdb-registers-mode"
                                     "gdb-breakpoints-mode"
                                     "gdb-threads-mode"
                                     "gdb-frames-mode"
                                     "gdb-inferior-io-mode"
                                     "gud-mode"
                                     "gdb-inferior-io-mode"
                                     "gdb-disassembly-mode"
                                     "gdb-memory-mode"
                                     "magit-log-mode"
                                     "magit-reflog-mode"
                                     "magit-status-mode"
                                     "IELM"
                                     "eshell-mode"
                                     "dired-mode"
                                     "pdf-outline-buffer-mode"
                                     "speedbar-mode"))

EDIT: You could replace auto-highlight-symbol with highlight-symbol. It offers the same feature and also offer navigation among highlighted symbols. Very useful.

(require 'highlight-symbol)
(highlight-symbol-nav-mode)
(add-hook 'prog-mode-hook (lambda () (highlight-symbol-mode)))
(add-hook 'org-mode-hook (lambda () (highlight-symbol-mode)))
(setq highlight-symbol-idle-delay 1
        highlight-symbol-on-navigation-p t)
(global-set-key (kbd "M-n") 'highlight-symbol-next)
(global-set-key (kbd "M-p") 'highlight-symbol-prev)

You can also customize highlight-symbol-face to fit your theme.

@danielwuz
Copy link
Contributor

@tuhdo auto-highlight-symbol can also navigate among symbols with ahs-backward and ahs-forward.

One thing I like about auto-highlight-symbol is that you can easily change its scoping to either "buffer", "visiable area" or "defun", those are very handing when renaming things in a file or function.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 4, 2014

This helm configuration thing makes me dizzy but we wil find the ultimate configuration :-)
I will try harder this evening about this. I would want to be able to achieve this:

no matter how many windows there are in the frame, when `helm` shows up
the frame would reduce to only 2 windows vertically separated with one being
the focused buffer and the other the helm buffer (like helm-swoop did on my box).

Thank you @tuhdo for the list of exclude modes for golden-ratio I will try them all.

@danielwuz +1

@tuhdo
Copy link
Contributor

tuhdo commented Nov 5, 2014

@danielwuz But highlight-symbol allows you to highlight any symbol persistently aside from current symbol at point. As for renaming things in a defun, you can narrow and query-replace/iedit easily, so you don't actually need to highlight in a defun.

@syl20bnr hmm why do you always need two windows? I think helm buffer for only active window look less confusing and less intrusive? I tried my suggested configuration and it has no problem with sr-speedbar in your distribution.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 5, 2014

@tuhdo to highlight any symbol persistently we can just use incremental search with /. Narrow then query replace then widen is not needed with ahs and the micro-state of spacemacs. Give it a try: https://github.com/syl20bnr/spacemacs#auto-highlight-symbols

@tuhdo
Copy link
Contributor

tuhdo commented Nov 5, 2014

@syl20bnr I see. If that is the case, it's better highlight-symbol then. But the highlighting I mentioned is that you can highlight multiple symbols with multiple colors at the same time without depending on incremental search. But I think the feature to replace local highlight is better.

@syl20bnr
Copy link
Owner Author

Seems that a sidebar is not an important component of spacemacs. I close this discussion.

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

No branches or pull requests

6 participants