Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NERDTree: square brackets around icon on sourcing vimrc #154

Closed
8 tasks done
tnguyen14 opened this issue May 25, 2016 · 24 comments
Closed
8 tasks done

NERDTree: square brackets around icon on sourcing vimrc #154

tnguyen14 opened this issue May 25, 2016 · 24 comments
Assignees
Milestone

Comments

@tnguyen14
Copy link

Whenever I try to source ~/.vimrc file when NERDTree is open, I get square brackets around the file icons like so:

screen shot 2016-03-03 at 11 07 51 am

This does not happen when I first start Vim and NERDTree, only when sourcing vimrc after vim has already opened.

The only reference to this problem I found in this repo is #42, but I didn't find any thing helpful there. I filed an issue with NERDTree preservim/nerdtree#557, but was told that this is actually a devicons issue. I also tried to post a question on stackexchange http://vi.stackexchange.com/questions/7932/sourcing-vimrc-file-put-square-brackets-around-file-icons

For reference, here's the link to my vimrc https://github.com/tnguyen14/dotfiles/blob/master/home/.vimrc

Requirements

  • I have searched the issues for my issue and found nothing related and/or helpful
  • I have read or at least glanced at the FAQ
  • I have read or at least glanced at the Wiki

These items you must provide answers to. Make sure to add all the information needed to understand the bug so that someone can help. If the info is missing we'll add the 'Needs more information' label and may choose to close the issue until there is enough information.

  • What version of vim are you using?
    • 7.4
  • What version of vim-devicons are you using?
    • 0.8.2
  • Are you using vim from the terminal or a GUI vim?
    • terminal
  • Are you using Mac, Linux or Windows?
    • mac

Optional

  • Provide screenshots where appropriate
@ryanoasis
Copy link
Owner

Thanks for the report. I'll try to debug when I get a chance but it won't be soon sorry

@tnguyen14
Copy link
Author

Thanks Ryan. If there's anything I could do/ places I could look into, I'd be more than happy to help.

@ryanoasis
Copy link
Owner

Ah I think I know what this is, see if putting this in your vimrc this helps you:

" after a re-source, fix syntax matching issues (concealing brackets):
if exists('g:loaded_webdevicons')
    call webdevicons#refresh()
endif

I forgot I even had this in my vimrc and when I commented it out I was able to replicate your exact issue

This was also referred to in #71

Also it was added to the readme in the FAQ / Troubleshooting section: 'Issues after re-sourcing vimrc'

@tnguyen14
Copy link
Author

Thanks @ryanoasis. Sorry I didn't make those connections before.

Just a minor question: now that I add that code in, upon sourcing vimrc, the NERDTree window collapses all existing directories that were open before. Is this the correct behavior?

@ryanoasis
Copy link
Owner

Good point, it currently loses what is opened and the cwd.

It is correct behavior but I just added and tested something that should do what you want 😄

I'll try to push something to a release branch today (along with something for #153)

@ryanoasis ryanoasis self-assigned this May 27, 2016
@ryanoasis ryanoasis added this to the v0.8.3 milestone May 27, 2016
@tnguyen14
Copy link
Author

Thank you for being super responsive! Let me know if you need help with testing it or sth.

@ryanoasis
Copy link
Owner

Hey not a problem! Thanks for the report, but also letting me know that the refresh was 'too hard'.

If you want to help test I just pushed the fixes to 0.8.3 branch let me know!

I had some problems with some icons being reset to the default icon when I resourced my vimrc but might just be my settings.

Anyway the refresh method should now by default do a 'soft refresh' with the same code in your vimrc

@tnguyen14
Copy link
Author

@ryanoasis sorry for the late response. I could verify that a soft refresh on your 0.8.3 branch works and won't close the tree.

@ryanoasis
Copy link
Owner

@tnguyen14 Hey no worries 😄 it's all good. As you can see by the way it is now been merged to master

@cmcginty
Copy link

cmcginty commented Jan 15, 2017

Can someone explain why this is happening? Why does the "syntax on" command in any buffer cause the brackets to show up? Some commands/plugins toggle the syntax settings, so I don't think its safe to assume the command is not going to be run in a session.

@ghost
Copy link

ghost commented Feb 20, 2017

So the fix for this should be in master now right? Because I'm running 0.8.5, but I'm still encountering this issue. After sourcing the brackets show up in nerdtree.

@ryanoasis
Copy link
Owner

@ismay Yeah it is in master. Maybe it is not very clear but you have to add something to your vimrc:

" after a re-source, fix syntax matching issues (concealing brackets):
if exists('g:loaded_webdevicons')
  call webdevicons#refresh()
endif

this is also in the FAQ

@ryanoasis
Copy link
Owner

@cmcginty Hmm interesting point. I see that setting it on/off does reset the brackets to default state but I think that is to be expected ?

From help:

							*:syn-on* *:syntax-on*
The ":syntax enable" command will keep your current color settings.  This
allows using ":highlight" commands to set your preferred colors before or
after using this command.  If you want Vim to overrule your settings with the
defaults, use: >
	:syntax on

So from what I can understand you cannot limit the syntax on/off to the buffer but there are ways:

I got some info here: http://stackoverflow.com/questions/11723175/enable-syntax-highlighting-in-vim-on-a-per-buffer-basis

But that still resets devicons syntax (and other plugins). another interesting command is: :ownsyntax which does not seem to reset vimdevicons syntax but just the buffer you are in.

@ghost
Copy link

ghost commented Feb 20, 2017

Yeah it is in master. Maybe it is not very clear but you have to add something to your vimrc

Ah ok, I saw that but thought that that was no longer necessary after the fix. Ok, adding it fixes the problem, but does lead to a new one. When resourcing while the cursor is in the nerdtree buffer, I get the following error:

untitled

Even though I have this in my config (on line 84):

if !&readonly
  set fileencoding=utf-8
endif

Which shouldn't try to set anything for buffers that aren't modifiable if I'm not mistaken. This is probably an error on my part, but I'm not sure where this is going wrong (this error does not occur when the cursor is not in the nerdtree buffer while resourcing btw).

@ryanoasis
Copy link
Owner

Ah ok, I saw that but thought that that was no longer necessary after the fix.

Oh okay I see your point. Sorry for confusion.


Not sure on those errors you are seeing... can you try with a minimal vimrc ? Potentially something specific to neo vim?


Your comment got me thinking about the 'fix' being necessary... it looks like it is possible to hook into a resource and execute some logic, we could theoretically call the refresh 😄

Per help:

							*SourcePre*
SourcePre			Before sourcing a Vim script. |:source|
				<afile> is the name of the file being sourced.

This could be a future improvement.

@ghost
Copy link

ghost commented Feb 24, 2017

Not sure on those errors you are seeing... can you try with a minimal vimrc ? Potentially something specific to neo vim?

After testing some more I suspect that this is not a devicons issue. I think it has to do with vim trying to set the nerdtree buffer to utf-8, which it can't do because it isn't modifiable. So your fix for the brackets works perfectly. Thanks!

@Val-istar-Guo
Copy link

same issue, i don't know how to fix it.....T_T

image

@tam5
Copy link

tam5 commented Jul 13, 2017

I too am still having this issue. calling refresh does not fix it

UPDATE: I did not have vim compiled with conceal.

@Janik-Tarverdyan
Copy link

It's working autocmd VimEnter * source ~/.vimrc

@Janik-Tarverdyan
Copy link

Janik-Tarverdyan commented Dec 19, 2018

same issue, i don't know how to fix it.....T_T

image

Please look at this #154 (comment)

pvxe pushed a commit to pvxe/dotfiles that referenced this issue Aug 18, 2019
Remove unnecessary airline_symbols space character code block and added
wildmenu option.
Added snippet for vim-devicons and NERDTree behaviour, see
ryanoasis/vim-devicons#154
@magicstep
Copy link

For me the solution is to put this at the bottom of .vimrc

"get rid of [  ] around icons in NerdTree
syntax enable
if exists("g:loaded_webdevicons")
	call webdevicons#refresh()
endif

@madmandd
Copy link

It's fixed when using combo

"get rid of [  ] around icons in NerdTree
autocmd VimEnter * source ~/.vimrc
if exists("g:loaded_webdevicons")
	call webdevicons#refresh()
endif

@alexsmartens
Copy link

I tried all the options suggested above but still having this nasty square brackets issue. Do you know what else I can try?

Plug 'ryanoasis/vim-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'preservim/nerdtree'

syntax enable
autocmd VimEnter * source ~/.vimrc
if exists('g:loaded_webdevicons')
  call webdevicons#refresh()
endif

Screen Shot 2021-08-31 at 12 18 12 PM

@mustafaergul
Copy link

mustafaergul commented Oct 6, 2021

Same here, I have tried all the suggestions and nothing worked. Here are some snippets from my .vimrc

echo g:webdevicons_conceal_nerdtree_brackets gives 0

vim --version | grep conceal gives -conceal

nmap <C-n> :NERDTreeToggle<CR>
let g:DevIconsEnableFoldersOpenClose=1
let NERDTreeShowHidden=1
let g:NERDTreeDirArrows=0
let g:webdevicons_enable_nerdtree=1
let g:webdevicons_conceal_nerdtree_brackets=0
packloadall

call plug#begin('~/.vim/plugged')
    Plug 'gruvbox-community/gruvbox'
    Plug 'preservim/nerdtree'
    Plug 'jremmen/vim-ripgrep'
    Plug 'vim-airline/vim-airline'
    Plug 'vim-airline/vim-airline-themes'
    Plug 'git@github.com:tpope/vim-rails.git'
    Plug 'leafgarland/typescript-vim'
    Plug 'vim-utils/vim-man'
    Plug 'git@github.com:kien/ctrlp.vim.git'
    Plug 'vim-ruby/vim-ruby'
    Plug 'pangloss/vim-javascript'
    Plug 'yuezk/vim-js'
    Plug 'maxmellon/vim-jsx-pretty'
    Plug 'vim-scripts/delimitMate.vim'
    Plug 'tpope/vim-fugitive'
    Plug 'junegunn/fzf.vim'
    Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
    Plug 'stsewd/fzf-checkout.vim'
    Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install'  }
    Plug 'prettier/vim-prettier', { 'do': 'yarn install', 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'html'] }
    Plug 'ryanoasis/vim-devicons'
    Plug 'bryanmylee/vim-colorscheme-icons'
call plug#end()

"Airline status bar config
let g:airline#extensions#tabline#enabled = 0
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_theme = 'gruvbox'
let g:airline_powerline_fonts = 1

" after a re-source, fix syntax matching issues (concealing brackets):
if exists('g:loaded_webdevicons')
    call webdevicons#refresh()
endif

image

Any help is appreciated. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants