Skip to content

Commit

Permalink
Merge pull request #99 from lambdalisue/winfixwidth
Browse files Browse the repository at this point in the history
Force 'winfixwidth' on drawer style window
  • Loading branch information
lambdalisue authored Jun 2, 2020
2 parents f02a232 + b192a76 commit e033e22
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions autoload/fern.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ call s:Config.config(expand('<sfile>:p'), {
\ 'keepalt_on_edit': 0,
\ 'keepjumps_on_edit': 0,
\ 'disable_default_mappings': 0,
\ 'disable_drawer_auto_winfixwidth': 0,
\ 'disable_drawer_auto_resize': 0,
\ 'disable_drawer_auto_quit': 0,
\ 'default_hidden': 0,
\ 'default_include': '',
\ 'default_exclude': '',
Expand Down
25 changes: 20 additions & 5 deletions autoload/fern/internal/drawer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ function! fern#internal#drawer#init() abort
return
endif

setlocal winfixwidth

augroup fern_drawer_internal
autocmd! * <buffer>
autocmd BufEnter <buffer> call s:auto_quit()
autocmd BufEnter <buffer> call s:auto_resize()
autocmd BufLeave <buffer> call s:auto_resize()
autocmd BufEnter <buffer> call s:auto_resize(v:false)
autocmd BufLeave <buffer> call s:auto_resize(v:false)
autocmd BufEnter <buffer> call s:auto_winfixwidth(v:false)
augroup END

call s:auto_resize(v:true)
call s:auto_winfixwidth(v:true)
endfunction

function! fern#internal#drawer#is_drawer(...) abort
Expand All @@ -47,13 +49,26 @@ function! s:focus_next() abort
return 1
endfunction

function! s:auto_resize() abort
function! s:auto_winfixwidth(force) abort
if !a:force && g:fern#disable_drawer_auto_winfixwidth
return
endif
setlocal winfixwidth
endfunction

function! s:auto_resize(force) abort
if !a:force && g:fern#disable_drawer_auto_resize
return
endif
let fri = fern#internal#bufname#parse(bufname('%'))
let width = str2nr(get(fri.query, 'width', string(g:fern#drawer_width)))
execute 'vertical resize' width
endfunction

function! s:auto_quit() abort
if g:fern#disable_drawer_auto_quit
return
endif
let fri = fern#internal#bufname#parse(bufname('%'))
let keep = get(fri.query, 'keep', g:fern#drawer_keep)
let width = str2nr(get(fri.query, 'width', string(g:fern#drawer_width)))
Expand Down
14 changes: 14 additions & 0 deletions doc/fern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ VARIABLE *fern-variable*
See |fern-action-mappings| for more detail.
Default: 0

*g:fern#disable_drawer_auto_winfixwidth*
Set 1 to disable automatically enable 'winfixwidth' to drawer on
|BufEnter| autocmd.
Default: 0

*g:fern#disable_drawer_auto_resize*
Set 1 to disable automatically resize drawer on |BufEnter| and
|BufLeave| autocmd.
Default: 0

*g:fern#disable_drawer_auto_quit*
Set 1 to disable automatic Vim quit when there is only drawer.
Default: 0

*g:fern#default_hidden*
Set 1 to enter hidden mode (show hidden files) in default.
Default: 0
Expand Down

0 comments on commit e033e22

Please sign in to comment.