Skip to content
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

Wrong split and window positions #66

Closed
petobens opened this issue Jan 5, 2019 · 10 comments
Closed

Wrong split and window positions #66

petobens opened this issue Jan 5, 2019 · 10 comments
Labels

Comments

@petobens
Copy link

petobens commented Jan 5, 2019

Consider the following minimal init.vim:

set nocompatible

let $DOTVIM = expand('$HOME/.config/nvim')

set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/defx.nvim
set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/vimfiler
set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/unite.vim

set splitright
set splitbelow

call defx#custom#option('_', {
            \ 'winwidth': 40,
            \ 'split': 'vertical',
            \ 'direction': 'topleft',
            \ })
call vimfiler#custom#profile('default', 'context', {
            \ 'direction' : 'topleft',
            \ 'split': 1,
            \ 'winwidth' : 40,
            \ 'force_quit': 1,
            \ })

nnoremap <silent> ,xfe :Defx<CR>
nnoremap <silent> ,fe :VimFilerBufferDir<CR>

augroup ps_defx_vimfiler
    au!
    au FileType defx call s:defx_settings()
    au FileType vimfiler call s:vimfiler_settings()
augroup END

function! s:defx_settings()
    " nnoremap <silent><buffer><expr> <CR> defx#do_action('open')
    nnoremap <silent><buffer><expr> <CR> defx#do_action('drop')
    nnoremap <silent><buffer><expr> s defx#do_action('open', 'split')
    nnoremap <silent><buffer><expr> v defx#do_action('open', 'vsplit')
    nnoremap <silent><buffer><expr> q defx#do_action('quit')
endfunction
function! s:vimfiler_settings()
    nnoremap <buffer><expr><silent> s vimfiler#do_switch_action('split')
    nnoremap <buffer><expr><silent> v vimfiler#do_switch_action('vsplit')
    nmap <buffer> q <Plug>(vimfiler_exit)
endfunction

In the following gif I show vimfiler's behaviour (called via the ,fe mapping):
i) press ,fe and open the a.txt file with <CR>.
ii) press ,fe again and open b.txt with v mapping
iii) press ,fe again and open c.txt with <CR>
iv) press ,fe and open b.txt with s
vimfiler

I want to achieve the same behaviour with defx however i find the following problems/differences:
i) press ,xfe and open the a.txt file with <CR> -> the defx buffer doesn't close (if I use open instead of drop the buffer does close but the file is opened in the defx window (that it's only 40 characters wide))
ii) go back to the defx buffer with <C-W>h and open b.txt with v mapping -> instead of opening to the right (as per the splitright setting) the b.txt file is opened to the left
iii) go back to the defx buffer with <C-W>h and and open c.txt with <CR> -> this is correctly opened in the corresponding buffer (where the b.txt file was)
iv) close the defx buffer with q, move to the right to the a.txt file with <C-W>l, press ,fe and open c.txt with s -> it's not opened below the a.txt buffer (which is the buffer that called defx) but rather on the same defx buffer window
defx

I think vimfiler has the proper predictable behaviour and defx should follow it.

@Shougo
Copy link
Owner

Shougo commented Jan 6, 2019

I think vimfiler has the proper predictable behaviour and defx should follow it.

Sorry. I don't want to follow the complicated behavior in vimfiler.

@Shougo Shougo closed this as completed Jan 6, 2019
@Shougo Shougo added the wontfix label Jan 6, 2019
@petobens
Copy link
Author

petobens commented Jan 6, 2019

Sorry. I don't want to follow the complicated behavior in vimfiler.

But the current behaviour is completely unpredictable now. For instance If I call :Defx from one window and press s to open the file in a split window then I expect it to open below the window that called defx.

Besides Defx should honor the splitright and splitbelow settings. Otherwise you never know where files will open.

@petobens
Copy link
Author

petobens commented Jan 6, 2019

In other words: Defx messes up the window layout and opens windows wherever it wants. This shouldn't be a feature.

@Shougo
Copy link
Owner

Shougo commented Jan 6, 2019

But the current behaviour is completely unpredictable now.

The current behavior is very clearly for me.
In "open", it opens from defx window.
In "drop", it opens from previous window.

@Shougo
Copy link
Owner

Shougo commented Jan 6, 2019

Besides Defx should honor the splitright and splitbelow settings.

Defx already honor splitright and splitbelow configurations.
Defx opens right of defx window.
Because, you have used open action. It opens from defx window.

@Shougo
Copy link
Owner

Shougo commented Jan 6, 2019

So you should use drop action instead.

@petobens
Copy link
Author

petobens commented Jan 6, 2019

How I can open from the previous window and close/quit the defx buffer upon opening the file?

@petobens
Copy link
Author

petobens commented Jan 6, 2019

I want to do something like defx#do_action('drop', 'quit') but that doesn't work

@Shougo
Copy link
Owner

Shougo commented Jan 6, 2019

How I can open from the previous window and close/quit the defx buffer upon opening the file?

It is not supported. It is another feature. You should create another issue.

@petobens
Copy link
Author

petobens commented Jan 6, 2019

Ok thanks. I will try the drop action and report if there are problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants