老旧 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*} }}}}}}再次运行 gcc,确认已加载修改后的 spec 文件:
> 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}第一行的输出符合预期,整个过程可参考附录 4。
如果不举行这个设置,后面在编译 lsp-server 中的 lsp-kind.nvim & nvim-lspconfig 模块时会失败:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524104530288-503821902.png
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524104601163-1012904018.png
glibc
体系提供的 2.17 不行,clangd 需要至少 2.18,否则 neovim 中跳转相干的键 (gd/gD) 会失效,而 yum 上没有大于 2.17 版本的软件可用,需要手动更新下:
> 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 --enable-__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)具体升级过程可参考附录 2。
make
体系提供的 3.82 GNU Make 根本够用。
openssl
体系提供的 1.0.2k 根本够用。
git
体系提供的 1.8 版本不行,需要升级到 2.38,否则不能识别 rebase=false 参数,导致插件更新时拉取代码库失败:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240517153507678-1410975709.png
当时直接使用 yum install git 升级的版本还是比较低,所以我是手动安装的,但也取了个巧,直接安装了个 rpm 来更新 CentOS7 的软件源:
# 通过网盘链接下载 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 DOORGOD12M 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.从而找到更新版本的 git,省了不少事。厥后这个源还更新了,如今安装的话是 2.43 版本。
别的最好更新 /etc/hosts 文件以便加快对 github.com 的访问速度:
> 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这里的 ip 都是通过反查相干域名得到的,可能会有所不同,详情参考附录 3。
wget
体系提供的 1.14 版本不行,在拉取部分 lsp-server 时会出错 (cpp/lua),需要升级到 1.21.3:
> 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目前的 wget-lastest 指向的最新版本是 1.24.5。
python3
体系提供的 3.6.8 版本勉强够用,clang-format 编译安装要求 python 至少为 3.8 版本,可以选择安装 Python 3.8.1:
> 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>.不过可以通过直接下载 clang-format 来忽略这步,所以这里的 python3 没有升级,具体操作步调在安装 clang-format 时介绍。
cargo
rust 的包管理器,体系未提供,需要单独安装:
> 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用于后续安装 fd,它是一款 find 的替代者,可以实现更高效的文件查找,目前 yum 上最新的版本是 1.72.1。
go
go 语言编译器,体系未提供,需要单独安装:
> sudo yum install cargo
> cargo --version
cargo 1.65.0用来后续编译安装 efm-langserver,它是一款代码检察工具。目前 yum 源最新 go 版本是 1.20.12。为避免后续安装过程中出现网络访问错误的问题,可提前设置以下代理:
> sudo yum install go
> go version
go version go1.17.12 linux/amd64sqlite3
当地数据库,体系未提供,需要单独安装:
> go env -w GO111MODULE=on
> go env -w GOPROXY=https://goproxy.io,direct
> go env -w GOPRIVATE=*.corp.example.com用于后续安装 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 install sqlite sqlite-devel
> sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668源是固定的,版本目前仍保持 13.0.0。
fd
全名 fd-find,用来替代 find,功能更强大,有之前安装 cargo 的基础,直接安装:
> 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)基于最新的 cargo 1.72.1 安装会报错:
> cargo install fd-find
> sudo cp ~/.cargo/bin/fd /usr/local/bin/
> fd --version
fd 8.5.3看起来需要升级 rustc (1.74 > 1.72.1),不过看到要安装的 fd-find 版本为 10.1.0,好像受到了启发,直接指定 fd-find 的版本为 8.5.3 重试:
> cargo install fd-find
Updating crates.io index
Downloaded fd-find v10.1.0
...
warning: spurious network error (3 tries remaining): 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`仍旧失败,叔可忍婶不可忍,直接按提示加 --locked 选项:
查看代码> 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`这回乐成了。实验为之前安装失败的 10.1.0 版本增加 --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): 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): Timeout was reached (Operation timed out after 30000 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): 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): 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): 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): 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 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仍旧不行,看来回退 8.5.3 是唯一的解决办法。之前还探索过将 cargo 版本降为 1.65.0:
> 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未能乐成。在网上也没搜到 1.65.0 的 cargo rpm 包,只能作罢。不清楚为何 1.72.1 的 cargo 要求 1.74 的 rustc,严肃猜疑这是一个 bug。
书归正题,在安装完 fd 8.5.3 后需要按提示将 fd 移到 /usr/loca/bin:
> 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否则 neovim 找不到。
tree-sitter
是一个解析器天生工具和增量解析库,在 nvim 中主要用作 latex 语言解析器、以及 rainbow-delimiters.nvim 和 nvim-treesitter.nvim 插件的底层支持。rainbow-delimiters 主要用于多种语言的语法高亮,特殊是多括号的展示;nvim-treesitter 主要用于高效代码导航与编辑,是 IDE 不可或缺的底层组件。
可以使用 cargo 安装:
> sudo cp /home/users/yunhai01/.cargo/bin/fd /usr/local/bin/
> fd --version
fd 8.5.3会遇到和安装 fd 类似的问题:
查看代码 > sudo cp /home/users/yunhai01/.cargo/bin/fd /usr/local/bin/
> fd --version
fd 8.5.3 Updating crates.io indexInstalling tree-sitter-cli v0.22.6 Updating crates.io indexwarning: spurious network error (3 tries remaining): Timeout was reached (Operation timed out after 30001 milliseconds with 0 out of 0 bytes received)warning: spurious network error (3 tries remaining): Timeout was reached (Operation timed out after 30000 milliseconds with 0 out of 0 bytes received)warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)warning: spurious network error (3 tries remaining): Timeout was reached (Operation timed out after 30001 milliseconds with 0 out of 0 bytes received)warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)Downloaded httpdate v1.0.3Downloaded equivalent v1.0.1Downloaded tiny_http v0.12.0Downloaded anstyle-query v1.1.0Downloaded ascii v1.1.0Downloaded dirs-sys v0.4.1Downloaded serde_derive v1.0.203Downloaded tempfile v3.10.1Downloaded clap_builder v4.5.6Downloaded webbrowser v1.0.1Downloaded tree-sitter-config v0.22.6Downloaded tree-sitter-tags v0.22.6Downloaded proc-macro2 v1.0.85Downloaded percent-encoding v2.3.1Downloaded unicode-normalization v0.1.23Downloaded semver v1.0.23Downloaded libloading v0.8.3Downloaded filetime v0.2.23Downloaded idna v0.5.0Downloaded ahash v0.8.11Downloaded itoa v1.0.11Downloaded form_urlencoded v1.2.1Downloaded zerocopy v0.7.34Downloaded wasmparser v0.206.0Downloaded option-ext v0.2.0Downloaded dirs v5.0.1Downloaded serde_json v1.0.117Downloaded chunked_transfer v1.5.0Downloaded ryu v1.0.18Downloaded tree-sitter v0.22.6warning: spurious network error (3 tries remaining): SSL connect error (TCP connection reset by peer)Downloaded thiserror-impl v1.0.61Downloaded clap_lex v0.7.1Downloaded serde v1.0.203Downloaded unicode-bidi v0.3.15Downloaded glob v0.3.1Downloaded tree-sitter-loader v0.22.6Downloaded indexmap v2.2.6Downloaded fastrand v2.1.0Downloaded url v2.5.0Downloaded indoc v2.0.5Downloaded tinyvec_macros v0.1.1Downloaded rustc-hash v1.1.0Downloaded clap v4.5.6Downloaded html-escape v0.2.13Downloaded clap_derive v4.5.5Downloaded tree-sitter-highlight v0.22.6Downloaded fs4 v0.8.3warning: spurious network error (3 tries remaining): Timeout was reached (download of `difference v2.0.0` failed to transfer more than 10 bytes in 30s)Downloaded difference v2.0.0warning: spurious network error (3 tries remaining): Couldn't connect to server (Failed to connect to 2a04:4e42:1a::649: Network is unreachable)Downloaded utf8-width v0.1.7warning: spurious network error (3 tries remaining): Timeout was reached (download of `hashbrown v0.14.5` failed to transfer more than 10 bytes in 30s)Downloaded hashbrown v0.14.5warning: spurious network error (3 tries remaining): Timeout was reached (download of `smallbitvec v2.5.3` failed to transfer more than 10 bytes in 30s)Downloaded smallbitvec v2.5.3warning: spurious network error (3 tries remaining): Timeout was reached (download of `thiserror v1.0.61` failed to transfer more than 10 bytes in 30s)Downloaded thiserror v1.0.61warning: spurious network error (3 tries remaining): Timeout was reached (download of `tinyvec v1.6.0` failed to transfer more than 10 bytes in 30s)Downloaded tinyvec v1.6.0Downloaded 53 crates (2.7 MB) in 4m 35serror: 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.1Try re-running cargo install with `--locked`增加 --locked 选项应该可以解决问题,使用 cargo 1.72.1 目前安装的版本为 0.22.6,这个版本运行依赖较高的 glibc,所以放弃。
通过官方提示的 npm 方式安装的结果也差不多:
> 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): Timeout was reached (Operation timed out after 30001 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation timed out after 30000 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation timed out after 30001 milliseconds with 0 out of 0 bytes received)
warning: spurious network error (3 tries remaining): Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (3 tries remaining): 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): 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): 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): 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): 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): 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): 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): 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`最早之前安装的 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 下载即可:
> npm install tree-sitter-cli
added 1 package in 10m
> ls -lh node_modules/tree-sitter-cli/
total 25M
-rwxr-xr-x 1 yunhai01 DOORGOD303 Jun7 12:13 cli.js
-rw-r--r-- 1 yunhai01 DOORGOD14K Jun7 12:13 dsl.d.ts
-rwxr-xr-x 1 yunhai01 DOORGOD 3.4K Jun7 12:13 install.js
-rw-r--r-- 1 yunhai01 DOORGOD 1.1K Jun7 12:13 LICENSE
-rw-r--r-- 1 yunhai01 DOORGOD534 Jun7 12:13 package.json
-rw-r--r-- 1 yunhai01 DOORGOD 1.7K Jun7 12:13 README.md
-rwxr-xr-x 1 yunhai01 DOORGOD25M Jun7 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.4 的版本就有 glibc 兼容问题 (>2.18)。
efm-langserver
实现智能 IDE 的焦点,基于 go 语言开辟,使用 go 编译安装:
> 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)安装后没有找到 efm-langserver,经查,go 1.20 之后,需要通过 GOPATH 情况变量来指定安装目录:
> export GOPATH=/ext/tools> 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)go: downloading github.com/mattn/efm-langserver v0.0.53go: downloading github.com/sourcegraph/jsonrpc2 v0.2.0go: downloading gopkg.in/yaml.v3 v3.0.1go: downloading github.com/mattn/go-unicodeclass v0.0.2go: downloading github.com/reviewdog/errorformat v0.0.0-20240311054359-739e471a49b3同样需要复制到 /usr/local/bin 目录以便全局见效:
> 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比之前安装的版本略高一些:
> sudo cp bin/efm-langserver /usr/local/bin
> efm-langserver -v
efm-langserver 0.0.53 (rev: HEAD/go1.20.12)Font
下载可支持符号的字体,例如:Nerd Font,在 macOS 上的安装非常简单,直接双击 ttf 文件安装:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240517204403986-1009438212.png
然后在 macOS 终端上指定该字体,这里我使用的是 iTerm2,其它终端大同小异:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240517204848714-1565156.png
iTerm2 有以下 UI 路径:iTerm2 -> settings -> Profiles -> Default -> Text -> Font。下面是安装带符号字体前后的对比:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240517204730837-103619080.png
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240517205014081-1302660088.png
状态栏很多不能表现的符号都正常了 (标签页的仍保持问号,可能是一个特殊符号 Nerd Font 不支持)。
neovim
IDE 的载体,不使用 yum 安装,缘故原由是 yum 上目前只有 0.3 版本的 neovim,而支持现代化 IDE 焦点的 packer 包管理器至少需要 0.7 版本。这里使用 curl 直接下载最新版本:
> efm-langserver -v
efm-langserver 0.0.44 (rev: 36a4d81/go1.17.12)启动:
> curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage报错:
> chmod u+x nvim.appimage
> ./nvim.appimage看起来需要升级 glibc 2.29,为了避免再次更新 glibc,这里直接选择可以乐成安装的 neovim 0.9.2 版本:
/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)友情提示:可以在 web 端下载后传递给虚拟机,macOS 访问 github 要比虚拟机快许多。
下载乐成后,运行 nvim.appimage 可以自动释放目标文件:
> curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage如果运行后没有产生 squashfs-root 目录,阐明体系缺乏 FUSE (用户空间文件体系),需要手动释放一下:
> chmod u+x nvim.appimage
> ./nvim.appimage设置到 /usr/local/bin 后就可以被全局引用了:
> ./nvim.appimage --appimage-extractnvimdots
IDE 的实现,按照 github 主页 README 的阐明直接安装:
> 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脚本会自动判断 neovim 版本并举行适配:
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执行过程中会让用户举行若干选项,都按默认处置处罚就可以了。到这里所有必须软件就都安装完成了,按任意键将进入插件的安装,具体内容在下一节介绍。
安装后的目录位于:~/.config/nvim/。注意这里不要选择 neovim 0.8.1 (说的就是我),否则后面启动插件管理器时会报错:
> 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)
Saving to: ‘STDOUT’
- 100%[======================================================================================================>] 7.65K6.79KB/s in 1.1s
2024-05-24 15:32:25 (6.79 KB/s) - written to stdout
==> 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) :
==> Checking 'git clone' preferences...
Would you like to perform a shallow clone ('--depth=1')? :
==> 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...根本无解。
开辟情况搭建
框架比如是毛坯房,想要入住还得“精装修”一下,主要是安装各种插件,以及当地化配置。
插件安装
同许多 IDE 一样,vim 很多功能是通过插件实现的,插件本身需要管理,这就催生了形形色色的插件管理器,知名的有 vim-plug、Vundle;vim 进化到 neovim 之后,有两个主要的插件管理器,一个是 packer,另一个是 lazy,两个都很好用,之前 nvimdots 使用的 packer,厥后更新到了 lazy,可以有效的提拔 neovim 的启动速度。
lazy
书接上节,在 nvimdots 安装结束后,按任意键将启动 nvim、自动拉起插件更新:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524190909496-1717910690.png
这个界面静静等待即可,最终都能安装乐成:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524200503044-1588807988.png
在 lazy 插件管理页面,输入标签后面的字符可实现跳转,例如 U 跳转到更新插件页面。
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524200554985-598972708.png
也可以直接在命令行输入 :Lazy sync 来切换到 Sync 标签:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524200626519-1686654906.png
其它也类似,不再赘述。当所有插件安装结束后,q 退出界面。与原先的 packer 界面相比:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524160028965-100606491.png
简直像从远古社会跨进到了现代社会。退出 lazy、退出 nvim,插件安装路径位于:~/.local/share/nvim 目录下。再次进入 nvim,将看到欢迎界面:
https://img2024.cnblogs.com/blog/1707550/202405/1707550-20240524201001924-1623736169.png
根本功能已经可用,有几个未安装的插件将继续安装。
mason
mason 也是一个插件管理器,聚焦于 lsp 服务、dap 服务、linter 和 formatter 方向,通过它可以让 nvim 轻松支持多种编程语言的智能化展示。通过 :Mason 启动:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607113459209-343166960.png
可以观察到体系可用的语言插件、安装乐成的、安装失败的,这里主要需要处置处罚 2 个插件的安装。
clangd
从上面的日记可以看出,安装失败的缘故原由主要是从网络获取 clangd 包失败,这里改为手动下载:
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>
: 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:
: 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>解压并替换到目标目录、设置命令软链接后,重启 nvim 查看:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607113158379-611750242.png
安装乐成,如果 nvim 仍表现安装 clangd,就多重启几次,甚至重启下机器。
clang-format
查看 clang-format 错误日记:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607111717037-989434053.png
没看出来安装失败的直接缘故原由,这里改为手动下载:
> 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 查看:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607114254616-1771036578.png
安装乐成。如果想让 Mason 安装 clang-format,除了之前介绍的升级 python3 步调外,还需要以下操作:
> 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末了还有两个插件 python-lsp-server & gopls 没安装乐成,分别是 python 与 go 语言 lspserver,由于本文着重介绍 C/C++ 情况的搭建,这个偏离主题就不再赘述了,有需求的小同伴可以在 nvimdots 中提问寻求帮助。
如果不想看到每次在启动时它们的报错信息,可以选择不加载它们,具体操作步调详见配置一节。
配置
各种功能插件安装完成后,还需要修改化配置一番,为了方便调用 neovim,在 bash 启动脚本中增加以下内容:
> sudo pip3 install wheel
# 进入 nvim
MasonInstall clang-format这样就可以使用 vi 或 vim 代替 nvim 了,相当于替换了默认的 vim 编辑器,如果想调用原始的 vim 编辑器,需要输入完整路径:
alias vi=nvim
alias vim=nvim在举行配置之前,起首对 nvim 举行一次自我体验,这主要是通过 :checkhealth 命令来完成,下面是完整的 checkhealth 输出:
查看代码> /usr/bin/vi如果有插件工作不正常、老报警告框,可以通过自检发现一些问题。
主题
启动后默认的黑色背景看着黑乎乎的不够亮快,通过快捷键 (SPACE + f + c) 调出主题切换页:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607163617090-2037941782.png
这里选择 catppuccin-latte:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607163832161-1071956386.png
很多多少了。不过重启后就又规复默认了,需要修改以下 lua 配置 (~/.config/nvim/lua/core/settings.lua):
==============================================================================
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 ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-06-07-fast-test` is installed.
mason.nvim ~
- 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 ~
- 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 ~
- 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, L, F, I, Inections
+) 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 = ; 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:
: 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'
:1: in main chunk本来是想改 colorscheme 选项的,厥后发现有个 background = dark,实验将这个改为 light 试试,重启后默认主题自动切换为 catppuccin-latte 了,下面是主题实时切换的结果:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607165128892-1959983830.gif
2 核 CPU 切换有点费劲,毕竟是老旧机器,将就看吧~
状态栏
上一节中切换主题时,很多多少 scheme 套件的状态栏展示有问题,黑乎乎的一块表现不清楚,这是由于状态栏使用的插件 lualine 有自己的主题,需要单独设置,由于 lualine 属于插件,它们的配置文件位置稍有不同 (~/.config/nvim/lua/modules/configs/ui/lualine.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"
...主要修改 require("lualine").setup 一行中 theme = 的值即可,可供选择的值参考这篇。从代码上看,对于 catppuccin-* 主题,会做状态栏的同步,所以相对要好一些,可以无脑选择。
目前 nvimdots 对老旧体系的支持已经不错了,早先我设置 blue 主题时,状态栏是这个样子:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607172855502-30113054.png
根本没法看,通过设置 lualine 主题为 onenight 解决了这个问题:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607173009684-328446708.png
目前已经不需要单独举行设置了。
快捷键
nvimdots 提供了很丰富的快捷键支持,一样平常都是三键组合,例如 +f+w 进入关键字搜索,其中是可定义的,目前默认为空格键。
通过 :verbose nmap 可以查看所有的键映射:
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607183824209-1838592736.png
想看单独的键可以在后面增加参数,例如输入 :verbose nmap gD :
https://img2024.cnblogs.com/blog/1707550/202406/1707550-20240607192631590-1850995453.png
常用的 gD、gd、gh、gf、gr、K 都有阐明。自定义的键映射位于:~/.config/nvim/lua/core/mapping.lua
local bind = require("keymap.bind")local map_cr = bind.map_crlocal map_cu = bind.map_culocal map_cmd = bind.map_cmdlocal map_callback = bind.map_callbacklocal core_map = { -- Suckless ["n|"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"), ["n|"] = 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|"] = map_callback(function() _flash_esc_or_noh() end) :with_noremap() :with_silent() :with_desc("edit: Clear search highlight"), ["n|"] = map_cmd("h"):with_noremap():with_desc("window: Focus left"), ["n|"] = map_cmd("l"):with_noremap():with_desc("window: Focus right"), ["n|"] = map_cmd("j"):with_noremap():with_desc("window: Focus down"), ["n|"] = map_cmd("k"):with_noremap():with_desc("window: Focus up"), ["t|h"] = map_cmd("wincmd h"):with_silent():with_noremap():with_desc("window: Focus left"), ["t|l"] = map_cmd("wincmd l"):with_silent():with_noremap():with_desc("window: Focus right"), ["t|j"] = map_cmd("wincmd j"):with_silent():with_noremap():with_desc("window: Focus down"), ["t|k"] = map_cmd("wincmd k"):with_silent():with_noremap():with_desc("window: Focus up"), ["n|"] = map_cr("vertical resize -3"):with_silent():with_desc("window: Resize -3 vertically"), ["n|"] = map_cr("vertical resize +3"):with_silent():with_desc("window: Resize +3 vertically"), ["n|"] = map_cr("resize -3"):with_silent():with_desc("window: Resize -3 horizontally"), ["n|"] = map_cr("resize +3"):with_silent():with_desc("window: Resize +3 horizontally"), ["n|"] = map_cr("wq"):with_desc("edit: Save file and quit"), ["n|"] = map_cr("q!"):with_desc("edit: Force quit"), ["n|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|"] = map_cmd("u"):with_noremap():with_desc("edit: Delete previous block"), ["i|"] = map_cmd(""):with_noremap():with_desc("edit: Move cursor to left"), ["i|"] = map_cmd("^i"):with_noremap():with_desc("edit: Move cursor to line start"), ["i|"] = map_cmd(":w"):with_desc("edit: Save file"), ["i|"] = map_cmd(":wq"):with_desc("edit: Save file and quit"), -- Command mode ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Left"), ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Right"), ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Home"), ["c|"] = map_cmd(""):with_noremap():with_desc("edit: End"), ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Delete"), ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Backspace"), ["c|"] = map_cmd([[=expand("%:p:h") . "/" ]]) :with_noremap() :with_desc("edit: Complete path of current file"), -- Visual mode ["v|J"] = map_cmd(":m '>+1gv=gv"):with_desc("edit: Move this line down"), ["v|K"] = map_cmd(":m '
页:
[1]