justinmk / vim-dirvish

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

g:dirvish_relative_paths : reload is required after changing directory #98

Closed davidsierradz closed 6 years ago

davidsierradz commented 6 years ago

I think let g:dirvish_relative_paths = 1 its not working, I dont see any changes in the way the dirvish buffer shows the current path in the statusline (its always absolute paths), also if set to 1 the error in the title is show

Manjaro Linux - i3: 17.0.6 Neovim version: NVIM v0.2.2-5-ge98bcf052

minimal init.vim file:

call plug#begin('~/.local/share/nvim/plugged')
Plug 'justinmk/vim-dirvish'
call plug#end()
let g:dirvish_relative_paths = 1

Open a terminal:

$ pwd shows /home/user

$ nvim Code/FooBar opens neovim inside a dirvish buffer

:pwd shows /home/user

:cd %

:pwd shows /home/user/Code/FooBar

Try to open some directory or file shows (For example the App directory):

dirvish: invalid (or access denied): Code/FooBar/App/

Investigating more after :cd % if I press R to reload the buffer, the error doesn't happen, maybe do a refresh of the buffer after :cd %? If I set let g:dirvish_relative_paths = 0 there is no need to press R after :cd %.

If I :set statusline=%f to show relative paths in the statusline inside a dirvish buffer the statusline always show absolute paths, doesn't matter what value g:dirvish_relative_paths is set to.

Sorry bad english, and thanks!

justinmk commented 6 years ago

I dont see any changes in the way the dirvish buffer shows the current path in the statusline

It doesn't affect the statusline. Dirvish buffer name is always absolute, for predictability. The way Vim changes the buffer name depending on current directory is insane.

g:dirvish_relative_paths affects the buffer contents. You can check it with:

:set conceallevel=0

Investigating more after :cd % if I press R to reload the buffer, the error doesn't happen, maybe do a refresh of the buffer after :cd %

If you change CWD while viewing an existing Dirvish buffer, the relative paths in the buffer are no longer valid. Yes, R is required then.

:set statusline=%f shows the buffer name. If you want it to be relative, use something like

:set statusline=%{fnamemodify(bufname('%'),':.')}
justinmk commented 6 years ago

Nvim has a DirChanged event which could be used to reload all dirvish buffers when CWD changes. But this is ugly, for little gain. g:dirvish_relative_paths is not really needed if you have a recent version of vim, anyways.

if exists('##DirChanged') && get(g:, 'dirvish_relative_paths', 0)                                                                                              
  augroup dirvish_dirchanged                                                                                                                                   
    autocmd!                                                                                                                                                   
    autocmd DirChanged * " TODO: reload all dirvish buffers ...                                                                                                      
  augroup END                                                                                                                                                  
endif