prettier / vim-prettier

A Vim plugin for Prettier
MIT License
1.78k stars 138 forks source link

E121: Undefined variable: g:prettier#autoformat #216

Closed lheberlie closed 4 years ago

lheberlie commented 4 years ago

Do you want to request a feature or report a bug? Bug

$ vi tsconfig.json 
$ Error detected while processing /Users/currentuser/.vim/bundle/vim-prettier/ftplugin/json.vim:
line    7:
E121: Undefined variable: g:prettier#autoformat
E121: Undefined variable: g:prettier#autoformat

What is the current/expected behavior? No Errors when opening a file

What version of vim-prettier are you using - (output of :PrettierVersion) ? 0.2.7

What version of prettier are you using - (output of :PrettierCliVersion) ?

1.18.2

What is your prettier executable path - (output of :PrettierCliPath) ?

/Users/currentuser/.vim/bundle/vim-prettier/node_modules/prettier/bin-prettier.js

Did this work in previous versions of vim-prettier and/or prettier ?

I didn't remember this error in previous version, but have been ignoring the errors for so long I could be mistaken.

Additional details

macOS Mojave: 10.14.6

node -v: v13.0.1

pathogen -v: 2.4

/Users/currentuser/.vim

.
├── after
│   └── ftplugin
│       └── html.vim
├── autoload
│   └── pathogen.vim
└── bundle
    ├── solarized
    │   └── colors
    │       └── solarized.vim
    ├── typescript-vim
    │   ├── README.md
    │   ├── compiler
    │   │   └── typescript.vim
    │   ├── ftdetect
    │   │   └── typescript.vim
    │   ├── ftplugin
    │   │   └── typescript.vim
    │   ├── indent
    │   │   └── typescript.vim
    │   ├── syntax
    │   │   └── typescript.vim
    │   └── vimshot01.png
    ├── vim-json
    │   ├── ftdetect
    │   │   └── json.vim
    │   ├── ftplugin
    │   │   └── json.vim
    │   ├── indent
    │   │   └── json.vim
    │   ├── json-test.json
    │   ├── jsonl-test.jsonl
    │   ├── jsonp-test.jsonp
    │   ├── license.md
    │   ├── readme.md
    │   └── syntax
    │       └── json.vim
    └── vim-prettier
        ├── CHANGELOG.md
        ├── LICENSE
        ├── README.md
        ├── autoload
        │   └── prettier.vim
        ├── doc
        │   └── prettier.txt
        ├── ftdetect
        │   ├── css.vim
        │   ├── graphql.vim
        │   ├── html.vim
        │   ├── javascript.vim
        │   ├── json.vim
        │   ├── less.vim
        │   ├── markdown.vim
        │   ├── scss.vim
        │   ├── typescript.vim
        │   ├── vue.vim
        │   └── yaml.vim
        ├── ftplugin
        │   ├── css.vim
        │   ├── graphql.vim
        │   ├── html.vim
        │   ├── javascript.vim
        │   ├── json.vim
        │   ├── less.vim
        │   ├── markdown.vim
        │   ├── scss.vim
        │   ├── typescript.vim
        │   ├── vue.vim
        │   └── yaml.vim
        ├── media
        │   └── vim-prettier.gif
        ├── node_modules
        │   └── prettier
        │       ├── LICENSE
        │       ├── README.md
        │       ├── bin-prettier.js
        │       ├── doc.js
        │       ├── index.js
        │       ├── package.json
        │       ├── parser-angular.js
        │       ├── parser-babylon.js
        │       ├── parser-flow.js
        │       ├── parser-glimmer.js
        │       ├── parser-graphql.js
        │       ├── parser-html.js
        │       ├── parser-markdown.js
        │       ├── parser-postcss.js
        │       ├── parser-typescript.js
        │       ├── parser-yaml.js
        │       ├── standalone.js
        │       └── third-party.js
        ├── package-lock.json
        ├── package.json
        └── plugin
            └── prettier.vim

.vimrc

" VIM Configuration

set nocompatible

" Activate pathogen
execute pathogen#infect()
filetype plugin on
filetype detect

" How can I make the toolbar stay hidden after a restart?
set guioptions-=T

" How can I prevent Finder file labels from disappearing when saving a file?
set backupcopy=yes

" -- Display
set title                 " Update the title of your window or your terminal
set number                " Display line numbers
set ruler                 " Display cursor position
set wrap                  " Wrap lines when they are too long

set scrolloff=3           " Display at least 3 lines around you cursor

" -- Search
set ignorecase            " Ignore case when searching
set smartcase             " If there is an uppercase in your search term
                          " search case sensitive again
set incsearch             " Highlight search results when typing
set hlsearch              " Highlight search results

" -- Beep
set visualbell            " Prevent Vim from beeping
set noerrorbells          " Prevent Vim from beeping

" Backspace behaves as expected
set backspace=indent,eol,start

" Hide buffer (file) instead of abandoning when switching
" to another buffer
set hidden

" Enable syntax highlighting
" syntax enable 
" Enable file specific behavior like syntax highlighting and indentation
" filetype on
" filetype indent on

" Use the dark version of Solarized
set background=dark
colorscheme solarized

set guifont=Monaco:h14
set antialias

let g:prettier#autoformat = 0
let g:prettier#exec_cmd_path = "/Users/currentuser/.vim/bundle/vim-prettier/node_modules/prettier/bin-prettier.js"

FYI: I've tried it with and without the custom vim-prettier configuration in my .vimrc and still get the errors.

vim --version

 vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 30 2019 11:57:56)
macOS version
Included patches: 1-2234
Compiled by travis@Traviss-Mac.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tcl
+arabic            +find_in_path      +mouse_xterm       +termguicolors
+autocmd           +float             +multi_byte        +terminal
+autochdir         +folding           +multi_lang        +terminfo
-autoservername    -footer            -mzscheme          +termresponse
+balloon_eval      +fork()            +netbeans_intg     +textobjects
+balloon_eval_term +fullscreen        +num64             +textprop
+browse            -gettext           +odbeditor         +timers
++builtin_terms    -hangul_input      +packages          +title
+byte_offset       +iconv             +path_extra        +toolbar
+channel           +insert_expand     +perl/dyn          +transparency
+cindent           +job               +persistent_undo   +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           +python/dyn        +visual
+cmdline_info      +libcall           +python3/dyn       +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        +lua/dyn           +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con_gui    +mksession         +smartindent       -X11
+diff              +modify_fname      -sound             -xfontset
+digraphs          +mouse             +spell             +xim
+dnd               +mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        -xsmp
+emacs_tags        -mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
-farsi             -mouse_sysmouse    -tag_any_white     
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE 

Related issue:

E121: Undefined variable: g:prettier#autoformat when executing vi #161

cc: @hankchiutw

hankchiutw commented 4 years ago

I think this should be fixed after #217

mitermayer commented 4 years ago

This has been fixed on https://github.com/prettier/vim-prettier/pull/217

Will port the fix to other branches soon

lheberlie commented 4 years ago

thank you @hankchiutw @mitermayer