Home > Blockchain >  How can I install MacVim on OSX 12.5 and get it to run the REPL for Lisp?
How can I install MacVim on OSX 12.5 and get it to run the REPL for Lisp?

Time:09-03

I have installed MacVim on OS X 12.5 (Monterey) and have the Lisp highlighting working having installed Slimv into ~/.vim/pack/plugins/start/slimv. While the highlighting and auto paren management works fine from either MacVim launched from the Dock or vim from the Terminal, the system will not run the REPL, saying the version of vim is not enabled for python.

I installed vim via brew and the python option is enabled, confirmed with a check of --version. MacVim was installed in /applications via "brew install --cask macvim".

I have tried setting a PATH to include the brew directory with launchctl. I tried adding a directory clause to the MacVim .plist file to include the brew directory. Also tried modifying /etc/paths and added a file to /etc/paths.d without success.

Is there a setting in MacVim or vim that will point to the version of vim that brew loaded? Other recommedations to get the REPL working within vim?

User romainl, a kind stackoverflower asked that I add the --version output for vim. (I think it was for confirming the python capability so I isolated those lines.)

sholland@HHC ~ % which vim
/opt/homebrew/bin/vim
sholland@HHC ~ % echo $path
/opt/homebrew/bin /opt/homebrew/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /opt/X11/bin /Library/Apple/usr/bin
sholland@HHC ~ % vim --version 
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jul 25 2022 08:23:04)
macOS version - arm64
Included patches: 1-65
Compiled by GitHub Actions
Huge version with MacVim GUI.  Features included ( ) or not (-):
 acl                find_in_path       mouse_xterm       -tcl
 arabic             float              multi_byte         termguicolors
 autocmd            folding            multi_lang         terminal
 autochdir         -footer            -mzscheme           terminfo
-autoservername     fork()             netbeans_intg      termresponse
 balloon_eval       fullscreen         num64              textobjects
 balloon_eval_term  gettext            odbeditor          textprop
 browse            -hangul_input       packages           timers
  builtin_terms     iconv              path_extra         title
 byte_offset        insert_expand      perl/dyn           toolbar
 channel            ipv6               persistent_undo    transparency
 cindent            job                popupwin           user_commands
 clientserver       jumplist           postscript         vartabs
 clipboard          keymap             printer            vertsplit
 cmdline_compl      lambda             profile            vim9script
 cmdline_hist       langmap            python/dyn         viminfo
 cmdline_info       libcall            python3/dyn        virtualedit
 comments           linebreak          quickfix           visual
 conceal            lispindent         reltime            visualextra
 cryptv             listcmds           rightleft          vreplace
 cscope             localmap           ruby/dyn           wildignore
 cursorbind         lua/dyn            scrollbind         wildmenu
 cursorshape        menu               signs              windows
 dialog_con_gui     mksession          smartindent        writebackup
 diff               modify_fname       sodium            -X11
 digraphs           mouse             -sound             -xfontset
 dnd                mouseshape         spell              xim
-ebcdic             mouse_dec          startuptime       -xpm
 emacs_tags        -mouse_gpm          statusline        -xsmp
 eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
 ex_extra           mouse_netterm      syntax            -xterm_save
 extra_search       mouse_sgr          tag_binary        
-farsi             -mouse_sysmouse    -tag_old_static    
 file_in_path       mouse_urxvt       -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 -arch x86_64 -arch arm64 -I/usr/local/Cellar/libsodium/1.0.18_1/include -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -Wall -Wextra -Wshadow -Werror -Wno-error=missing-field-initializers -Wno-error=deprecated-declarations -Wno-error=unused-function 
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/[email protected]/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/[email protected]/lib -L/usr/local/opt/readline/lib -arch x86_64 -arch arm64 -L/usr/local/lib -o Vim -lm -lncurses /usr/local/lib/libsodium.a -liconv /usr/local/lib/libintl.a -framework AppKit -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE

I think when Slimv executes it is picking the vim in /usr/bin. That vim does not have the python ability. Or maybe it just can't find vim anywhere. --version for /usr/bin/vim below:

sholland@HHC ~ % /usr/bin/vim --version | grep python
 cmdline_hist      -langmap           -python             viminfo
 cmdline_info       libcall           -python3            virtualedit

Extending on the above, I see I can do a :ver in vim. I also found there is a test for python availability. That gave an interesting result (run in the vim command mode):

:execute (has('python3') ? "python3" : "python") . " import sys; print(sys.version)"

E370: Could not load library /System/Library/Frameworks/Python.framework/Versions/2.7/Python: dlopen(/System/Library/Frameworks/Python.fra
mework/Versions/2.7/Python, 0x0009): tried: '/System/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file), '/Library/Fr
ameworks/Python.framework/Versions/2.7/Python' (no such file)
E263: Sorry, this command is disabled, the Python library could not be loaded.


:ver
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jul 25 2022 08:23:04)
macOS version - arm64
Included patches: 1-65
Compiled by GitHub Actions
Huge version with MacVim GUI.  Features included ( ) or not (-):
 acl                dialog_con_gui     jumplist           multi_byte         sodium             vertsplit
 arabic             diff               keymap             multi_lang        -sound              vim9script
 autocmd            digraphs           lambda            -mzscheme           spell              viminfo
 autochdir          dnd                langmap            netbeans_intg      startuptime        virtualedit
-autoservername    -ebcdic             libcall            num64              statusline         visual
 balloon_eval       emacs_tags         linebreak          odbeditor         -sun_workshop       visualextra
 balloon_eval_term  eval               lispindent         packages           syntax             vreplace
 browse             ex_extra           listcmds           path_extra         tag_binary         wildignore
  builtin_terms     extra_search       localmap           perl/dyn          -tag_old_static     wildmenu
 byte_offset       -farsi              lua/dyn            persistent_undo   -tag_any_white      windows
 channel            file_in_path       menu               popupwin          -tcl                writebackup
 cindent            find_in_path       mksession          postscript         termguicolors     -X11
 clientserver       float              modify_fname       printer            terminal          -xfontset
 clipboard          folding            mouse              profile            terminfo           xim
 cmdline_compl     -footer             mouseshape         python/dyn         termresponse      -xpm
 cmdline_hist       fork()             mouse_dec          python3/dyn        textobjects       -xsmp
 cmdline_info       fullscreen        -mouse_gpm          quickfix           textprop          -xterm_clipboard
 comments           gettext           -mouse_jsbterm      reltime            timers            -xterm_save
 conceal           -hangul_input       mouse_netterm      rightleft          title
 cryptv             iconv              mouse_sgr          ruby/dyn           toolbar
 cscope             insert_expand     -mouse_sysmouse     scrollbind         transparency
 cursorbind         ipv6               mouse_urxvt        signs              user_commands
 cursorshape        job                mouse_xterm        smartindent        vartabs
   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 -arch x86_64 -arch arm64 -I/usr/local/Cellar/libsodium/1.0.18_1/include -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -W
all -Wextra -Wshadow -Werror -Wno-error=missing-field-initializers -Wno-error=deprecated-declarations -Wno-error=unused-function
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/[email protected]/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/[email protected]/lib
 -L/usr/local/opt/readline/lib -arch x86_64 -arch arm64 -L/usr/local/lib -o Vim -lm -lncurses /usr/local/lib/libsodium.a -liconv /
usr/local/lib/libintl.a -framework AppKit -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
Press ENTER or type command to continue

The interesting bit here is vim reports it has python and python3 enabled. However, the python test command errors out saying it couldn't find the files.

CodePudding user response:

MacVim doesn't have python3, it has python3/dyn which is quite different. See :help python-dynamic.

The former can be tested with:

:echo has('python3_dynamic')

while the latter can be tested with:

:echo has('python3')

The plugin you are trying to set up incorrectly tests for python3:

if ( !exists( 'g:slimv_python_version' ) && has( 'python3' ) ) ||

which can't work at all in MacVim, where has( 'python3' ) will always be false.

If you want to use that plugin, you have two options:

  • configure Vim properly and patch the plugin,
  • use a version of Vim that is built with python3.
  • Related