My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMSΒ for Enterprise.
Upgrade ✨Learn more

Use faster file tree on SpaceVim

Heechul Ryu's photo
Heechul Ryu
Β·Feb 8, 2020

this post is as much tl;dr: as possible

  • Vimfiler is the default file tree on SpaceVim and it can be quite slow to open the window or change the focus to it. (if you don't notice anything, try with a more complex file tree then you will probably start noticing.)
  • another option, Nerdtree was quite fast and easy to start using (all you need to do is file manager = "nerdtree", but navigation keys are quite different for me and I like Vimfiler way that allows me to traverse the tree up and down with h and l.
  • so I researched more and apparently Vimfiler is deprecated and fortunately, there is Defx which is built by the same person who built Vimfiler, so I hoped h and l work as the way Vimfiler does and it indeed works in that way.
  • also, Defx is fast and easy to start using just like Nerdtree, but unlike Nerdtree it doesn't show vim-devicons out of the box.
  • when you read the Defx docs, there are two third parties mentioned for that purpose
EXTERNAL COLUMNS                *defx-external-columns*

git         Git status.
        https://github.com/kristijanhusak/defx-git

icons        Nerd font icons.
        https://github.com/kristijanhusak/defx-icons
  • so I install the plugins and restart the SpaceVim, but it still doesn't show anything
  • apparently, I had to open the Defx with options like this :Defx -columns=git:indent:icons:filename:type for that.
  • now the tree shows icons. Great! if I run that command, but I don't want to open a file tree like that. I want to open it SpaceVim way which is <SPC> f t.
  • so I spent a couple of hours tweaking things and finally got it working and I still don't understand very clearly why I had to put things where I put. (I'm not Vimscript heavy user yet) But I'm satisfied for now.

  • this is the result and the link and code block below is the same.

function! myspacevim#after() abort
  " ... other stuff here

  " set defx column to use icons and git
  call defx#custom#option('_', 'columns', 'git:mark:indent:icons:filename:type:size:time')
  Defx | Defx | wincmd p
endfunction
  • so call defx#custom#option is important to configure the columns with what you want to change the content for your needs.
  • and I had to toggle Defx to apply the new changes right away that's why the two Defx are there. if you don't understand what' I'm saying, then simply delete the line and see what's different.
  • and wincmd p to bring the focus back to the original window.

I'm sure there is much more to Defx other than just performance, but I'm pretty glad that I upgraded my Vimfiler with the faster performance for now.

a twist after posting

I just found out that if you are using the master branch of SpaceVim, you don't need to do anything but filemanager = "defx". All the work is already done from SpaceVim team πŸ‘πŸΌπŸ‘πŸΌπŸ‘πŸΌ, but I'm using v1.3.0 which is the current most recent stable version, that's why I went with all this hassle but it was fun.