-
-
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
Update g:netrw_list_hide from wildignore when entering netrw #69
Comments
Following code change updates function! s:setup_vinegar() abort
+ if exists("w:netrw_wigkeep")
+ let g:netrw_list_hide =
+ \ join(map(split(w:netrw_wigkeep, ','), '"^".' . s:escape . '. "$"'), ',') .
+ \ ',^\.\.\=/\=$' .
+ \ (get(g:, 'netrw_list_hide', '')[-strlen(s:dotfiles):-1] ==# s:dotfiles ? ','.s:dotfiles : '')
+ endif
+
if empty(s:netrw_up)
" save netrw mapping
let s:netrw_up = substitute(maparg('-', 'n'), '\c^:\%(<c-u>\)\=', '', '') NOTES:
❯ git diff
diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim
index f471141..d228e78 100644
--- a/plugin/vinegar.vim
+++ b/plugin/vinegar.vim
@@ -20,7 +20,7 @@ let g:netrw_sort_sequence = '[\/]$,*,\%(' . join(map(split(&suffixes, ','), 'esc
let s:escape = 'substitute(escape(v:val, ".$~"), "*", ".*", "g")'
let g:netrw_list_hide =
\ join(map(split(&wildignore, ','), '"^".' . s:escape . '. "$"'), ',') . ',^\.\.\=/\=$' .
- \ (get(g:, 'netrw_list_hide', '')[-strlen(s:dotfiles)-1:-1] ==# s:dotfiles ? ','.s:dotfiles : '')
+ \ (get(g:, 'netrw_list_hide', '')[-strlen(s:dotfiles):-1] ==# s:dotfiles ? ','.s:dotfiles : '')
if !exists("g:netrw_banner")
let g:netrw_banner = 0
endif To understand better the mistake in indexing see this simple example: let s:string1 = '0123'
let s:string2 = '456789'
let s:string = s:string1.s:string2
if s:string[-strlen(s:string2):-1] == s:string2
unsilent echom "s:string[-strlen(s:string2):-1]=".s:string[-strlen(s:string2):-1]."(== s:string2)"
endif
if s:string[-strlen(s:string2)-1:-1] == s:string2
unsilent echom "s:string[-strlen(s:string2)-1:-1]=".s:string[-strlen(s:string2)-1:-1]."(== s:string2)"
endif As far as I have understood the code, the only allowed pre-defined value for g:netrw_list_hide is the value of s:dotfiles. Therefore, the code could be made more readable: |
(1) s:setup_vinegar() is called two times; second time &wig is empty, use netrw save w:netrw_wigkeep (2) Fixed index bug when copying existing code: from [-strlen(s:dotfiles)-1:-1] to [-strlen(s:dotfiles):-1] For more details see tpope#69
(1) s:setup_vinegar() is called two times; second time &wig is empty, use netrw save w:netrw_wigkeep (2) Fixed index bug in existing code and in its copy of it: from [-strlen(s:dotfiles)-1:-1] to [-strlen(s:dotfiles):-1] see also tpope#69
(1) s:setup_vinegar() is called two times; second time &wig is empty, use netrw save w:netrw_wigkeep (2) Fixed index bug in existing code and in its copy of it: from [-strlen(s:dotfiles)-1:-1] to [-strlen(s:dotfiles):-1] see also tpope#69
(1) s:setup_vinegar() is called two times; second time &wig is empty, use netrw save w:netrw_wigkeep (2) Fixed index bug in existing code and in its copy of it: from [-strlen(s:dotfiles)-1:-1] to [-strlen(s:dotfiles):-1] see also tpope#69
Update
|
That seems like a no brainer. You can check for If the stuff in the rest of this issue is still relevant I'll entertain it too. Perhaps opening a fresh PR is the way to go? |
I am struggling with this right now. My testing scenario is following
I would have hoped that my netrw window would pick this up via the event However, Surprisingly, a Can you confirm this? BTW: vim-sensible interfers with netrw regarding
I would open a fresh PR if the refresh issue could be figured out. |
I can emphasize once again that, instead of pressing This looks like a netrw issue. I will send an email to Charles Campbell whether he can confirms this and can fix this. My own try by adding |
After some further digging around in "netrw version 163
1689:" s:NetrwOptionsSafe: sets options to help netrw do its job {{{2
1725: call s:NetrwSetSafeSetting("&l:wig","") " wig=wildignore This, however, also triggers the event IMHO it looks like Charles Campbell does not think that the value of |
I have found a solution by shielding the ❯ g diff
diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim
index 9473d70..c1361e5 100644
--- a/plugin/vinegar.vim
+++ b/plugin/vinegar.vim
@@ -19,9 +19,6 @@ endfunction
let s:dotfiles = '\(^\|\s\s\)\zs\.\S\+'
let s:escape = 'substitute(escape(v:val, ".$~"), "*", ".*", "g")'
-let g:netrw_list_hide =
- \ join(map(split(&wildignore, ','), '"^".' . s:escape . '. "/\\=$"'), ',') . ',^\.\.\=/\=$' .
- \ (get(g:, 'netrw_list_hide', '')[-strlen(s:dotfiles)-1:-1] ==# s:dotfiles ? ','.s:dotfiles : '')
if !exists("g:netrw_banner")
let g:netrw_banner = 0
endif
@@ -36,6 +33,16 @@ nnoremap <silent> <Plug>VinegarTabUp :call <SID>opendir('tabedit')<CR>
nnoremap <silent> <Plug>VinegarSplitUp :call <SID>opendir('split')<CR>
nnoremap <silent> <Plug>VinegarVerticalSplitUp :call <SID>opendir('vsplit')<CR>
+if exists('##OptionSet')
+ augroup Vinegar_redraw_netrw_windows
+ autocmd!
+ autocmd OptionSet wildignore,suffixes let s:currwin=winnr() | silent windo
+ \ | if &ft=='netrw' && !exists('w:netrw_wigkeep') && !exists('w:vinegar_ctrl_l')
+ \ | execute "normal \<C-L>" | endif
+ \ | execute s:currwin . 'wincmd w'
+ augroup END
+endif
+
function! s:opendir(cmd) abort
let df = ','.s:dotfiles
if expand('%:t')[0] ==# '.' && g:netrw_list_hide[-strlen(df):-1] ==# df
@@ -97,6 +104,13 @@ function! s:escaped(first, last) abort
endfunction
function! s:setup_vinegar() abort
+ if exists("w:netrw_wigkeep")
+ let g:netrw_list_hide =
+ \ join(map(split(w:netrw_wigkeep, ','), '"^".' . s:escape . '. "$"'), ',') .
+ \ ',^\.\.\=/\=$' .
+ \ (get(g:, 'netrw_list_hide', '')[-strlen(s:dotfiles):-1] ==# s:dotfiles ? ','.s:dotfiles : '')
+ endif
+
if !exists('s:netrw_up')
let orig = maparg('-', 'n')
if orig =~? '^<plug>'
@@ -109,6 +123,7 @@ function! s:setup_vinegar() abort
endif
endif
nmap <buffer> - <Plug>VinegarUp
+ nmap <buffer> <C-L> :let w:vinegar_ctrl_l=1<bar>execute "normal \<Plug>NetrwRefresh"<bar>unlet w:vinegar_ctrl_l<CR>
cnoremap <buffer><expr> <Plug><cfile> get(<SID>relatives('.'),0,"\022\006")
if empty(maparg('<C-R><C-F>', 'c'))
cmap <buffer> <C-R><C-F> <Plug><cfile> @tpope if you are fine with the change for the function |
Currently, vinegar reads
'wildignore'/'wig'
only a single time when vim is started and setsg:netrw_list_hide
withHowever,
'wig'
can change during a vim session: user wants to:se wig=<value>
, or<project-dir>/.gitignore
(:h netrw-gitignore
),$VIMRUNTIME/ftplugin/python.vim
(however, this should not be in there)Therefore, I would propose updating
g:netrw_list_hide
everytime the user enters the netrw window.The text was updated successfully, but these errors were encountered: