imxiejie / ThinkVim

Vim configuration in the 21st century

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:bd closes defx

ubmarco opened this issue · comments

Problems summary

I have defx open and some buffers on the right.
When running :bd or C-x the current buffer gets deleted but defx also closes.
Can this be avoided?

Environment Information

  • OS: Linux/Manjaro 64Bit

  • thinkvim :echo g:thinkvim_version output: 2.4.5

  • neovim :version output:

NVIM v0.4.3                                                                                                                                                  
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-protot
ypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLA
RATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/bu
ild/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"
  • :checkhealth or :CheckHealth result (neovim only):

health#coc#check
========================================================================
  - OK: Environment check passed

  - OK: Javascript entry lib/attach.js found
  - OK: Service started

health#defx#check
========================================================================
## defx.nvim
  - OK: has("python3") was successful
  - OK: Python 3.6.1+ was successful

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='6002'
  - INFO: $COLORTERM='truecolor'

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
  - INFO: Multiple python2 executables found.  Set `g:python_host_prog` to avoid surprises.
  - INFO: Executable: /usr/sbin/python2
  - INFO: Other python executable: /usr/bin/python2
  - INFO: Other python executable: /sbin/python2
  - INFO: Other python executable: /bin/python2
  - INFO: Python version: 2.7.18
  - INFO: pynvim version: 0.3.2 (outdated; from ~/.local/lib/python2.7/site-packages/neovim)
  - WARNING: Latest pynvim is NOT installed: 0.4.1

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Multiple python3 executables found.  Set `g:python3_host_prog` to avoid surprises.
  - INFO: Executable: /usr/sbin/python3
  - INFO: Other python executable: /usr/bin/python3
  - INFO: Other python executable: /sbin/python3
  - INFO: Other python executable: /bin/python3
  - INFO: Python version: 3.8.2
  - INFO: pynvim version: 0.4.1
  - OK: Latest pynvim is installed.

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v14.2.0
  - INFO: Neovim node.js host: /usr/lib/node_modules/neovim/bin/cli.js
  - WARNING: Package "neovim" is out-of-date. Installed: 4.6.0-alpha.0, latest: 4.9.0
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

How to reproduce the problem from neovim startup (Required!)

Open 2 buffers, start defx with <leader>e. Switch back to one of the buffers. Delete the buffer.
Then defx also closes.

Screenshot (if possible)

Peek 2020-05-29 15-01

@ubmarco thanks for report. on thinkvim version 2.6.2. use C-x b to close buffer,it doesn't close defx.
test3

@glepnir thanks for the quick reply. I updated to the develop branch and it looks like the behavior is still not as expected. For one buffer it behaves like you showed initially, but for multiple buffers it will close defx. I can't really determine the behaviour, seems not deterministic. See here:
Peek 2020-05-29 23-01

Indeed this never closes defx if I myself don't close it. Here is the new behavior:
Peek 2020-06-02 09-19

I think the issue is with windows. If I delete a buffer I don't want to lose the window/split but instead replace it with the next or previous buffer.

@ubmarco Ok, i think we should define a close function to check the current window and defx.

Yes this sounds like a good idea. I'd say the requirements are:

  • defx never closes automatically (only on user action)
  • if a buffer gets deleted, any window displaying it shows the previous or next buffer
  • if a buffer gets deleted and it is the last, the window is replaced by an empty buffer
  • it should also work for tabs

Stackoverflow has a nice solution to the problem. Another option mentioned is this plugin. We would have to care for the keymaps that it brings. Using the plugin would also have the advantage that the behavior is improved not only for defx.

Thanks ,I will check it and implement it later.

I had add bufkill.vim.please git pull then test it.

Wow, awesome, works as expected. Thanks a lot for your time again.