lambdalisue / vim-fern

🌿 General purpose asynchronous tree viewer written in Pure Vim script
MIT License
1.29k stars 49 forks source link

Fern's default render does not highlight folder correctly when setting `g:fern#renderer#default#leading` with consecutive spaces #267

Closed phongnh closed 3 years ago

phongnh commented 3 years ago
" ~/.vimrc

if has('vim_starting')
    set encoding=utf-8
endif
scriptencoding utf-8

" No Vi Compatibility
if &compatible
    set nocompatible
endif

if &shell =~# 'fish$' " && (v:version < 704 || v:version == 704 && !has('patch276'))
    if executable('zsh')
        let &shell = exepath('zsh')
    elseif executable('bash')
        let &shell = exepath('bash')
    endif
endif

" Python 3
if executable('python3')
    let g:python3_host_prog = exepath('python3')
endif

if has('pythonx')
    set pyxversion=3
endif

call plug#begin()

Plug 'lambdalisue/fern.vim'

call plug#end()

let g:fern#renderer#default#root_symbol      = "\u2302\u00a0"
let g:fern#renderer#default#leading          = '  '
let g:fern#renderer#default#leaf_symbol      = '  '
let g:fern#renderer#default#collapsed_symbol = '+ '
let g:fern#renderer#default#expanded_symbol  = '~ '

function! s:InitFern() abort
    nmap <buffer> <Plug>(fern-action-reload-and-redraw)
                \ <Plug>(fern-action-reload)
                \ <Plug>(fern-action-redraw)

    nmap     <buffer> <silent> o  <Plug>(fern-action-open-or-expand)
    nmap     <buffer> <silent> p  <Plug>(fern-action-leave)
    nmap     <buffer> <silent> u  <Plug>(fern-action-leave)
    nmap     <buffer> <silent> r  <Plug>(fern-action-reload-and-redraw)
    nmap     <buffer> <silent> I  <Plug>(fern-action-hidden-toggle)
    nmap     <buffer> <silent> cd <Plug>(fern-action-cd)
    nnoremap <buffer> <silent> q  :<C-u>quit<CR>
endfunction

augroup MyAutoCmd
    autocmd!
    autocmd FileType fern call <SID>InitFern()
augroup END

Could you please check it? Thanks.

phongnh commented 3 years ago

I figured out that default renderer will render node with one starting space.

Screen Shot 2020-11-13 at 5 08 32 PM

Tried to update regex with one more \s to FernRootSymbol, FernLeafSymbol and FernBranchSymbol. It seems that that will fix the problem.

lambdalisue commented 3 years ago

I'm sorry I didn't notice this. Well, I don't get the situation so could you create a minimal vimrc and step by step to reproduce the issue first? (note that what you wrote in PR description is not minimal)

phongnh commented 3 years ago

Here is my min vimrc

set encoding=utf-8
scriptencoding utf-8
set nocompatible
set termguicolors
set runtimepath^=~/.vim/plugged/fern.vim

let g:fern#renderer#default#root_symbol      = "\u2302\u00a0"
let g:fern#renderer#default#leading          = '  '
let g:fern#renderer#default#leaf_symbol      = '  '
let g:fern#renderer#default#collapsed_symbol = '+ '
let g:fern#renderer#default#expanded_symbol  = '~ '

syntax on
filetype plugin indent on

Reproduce issue: https://asciinema.org/a/UdlXe3sT2cqc2UhOhBQtL2u3T

With code from my fork: https://asciinema.org/a/OqYltWUh5eP7DUH0OuGapG0KG

Please check, thanks.

lambdalisue commented 3 years ago

Thanks. Now I got the situation.

I've create a new PR based on your fix. Please test it https://github.com/lambdalisue/fern.vim/pull/274