What i mean is, the color of the background of the selected folder/file in NERDTree is the same as set by the highlight hi CursorLine

It is possible for me to disassociate this? To set the bg color for the selected item in Nedtree to be different from the CursorLine color?
In Vim, I don't think it can be done. Any change to the CursorLine highlight group changes it in all windows. I could be mistaken, but that's what I discovered when I tried it. I welcome being proved wrong on this, if anyone knows better.
In Neovim, however, it is possible using the winhighlight setting and an autocmd. I based the solution on what I found in :help hl-StatusLineTerm and :help 'winhighlight'. Put this in your init.vim and you should be all set.
autocmd ColorScheme * highlight NERDTreeCursorLine ctermbg=208 " Change as needed.
autocmd User NERDTreeInit
\ if &filetype=='nerdtree' |
\ setlocal winhighlight=CursorLine:NERDTreeCursorLine |
\ else |
\ setlocal winhighlight= |
\ endif
Explanation: If you have defined a User NERDTreeInit autocmd, then NERDTree will call it after creating its window. This is an undocumented feature, intended for NERDTree plugin authors, but it works very well in this situation.
Exactly what i needed! Thanks!
The autocmd can be made simpler. The if statement was leftover from the Neovim help page, which used different events. Given that we're using the NERDTreeInit event, we'll always be in the NERDTree window when it runs. You can simplify the code like so:
autocmd ColorScheme * highlight CursorLineNERDTree ctermbg=208
autocmd User NERDTreeInit setlocal winhighlight=CursorLine:CursorLineNERDTree