老旧 Linux 系统搭建现代 C++ 开发环境 —— 基于 neovim

问题背景

公司配发的电脑是 macOS,日常开发需要访问 Linux 虚拟机,出于安全方面的考虑,只能通过跳板机登录。这阻止了大多数远程图形界面的使用,让写代码的工作变得复杂起来,市面上非常好用的 VSCode 都用不了。因此考虑基于 vim 搭建一套个人开发环境,需要支持以下特性:

  • 语法高亮 (风格可切换)
  • 自动格式化
  • 函数或变量定义跳转
  • 函数或变量引用跳转
  • 成员函数或变量下拉列表提示
  • 函数或变量 TAB 键自动补齐
  • 快速查找
  • ……

考察了多种方案后,决定基于目前比较流行的 neovim 来打造,不过它面向的是比较新的 Linux 发行版,不知道我这个老的 CentOS7 能不能带起来,本文就是一个探索过程。

系统环境

开始之前,先罗列下老旧系统的配置:

  • 硬件
    • CPU: 2.40GHz * 2 核
    • 内存: 16G
    • 存储: 40G + 100G
  • 软件
    • 系统:CentOS Linux release 7.9.2009 (Core)
    • kernel:3.10.0-1160.21.1.el7.x86_64
    • rpm:4.11.3
    • gcc:4.8.5 (备选 8.2)
    • glibc:2.17
    • make:GNU make 3.82
    • openssl:1.0.2k
    • git:1.8
    • wget:1.14
    • python: 3.6.8

确实是老旧,都是公司成本控制的泪~

软件安装

整个搭建过程是比较坎坷的,常常是装了 Z 之后才发现它依赖 X、Y,去安装 X、Y 的时候又发现一坨问题……这里为了直接上手,改为正叙模式,按这个方式一步步安装、升级,应该是没问题的。如果你的系统上已经存在依赖的软件且版本一致或更新,可以忽略对应安装过程。

在 Linux 上安装软件,一般有源码安装和包管理器安装两种方式,后者在 CentOS 上就是 yum 了,然而软件源提供的软件一般版本较低,有时需要使用前者,这就比较依赖 wget、git、gcc 和 make 了,这也是在上一节中列出他们版本的原因,在开始安装各种软件之前,需要首先升级他们。

基础软件升级

gcc

系统提供的 4.8.5 编译基本是够用的,后面代码格式化需要用到的 clang-format 模块如果是源码方式安装,要求 gcc 至少是 5.1,如果你有 5.1 及以上的 gcc 那更好。没有也没关系,本文会用其它方式绕过,毕竟升级 gcc 是一项大工程,没有半天是搞不定的,太耽误功夫。

虽然不必升级 gcc,但是一些代码库使用的高版本 gcc 默认了 -std=c99 选项,这点对老版本非常不友好,为此需要特意告诉老 gcc 编译器这个选项。具体就是修改 gcc 的 spec 文件,首先是确认当前系统 gcc 加载的 spec 文件:

> strace -e file gcc 2>&1 | grep specs
access("/usr/lib/gcc/x86_64-redhat-linux/4.8.5/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/lib/x86_64-redhat-linux/4.8.5/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/lib/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/x86_64-redhat-linux/specs", R_OK) = -1 ENOENT (No such file or directory)

目前看是没有,需要使用 gcc 析出一份默认的:

> sudo bash -c 'gcc -dumpspecs > /usr/lib/gcc/x86_64-redhat-linux/4.8.5/specs'

注意析出的路径就是上面加载路径中的第一条,内容如下:

查看代码
 *asm:
%{m32:--32} %{m32|mx32:;:--64} %{mx32:--x32} %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}
*asm_debug:
%{!g0:%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}} %{fdebug-prefix-map=*:--debug-prefix-map %*}
*asm_final:
%{gsplit-dwarf:
 objcopy --extract-dwo 	 %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O} 	 %{c:%{o*:%:replace-extension(%{o*:%*} .dwo)}%{!o*:%b.dwo}}%{!c:%b.dwo}
 objcopy --strip-dwo 	 %{c:%{o*:%*}%{!o*:%b%O}}%{!c:%U%O} }
*asm_options:
%{-target-help:%:print-asm-header()} %{v} %{w:-W} %{I*} %a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}
*invoke_as:
%{!fwpa: %{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()} %{!S:-o %|.s |
 as %(asm_options) %m.s %A } }
*cpp:
%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
*cpp_options:
%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*} %{undef} %{save-temps*:-fpch-preprocess}
*cpp_debug_options:
%{d*}
*cpp_unique_options:
%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I %{MD:-MD %{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}} %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD} %{!iplugindir*:%{fplugin*:%:find-plugindir()}} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{fmudflap:-D_MUDFLAP -include mf-runtime.h} %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h} %{E|M|MM:%W{o*}}
*trad_capable_cpp:
cc1 -E %{traditional|traditional-cpp:-traditional-cpp}
*cc1:
%{!mandroid|tno-android-cc:%(cc1_cpu) %{profile:-p};:%(cc1_cpu) %{profile:-p} %{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}}
*cc1_options:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %{!iplugindir*:%{fplugin*:%:find-plugindir()}} %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{aux-info*} %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{Qy:} %{-help:--help} %{-target-help:--target-help} %{-version:--version} %{-help=*:--help=%*} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage}
*cc1plus:
*link_gcc_c_sequence:
%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}
*link_ssp:
%{fstack-protector:}
*endfile:
%{!mandroid|tno-android-ld:%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s} %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s;:%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s} %{shared: crtend_so%O%s;: crtend_android%O%s}}
*link:
%{!r:--build-id} --no-add-needed %{!static:--eh-frame-hdr} --hash-style=gnu %{!mandroid|tno-android-ld:%{m32|mx32:;:-m elf_x86_64} %{m32:-m elf_i386} %{mx32:-m elf32_x86_64} %{shared:-shared} %{!shared: %{!static: %{rdynamic:-export-dynamic} %{m32:-dynamic-linker %{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:/lib/ld-linux.so.2}}} %{m32|mx32:;:-dynamic-linker %{muclibc:/lib/ld64-uClibc.so.0;:%{mbionic:/system/bin/linker64;:/lib64/ld-linux-x86-64.so.2}}} %{mx32:-dynamic-linker %{muclibc:/lib/ldx32-uClibc.so.0;:%{mbionic:/system/bin/linkerx32;:/libx32/ld-linux-x32.so.2}}}} %{static:-static}};:%{m32|mx32:;:-m elf_x86_64} %{m32:-m elf_i386} %{mx32:-m elf32_x86_64} %{shared:-shared} %{!shared: %{!static: %{rdynamic:-export-dynamic} %{m32:-dynamic-linker %{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:/lib/ld-linux.so.2}}} %{m32|mx32:;:-dynamic-linker %{muclibc:/lib/ld64-uClibc.so.0;:%{mbionic:/system/bin/linker64;:/lib64/ld-linux-x86-64.so.2}}} %{mx32:-dynamic-linker %{muclibc:/lib/ldx32-uClibc.so.0;:%{mbionic:/system/bin/linkerx32;:/libx32/ld-linux-x32.so.2}}}} %{static:-static}} %{shared: -Bsymbolic}}
*lib:
%{!mandroid|tno-android-ld:%{pthread:-lpthread} %{shared:-lc} %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}};:%{pthread:-lpthread} %{shared:-lc} %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}} %{!static: -ldl}}
*mfwrap:
 %{static: %{fmudflap|fmudflapth: --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc --wrap=mmap --wrap=mmap64 --wrap=munmap --wrap=alloca} %{fmudflapth: --wrap=pthread_create}} %{fmudflap|fmudflapth: --wrap=main}
*mflib:
%{fmudflap|fmudflapth: -export-dynamic}
*link_gomp:
*libgcc:
%{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --as-needed -lgcc_s --no-as-needed}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}}
*startfile:
%{!mandroid|tno-android-ld:%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s};:%{shared: crtbegin_so%O%s;: %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}}
*cross_compile:
0
*version:
4.8.5
*multilib:
. !m64 !m32;64:../lib64 m64 !m32;32:../lib !m64 m32;
*multilib_defaults:
m64
*multilib_extra:
*multilib_matches:
m64 m64;m32 m32;
*multilib_exclusions:
*multilib_options:
m64/m32
*multilib_reuse:
*linker:
collect2
*linker_plugin_file:
*lto_wrapper:
*lto_gcc:
*link_libgcc:
%D
*md_exec_prefix:
*md_startfile_prefix:
*md_startfile_prefix_1:
*startfile_prefix_spec:
*sysroot_spec:
--sysroot=%R
*sysroot_suffix_spec:
*sysroot_hdrs_suffix_spec:
*self_spec:
*cc1_cpu:
%{march=native:%>march=native %:local_cpu_detect(arch) %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune)}
*link_command:
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %{!fno-use-linker-plugin:%{flto|flto=*|fuse-linker-plugin: -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }}%{flto|flto=*:%<fcompare-debug*} %{flto} %{flto=*} %l %{pie:-pie} %{fuse-ld=*:-fuse-ld=%*} %X %{o*} %{e*} %{N} %{n} %{r} %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} %{static:} %{L*} %(mfwrap) %(link_libgcc) %{!nostdlib:%{!nodefaultlibs:%{fsanitize=address:%{!shared:libasan_preinit%O%s} %{static-libasan:%{!shared:-Bstatic --whole-archive -lasan --no-whole-archive -Bdynamic}}%{!static-libasan:-lasan}} %{fsanitize=thread:%{static-libtsan:%{!shared:-Bstatic --whole-archive -ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}}}} %o %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %{fgnu-tm:%:include(libitm.spec)%(link_itm)} %(mflib) %{fsplit-stack: --wrap=pthread_create} %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} %{!nostdlib:%{!nodefaultlibs:%{fsanitize=address: %{static-libasan:-ldl -lpthread} %{static:%ecannot specify -static with -fsanitize=address} %{fsanitize=thread:%e-fsanitize=address is incompatible with -fsanitize=thread}} %{fsanitize=thread: %{static-libtsan:-ldl -lpthread} %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or -shared}}}}} %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}} %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}

信息比较多,定位到关键字 *cc1_options:, 在 %{w}%{std*&ansi&trigraphs} 之间添加 -std=c99

> cat /usr/lib/gcc/x86_64-redhat-linux/4.8.5/specs.c99 | grep c99
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %{!iplugindir*:%{fplugin*:%:find-plugindir()}} %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{aux-info*} %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*} %{w} -std=c99 %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{Qy:} %{-help:--help} %{-target-help:--target-help} %{-version:--version} %{-help=*:--help=%*} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage}

再次运行 gcc,确认已加载修改后的 spec 文件:

> gcc -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

第一行的输出符合预期,整个过程可参考附录 4。

如果不进行这个设置,后面在编译 lsp-server 中的 lsp-kind.nvim & nvim-lspconfig 模块时会失败:

glibc

系统提供的 2.17 不行,clangd 需要至少 2.18,否则 neovim 中跳转相关的键 (gd/gD) 会失效,而 yum 上没有大于 2.17 版本的软件可用,需要手动更新下:

# 通过网盘链接下载 rpm 包
# 链接: https://pan.baidu.com/s/1QAyqa04iZ45q1-HqeYH80Q?pwd=1234 提取码: 1234 
> ls -lh *.rpm
-rw-r--r-- 1 yunhai01 DOORGOD 3.6M May 17 16:28 glibc-2.18-11.fc20.x86_64.rpm
-rw-r--r-- 1 yunhai01 DOORGOD 12M May 17 16:28 glibc-common-2.18-11.fc20.x86_64.rpm
-rw-r--r-- 1 yunhai01 DOORGOD 1.1M May 17 16:28 glibc-devel-2.18-11.fc20.x86_64.rpm
-rw-r--r-- 1 yunhai01 DOORGOD 648K May 17 16:28 glibc-headers-2.18-11.fc20.x86_64.rpm
> sudo rpm -Uvh --nodeps --force glibc-*.rpm
> ldd --version
ldd (GNU libc) 2.18
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

具体升级过程可参考附录 2。

make

系统提供的 3.82 GNU Make 基本够用。

openssl

系统提供的 1.0.2k 基本够用。

git

系统提供的 1.8 版本不行,需要升级到 2.38,否则不能识别 rebase=false 参数,导致插件更新时拉取代码库失败:

当时直接使用 yum install git 升级的版本还是比较低,所以我是手动安装的,但也取了个巧,直接安装了个 rpm 来更新 CentOS7 的软件源:

> sudo yum install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
> sudo yum install git
> git --version
git version 2.38.1

从而找到更新版本的 git,省了不少事。后来这个源还更新了,现在安装的话是 2.43 版本。

另外最好更新 /etc/hosts 文件以便加快对 github.com 的访问速度:

> cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
140.82.114.3 github.com
140.82.114.10 nodeload.github.com
140.82.114.6 api.github.com
140.82.114.10 codeload.github.com

这里的 ip 都是通过反查相关域名得到的,可能会有所不同,详情参考附录 3。

wget

系统提供的 1.14 版本不行,在拉取部分 lsp-server 时会出错 (cpp/lua),需要升级到 1.21.3:

> curl -o wget-latest.tar.gz http://mirrors.ustc.edu.cn/gnu/wget/wget-latest.tar.gz
> tar xvf wget-latest.tar.gz
> cd wget-1.21.3
> ./configure --with-ssl=openssl
> make -j8
> sudo make install
> wget --version
GNU Wget 1.21.3 built on linux-gnu.
-cares +digest -gpgme +https +ipv6 -iri +large-file -metalink +nls
+ntlm +opie -psl +ssl/openssl
Wgetrc:
 /usr/local/etc/wgetrc (system)
Locale:
 /usr/local/share/locale
Compile:
 gcc -std=gnu11 -DHAVE_CONFIG_H
 -DSYSTEM_WGETRC="/usr/local/etc/wgetrc"
 -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib
 -DHAVE_LIBSSL -DNDEBUG -g -O2
Link:
 gcc -std=gnu11 -DHAVE_LIBSSL -DNDEBUG -g -O2 -lpcre -lssl -lcrypto
 -lz ../lib/libgnu.a
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.

目前的 wget-lastest 指向的最新版本是 1.24.5。

python3

系统提供的 3.6.8 版本勉强够用,clang-format 编译安装要求 python 至少为 3.8 版本,可以选择安装 Python 3.8.1:

> sudo yum install libffi-devel
> wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
> tar -xvf Python-3.8.1.tgz
> cd Python-3.8.1
> ./configure --prefix=/usr/local/python3
> make -j8
> sudo make altinstall
> sudo ln -sf /usr/local/python3/bin/python3.8 /usr/bin/python3
> sudo ln -sf /usr/local/python3/bin/pip3.8 /usr/bin/pip3

不过可以通过直接下载 clang-format 来忽略这步,所以这里的 python3 没有升级,具体操作步骤在安装 clang-format 时介绍。

cargo

rust 的包管理器,系统未提供,需要单独安装:

> sudo yum install cargo
> cargo --version
cargo 1.65.0

用于后续安装 fd,它是一款 find 的替代者,可以实现更高效的文件查找,目前 yum 上最新的版本是 1.72.1。

go

go 语言编译器,系统未提供,需要单独安装:

> sudo yum install go
> go version
go version go1.17.12 linux/amd64

用来后续编译安装 efm-langserver,它是一款代码审查工具。目前 yum 源最新 go 版本是 1.20.12。为避免后续安装过程中出现网络访问错误的问题,可提前设置以下代理:

> go env -w GO111MODULE=on
> go env -w GOPROXY=https://goproxy.io,direct
> go env -w GOPRIVATE=*.corp.example.com

sqlite3

本地数据库,系统未提供,需要单独安装:

> sudo yum install sqlite sqlite-devel
> sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668

用于后续安装 scheme ,它是一款语法高亮插件,使用 sqlite3 存储信息。

升级后

  • gcc:4.8.5
  • glibc:2.18
  • make:GNU make 3.82
  • openssl:1.0.2k
  • git:2.43
  • wget:1.24.5
  • python: 3.6.8
  • cargo:1.72.1
  • go:1.20.12
  • sqlite3:3.7.17

依赖软件安装

rg

全名 ripgrep,是 grep 替代者,功能更强大,不能直接使用 yum 安装,通过添加 yum 源的方式来曲线安装:

> sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo
> sudo yum install ripgrep
> rg --version
ripgrep 13.0.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

源是固定的,版本目前仍保持 13.0.0。

fd

全名 fd-find,用来替代 find,功能更强大,有之前安装 cargo 的基础,直接安装:

> cargo install fd-find
> sudo cp ~/.cargo/bin/fd /usr/local/bin/
> fd --version 
fd 8.5.3

基于最新的 cargo 1.72.1 安装会报错:

> cargo install fd-find
 Updating crates.io index
 Downloaded fd-find v10.1.0
...
warning: spurious network error (3 tries remaining): [7] Couldn't connect to server (Failed to connect to 2a04:4e42:8c::649: Network is unreachable)
 Downloaded jemalloc-sys v0.5.4+5.3.0-patched
 Downloaded 64 crates (8.2 MB) in 3m 10s (largest was `linux-raw-sys` at 1.8 MB)
error: failed to compile `fd-find v10.1.0`, intermediate artifacts can be found at `/tmp/cargo-installBfI2hZ`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Caused by:
 package `clap_complete v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.72.1
 Try re-running cargo install with `--locked`

看起来需要升级 rustc (1.74 > 1.72.1),不过看到要安装的 fd-find 版本为 10.1.0,好像受到了启发,直接指定 fd-find 的版本为 8.5.3 重试:

> cargo install fd-find --version 8.5.3
 Downloaded fd-find v8.5.3
 Downloaded 1 crate (114.1 KB) in 9.31s
 Updating crates.io index
 Installing fd-find v8.5.3
 Updating crates.io index
...
 Downloaded 22 crates (2.2 MB) in 1m 07s (largest was `linux-raw-sys` at 1013.8 KB)
error: failed to compile `fd-find v8.5.3`, intermediate artifacts can be found at `/tmp/cargo-installmg1If6`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Caused by:
 package `clap_complete v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.72.1
 Try re-running cargo install with `--locked`

仍然失败,叔可忍婶不可忍,直接按提示加 --locked 选项:

查看代码
 > cargo install fd-find --version 8.5.3 --locked
 Updating crates.io index
 Installing fd-find v8.5.3
 Updating crates.io index
warning: spurious network error (3 tries remaining): [7] Couldn't connect to server (Failed to connect to 2600:9000:20e4:fe00:1f:a9f5:69c0:93a1: Network is unreachable)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation timed out after 30000 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: package `crossbeam-channel v0.5.6` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked
 Updating crates.io index
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation timed out after 30000 milliseconds with 0 out of 0 bytes received)
 Downloaded ctrlc v3.2.3
 Downloaded termcolor v1.1.3
 Downloaded crossbeam-utils v0.8.12
 Downloaded time v0.1.44
 Downloaded clap_complete v4.0.5
 Downloaded clap_derive v4.0.21
 Downloaded num-traits v0.2.15
 Downloaded thread_local v1.1.4
 Downloaded proc-macro2 v1.0.47
 Downloaded memchr v2.5.0
 Downloaded jemallocator v0.5.0
 Downloaded iana-time-zone v0.1.51
 Downloaded os_str_bytes v6.3.0
 Downloaded unicode-ident v1.0.5
 Downloaded globset v0.4.9
 Downloaded heck v0.4.0
 Downloaded clap v4.0.22
 Downloaded num-integer v0.1.45
 Downloaded proc-macro-error v1.0.4
 Downloaded quote v1.0.21
 Downloaded fs_extra v1.2.0
 Downloaded anyhow v1.0.66
 Downloaded fnv v1.0.7
 Downloaded nix v0.24.2
 Downloaded terminal_size v0.2.1
 Downloaded clap_lex v0.3.0
 Downloaded ignore v0.4.18
 Downloaded proc-macro-error-attr v1.0.4
 Downloaded io-lifetimes v0.7.4
 Downloaded log v0.4.17
 Downloaded regex v1.6.0
 Downloaded cc v1.0.73
 Downloaded once_cell v1.15.0
 Downloaded num_cpus v1.13.1
 Downloaded syn v1.0.103
 Downloaded rustix v0.35.12
 Downloaded nix v0.25.0
 Downloaded autocfg v1.1.0
 Downloaded crossbeam-channel v0.5.6
 Downloaded regex-syntax v0.6.27
 Downloaded bstr v0.2.17
 Downloaded chrono v0.4.22
 Downloaded linux-raw-sys v0.0.46
warning: spurious network error (3 tries remaining): [7] Couldn't connect to server (Failed to connect to 2a04:4e42:8c::649: Network is unreachable)
 Downloaded walkdir v2.3.2
 Downloaded jemalloc-sys v0.5.2+5.3.0-patched
 Downloaded aho-corasick v0.7.19
warning: spurious network error (3 tries remaining): [28] Timeout was reached (download of `libc v0.2.136` failed to transfer more than 10 bytes in 30s)
 Downloaded libc v0.2.136
 Downloaded 47 crates (5.7 MB) in 3m 17s
 Compiling libc v0.2.136
 Compiling cfg-if v1.0.0
 Compiling version_check v0.9.4
 Compiling proc-macro2 v1.0.47
 Compiling unicode-ident v1.0.5
 Compiling bitflags v1.3.2
 Compiling quote v1.0.21
 Compiling autocfg v1.1.0
 Compiling memchr v2.5.0
 Compiling proc-macro-error-attr v1.0.4
 Compiling io-lifetimes v0.7.4
 Compiling syn v1.0.103
 Compiling proc-macro-error v1.0.4
 Compiling log v0.4.17
 Compiling rustix v0.35.12
 Compiling num-traits v0.2.15
 Compiling crossbeam-utils v0.8.12
 Compiling cc v1.0.73
 Compiling fs_extra v1.2.0
 Compiling once_cell v1.15.0
 Compiling linux-raw-sys v0.0.46
 Compiling jemalloc-sys v0.5.2+5.3.0-patched
 Compiling aho-corasick v0.7.19
 Compiling num-integer v0.1.45
 Compiling os_str_bytes v6.3.0
 Compiling regex-syntax v0.6.27
 Compiling heck v0.4.0
 Compiling clap_derive v4.0.21
 Compiling regex v1.6.0
 Compiling clap_lex v0.3.0
 Compiling terminal_size v0.2.1
 Compiling bstr v0.2.17
 Compiling atty v0.2.14
 Compiling lazy_static v1.4.0
 Compiling strsim v0.10.0
 Compiling same-file v1.0.6
 Compiling fnv v1.0.7
 Compiling termcolor v1.1.3
 Compiling anyhow v1.0.66
 Compiling clap v4.0.22
 Compiling globset v0.4.9
 Compiling walkdir v2.3.2
 Compiling thread_local v1.1.4
 Compiling nix v0.25.0
 Compiling nix v0.24.2
 Compiling dirs-sys-next v0.1.2
 Compiling time v0.1.44
 Compiling fd-find v8.5.3
 Compiling ansi_term v0.12.1
 Compiling iana-time-zone v0.1.51
 Compiling chrono v0.4.22
 Compiling lscolors v0.12.0
 Compiling dirs-next v2.0.0
 Compiling argmax v0.3.1
 Compiling ctrlc v3.2.3
 Compiling ignore v0.4.18
 Compiling clap_complete v4.0.5
 Compiling jemallocator v0.5.0
 Compiling crossbeam-channel v0.5.6
 Compiling users v0.11.0
 Compiling num_cpus v1.13.1
 Compiling humantime v2.1.0
 Compiling normpath v0.3.2
 Finished release [optimized] target(s) in 10m 44s
warning: the following packages contain code that will be rejected by a future version of Rust: fs_extra v1.2.0
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
 Installing /home/users/yunhai01/.cargo/bin/fd
 Installed package `fd-find v8.5.3` (executable `fd`)
warning: be sure to add `/home/users/yunhai01/.cargo/bin` to your PATH to be able to run the installed binaries

这回成功了。尝试为之前安装失败的 10.1.0 版本增加 --locked 选项:

> cargo install fd-find --locked
 Updating crates.io index
 Installing fd-find v10.1.0
 Updating crates.io index
warning: package `libc v0.2.154` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked
 Updating crates.io index
 Downloaded proc-macro2 v1.0.81
 Downloaded anyhow v1.0.82
 Downloaded serde v1.0.200
 Downloaded errno v0.3.8
 Downloaded cc v1.0.96
 Downloaded syn v2.0.60
 Downloaded libc v0.2.154
 Downloaded linux-raw-sys v0.4.13
 Downloaded 8 crates (2.8 MB) in 1m 27s (largest was `linux-raw-sys` at 1.5 MB)
error: failed to compile `fd-find v10.1.0`, intermediate artifacts can be found at `/tmp/cargo-installVoh51U`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Caused by:
 package `clap_builder v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.72.1

仍然不行,看来回退 8.5.3 是唯一的解决办法。之前还探索过将 cargo 版本降为 1.65.0:

> sudo yum remove cargo
> sudo yum install cargo-1.65.0-1.el7.x86_64
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use "yum versionlock status" to show it)
No package cargo-1.65.0-1.el7.x86_64 available.
Error: Nothing to do

未能成功。在网上也没搜到 1.65.0 的 cargo rpm 包,只能作罢。不清楚为何 1.72.1 的 cargo 要求 1.74 的 rustc,严重怀疑这是一个 bug。

书归正题,在安装完 fd 8.5.3 后需要按提示将 fd 移到 /usr/loca/bin:

> sudo cp /home/users/yunhai01/.cargo/bin/fd /usr/local/bin/
> fd --version
fd 8.5.3

否则 neovim 找不到。

tree-sitter

是一个解析器生成工具和增量解析库,在 nvim 中主要用作 latex 语言解析器、以及 rainbow-delimiters.nvim 和 nvim-treesitter.nvim 插件的底层支持。rainbow-delimiters 主要用于多种语言的语法高亮,特别是多括号的展示;nvim-treesitter 主要用于高效代码导航与编辑,是 IDE 不可或缺的底层组件。

可以使用 cargo 安装:

> cargo install tree-sitter-cli

会遇到和安装 fd 类似的问题:

查看代码
 > cargo install tree-sitter-cli
 Updating crates.io index
 Installing tree-sitter-cli v0.22.6
 Updating crates.io index
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation timed out after 30001 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation timed out after 30000 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation timed out after 30001 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
 Downloaded httpdate v1.0.3
 Downloaded equivalent v1.0.1
 Downloaded tiny_http v0.12.0
 Downloaded anstyle-query v1.1.0
 Downloaded ascii v1.1.0
 Downloaded dirs-sys v0.4.1
 Downloaded serde_derive v1.0.203
 Downloaded tempfile v3.10.1
 Downloaded clap_builder v4.5.6
 Downloaded webbrowser v1.0.1
 Downloaded tree-sitter-config v0.22.6
 Downloaded tree-sitter-tags v0.22.6
 Downloaded proc-macro2 v1.0.85
 Downloaded percent-encoding v2.3.1
 Downloaded unicode-normalization v0.1.23
 Downloaded semver v1.0.23
 Downloaded libloading v0.8.3
 Downloaded filetime v0.2.23
 Downloaded idna v0.5.0
 Downloaded ahash v0.8.11
 Downloaded itoa v1.0.11
 Downloaded form_urlencoded v1.2.1
 Downloaded zerocopy v0.7.34
 Downloaded wasmparser v0.206.0
 Downloaded option-ext v0.2.0
 Downloaded dirs v5.0.1
 Downloaded serde_json v1.0.117
 Downloaded chunked_transfer v1.5.0
 Downloaded ryu v1.0.18
 Downloaded tree-sitter v0.22.6
warning: spurious network error (3 tries remaining): [35] SSL connect error (TCP connection reset by peer)
 Downloaded thiserror-impl v1.0.61
 Downloaded clap_lex v0.7.1
 Downloaded serde v1.0.203
 Downloaded unicode-bidi v0.3.15
 Downloaded glob v0.3.1
 Downloaded tree-sitter-loader v0.22.6
 Downloaded indexmap v2.2.6
 Downloaded fastrand v2.1.0
 Downloaded url v2.5.0
 Downloaded indoc v2.0.5
 Downloaded tinyvec_macros v0.1.1
 Downloaded rustc-hash v1.1.0
 Downloaded clap v4.5.6
 Downloaded html-escape v0.2.13
 Downloaded clap_derive v4.5.5
 Downloaded tree-sitter-highlight v0.22.6
 Downloaded fs4 v0.8.3
warning: spurious network error (3 tries remaining): [28] Timeout was reached (download of `difference v2.0.0` failed to transfer more than 10 bytes in 30s)
 Downloaded difference v2.0.0
warning: spurious network error (3 tries remaining): [7] Couldn't connect to server (Failed to connect to 2a04:4e42:1a::649: Network is unreachable)
 Downloaded utf8-width v0.1.7
warning: spurious network error (3 tries remaining): [28] Timeout was reached (download of `hashbrown v0.14.5` failed to transfer more than 10 bytes in 30s)
 Downloaded hashbrown v0.14.5
warning: spurious network error (3 tries remaining): [28] Timeout was reached (download of `smallbitvec v2.5.3` failed to transfer more than 10 bytes in 30s)
 Downloaded smallbitvec v2.5.3
warning: spurious network error (3 tries remaining): [28] Timeout was reached (download of `thiserror v1.0.61` failed to transfer more than 10 bytes in 30s)
 Downloaded thiserror v1.0.61
warning: spurious network error (3 tries remaining): [28] Timeout was reached (download of `tinyvec v1.6.0` failed to transfer more than 10 bytes in 30s)
 Downloaded tinyvec v1.6.0
 Downloaded 53 crates (2.7 MB) in 4m 35s
error: failed to compile `tree-sitter-cli v0.22.6`, intermediate artifacts can be found at `/tmp/cargo-installFBNfkt`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Caused by:
 package `tree-sitter-highlight v0.22.6` cannot be built because it requires rustc 1.74.1 or newer, while the currently active rustc version is 1.72.1
 Try re-running cargo install with `--locked`

增加 --locked 选项应该可以解决问题,使用 cargo 1.72.1 目前安装的版本为 0.22.6,这个版本运行依赖较高的 glibc,所以放弃。

通过官方提示的 npm 方式安装的结果也差不多:

> npm install tree-sitter-cli
added 1 package in 10m
> ls -lh node_modules/tree-sitter-cli/
total 25M
-rwxr-xr-x 1 yunhai01 DOORGOD 303 Jun 7 12:13 cli.js
-rw-r--r-- 1 yunhai01 DOORGOD 14K Jun 7 12:13 dsl.d.ts
-rwxr-xr-x 1 yunhai01 DOORGOD 3.4K Jun 7 12:13 install.js
-rw-r--r-- 1 yunhai01 DOORGOD 1.1K Jun 7 12:13 LICENSE
-rw-r--r-- 1 yunhai01 DOORGOD 534 Jun 7 12:13 package.json
-rw-r--r-- 1 yunhai01 DOORGOD 1.7K Jun 7 12:13 README.md
-rwxr-xr-x 1 yunhai01 DOORGOD 25M Jun 7 12:23 tree-sitter
> node_modules/tree-sitter-cli/tree-sitter --version
node_modules/tree-sitter-cli/tree-sitter: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node_modules/tree-sitter-cli/tree-sitter)
node_modules/tree-sitter-cli/tree-sitter: /lib64/libc.so.6: version `GLIBC_2.29' not found (required by node_modules/tree-sitter-cli/tree-sitter)
node_modules/tree-sitter-cli/tree-sitter: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node_modules/tree-sitter-cli/tree-sitter)

最早之前安装的 0.20.7 版本是 ok 的,想通过这种方式安装的朋友,可以指定版本试一下。注意这两种方式安装后的文件分别位于 ~/.cargo/bin./node_modules/tree-sitter-cli 下,需要手动复制到 /usr/local/bin 以便生效。

现在介绍第三种安装方式,不依赖 cargo、npm 等包管理器,直接定位到 tree-sitter 官方下载页面,选择 0.20.4 版本,对于我的 CentOS7 x64 版本,选择 tree-sitter-linux-x64.gz 下载即可:

> gunzip tree-sitter-linux-x64.gz 
> chmod u+x tree-sitter-linux-x64
> sudo mv tree-sitter-linux-x64 /usr/local/bin
> tree-sitter --version
tree-sitter 0.20.4 (714bfd47a744ab44b904375c177a24c0614ef49c)

按上一面一步步执行就安装好了,亲测高于 0.20.4 的版本就有 glibc 兼容问题 (>2.18)。

efm-langserver

实现智能 IDE 的核心,基于 go 语言开发,使用 go 编译安装:

> go install github.com/mattn/efm-langserver@latest

安装后没有找到 efm-langserver,经查,go 1.20 之后,需要通过 GOPATH 环境变量来指定安装目录:

> export GOPATH=/ext/tools
> go install github.com/mattn/efm-langserver@latest
go: downloading github.com/mattn/efm-langserver v0.0.53
go: downloading github.com/sourcegraph/jsonrpc2 v0.2.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/mattn/go-unicodeclass v0.0.2
go: downloading github.com/reviewdog/errorformat v0.0.0-20240311054359-739e471a49b3

同样需要复制到 /usr/local/bin 目录以便全局生效:

> sudo cp bin/efm-langserver /usr/local/bin
> efm-langserver -v
efm-langserver 0.0.53 (rev: HEAD/go1.20.12)

比之前安装的版本略高一些:

> efm-langserver -v
efm-langserver 0.0.44 (rev: 36a4d81/go1.17.12)

Font

下载可支持符号的字体,例如:Nerd Font,在 macOS 上的安装非常简单,直接双击 ttf 文件安装:

然后在 macOS 终端上指定该字体,这里我使用的是 iTerm2,其它终端大同小异:

iTerm2 有以下 UI 路径:iTerm2 -> settings -> Profiles -> Default -> Text -> Font。下面是安装带符号字体前后的对比:

状态栏很多不能显示的符号都正常了 (标签页的仍保持问号,可能是一个特殊符号 Nerd Font 不支持)。

neovim

IDE 的载体,不使用 yum 安装,原因是 yum 上目前只有 0.3 版本的 neovim,而支持现代化 IDE 核心的 packer 包管理器至少需要 0.7 版本。这里使用 curl 直接下载最新版本:

> curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage

启动:

> chmod u+x nvim.appimage
> ./nvim.appimage

报错:

/tmp/.mount_nvim.aw3KspQ/usr/bin/nvim: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /tmp/.mount_nvim.aw3KspQ/usr/bin/nvim)
/tmp/.mount_nvim.aw3KspQ/usr/bin/nvim: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/.mount_nvim.aw3KspQ/usr/bin/nvim)

看起来需要升级 glibc 2.29,为了避免再次更新 glibc,这里直接选择可以成功安装的 neovim 0.9.2 版本:

> wget https://github.com/neovim/neovim/releases/download/v0.9.2/nvim.appimage

友情提示:可以在 web 端下载后传递给虚拟机,macOS 访问 github 要比虚拟机快许多。

下载成功后,运行 nvim.appimage 可以自动释放目标文件:

> chmod u+x nvim.appimage
> ./nvim.appimage

如果运行后没有产生 squashfs-root 目录,说明系统缺乏 FUSE (用户空间文件系统),需要手动释放一下:

> ./nvim.appimage --appimage-extract

设置到 /usr/local/bin 后就可以被全局引用了:

> sudo ln -s $PWD/squashfs-root/AppRun /usr/local/bin/nvim
> nvim --version
NVIM v0.9.2
Build type: Release
LuaJIT 2.1.1692716794
 system vimrc file: "$VIM/sysinit.vim"
 fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info

nvimdots

IDE 的实现,按照 github 主页 README 的说明直接安装:

if command -v curl >/dev/null 2>&1; then
 bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)"
else
 bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)"
fi

脚本会自动判断 neovim 版本并进行适配:

> bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)"
--2024-05-24 15:32:21-- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh
Resolving raw.githubusercontent.com... 185.199.108.133, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7830 (7.6K) [text/plain]
Saving to: ‘STDOUT’
- 100%[======================================================================================================>] 7.65K 6.79KB/s in 1.1s
2024-05-24 15:32:25 (6.79 KB/s) - written to stdout [7830/7830]
==> This script will install ayamir/nvimdots to:
/home/users/yunhai01/.config/nvim
Press RETURN/ENTER to continue or any other key to abort...
==> Validating SSH connection...
Do you prefer to use SSH to fetch and update plugins? (otherwise HTTPS) [Y/n]:
==> Checking 'git clone' preferences...
Would you like to perform a shallow clone ('--depth=1')? [Y/n]:
==> Fetching in progress...
Cloning into '/home/users/yunhai01/.config/nvim'...
remote: Enumerating objects: 170, done.
remote: Counting objects: 100% (170/170), done.
remote: Compressing objects: 100% (162/162), done.
remote: Total 170 (delta 5), reused 73 (delta 0), pack-reused 0
Receiving objects: 100% (170/170), 108.87 KiB | 203.00 KiB/s, done.
Resolving deltas: 100% (5/5), done.
==> Spawning Neovim and fetching plugins... (You'll be redirected shortly)
==> NOTE: Please make sure you have a Rust Toolchain installed via `rustup`! Otherwise, unexpected things may
 happen. See: https://www.rust-lang.org/tools/install.
==> If lazy.nvim failed to fetch any plugin(s), maunally execute `:Lazy sync` until everything is up-to-date.
Thank you for using this set of configuration!
- Project Homepage:
 https://github.com/ayamir/nvimdots
- Further documentation (including executables you must install for full functionality):
 https://github.com/ayamir/nvimdots/wiki/Prerequisites
Press RETURN/ENTER to continue or any other key to abort...

执行过程中会让用户进行若干选项,都按默认处理就可以了。到这里所有必需软件就都安装完成了,按任意键将进入插件的安装,具体内容在下一节介绍。

安装后的目录位于:~/.config/nvim/。注意这里不要选择 neovim 0.8.1 (说的就是我),否则后面启动插件管理器时会报错:

Error executing Lua callback: ...l/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/float.lua:159: Vim(append):Error executing lua callback: ...zy/rainbow-delimiters.nvim/plugin/rainbow-delimiter
s.lua:50: attempt to call field 'get_lang' (a nil value)
stack traceback:
 ...zy/rainbow-delimiters.nvim/plugin/rainbow-delimiters.lua:50: in function 'attach'
 ...zy/rainbow-delimiters.nvim/plugin/rainbow-delimiters.lua:151: in function <...zy/rainbow-delimiters.nvim/plugin/rainbow-delimiters.lua:151>
 [C]: in function '__newindex'
 ...l/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/float.lua:159: in function 'mount'
 ...l/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/float.lua:75: in function 'init'
 ...al/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/init.lua:53: in function 'create'
 ...al/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/init.lua:38: in function 'show'
 ...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:38: in function 'command'
 ...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:24: in function 'cmd'
 ...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:111: in function <...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:98>
stack traceback:
 [C]: in function '__newindex'
 ...l/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/float.lua:159: in function 'mount'
 ...l/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/float.lua:75: in function 'init'
 ...al/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/init.lua:53: in function 'create'
 ...al/share/nvim/site/lazy/lazy.nvim/lua/lazy/view/init.lua:38: in function 'show'
 ...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:38: in function 'command'
 ...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:24: in function 'cmd'
 ...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:111: in function <...hare/nvim/site/lazy/lazy.nvim/lua/lazy/view/commands.lua:98>

基本无解。

开发环境搭建

框架好比是毛坯房,想要入住还得“精装修”一下,主要是安装各种插件,以及本地化配置。

插件安装

同许多 IDE 一样,vim 很多功能是通过插件实现的,插件本身需要管理,这就催生了形形色色的插件管理器,知名的有 vim-plug、Vundle;vim 进化到 neovim 之后,有两个主要的插件管理器,一个是 packer,另一个是 lazy,两个都很好用,之前 nvimdots 使用的 packer,后来更新到了 lazy,可以有效的提升 neovim 的启动速度。

lazy

书接上节,在 nvimdots 安装结束后,按任意键将启动 nvim、自动拉起插件更新:

这个界面静静等待即可,最终都能安装成功:

在 lazy 插件管理页面,输入标签后面的字符可实现跳转,例如 U 跳转到更新插件页面。

也可以直接在命令行输入 :Lazy sync 来切换到 Sync 标签:

其它也类似,不再赘述。当所有插件安装结束后,q 退出界面。与原先的 packer 界面相比:

简直像从远古社会跨进到了现代社会。退出 lazy、退出 nvim,插件安装路径位于:~/.local/share/nvim 目录下。再次进入 nvim,将看到欢迎界面:

基本功能已经可用,有几个未安装的插件将继续安装。

mason

mason 也是一个插件管理器,聚焦于 lsp 服务、dap 服务、linter 和 formatter 方向,通过它可以让 nvim 轻松支持多种编程语言的智能化展示。通过 :Mason 启动:

可以观察到系统可用的语言插件、安装成功的、安装失败的,这里主要需要处理 2 个插件的安装。

clangd

从上面的日志可以看出,安装失败的原因主要是从网络获取 clangd 包失败,这里改为手动下载:

> wget https://github.com/clangd/clangd/releases/download/18.1.3/clangd-linux-18.1.3.zip
> mv clangd-linux-18.1.3.zip ~/.local/share/nvim/mason/packages
> cd ~/.local/share/nvim/mason/packages
> unzip clangd-linux-18.1.3.zip
> cd ../bin
> ln -s $PWD/../packages/clangd_18.1.3/bin/clangd clangd
> ./clangd --version
clangd version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu

解压并替换到目标目录、设置命令软链接后,重启 nvim 查看:

安装成功,如果 nvim 仍显示安装 clangd,就多重启几次,甚至重启下机器。

clang-format

查看 clang-format 错误日志:

没看出来安装失败的直接原因,这里改为手动下载:

> wget -c https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-1d7ec53d/clang-format-10_linux-amd64
> chmod u+x clang-format-10_linux-arm64
> mkdir -p ~/.local/share/nvim/mason/packages/clang-format/bin
> mv clang-format-10_linux-amd64 ~/.local/share/nvim/mason/packages/clang-format/bin
> cd ~/.local/share/nvim/mason/bin
> ln -s $PWD/../packages/clang-format/bin/clang-format-10_linux-amd64 clang-format
> ./clang-format --version
clang-format version 10.0.1

替换到目标目录、设置命令软链接后,重启 nvim 查看:

安装成功。如果想让 Mason 安装 clang-format,除了之前介绍的升级 python3 步骤外,还需要以下操作:

> sudo pip3 install wheel
# 进入 nvim
MasonInstall clang-format

最后还有两个插件 python-lsp-server & gopls 没安装成功,分别是 python 与 go 语言 lspserver,由于本文着重介绍 C/C++ 环境的搭建,这个偏离主题就不再赘述了,有需求的小伙伴可以在 nvimdots 中提问寻求帮助。

如果不想看到每次在启动时它们的报错信息,可以选择不加载它们,具体操作步骤详见配置一节。

配置

各种功能插件安装完成后,还需要修改化配置一番,为了方便调用 neovim,在 bash 启动脚本中增加以下内容:

alias vi=nvim
alias vim=nvim

这样就可以使用 vi 或 vim 代替 nvim 了,相当于替换了默认的 vim 编辑器,如果想调用原始的 vim 编辑器,需要输入完整路径:

> /usr/bin/vi

在进行配置之前,首先对 nvim 进行一次自我体验,这主要是通过 :checkhealth 命令来完成,下面是完整的 checkhealth 输出:

查看代码
 
==============================================================================
hop: require("hop.health").check()
Ensuring keys are unique ~
- OK Keys are unique
Checking for deprecated features ~
- OK All good
==============================================================================
lazy: require("lazy.health").check()
lazy.nvim ~
- OK Git installed
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found
==============================================================================
lspsaga: require("lspsaga.health").check()
Lspsaga.nvim report ~
- OK `tree-sitter` found
- OK tree-sitter `markdown` parser found
- OK tree-sitter `markdown_inline` parser found
==============================================================================
luasnip: require("luasnip.health").check()
luasnip ~
- WARNING For Variable/Placeholder-transformations, luasnip requires
 the jsregexp library. See `:help |luasnip-lsp-snippets-transformations`| for advice
==============================================================================
mason: require("mason.health").check()
mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: prepend
- OK Providers:
 mason.providers.registry-api
 mason.providers.client
- OK neovim version >= 0.7.0
mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-06-07-fast-test` is installed.
mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send`
- OK wget: `GNU Wget 1.24.5 built on linux-gnu.`
- OK curl: `curl 7.87.0 (x86_64-pc-linux-muslx32) libcurl/7.87.0 OpenSSL/1.1.1s zlib/1.2.12 libssh2/1.9.0 nghttp2/1.43.0`
- OK gzip: `gzip 1.5`
- OK gtar: `tar (GNU tar) 1.26`
- OK bash: `GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)`
- OK sh: `Ok`
mason.nvim [Languages] ~
- WARNING luarocks: not available
 - ADVICE:
 - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- WARNING Ruby: not available
 - ADVICE:
 - spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING RubyGem: not available
 - ADVICE:
 - spawn: gem failed with exit code - and signal -. gem is not executable
- WARNING Composer: not available
 - ADVICE:
 - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
 - ADVICE:
 - spawn: php failed with exit code - and signal -. php is not executable
- OK node: `v16.18.1`
- OK cargo: `cargo 1.72.1`
- WARNING julia: not available
 - ADVICE:
 - spawn: julia failed with exit code - and signal -. julia is not executable
- OK Go: `go version go1.20.12 linux/amd64`
- OK python: `Python 3.6.8`
- OK java: `openjdk version "1.8.0_322"`
- OK pip: `pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)`
- OK python venv: `Ok`
- OK javac: `Ok`
- OK npm: `8.19.2`
mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 1. Remaining: 59. Limit: 60. Reset: Fri 07 Jun 2024 04:40:44 PM CST.
 Install and authenticate via gh-cli to increase rate limit.
==============================================================================
neoconf: require("neoconf.health").check()
neoconf.nvim ~
- OK **treesitter-nvim** is installed
- OK **TreeSitter jsonc** parser is installed
- WARNING **neodev.nvim** is not installed. You won't get any proper completion for your Neovim config.
- OK **lspconfig** is installed
- OK **lspconfig jsonls** is installed
- OK **lspconfig lua_ls** is installed
==============================================================================
null-ls: require("null-ls.health").check()
- OK clang_format: the command "clang-format" is executable.
- OK prettier: the command "prettier" is executable.
- OK gofumpt: the command "gofumpt" is executable.
- OK shfmt: the command "shfmt" is executable.
- OK stylua: the command "stylua" is executable.
- OK vint: the command "vint" is executable.
- OK goimports: the command "goimports" is executable.
==============================================================================
nvim: require("nvim.health").check()
Configuration ~
- OK no issues found
Runtime ~
- OK $VIMRUNTIME: /ext/tools/squashfs-root/usr/share/nvim/runtime
Performance ~
- OK Build type: Release
Remote Plugins ~
- WARNING "wilder.nvim" is not registered.
- WARNING Out of date
 - ADVICE:
 - Run `:UpdateRemotePlugins`
terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=\177`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $SSH_TTY="/dev/pts/0"
==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()
Installation ~
- OK `tree-sitter` found 0.20.4 (714bfd47a744ab44b904375c177a24c0614ef49c) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v16.18.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
 Version: cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
OS Info:
{
 machine = "x86_64",
 release = "3.10.0-1160.21.1.el7.x86_64",
 sysname = "Linux",
 version = "#1 SMP Tue Mar 16 18:28:22 UTC 2021"
} ~
Parser/Features H L F I J
 - bash ✓ ✓ ✓ . ✓
 - c ✓ ✓ ✓ ✓ ✓
 - cpp ✓ ✓ ✓ ✓ ✓
 - css ✓ . ✓ ✓ ✓
 - go ✓ ✓ ✓ ✓ ✓
 - gomod ✓ . . . ✓
 - html ✓ ✓ ✓ ✓ ✓
 - javascript ✓ ✓ ✓ ✓ ✓
 - json ✓ ✓ ✓ ✓ .
 - jsonc ✓ ✓ ✓ ✓ ✓
 - latex ✓ . ✓ . ✓
 - lua ✓ ✓ ✓ ✓ ✓
 - make ✓ . ✓ . ✓
 - markdown ✓ . ✓ ✓ ✓
 - markdown_inline ✓ . . . ✓
 - python ✓ ✓ ✓ ✓ ✓
 - query ✓ ✓ ✓ ✓ ✓
 - rust ✓ ✓ ✓ ✓ ✓
 - typescript ✓ ✓ ✓ ✓ ✓
 - vim ✓ ✓ ✓ . ✓
 - vimdoc ✓ . . . ✓
 - vue ✓ . ✓ ✓ ✓
 - yaml ✓ ✓ ✓ ✓ ✓
 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
 +) multiple parsers found, only one will be used
 x) errors found in the query, try to run :TSUpdate {lang} ~
==============================================================================
provider: health#provider#check
Clipboard (optional) ~
- WARNING No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.
 - ADVICE:
 - :help |clipboard|
Python 3 provider (optional) ~
- Using: g:python3_host_prog = "python3"
- Executable: /usr/bin/python3
- ERROR Command error (job=16, exit code 1): `'/usr/bin/python3' -c 'import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; print(neovim.__file__)'` (in '/home/users/yunhai01/project/baidu/netdisk/p2p-sdk-mobile')
 stderr: Traceback (most recent call last): File "<string>", line 1, in <module>ModuleNotFoundError: No module named 'neovim'
- Python version: 3.6.8
- pynvim version: unable to load neovim Python module
- ERROR pynvim is not installed.
 Error: unable to load neovim Python module
 - ADVICE:
 - Run in shell: /usr/bin/python3 -m pip install pynvim
Python virtualenv ~
- OK no $VIRTUAL_ENV
Ruby provider (optional) ~
- WARNING `ruby` and `gem` must be in $PATH.
 - ADVICE:
 - Install Ruby and verify that `ruby` and `gem` commands work.
Node.js provider (optional) ~
- Node.js: v16.18.1
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
 - ADVICE:
 - Run in shell: npm install -g neovim
 - Run in shell (if you use yarn): yarn global add neovim
 - Run in shell (if you use pnpm): pnpm install -g neovim
 - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim
Perl provider (optional) ~
- WARNING Perl version is too old, 5.22+ required
 - ADVICE:
 - See :help |provider-perl| for more information.
 - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim
==============================================================================
rainbow-delimiters: require("rainbow-delimiters.health").check()
Custom strategies ~
- OK Valid custom default strategy.
- OK Valid custom strategy for 'vim'.
- OK Valid custom strategy for 'lua'.
- OK Valid custom strategy for 'cpp'.
- OK Valid custom strategy for 'vimdoc'.
- OK Valid custom strategy for 'c'.
Custom queries ~
- OK Valid custom default query
- OK Valid custom query for 'javascript'
- OK Valid custom query for 'latex'
Custom highlight groups ~
- OK Highlight group 'RainbowDelimiterRed' defined.
- OK Highlight group 'RainbowDelimiterOrange' defined.
- OK Highlight group 'RainbowDelimiterYellow' defined.
- OK Highlight group 'RainbowDelimiterGreen' defined.
- OK Highlight group 'RainbowDelimiterBlue' defined.
- OK Highlight group 'RainbowDelimiterCyan' defined.
- OK Highlight group 'RainbowDelimiterViolet' defined.
==============================================================================
telescope: require("telescope.health").check()
Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.
Checking external dependencies ~
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.5.3
===== Installed extensions ===== ~
Telescope Extension: `aerial` ~
- No healthcheck provided
Telescope Extension: `frecency` ~
- OK nvim-web-devicons installed.
- OK ripgrep installed.
Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured
Telescope Extension: `live_grep_args` ~
- No healthcheck provided
Telescope Extension: `notify` ~
- No healthcheck provided
Telescope Extension: `persisted` ~
- No healthcheck provided
Telescope Extension: `projects` ~
- No healthcheck provided
Telescope Extension: `undo` ~
- No healthcheck provided
Telescope Extension: `zoxide` ~
- No healthcheck provided
==============================================================================
vim.lsp: require("vim.lsp.health").check()
- LSP log level : WARN
- Log path: /home/users/yunhai01/.local/state/nvim/lsp.log
- Log size: 54 KB
vim.lsp: Active Clients ~
- clangd (id=1, root_dir=/home/users/yunhai01/project/baidu/netdisk/p2p-sdk-mobile)
- null-ls (id=2, root_dir=/home/users/yunhai01/project/baidu/netdisk/p2p-sdk-mobile/project/src)
- copilot (id=3, root_dir=/home/users/yunhai01/project/baidu/netdisk/p2p-sdk-mobile/project/src)
==============================================================================
vim.treesitter: require("vim.treesitter.health").check()
- Nvim runtime ABI version: 14
- OK Parser: bash ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/bash.so
- OK Parser: c ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/c.so
- OK Parser: cpp ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/cpp.so
- OK Parser: css ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/css.so
- OK Parser: go ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/go.so
- OK Parser: gomod ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/gomod.so
- OK Parser: html ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/html.so
- OK Parser: javascript ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/javascript.so
- OK Parser: json ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/json.so
- OK Parser: jsonc ABI: 13, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/jsonc.so
- OK Parser: latex ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/latex.so
- OK Parser: lua ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/lua.so
- OK Parser: make ABI: 13, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/make.so
- OK Parser: markdown ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/markdown.so
- OK Parser: markdown_inline ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/markdown_inline.so
- OK Parser: python ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/python.so
- OK Parser: rust ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/rust.so
- OK Parser: typescript ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/typescript.so
- OK Parser: vimdoc ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/vimdoc.so
- OK Parser: vue ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/vue.so
- OK Parser: yaml ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/yaml.so
- OK Parser: c ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/c.so
- OK Parser: lua ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/lua.so
- OK Parser: query ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/query.so
- OK Parser: vim ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/vim.so
- OK Parser: vimdoc ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/vimdoc.so
==============================================================================
which-key: require("which-key.health").check()
- ERROR Failed to run healthcheck for "which-key" plugin. Exception:
 function health#check, line 25
 Vim(eval):E5108: Error executing lua ...are/nvim/site/lazy/which-key.nvim/lua/which-key/keys.lua:406: Invalid buffer id: 97
 stack traceback:
 [C]: in function 'nvim_buf_get_keymap'
 ...are/nvim/site/lazy/which-key.nvim/lua/which-key/keys.lua:406: in function 'update_keymaps'
 ...e/nvim/site/lazy/which-key.nvim/lua/which-key/health.lua:15: in function 'check'
 [string "luaeval()"]:1: in main chunk

如果有插件工作不正常、老报警告框,可以通过自检发现一些问题。

主题

启动后默认的黑色背景看着黑乎乎的不够亮快,通过快捷键 (SPACE + f + c) 调出主题切换页:

这里选择 catppuccin-latte:

好多了。不过重启后就又恢复默认了,需要修改以下 lua 配置 (~/.config/nvim/lua/core/settings.lua):

...
-- Set the colorscheme to use here.
-- Available values are: `catppuccin`, `catppuccin-latte`, `catppucin-mocha`, `catppuccin-frappe`, `catppuccin-macchiato`.
---@type string
settings["colorscheme"] = "catppuccin"
-- Set it to true if your terminal has transparent background.
---@type boolean
settings["transparent_background"] = false
-- Set background color to use here.
-- Useful if you would like to use a colorscheme that has a light and dark variant like `edge`.
-- Valid values are: `dark`, `light`.
---@type "dark"|"light"
settings["background"] = "dark"
...

本来是想改 colorscheme 选项的,后来发现有个 background = dark,尝试将这个改为 light 试试,重启后默认主题自动切换为 catppuccin-latte 了,下面是主题实时切换的效果:

2 核 CPU 切换有点费劲,毕竟是老旧机器,将就看吧~

状态栏

上一节中切换主题时,好多 scheme 套件的状态栏展示有问题,黑乎乎的一块显示不清楚,这是由于状态栏使用的插件 lualine 有自己的主题,需要单独设置,由于 lualine 属于插件,它们的配置文件位置稍有不同 (~/.config/nvim/lua/modules/configs/ui/lualine.lua):

...
	local function custom_theme()
	vim.api.nvim_create_autocmd("ColorScheme", {
	group = vim.api.nvim_create_augroup("LualineColorScheme", { clear = true }),
	pattern = "*",
	callback = function()
	has_catppuccin = vim.g.colors_name:find("catppuccin") ~= nil
	require("lualine").setup({ options = { theme = custom_theme() } })
	end,
	})
...

主要修改 require("lualine").setup 一行中 theme = 的值即可,可供选择的值参考这篇。从代码上看,对于 catppuccin-* 主题,会做状态栏的同步,所以相对要好一些,可以无脑选择。

目前 nvimdots 对老旧系统的支持已经不错了,早先我设置 blue 主题时,状态栏是这个样子:

根本没法看,通过设置 lualine 主题为 onenight 解决了这个问题:

目前已经不需要单独进行设置了。

快捷键

nvimdots 提供了很丰富的快捷键支持,一般都是三键组合,例如 <leader>+f+w 进入关键字搜索,其中 <leader> 是可定义的,目前默认为空格键。

通过 :verbose nmap 可以查看所有的键映射:

想看单独的键可以在后面增加参数,例如输入 :verbose nmap gD

常用的 gD、gd、gh、gf、gr、K 都有说明。自定义的键映射位于:~/.config/nvim/lua/core/mapping.lua

local bind = require("keymap.bind")
local map_cr = bind.map_cr
local map_cu = bind.map_cu
local map_cmd = bind.map_cmd
local map_callback = bind.map_callback
local core_map = {
	-- Suckless
	["n|<S-Tab>"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"),
	["n|<C-s>"] = map_cu("write"):with_noremap():with_silent():with_desc("edit: Save file"),
	["n|Y"] = map_cmd("y$"):with_desc("edit: Yank text to EOL"),
	["n|D"] = map_cmd("d$"):with_desc("edit: Delete text to EOL"),
	["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"),
	["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"),
	["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"),
	["n|<Esc>"] = map_callback(function()
	_flash_esc_or_noh()
	end)
	:with_noremap()
	:with_silent()
	:with_desc("edit: Clear search highlight"),
	["n|<C-h>"] = map_cmd("<C-w>h"):with_noremap():with_desc("window: Focus left"),
	["n|<C-l>"] = map_cmd("<C-w>l"):with_noremap():with_desc("window: Focus right"),
	["n|<C-j>"] = map_cmd("<C-w>j"):with_noremap():with_desc("window: Focus down"),
	["n|<C-k>"] = map_cmd("<C-w>k"):with_noremap():with_desc("window: Focus up"),
	["t|<C-w>h"] = map_cmd("<Cmd>wincmd h<CR>"):with_silent():with_noremap():with_desc("window: Focus left"),
	["t|<C-w>l"] = map_cmd("<Cmd>wincmd l<CR>"):with_silent():with_noremap():with_desc("window: Focus right"),
	["t|<C-w>j"] = map_cmd("<Cmd>wincmd j<CR>"):with_silent():with_noremap():with_desc("window: Focus down"),
	["t|<C-w>k"] = map_cmd("<Cmd>wincmd k<CR>"):with_silent():with_noremap():with_desc("window: Focus up"),
	["n|<A-h>"] = map_cr("vertical resize -3"):with_silent():with_desc("window: Resize -3 vertically"),
	["n|<A-l>"] = map_cr("vertical resize +3"):with_silent():with_desc("window: Resize +3 vertically"),
	["n|<A-j>"] = map_cr("resize -3"):with_silent():with_desc("window: Resize -3 horizontally"),
	["n|<A-k>"] = map_cr("resize +3"):with_silent():with_desc("window: Resize +3 horizontally"),
	["n|<C-q>"] = map_cr("wq"):with_desc("edit: Save file and quit"),
	["n|<A-S-q>"] = map_cr("q!"):with_desc("edit: Force quit"),
	["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"),
	["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"),
	["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"),
	["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"),
	["n|to"] = map_cr("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"),
	-- Insert mode
	["i|<C-u>"] = map_cmd("<C-G>u<C-U>"):with_noremap():with_desc("edit: Delete previous block"),
	["i|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Move cursor to left"),
	["i|<C-a>"] = map_cmd("<ESC>^i"):with_noremap():with_desc("edit: Move cursor to line start"),
	["i|<C-s>"] = map_cmd("<Esc>:w<CR>"):with_desc("edit: Save file"),
	["i|<C-q>"] = map_cmd("<Esc>:wq<CR>"):with_desc("edit: Save file and quit"),
	-- Command mode
	["c|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Left"),
	["c|<C-f>"] = map_cmd("<Right>"):with_noremap():with_desc("edit: Right"),
	["c|<C-a>"] = map_cmd("<Home>"):with_noremap():with_desc("edit: Home"),
	["c|<C-e>"] = map_cmd("<End>"):with_noremap():with_desc("edit: End"),
	["c|<C-d>"] = map_cmd("<Del>"):with_noremap():with_desc("edit: Delete"),
	["c|<C-h>"] = map_cmd("<BS>"):with_noremap():with_desc("edit: Backspace"),
	["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]])
	:with_noremap()
	:with_desc("edit: Complete path of current file"),
	-- Visual mode
	["v|J"] = map_cmd(":m '>+1<CR>gv=gv"):with_desc("edit: Move this line down"),
	["v|K"] = map_cmd(":m '<-2<CR>gv=gv"):with_desc("edit: Move this line up"),
	["v|<"] = map_cmd("<gv"):with_desc("edit: Decrease indent"),
	["v|>"] = map_cmd(">gv"):with_desc("edit: Increase indent"),
}
bind.nvim_load_mapping(core_map)

这里有两个键是我之前用习惯的:Ctrl+j 向上移屏一行、Ctrl+k 向下移屏一行。vim 将这两个键映射到了 Ctrl+e 和 Ctrl+y,一直觉得用着不太顺手,可以手动添加:

:nmap <C-j> <C-e>
:nmap <C-k> <C-y>

然而重启 nvim 后就不起作用了。可以在上面的配置文件中加入以下内容实现永久修改:

 -- Move Up/Down
 ["n|<C-h>"] = map_cmd("<C-e>"),
 ["n|<C-l>"] = map_cmd("<C-y>"),
 ["n|<C-k>"] = map_cmd("<C-y>"):with_noremap(),
 ["n|<C-j>"] = map_cmd("<C-e>"):with_noremap(),

注意由于 Ctrl+h/j/k/l 已被 nvimdots 挪为它用,为防止热键冲突,需要将之前的注释掉:

	-- ["n|<C-h>"] = map_cmd("<C-w>h"):with_noremap():with_desc("window: Focus left"),
	-- ["n|<C-l>"] = map_cmd("<C-w>l"):with_noremap():with_desc("window: Focus right"),
	-- ["n|<C-j>"] = map_cmd("<C-w>j"):with_noremap():with_desc("window: Focus down"),
	-- ["n|<C-k>"] = map_cmd("<C-w>k"):with_noremap():with_desc("window: Focus up"),

看起来是用于窗口切换 (Ctrl+w+h/j/k/l) 了,感觉没啥必要。注意看 Ctrl+j 与 Ctrl+h、Ctrl+k 与 Ctrl+l 只相差了一个 :with_noremap(),这个能起什么作用?看下面这个演示就清楚了:

加了了 :with_noremap() 的,会上下滑动多行,实现按更少的键的目的。

PS:目前在新版本的 nvimdots 上,新增的键还是不起作用,目前还没有精力研究,回头研究通了再更新一波~

编程语言支持

相比于主流的 IDE 只能支持若干编程语言,neovim+nvimdots 搭建的 IDE 更加强大,可以轻松支持几十种语言,是冷门语言开发者的福音。输入 :LspInfo 查看已安装的语言服务:

这是 nvimdots 的默认配置,可以通过修改配置文件来增加或删除语言服务 (~/.config/nvim/lua/core/settings.lua):

...
-- Set the language servers that will be installed during bootstrap here.
-- check the below link for all the supported LSPs:
-- https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/server_configurations
---@type string[]
settings["lsp_deps"] = {
	"bashls",
	"clangd",
	"html",
	"jsonls",
	"lua_ls",
	"pylsp",
	"gopls",
}
-- Set the general-purpose servers that will be installed during bootstrap here.
-- Check the below link for all supported sources.
-- in `code_actions`, `completion`, `diagnostics`, `formatting`, `hover` folders:
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins
---@type string[]
settings["null_ls_deps"] = {
	"clang_format",
	"gofumpt",
	"goimports",
	"prettier",
	"shfmt",
	"stylua",
	"vint",
}
-- Set the Debug Adapter Protocol (DAP) clients that will be installed and configured during bootstrap here.
-- Check the below link for all supported DAPs:
-- https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/source.lua
---@type string[]
settings["dap_deps"] = {
	"codelldb", -- C-Family
	"delve", -- Go
	"python", -- Python (debugpy)
}
...

主要就是修改 lsp_deps 数组了。例如对于不需要且没有安装成功的 pylsp 和 gopls,直接删除之。重启 nvim 后,不再报烦人的警告了。

另外 checkhealth 中也有 tree-sitter 支持的语言列表:

Parser/Features H L F I J
 - bash ✓ ✓ ✓ . ✓
 - c ✓ ✓ ✓ ✓ ✓
 - cpp ✓ ✓ ✓ ✓ ✓
 - css ✓ . ✓ ✓ ✓
 - go ✓ ✓ ✓ ✓ ✓
 - gomod ✓ . . . ✓
 - html ✓ ✓ ✓ ✓ ✓
 - javascript ✓ ✓ ✓ ✓ ✓
 - json ✓ ✓ ✓ ✓ .
 - jsonc ✓ ✓ ✓ ✓ ✓
 - latex ✓ . ✓ . ✓
 - lua ✓ ✓ ✓ ✓ ✓
 - make ✓ . ✓ . ✓
 - markdown ✓ . ✓ ✓ ✓
 - markdown_inline ✓ . . . ✓
 - python ✓ ✓ ✓ ✓ ✓
 - query ✓ ✓ ✓ ✓ ✓
 - rust ✓ ✓ ✓ ✓ ✓
 - typescript ✓ ✓ ✓ ✓ ✓
 - vim ✓ ✓ ✓ . ✓
 - vimdoc ✓ . . . ✓
 - vue ✓ . ✓ ✓ ✓
 - yaml ✓ ✓ ✓ ✓ ✓
 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
 +) multiple parsers found, only one will be used
 x) errors found in the query, try to run :TSUpdate {lang} ~

每列为一个功能点,每行为一种语言,全打勾表示所有功能在线。

保存时美化

各种 formatter 设置好了不用岂不可惜,所以 nvimdots 默认的行为是关闭文件自动使用对应语言的 formatter 进行格式美化。然而在浏览第三方库文件或其它开源库代码时,这么做就有点画蛇添足了,通过 FormatToggle 可以关闭默认选项,然而重启 nvim 后又会自动打开,因此需要修改配置文件 (~/.config/nvim/lua/core/settings.lua):

...
-- Set it to false if there are no need to format on save.
---@type boolean
settings["format_on_save"] = true
-- Set it to false if the notification after formatting is annoying.
---@type boolean
settings["format_notify"] = true
-- Set it to true if you prefer formatting ONLY the *changed lines* as defined by your version control system.
-- NOTE: This entry will only be respected if:
-- > The buffer to be formatted is under version control (Git or Mercurial);
-- > Any of the server attached to that buffer supports |DocumentRangeFormattingProvider| server capability.
-- Otherwise Neovim would fall back to format the whole buffer, and a warning will be issued.
---@type boolean
settings["format_modifications_only"] = false
-- Set the format disabled directories here, files under these dirs won't be formatted on save.
--- NOTE: Directories may contain regular expressions (grammar: vim). |regexp|
--- NOTE: Directories are automatically normalized. |vim.fs.normalize()|
---@type string[]
settings["format_disabled_dirs"] = {
	-- Example
	"~/format_disabled_dir",
}
...

format_on_save 改为 false 即可。

效果

至此基于 neovim 的 IDE 就搭建完成了,在正式开始演试之前,需要为 efm-langserver 插件生成一份代码编译清单:compile_commands.json。

compile_commands

这个文件的内容是实际传递给编译器的命令行,包括各种参数:

...
{
 "directory": "/ext/code/transmission/build/libtransmission",
 "command": "/opt/compiler/gcc-8.2/bin/g++ -DCURL_STATICLIB -DFMT_EXCEPTIONS=0 -DFMT_HEADER_ONLY=1 -DHAVE_FALLOCATE64 -DHAVE_FLOCK -DHAVE_GETMNTENT -DHAVE_GETTEXT -DHAVE_LIBINTL_H -DHAVE_MKDTEMP -DHAVE_NGETTEXT -DHAVE_POSIX_FADVISE -DHAVE_POSIX_FALLOCATE -DHAVE_PREAD -DHAVE_PWRITE -DHAVE_SENDFILE64 -DHAVE_SO_REUSEPORT=1 -DHAVE_STATVFS -DHAVE_SYS_STATVFS_H -DHAVE_XLOCALE_H -DMINIUPNP_STATICLIB -DNATPMP_STATICLIB -DPACKAGE_DATA_DIR=\\\"/usr/local/share\\\" -DPOSIX -DSYSTEM_MINIUPNP -DWIDE_INTEGER_DISABLE_FLOAT_INTEROP -DWIDE_INTEGER_DISABLE_IOSTREAM -DWITH_INOTIFY -DWITH_UTP -D__TRANSMISSION__ -I/ext/code/transmission/build/libtransmission -I/ext/code/transmission/third-party/libutp/include -I/ext/code/transmission/third-party/libb64/include -I/ext/code/transmission/third-party/jsonsl -I/ext/code/transmission/third-party/wildmat -isystem /ext/code/transmission/build/third-party/libdeflate.bld/pfx/include -isystem /usr/local/include -isystem /ext/code/transmission/cmake/../third-party/fast_float/include -isystem /ext/code/transmission/build/third-party/libpsl.bld/pfx/include -isystem /ext/code/transmission/build/third-party/libnatpmp.bld/pfx/include -isystem /ext/code/transmission/build/third-party/miniupnpc.bld/pfx/include -isystem /ext/code/transmission/build/third-party/dht.bld/pfx/include -isystem /ext/code/transmission/cmake/../third-party/utfcpp/source -isystem /ext/code/transmission/cmake/../third-party/wide-integer -isystem /ext/code/transmission/cmake/../third-party/fmt/include -isystem /ext/code/transmission/build/third-party/libevent.bld/pfx/include -O3 -DNDEBUG -fPIC -W -Wall -Wextra -Wcast-align -Wduplicated-cond -Wextra-semi -Wfloat-equal -Winit-self -Wint-in-bool-context -Wlogical-op -Wmissing-format-attribute -Wnull-dereference -Wpointer-arith -Wredundant-decls -Wrestrict -Wshadow -Wsign-compare -Wsuggest-override -Wuninitialized -Wunreachable-code -Wunused -Wunused-const-variable -Wunused-parameter -Wunused-result -Wwrite-strings -std=gnu++17 -o CMakeFiles/transmission.dir/session.cc.o -c /ext/code/transmission/libtransmission/session.cc",
 "file": "/ext/code/transmission/libtransmission/session.cc"
},
...

如此,efm-langserver 等语言服务,就能借助这里的信息,更好的理解代码,例如哪些预处理中的代码是生效的,从而更好的实现符号跳转与补全等功能。这类清单也用于 ccls、VSCode 等 IDE 中,并不是 efm-langserver 专属的。一般项目本身并不包含这类清单,需要单独生成一下,下面分项目类型分别介绍。

  • cmake:cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
  • make:bear make
  • Android NDK
    • ndk-build GEN_COMPILE_COMMANDS_DB=true
    • bear ndk-build
  • ninja:ninja -f out/combined-kona.ninja -t compdb | tee ./compile_commands.json
  • ...

cmake、ninja 支持的比较好,NDK 算 make 的一种,也有自己的选项可以设置,对于最原始的 make,只能借助于 bear 命令了,另外 ndk-build 也可以基于这种方式生成。

bear

bear 是一个用来生成包含编译时选项的数据库的工具。 通常它将输出文件 compile_commands.json ,可以供给例如 vscode 中的 Microsoft C/C++ 插件或者 vim 中的 YouCompleteMe 插件使用,让插件可以正确的解析当前 C++ 源文件的各种依赖信息,例如头文件包含路径。

在 CentOS 上默认没有这个命令,需要安装一下,默认的 yum 源没有,需要源码安装:

wget https://github.com/rizsotto/Bear/archive/refs/tags/2.4.4.zip
unzip 2.4.4.zip
cd Bear-2.4.4
mkdir build; cd build
cmake ..
make
sudo make install

安装过程也比较简单,CentOS7 适合老一点的版本,2.4.4 实测可用。

transmission

下面用一个 BitTorrent 网络传输方面很知名的开源库 tranmission 从头到尾做个测试。

git clone --recurse-submodules git@github.com:firedgirl/transmission.git transmission
cd transmission
git checkout -b 4.0.x origin/4.0.x
mkdir build; cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=/opt/compiler/gcc-8.2/bin/g++ -DCMAKE_C_COMPILER=/opt/compiler/gcc-8.2/bin/gcc -DCMAKE_CXX_FLAGS="-Wl,-rpath,/opt/compiler/gcc-8.2/lib64 -I /usr/local/include" -DCMAKE_BUILD_TYPE=Release .. 
make -j8

注意添加到 cmake 中的 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 选项,他的作用和 bear 是一致的。项目编译完成后,将在根目录生成一个 compile_commands.json 文件,内容比较多就不展示了,感兴趣的可以看这个链接

将它移动到项目根目录,打开 neovim,就可以像 VSCode 一样浏览啦。上面的 transmission 只是一个例子,可以更换为任意 c/c++ 开源库。有的平台不支持 compile_commands.json 的生成,此时符号跳转就没那么准了,不过文件内的一些函数定义跳转还是支持的。

功能展示

自动补全

这里演示的是成员变量与成员函数,其它像普通变量、函数调用什么的也都能自动补全。

字符串查找

Telescope 插件,底层基于 fzf & rg,快捷键 SPACE + f + w 调出。缺点有以下几点

  • 多次查询一个关键字不便,需要每次输入关键词且从头开始遍历
  • 跳转到某个文件再查找,会局限查找范围为文件当前所在目录

对于第二个问题,在老版本上通过修改配置可以修复,具体修改 ~/.config/nvim/lua/core/event.lua:

{ "BufEnter", "*", "silent! lcd %:p:h" },

将上面这行注释掉即可。但是目前新版本,这个配置不见了,目前还没有抽出精力来研究。

符号跳转

上图演示了几种典型的跳转场景:

  • gD:声明、调用点跳转定义
  • K:提示定义
  • gd:小窗显示定义

除了 c++ 中的虚函数都能比较好的进行处理,虚函数由于是运行时才能确定调用哪个实现,这里跳不过去也情有可原,但是如果能将备选的实现列出来让用户自己选择,就更好了。

上面的动图,展示的是 gh 命令查找所有调用点,在弹出的浮窗中,右侧按文件列出所有调用点,进入文件下面每个调用点时,左侧可以预览,回车时跳转到调用点。大部分时间可用,有时一些符号找不到,就得使用之前的字符串查找了。

h/cpp 文件切换

ClangdSwitchSourceHeaderVSplit,基于 clangd,快捷键 SPACE + h 调出,同级别的还可以使用 ClangdSwitchSourceHeader & ClangdSwitchSourceHeaderSplit,前者直接替换当前 buffer,后者是横向分屏,可以让 SPACE + h 指向其中任何一个,看个人偏好。头文件可以不必和 cpp 在同一个目录,这个插件一样可以找到。

后记

第一次入坑  neovm + nvimdots 是 2022.11 的事情了,最近有新机器了又在 2024.07 搞了一次,发现nvimdots 有很大更新,以至于之前的一些快捷键、UI 发生了变化,一些移植经验也已经不适用了,虽然一度很懵逼,但这是一件好事,说明 neovim + 基于 lua 的插件配置正在蓬勃发展,现在写出来的文字,可能过一两年又面目全非了。总归来说,现在这条路是对的,比那些还在坚守 vim + gtags + cscope + YouCompleteMe… 老路的要强大太多了,现在网上这方面的资料,远远跟不上开源社区的进步速度,毫不夸张的说,关于 vim 搭建现代化 IDE 的文章,只要超过五年以上,就是老古董了,除非研究技术发展历史,否则没必要深究。

基于 lua 的 neovim 配置还有很多,nvimdots 只是其中的一个,其实他们采用的基础插件是相通的,像 Lazy、Mason、Lsp 等等,这种项目像一个粘合剂,将各种零散的小插件整合在一起,达到用户开箱即用的效果,免去了很多插件搜索的过程,各位有使用的好的项目,也可以在留言区分享哈~

关于 nvimdots 的任何使用问题都可以在 Issue 页面提问,之前我在这里提的一些问题,很快就有人回复,一些不错的建议还得到了采纳,成就感满满!总之,除了一帮子中国人在那飙英文有点受不了,其它都还好?。

参考

[1]. Linux(Ubuntu/CentOS) 下查看 GLIBC 版本

[2]. 升级glibc至2.18

[3]. 通过ipaddress更新github的hostsIP

[4]. Can one set std=c99 in GCC as a default? [duplicate]

[5]. yum安装指定版本软件包

[6]. The Cargo Book

[7]. 5分钟搞懂用户空间文件系统FUSE工作原理

[8]. ayamir/nvimdots

[9]. Neovim 代码高亮插件 nvim-treesitter 的安装与配置

[10]. lazy-nvim插件管理器基础入门

[11]. neovim入门指南(一):基础配置

[12]. 我的现代化Neovim配置

[13]. 详解nvim内建LSP体系与基于nvim-cmp的代码补全体系

[14]. CentOS7 使用脚本安装后插件一直报下载失败#326

[15]. CentOS7 安装后 scheme 无法保存

[16]. gd/D 不能跳转到定义

[17]. change theme can't change status line theme

[18]. how to disable FormatOnSave permanently?

[19]. How can I map C-j to C-e in lua

[20]. 生成compile_commands.json文件

[21]. Android C++ 生成 compile_commands.json

[22]. Bear 2.4.4 精简版

[23]. How can I traverse functions with jump list?

 

作者:goodcitizen原文地址:https://www.cnblogs.com/goodcitizen/p/18197750/build_development_environment_for_cpp_on_old_linux_by_neovim

%s 个评论

要回复文章请先登录注册