-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
'-' goes back to the netrw explorer but in a non unlisted buffer. #74
Comments
More info: So I wrote a wrapper functions (vimdir) that does arg checking (1 arg and said arg is a directory) and then calls:
After vim opens, I see a netrw screen and :ls! displays:
Compared to just
With this wrapper, if I open a file in the directory that I passed to vim (in this case '.'), it will open in a listed buffer. However if I use So I thought I had worked around the issue, but in the case that the file I'm opening in netrw is in the directory that I called vim upon, then EDIT: removing |
I can reproduce this without vinegar. IMHO this is netrw related.
UPDATE diff --git a/vinegar-edit.vim b/vinegar-Explore.vim
index f471141..529d620 100644
--- a/vinegar-edit.vim
+++ b/vinegar-Explore.vim
@@ -26,7 +26,7 @@ if !exists("g:netrw_banner")
endif
let s:netrw_up = ''
-nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('edit')<CR>
+nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('Explore')<CR>
if empty(maparg('-', 'n'))
nmap - <Plug>VinegarUp
endif
@@ -47,6 +47,7 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let @# = expand('%')
execute a:cmd '%:h/'
call s:seek(expand('#:t'))
endif
As far as I can see, the only use of function! s:opendir(cmd) abort
let df = ','.s:dotfiles
if expand('%:t')[0] ==# '.' && g:netrw_list_hide[-strlen(df):-1] ==# df
let g:netrw_list_hide = g:netrw_list_hide[0 : -strlen(df)-1]
endif
if &filetype ==# 'netrw'
let currdir = fnamemodify(b:netrw_curdir, ':t')
execute s:netrw_up
call s:seek(currdir)
elseif expand('%') =~# '^$\|^term:[\/][\/]' " Handle nvim term:// buffers
execute a:cmd '.'
else
execute a:cmd '%:h/'
call s:seek(expand('#:t'))
endif
endfunction However, if there is a reason to use |
I checked with alternating between If I keep the default @tpope has right now, the selected entry on pressing When I use Thus the problem of a stray netrw buffer stays for me even now. Any suggestions? |
@manasthakur: Does following help you? diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim
index 85ed2a4..d61cc10 100644
--- a/plugin/vinegar.vim
+++ b/plugin/vinegar.vim
@@ -50,7 +50,7 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
- execute a:cmd '%:h/'
+ execute a:cmd
call s:seek(expand('#:t'))
endif
endfunction UPDATE |
Yes, I checked. The problem persists. |
Another try: diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim
index 85ed2a4..c3f8a10 100644
--- a/plugin/vinegar.vim
+++ b/plugin/vinegar.vim
@@ -50,7 +50,11 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
- execute a:cmd '%:h/'
+ if exists(":Rexplore")
+ execute "Rexplore"
+ else
+ execute a:cmd '%:h/'
+ endif
call s:seek(expand('#:t'))
endif
endfunction |
Hi @kiryph . No, the behaviour still remains the same. |
Hi @manasthakur, did I get you right:
I can confirm this.
|
Hi @kiryph , The issue I am mentioning is the same as the title. If I use I understand that these anomalies have nothing much to do with vinegar, though. |
tpope added a seek function
empties the alternate file stored in
Storing the filename in a temporary variable circumvents this problem and should resolve your issue when using @@ -50,8 +50,9 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let alt_file = expand('%:t')
execute a:cmd '%:h/'
- call s:seek(expand('#:t'))
+ call s:seek(alt_file)
endif
endfunction However, I do not like that |
Hi @kiryph, Thanks for this. It works but still has an issue: if we close netrw using |
Hi @manasthakur, should following steps reproduce your issue with :bdelete in netrw returning to the wrong file:
I cannot reproduce it. Did you try @@ -50,8 +50,9 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let alt_file = expand('%:t')
execute a:cmd '%:h/'
- call s:seek(expand('#:t'))
+ call s:seek(alt_file)
endif
endfunction or @@ -47,6 +47,7 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let @# = expand('%')
execute a:cmd '%:h/'
call s:seek(expand('#:t'))
endif |
Hi @kiryph, Thanks for the detailed steps. I have used the first code-block, along with After step 4, when I ran p.s. However, I won't stretch this further if you are not able to reproduce this. Thanks again. |
Sorry I had an issue identifying which vinegar.vim script file was sourced by vim. I recently switched to dein.vim which caches plugins in an additional folder where you have to watchout which file is actually sourced. Now, I can reproduce your issue with @@ -50,8 +50,9 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let alt_file = expand('%:t')
execute a:cmd '%:h/'
- call s:seek(expand('#:t'))
+ call s:seek(alt_file)
endif
endfunction However, it should be resolved when you use instead @@ -47,6 +47,7 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let @# = expand('%')
execute a:cmd '%:h/'
call s:seek(expand('#:t'))
endif UPDATE UPDATE 2 @@ -47,6 +47,7 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let @# = expand('%')
+ normal! m`
execute a:cmd '%:h/'
call s:seek(expand('#:t'))
endif |
I add a complete patch with another addition taking the variable diff --git a/vinegar.vim b/vinegar-Explore.vim
index f471141..e16898c 100644
--- a/vinegar.vim
+++ b/vinegar-Explore.vim
@@ -26,7 +26,7 @@ if !exists("g:netrw_banner")
endif
let s:netrw_up = ''
-nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('edit')<CR>
+nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('Explore')<CR>
if empty(maparg('-', 'n'))
nmap - <Plug>VinegarUp
endif
@@ -47,8 +47,13 @@ function! s:opendir(cmd) abort
elseif expand('%') =~# '^$\|^term:[\/][\/]'
execute a:cmd '.'
else
+ let alt_file = expand('%:t')
+ if !exists("g:netrw_altfile") || g:netrw_altfile == 0
+ let @# = expand('%')
+ endif
+ normal! m`
execute a:cmd '%:h/'
- call s:seek(expand('#:t'))
+ call s:seek(alt_file)
endif
endfunction Hopefully, this
The behavior for the alternate buffer has to be clarified and should possibly be improved. Note, netrw intends to keep remote netrw buffers for speed reasons. |
It seems there is no variable If I change it to The patched fork is available here. |
Add experimental workaround to remove netrw buffers from the buffer list. This happens when using vinegar to navigate the directory of the current file: the netrw buffers may stick around unclosed [1], or the first netrw buffer will be part of the list of buffers [2]. It is annoying to navigate buffers with buffergator or ctrlp when there are several netrw buffers listed along with the open files. Try setting the bufhidden option to delete the netrw buffers, and use a custom function to delete that first netrw buffer that is not removed just by setting bufhidden. [1] tpope/vim-vinegar#13 [2] tpope/vim-vinegar#74
Add experimental workaround to remove netrw buffers from the buffer list. This happens when using vinegar to navigate the directory of the current file: the netrw buffers may stick around unclosed [1], or the first netrw buffer will be part of the list of buffers [2]. It is annoying to navigate buffers with buffergator or ctrlp when there are several netrw buffers listed along with the open files. Try setting the bufhidden option to delete the netrw buffers, and use a custom function to delete that first netrw buffer that is not removed just by setting bufhidden. [1] tpope/vim-vinegar#13 [2] tpope/vim-vinegar#74
I just came across the same issue. I had to change this...
...to this...
...to avoid the bug where pressing |
This change is borrowed from here: manasthakur@aea8f28 From the discussion here: tpope#74 (comment)
It is not needed anymore due to auto-save hooks and deleting it helps with this nasty vim-vinegar bug: Issue: tpope/vim-vinegar#74
Using :Ex directly opens netrw with an unlisted buffer. This allows me to use :bp/:bn to hop around between buffers without issue (and wraps when I get to the end). If at anytime I hit '-', it goes to a netrw explorer buffer that is listed, which causes some very odd :bp/:bn behavior.
Is there some config to force vinegar/netrw to always open in an unlisted buffer?
Note this seems to happen in 2 circumstances:
netrw list style is 3
if netrw list style is not 3, but you open a directory with vim:
vim .
In both of those cases there is at least 1 file explorer buffer that is not unlisted, which causes the - and
:bn/:bp
to misbehave.I'm wondering if there is a work around to this?
The text was updated successfully, but these errors were encountered: