scrooloose / nerdtree-project-plugin

Proof of concept for project plugin
Do What The F*ck You Want To Public License
38 stars 6 forks source link

"E121: Undefined variable: b:NERDTree" #1

Open cmdcolin opened 5 years ago

cmdcolin commented 5 years ago

Hi there,

I just was trying to use the command

:NERDTreeProjectSave myproj

It gave me the error "E121: Undefined variable: b:NERDTree"

My full vimrc is

set t_Co=256
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
      \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')
Plug 'editorconfig/editorconfig-vim' " editorconfig, always not fucking working
Plug 'tpope/vim-commentary' " allows typing v-select block then gc to comment block
Plug 'tpope/vim-fugitive' " allows some git commands inside vim
Plug 'joshdick/onedark.vim' " theme
Plug 'vim-airline/vim-airline' " status line
Plug 'leafgarland/typescript-vim'
Plug 'pangloss/vim-javascript'
Plug 'scrooloose/nerdtree' ""
Plug 'w0rp/ale' " autofix and linting
Plug 'Xuyuanp/nerdtree-git-plugin' " display files as modified from git in nerdtree
Plug 'junegunn/fzf.vim'
Plug 'yegappan/mru'
Plug 'scrooloose/nerdtree-project-plugin'
call plug#end()
colorscheme onedark
let g:airline#extensions#tabline#enabled = 1
autocmd vimenter * NERDTree
autocmd VimEnter * wincmd p

"closes nerdtree on last
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
set mouse=a
set autoread
set nu
set noswapfile
set nobackup
set nowb

let NERDTreeMouseMode=3
let g:ale_fixers = ['eslint']

let g:ale_fix_on_save = 1
set backspace=indent,eol,start " for some reason backspace doesn't work normally, wtf
set list
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
noscript commented 4 years ago

It looks like NERDTree window has to be focused to use this functionality. @scrooloose is it possible to e.g. fetch open directories without having NERDTree visible?

UPDATE: answering my own question:

let b_NERDTree = getbufvar(t:NERDTreeBufName, 'NERDTree')