preservim / nerdtree

A tree explorer plugin for vim.
Do What The F*ck You Want To Public License
19.56k stars 1.44k forks source link

How to set the padding width between arrow and the icon #1378

Closed tracyone closed 11 months ago

tracyone commented 11 months ago
Screen Shot 2023-10-18 at 21 22 07
rzvxa commented 11 months ago

Hello, May I ask what you use for displaying those icons? I can see 2 spaces here. NERDTree only puts one space between the directory arrow and the rest of it. The extra space here is introduced by those icons. As for the space from NERDTree, there is no option available to remove this space.

tracyone commented 11 months ago

Hi, rzvxa

I use ryanoasis/vim-devicons plugin.

rzvxa commented 11 months ago

I also use vim-devicons, there is no option in either of these 2 plugins to remove that extra space when they are working together. Fun Fact: The icon you see is called a flag, And NERDTree actually shows the flag inside of brackets [ ] like this: image vim-devicons uses a special hackish way to conceal these brackets using syntax highlighting with this code:

function! s:setSyntax()
  if g:webdevicons_enable_nerdtree == 1 && g:webdevicons_conceal_nerdtree_brackets == 1
    augroup webdevicons_conceal_nerdtree_brackets
      au!
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\]" contained conceal containedin=NERDTreeFlags
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\[" contained conceal containedin=NERDTreeFlags
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\]" contained conceal containedin=NERDTreeLinkFile
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\]" contained conceal containedin=NERDTreeLinkDir
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\[" contained conceal containedin=NERDTreeLinkFile
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\[" contained conceal containedin=NERDTreeLinkDir
      autocmd FileType nerdtree setlocal conceallevel=3
      autocmd FileType nerdtree setlocal concealcursor=nvic
    augroup END
  endif
endfunction

So in theory you should also be able to conceal those extra spaces. Or even patch one of these 2 plugins for your use case and remove the spacing in them. TL;DR There is no way to change this padding behavior.

tracyone commented 11 months ago

Thanks a lot, look like a good solution, I will try it later tonight