lens.vim icon indicating copy to clipboard operation
lens.vim copied to clipboard

Unable to exclude defx from lens

Open infinite-ops opened this issue 4 years ago • 13 comments

Lens tries to resize defx even when listed in disabled_filetypes

I'm using vim 8.2 patch 1-148 Here is a minimal vimrc to reproduce

autocmd!

call plug#begin('~/.vim/plugged')
filetype plugin indent on

if has('nvim')
  Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/defx.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'   
endif
Plug 'camspiers/animate.vim'
Plug 'camspiers/lens.vim'
call plug#end()

noremap <silent> <F3> :Defx -toggle<CR>

" =====================
" defx
" =====================
" Set appearance
call defx#custom#option('_', {
  \ 'winwidth': 35,
  \ 'split': 'vertical',
  \ 'direction': 'topleft',
  \ 'show_ignored_files': 0,
  \ 'buffer_name': 'defxplorer',
  \ 'columns': 'icon:indent:icons:filename',
  \ 'resume': 1,
  \ })

" =====================
" lens
" =====================
let g:lens#disabled = 0
let g:lens#animate = 1
let g:lens#disabled_filetypes = ['defx', 'nerdtree', 'fzf', 'defxplorer']

Start vim and hit F3, straight away defx is resized beyond the defined 35 set let g:lens#disabled = 1 and defx behaves as expected

When defx is loaded, running :set ft reports filetype=defx

Is this a lens issue or defx? any chance of a work around?

infinite-ops avatar Feb 25 '20 13:02 infinite-ops

I have the same issue with it still resizing NERDTree windows, even when using the example given in the readme of let g:lens#disabled_filetypes = ['nerdtree', 'fzf']

brokenbyte avatar Feb 25 '20 16:02 brokenbyte

that is weird, I am also using Defx and it does work for me with :

let g:lens#disabled_filetypes = ['nerdtree', 'fzf', 'defx']

jemag avatar Feb 26 '20 15:02 jemag

that is weird, I am also using Defx and it does work for me with :

let g:lens#disabled_filetypes = ['nerdtree', 'fzf', 'defx']

Using the vimrc I posted? What version of vim?

infinite-ops avatar Feb 26 '20 22:02 infinite-ops

I just meant that it works on my own setup. I am using neovim v0.5.0-378-gbb331a9b3 and lens.vim commit 8a1a14b.

jemag avatar Feb 27 '20 01:02 jemag

@jemag you are right! the problem for me is not lens but animate! if I disable animate from the config above and lens behaves as expected.

let g:lens#animate = 0

@camspiers it appears lens was not the cause of this issue but rather one of your other plugins I was using in combination with it. Shall I raise a new issue against animate? Would it be possible to get a similar disabled_filetypes in animate?

infinite-ops avatar Feb 27 '20 13:02 infinite-ops

@infinite-ops Wow, I had thrown these plugins in the trash because the resize filtering didn't work! Disabling g:lens#animate worked for me too.

PolarJunction avatar Feb 28 '20 09:02 PolarJunction

Thanks for the reports, I will fix this behavior when I get some time,

camspiers avatar Feb 29 '20 03:02 camspiers

sounds good thank you @camspiers !

infinite-ops avatar Feb 29 '20 03:02 infinite-ops

it also does not work for voomtree side panel. https://github.com/vim-voom/VOoM

when you generate voomtree panel, it is extended he width unexpectedly. then you manually squeeze the width back. from now it won't be extended anymore, which is good. but then everytime you toggle the voomtree panel, it will be extended again. very annoying.

my vimrc:

let g:lens#width_resize_max = 80
"let g:lens#disabled = 1
let g:lens#animate = 0
let g:lens#disabled_filetypes = ['nerdtree', 'fzf', 'voomtree', 'vim-plug']

this plugin is super and useful since I'm a buffer split lover. but I'm also a Voom user and can't live without it. so this issue is a stopper for me. have to uninstall it for now...

btw nerdtree work fine after I disabled animate.

pinggit avatar Mar 02 '20 14:03 pinggit

The problem might be related to this. Particularly, for me the filter doesn't work for neovim's terminal because when opening a terminal, in the lens#win_enter function still see the current window as the original window, which can be confirmed easily by putting the following autocmd in vimrc

augroup Testingautocmd!
    autocmd WinEnter * echom expand('%:p')
augroup END

A quick solution would be (as indicated by the previous link) changing this line to

  autocmd! BufEnter * call lens#win_enter()

However, this will then fail the case if you want to have two window viewing the same file in the same tabpage, which I have no idea how to fix.

ipod825 avatar Apr 25 '20 06:04 ipod825

It turned out that #31 could solve the problem.

ipod825 avatar Apr 25 '20 08:04 ipod825

I just tried @ipod825 fork and it fixes this problem and also a new one I found with nnn.vim I used this branch which appears to have a bunch of his PR's for lens.vim applied.

Plug 'ipod825/lens.vim', {'branch': 'disableoption'}

infinite-ops avatar Aug 22 '20 11:08 infinite-ops

I ended up implemented my own plugin that only resize window if specified by rules: ipod825/war.vim.

ipod825 avatar Aug 22 '20 17:08 ipod825