justinmk / vim-dirvish

Directory viewer for Vim :zap:
Other
1.18k stars 64 forks source link

g:dirvish_mode won't work if g:dirvish_relative_paths = 1 #153

Closed zealotrush closed 4 years ago

zealotrush commented 4 years ago

Here is a simple way to reproduce this issue.

  1. Prepare a test folder as below.
tree -a .
.
├── .hidden
├── bar
├── folder-a
├── folder-b
└── foo

2 directories, 3 files
  1. In $MYVIMRC file, add these settings:
let g:dirvish_mode = ':sort ,^.*[\/],'
let g:dirvish_relative_paths = 0
  1. Open vim, press - to open Dirvish. It can be seen that folders are displayed first, which means the g:dirvish_mode settings is effective.
folder-a/
folder-b/
.hidden
bar
foo
  1. Change g:dirvish_relative_paths to 1. Repeat step 3. Folders are no longer displayed first.
bar
folder-a/
folder-b/
foo
.hidden

By saying vim, I'm actually referring to Neovim v0.4.3.

Is this a bug, or it's just I missed something?

justinmk commented 4 years ago

Did you try navigating to another directory? It should work for all directories except "current directory" (:pwd). Because

:sort ,^.*[\/],

depends on at least one slash (/) existing in each buffer line. With relative paths some lines may not have slashes. See also :help :sort.

This works instead:

:sort ,^\v(.*[\/])|\ze,

More discussion in https://github.com/justinmk/vim-dirvish/issues/89 .

zealotrush commented 4 years ago

It worked. Thanks!

But now I cannot hide hidden files in Dirvish buffer with g:dirvish_relative_paths = 1. Here is my dirvish config:

let g:dirvish_mode =
      \ ':sort ,^\v(.*[\/])|\ze, | silent keeppatterns g@\v/\.[^\/]+/?$@d _'
let g:dirvish_relative_paths = 1

The regex is a little bit obscure to me. Could you please help me?