使用 fish shell 采购 nvim 配置抛出错误

sourcing nvim config throwing error with fish shell

我最近从 zsh 切换到 fish shell 并且在更新我的 nvim 配置文件时遇到错误

在条件语句中检查 $TMUX 环境变量时似乎出现错误。我在配置中添加了 set shell=/bin/bash 解决了重新加载问题 vim 但错误仍然存​​在。

这是我尝试 source ~/.config/nvim/init.vim:

时的错误
~/.config/nvim/init.vim (line 99): Illegal command name “exists("$TMUX")”
if exists("$TMUX")
   ^
from sourcing file ~/.config/nvim/init.vim
    called on line 1 of file -

in function “sv”
    called on standard input

source: Error while reading file “/home/slick/.config/nvim/init.vim”

困惑,因为我对 vim 脚本不是很扎实,我不确定 nvim 配置中的条件语句应该用哪种语言编写或如何解决此错误。

Vim 脚本,运行 外部命令需要 POSIX 兼容 shell。 Fish 显然不 POSIX 兼容。添加 set shell=/bin/sh(或其他一些 POSIX shell)到你的 vimrc。

source ~/.config/nvim/init.vim

是 Neovim 命令,而不是 shell 命令。没有理由 无论如何 期望您的 shell 理解 Neovim 的脚本语言,因此 运行 您 shell 中的命令毫无意义 完全.

运行 它在 Neovim 中,而不是在你的 shell 中。