justinmk / vim-dirvish

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

dir up stopped working #226

Closed TamaMcGlinn closed 2 years ago

TamaMcGlinn commented 2 years ago

I was used to being able to press - to go up from one directory to its parent. This commit broke that:

├ 2022-07-13 [6f52d72] {Justin M. Keyes} fix: <Plug>(dirvish_up) fails on crazy filenames

I'm still investigating why.

justinmk commented 2 years ago

Thanks for the report. I definitely tested this on unix + Windows, with various dirvish settings, so will need exact steps to reproduce.

TamaMcGlinn commented 2 years ago

Found it; looks like you removed this default mapping accidentally:

if !hasmapto('<Plug>(dirvish_up)', 'n')
  execute 'nmap '.s:nowait.'<buffer> - <Plug>(dirvish_up)'
endif
justinmk commented 2 years ago

It wasn't an accident, there is already a global mapping defined in plugin/dirvish.vim. Did you, or a plugin, override the global - mapping? If so, you can define a buffer-local one:

au FileType dirvish nmap - <plug>(dirvish_up)
TamaMcGlinn commented 2 years ago

Yes, I had defined the global - mapping to open the directory of the current file in Dirvish, which feels consistent with using - inside Dirvish. Yes, of course I can just copy the line into my local config to fix this instead. Thanks.

justinmk commented 2 years ago

I had defined the global - mapping to open the directory of the current file in Dirvish, which feels consistent with using - inside Dirvish.

Hmm, that's been the default behavior of global - for a long time.

Also recently changed :Dirvish command to do that: https://github.com/justinmk/vim-dirvish/commit/a65debefd9928f331587c76f20a41fedf827fc4c

TamaMcGlinn commented 2 years ago

Just a typical case of spacebar heating :) I am adjusting the workaround in my plugin, no need for any changes in dirvish. In case you're interested in the details:

I use terminals inside NeoVim a lot, and sometimes I change directories in that terminal, but then find I want to quickly open up one of the directories mentioned on the commandline. Since just remapping inside ftplugin/terminal.vim doesn't work (vim-dirvish mapping takes preference over it), my chosen hack was to remap globally and check the filetype inside the function:

function! browsedir#BrowseDir() abort
  if &buftype ==# 'terminal'
    let l:dir = dirhere#GetDirFromPrompt()
    call better_gf#JumpToNormalBuffer()
    execute ':e '.l:dir
  else
    e %:h
  endif
endfunction

Since I also wanted to support people using non-Dirvish editors, I call e %:h which ends up calling Dirvish. This happened to work because Dirvish was also mapping the key again in the ftplugin file.

I was, of course, not aware of any of this interplay until your recent commit, which rightly calls the ftplugin mapping superfluous.

miguel9554 commented 1 year ago

Is this solved? I'm having the same problem

TamaMcGlinn commented 1 year ago

Yes; my fix was in this commit, and you can install the browsedir plugin to fix this for you as well.

miguel9554 commented 1 year ago

OK thank you that fixed it, would be interesting to find the offending mapping too