Background to the issue
The company's computers are macOS, and daily development requires access to a Linux virtual machine, which can only be accessed via a springboard for security reasons. This prevents the use of most remote graphical interfaces, complicating the work of writing code, and the very good VSCode on the market does not work. Therefore, we are considering building a personal development environment based on vim, which needs to support the following features:
- Syntax highlighting (style switchable)
- Auto formatting
- Function or Variable Definition Jumps
- Function or variable reference jumps
- Member function or variable drop-down list hints
- Function or variable TAB key auto-completion
- Quick Find
- ……
After examining a variety of options, I decided to build it based on the currently popular neovim, but it is geared towards newer Linux distributions, so I don't know if my old CentOS7 will be able to bring it up, and this article is an exploration of that process.
system environment
Before we start, let's list the configurations of older systems:
- software
- CPU: 2.40GHz * 2 cores
- Memory: 16G
- Storage: 40G + 100G
- hardware
- System: 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 (alternative 8.2)
- glibc:2.17
- make:GNU make 3.82
- openssl:1.0.2k
- git:1.8
- wget:1.14
- python: 3.6.8
Old indeed, it's all a tear in the company's cost control~
software installation
The whole building process is quite bumpy, often after installing Z only to realize that it depends on X, Y, and when you go to install X, Y, you find a pile of problems ...... Here in order to get started directly, changed to the main narrative mode, according to this way of installing and upgrading step by step, it should be no problem. If you already have dependent software on your system with the same version or newer, you can ignore the installation process.
To install software on Linux, there are generally two ways to do it: source installation and package manager installation, the latter of which is yum on CentOS. However, the software provided by the source is generally of a lower version, and sometimes you need to use the former, which relies more on wget, git, gcc, and make, which is why their versions were listed in the previous section, and you need to upgrade them first before you start to install the various software. This is why they were listed in the previous section, and you need to upgrade them first before you start installing the various software.
Basic software upgrades
gcc
The 4.8.5 compilation provided by the system is basically enough, but the clang-format module that is needed to format the code behind is required to be at least 5.1 if it is installed from source, so if you have 5.1 and above, then it's better. If you don't have gcc 5.1 and above, it's better. It doesn't matter if you don't have gcc 5.1 or above, this article will use other ways to bypass it.
Although you don't have to upgrade gcc, some libraries use a higher version of gcc that defaults to the-std=c99
option, which is very unfriendly to older versions, so you need to tell the old gcc compiler about this option. To do this, you need to tell the old gcc compiler about this option. The first thing you need to do is change the gcc spec file, by checking which spec file is loaded by gcc on the current system:
> 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)
It doesn't look like it at the moment, you need to analyze a copy of the default using gcc:
> sudo bash -c 'gcc -dumpspecs > /usr/lib/gcc/x86_64-redhat-linux/4.8.5/specs'
Notice that the parsed path is the first of the loaded paths above, which reads as follows:
View Code
*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*:%}}%{!c:%}
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) % %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:%}%{o*:%.d%*}} %{MMD:-MMD %{!o:%}%{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 } %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include } %{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 %}}} %{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:%s} %{mpc32:%s} %{mpc64:%s} %{mpc80:%s} %{shared|pie:%s;:%s} %s;:%{Ofast|ffast-math|funsafe-math-optimizations:%s} %{mpc32:%s} %{mpc64:%s} %{mpc80:%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/.0;:%{mbionic:/system/bin/linker;:/lib/.2}}} %{m32|mx32:;:-dynamic-linker %{muclibc:/lib/.0;:%{mbionic:/system/bin/linker64;:/lib64/.2}}} %{mx32:-dynamic-linker %{muclibc:/lib/.0;:%{mbionic:/system/bin/linkerx32;:/libx32/.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/.0;:%{mbionic:/system/bin/linker;:/lib/.2}}} %{m32|mx32:;:-dynamic-linker %{muclibc:/lib/.0;:%{mbionic:/system/bin/linker64;:/lib64/.2}}} %{mx32:-dynamic-linker %{muclibc:/lib/.0;:%{mbionic:/system/bin/linkerx32;:/libx32/.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:%s;pie:%s;:%s}} %s %{static:%s;shared|pie:%s;:%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=% %{!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()%(link_gomp)} %{fgnu-tm:%:include()%(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*} }}}}}}
More information, locate keywords*cc1_options:
, in%{w}
cap (a poem)%{std*&ansi&trigraphs}
Add-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 %}}} %{fsyntax-only:-o %j} %{-param*} %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage}
Run gcc again to make sure the modified spec file is loaded:
> 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=/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)
The output of the first line is as expected and the whole process can be found in Appendix 4.
Without this setting, compiling the & nvim-lspconfig module in lsp-server will fail later:
glibc
The 2.17 provided by the system doesn't work, clangd needs to be at least 2.18, or else the jump-related keys (gd/gD) in neovim won't work, and there's nothing older than 2.17 available on yum, so you need to manually update it:
# Download via web link rpm contract (to or for)
# link (on a website): /s/1QAyqa04iZ45q1-HqeYH80Q?pwd=1234 extraction code: 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.
The specific upgrade procedure can be found in Appendix 2.
make
The 3.82 GNU Make provided with the system is basically sufficient.
openssl
The 1.0.2k provided by the system is basically sufficient.
git
The 1.8 version provided by the system doesn't work, you need to upgrade to 2.38, otherwise it can't recognize the rebase=false parameter, which leads to failure in pulling the codebase when the plugin is updated:
At the time, yum install git upgraded me to a lower version, so I installed it manually, but I also took the liberty of installing an rpm to update the CentOS7 repositories:
> sudo yum install /rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
> sudo yum install git
> git --version
git version 2.38.1
This saved me a lot of work, as I was able to find a newer version of git. The source has since been updated and is now version 2.43 when installed.
It is also a good idea to update the /etc/hosts file for faster access:
> cat /etc/hosts
127.0.0.1 localhost localhost4 localhost4.localdomain4
::1 localhost localhost6 localhost6.localdomain6
140.82.114.3
140.82.114.10
140.82.114.6
140.82.114.10
The ip's here are all obtained by back-checking the relevant domains and may vary, refer to Appendix 3 for details.
wget
The 1.14 version provided by the system doesn't work, it gives an error when pulling part of the lsp-server (cpp/lua), and needs to be upgraded to 1.21.3:
> curl -o /gnu/wget/
> tar xvf
> 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/
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
</licenses/>.
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@>.
Please send bug reports and questions to <bug-wget@>.
The latest version pointed to by wget-lastest is currently 1.24.5.
python3
The 3.6.8 version provided by the system is barely sufficient, but the clang-format compilation installation requires python to be at least 3.8, so you can install Python 3.8.1 as an option:
> sudo yum install libffi-devel
> wget /ftp/python/3.8.1/Python-3.8.
> tar -xvf Python-3.8.
> 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
However, this step can be ignored by downloading clang-format directly, so python3 is not upgraded here, as described in Installing clang-format.
cargo
The package manager for rust is not provided and needs to be installed separately:
> sudo yum install cargo
> cargo --version
cargo 1.65.0
For subsequent installations of fd, an alternative to find for more efficient file finding, the latest version on yum is 1.72.1.
go
The go language compiler, which is not provided by the system, needs to be installed separately:
> sudo yum install go
> go version
go version go1.17.12 linux/amd64
It is used to compile and install efm-langserver, which is a code review tool. The latest go version of the yum source is 1.20.12. In order to avoid network access errors during subsequent installations, you can set up the following proxy in advance:
> go env -w GO111MODULE=on
> go env -w GOPROXY=,direct
> go env -w GOPRIVATE=*.
sqlite3
Local database, not provided by the system, needs to be installed separately:
> sudo yum install sqlite sqlite-devel
> sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
For subsequent installation of scheme, a syntax highlighting plugin that uses sqlite3 to store information.
after an upgrade
- 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
Dependent software installation
rg
The full name is ripgrep, it's a grep replacement, more powerful, can't be installed directly by yum, it's installed by adding yum sources to the curve:
> sudo yum-config-manager --add-repo=/coprs/carlwgeorge/ripgrep/repo/epel-7/
> sudo yum install ripgrep
> rg --version
ripgrep 13.0.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)
The source is fixed and the version currently remains 13.0.0.
fd
The full name is fd-find, it is used to replace find, it is more powerful, and you can install it directly with the base of previous cargo installations:
> cargo install fd-find
> sudo cp ~/.cargo/bin/fd /usr/local/bin/
> fd --version
fd 8.5.3
Installation based on the latest cargo 1.72.1 will report errors:
> cargo install fd-find
Updating 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`
It looks like an upgrade of rustc (1.74 > 1.72.1) is required, but seeing that the version of fd-find to be installed is 10.1.0, I seem to have been inspired to just specify the version of fd-find as 8.5.3 and retry:
> cargo install fd-find --version 8.5.3
Downloaded fd-find v8.5.3
Downloaded 1 crate (114.1 KB) in 9.31s
Updating index
Installing fd-find v8.5.3
Updating 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`
Still failing, I can't tolerate it, so I'll just follow the prompts and add it.--locked
Options:
View Code
> cargo install fd-find --version 8.5.3 --locked
Updating index
Installing fd-find v8.5.3
Updating 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 is yanked in registry `crates-io`, consider running without --locked
Updating 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
It worked this time. Trying to add the 10.1.0 version for which the previous installation failed--locked
Options:
> cargo install fd-find --locked
Updating index
Installing fd-find v10.1.0
Updating index
warning: package `libc v0.2.154` in is yanked in registry `crates-io`, consider running without --locked
Updating 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
It still doesn't work, so it seems that rolling back to 8.5.3 is the only solution. Also explored previously was downgrading cargo to 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
It didn't work. I couldn't find a cargo rpm package for 1.65.0 on the web, so I had to stop. I'm not sure why 1.72.1 cargo requires 1.74 rustc, but I seriously doubt it's a bug.
To get back to the point, after installing fd 8.5.3 you need to move fd to /usr/loca/bin when prompted:
> sudo cp /home/users/yunhai01/.cargo/bin/fd /usr/local/bin/
> fd --version
fd 8.5.3
Otherwise neovim won't find it.
tree-sitter
is a parser generation tool and incremental parsing library, used in nvim mainly as a latex parser, as well as the underlying support for the and plugins. rainbow-delimiters is mainly used for syntax highlighting in multiple languages, especially for displaying braces; nvim-treesitter is mainly used for efficient code navigation and editing, and is an indispensable component of the IDE's It is an indispensable component of IDE.
It can be installed using cargo:
> cargo install tree-sitter-cli
You will encounter similar problems to installing fd:
View Code
> cargo install tree-sitter-cli
Updating index
Installing tree-sitter-cli v0.22.6
Updating 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`
rise--locked
option should solve the problem, using cargo 1.72.1 currently installs version 0.22.6, which runs with a higher dependency on glibc, so drop it.
Installing via npm from the official hints gives similar results:
> 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
-rw-r--r-- 1 yunhai01 DOORGOD 14K Jun 7 12:13
-rwxr-xr-x 1 yunhai01 DOORGOD 3.4K Jun 7 12:13
-rw-r--r-- 1 yunhai01 DOORGOD 1.1K Jun 7 12:13 LICENSE
-rw-r--r-- 1 yunhai01 DOORGOD 534 Jun 7 12:13
-rw-r--r-- 1 yunhai01 DOORGOD 1.7K Jun 7 12:13
-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/.6: version `GLIBC_2.25' not found (required by node_modules/tree-sitter-cli/tree-sitter)
node_modules/tree-sitter-cli/tree-sitter: /lib64/.6: version `GLIBC_2.29' not found (required by node_modules/tree-sitter-cli/tree-sitter)
node_modules/tree-sitter-cli/tree-sitter: /lib64/.6: version `GLIBC_2.28' not found (required by node_modules/tree-sitter-cli/tree-sitter)
The oldest version of 0.20.7 is ok, so if you want to install it this way, you can specify the version and try it out. Note that the files from these two installations are located in the~/.cargo/bin
cap (a poem)./node_modules/tree-sitter-cli
If you are using the following command, you need to manually copy it to /usr/local/bin in order for it to take effect.
We will now introduce the third way of installation, which does not rely on cargo, npm and other package managers, and directly locates the tree-sitter officialdownload page, select version 0.20.4, and for my CentOS7 x64 version, select the Just download it:
> gunzip
> 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)
Step by step on the above side, the installation is done, the pro-test version higher than 0.20.4 has glibc compatibility problems (>2.18).
efm-langserver
Realization of the core of the intelligent IDE , based on the go language development , using go compile and install :
> go install /mattn/efm-langserver@latest
I didn't find efm-langserver after installing it. After checking, after go 1.20, you need to specify the installation directory via GOPATH environment variable:
> export GOPATH=/ext/tools
> go install /mattn/efm-langserver@latest
go: downloading /mattn/efm-langserver v0.0.53
go: downloading /sourcegraph/jsonrpc2 v0.2.0
go: downloading /yaml.v3 v3.0.1
go: downloading /mattn/go-unicodeclass v0.0.2
go: downloading /reviewdog/errorformat v0.0.0-20240311054359-739e471a49b3
It also needs to be copied to the /usr/local/bin directory for it to take effect globally:
> sudo cp bin/efm-langserver /usr/local/bin
> efm-langserver -v
efm-langserver 0.0.53 (rev: HEAD/go1.20.12)
Slightly higher version than previously installed:
> efm-langserver -v
efm-langserver 0.0.44 (rev: 36a4d81/go1.17.12)
Font
Download fonts that can support symbols, for example:Nerd FontThe installation on macOS is very simple, just double-click on the ttf file to install it:
Then specify the font in your macOS terminal. I'm using iTerm2 here, but other terminals are similar:
iTerm2 has the following UI paths: iTerm2 -> settings -> Profiles -> Default -> Text -> Font. Below is a comparison between before and after installing a font with symbols:
Many of the symbols in the status bar that could not be displayed are now normal (the question mark on the tabs remains, probably a special symbol that Nerd Font does not support).
neovim
The reason for not using yum to install the IDE carrier is that there is only version 0.3 of neovim on yum, and the packer package manager that supports the modern IDE core requires version 0.7 at least. Use curl to download the latest version directly:
> curl -LO /neovim/neovim/releases/latest/download/
Initiation:
> chmod u+x
> ./
Report an error:
/tmp/.mount_nvim.aw3KspQ/usr/bin/nvim: /lib64/.6: version `GLIBC_2.28' not found (required by /tmp/.mount_nvim.aw3KspQ/usr/bin/nvim)
/tmp/.mount_nvim.aw3KspQ/usr/bin/nvim: /lib64/.6: version `GLIBC_2.29' not found (required by /tmp/.mount_nvim.aw3KspQ/usr/bin/nvim)
It looks like you need to update glibc 2.29, so to avoid having to update glibc again, you can just choose the version of neovim 0.9.2 that you can install successfully:
> wget /neovim/neovim/releases/download/v0.9.2/
Tip: You can download it on the web and pass it on to a virtual machine. macOS access to github is much faster than a virtual machine.
After successful download, run it to automatically release the target file:
> chmod u+x
> ./
If the run does not producesquashfs-root
directory, it means that the system lacks FUSE (File System in User Space) and you need to free it manually:
> ./ --appimage-extract
Setting it to /usr/local/bin will allow it to be globally referenced:
> 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/"
fall-back for $VIM: "/__w/neovim/neovim/build//usr/share/nvim"
Run :checkhealth for more info
nvimdots
For the IDE implementation, follow the instructions in the README on the github homepage and install it directly:
if command -v curl >/dev/null 2>&1; then
bash -c "$(curl -fsSL /ayamir/nvimdots/HEAD/scripts/)"
else
bash -c "$(wget -O- /ayamir/nvimdots/HEAD/scripts/)"
fi
The script automatically determines the neovim version and adapts it:
> bash -c "$(wget -O- /ayamir/nvimdots/HEAD/scripts/)"
--2024-05-24 15:32:21-- /ayamir/nvimdots/HEAD/scripts/
Resolving ... 185.199.108.133, 185.199.109.133, 185.199.111.133, ...
Connecting to |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: /tools/install.
==> If 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:
/ayamir/nvimdots
- Further documentation (including executables you must install for full functionality):
/ayamir/nvimdots/wiki/Prerequisites
Press RETURN/ENTER to continue or any other key to abort...
The execution process will allow the user to carry out a number of options, all according to the default processing can be. Here all the necessary software is installed, press any key will enter the installation of plug-ins, the specific content in the next section.
The installed directory is located at: ~/.config/nvim/. Be careful not to select neovim 0.8.1 here (that's me), otherwise you will get an error when starting the plugin manager later:
Error executing Lua callback: ...l/share/nvim/site/lazy//lua/lazy/view/:159: Vim(append):Error executing lua callback: ...zy//plugin/rainbow-delimiter
:50: attempt to call field 'get_lang' (a nil value)
stack traceback:
...zy//plugin/:50: in function 'attach'
...zy//plugin/:151: in function <...zy//plugin/:151>
[C]: in function '__newindex'
...l/share/nvim/site/lazy//lua/lazy/view/:159: in function 'mount'
...l/share/nvim/site/lazy//lua/lazy/view/:75: in function 'init'
...al/share/nvim/site/lazy//lua/lazy/view/:53: in function 'create'
...al/share/nvim/site/lazy//lua/lazy/view/:38: in function 'show'
...hare/nvim/site/lazy//lua/lazy/view/:38: in function 'command'
...hare/nvim/site/lazy//lua/lazy/view/:24: in function 'cmd'
...hare/nvim/site/lazy//lua/lazy/view/:111: in function <...hare/nvim/site/lazy//lua/lazy/view/:98>
stack traceback:
[C]: in function '__newindex'
...l/share/nvim/site/lazy//lua/lazy/view/:159: in function 'mount'
...l/share/nvim/site/lazy//lua/lazy/view/:75: in function 'init'
...al/share/nvim/site/lazy//lua/lazy/view/:53: in function 'create'
...al/share/nvim/site/lazy//lua/lazy/view/:38: in function 'show'
...hare/nvim/site/lazy//lua/lazy/view/:38: in function 'command'
...hare/nvim/site/lazy//lua/lazy/view/:24: in function 'cmd'
...hare/nvim/site/lazy//lua/lazy/view/:111: in function <...hare/nvim/site/lazy//lua/lazy/view/:98>
It's basically unsolvable.
Development Environment Setup
The framework is like a rough house, want to move in still have to "fine-tune" a bit, mainly to install a variety of plug-ins, as well as the localization of the configuration.
Plug-in Installation
Like many IDEs, many features of vim are realized by plugins, and the plugins themselves need to be managed, which gives rise to all kinds of plugin managers, the well-known ones are vim-plug and Vundle; after vim evolved to neovim, there are two main plugin managers, one is packer, the other is lazy, both are very good, and before that, nvimdots used packer. Before nvimdots used packer, but later updated to lazy, which can effectively improve the startup speed of neovim.
lazy
The book picks up where the previous section left off, at the end of the nvimdots installation, pressing any key will start nvim, automatically pulling up the plugin updates:
This interface just wait quietly, and eventually all can be installed successfully:
On the lazy plugin management page, enter the characters after the label to jump, e.g. U to the update plugin page.
It is also possible to type directly on the command line:Lazy sync
to switch to the Sync tab:
Others are similar and will not be repeated. When all plugins are installed, q exits the interface. Compared to the original packer interface:
It's almost like crossing over from an ancient society to a modern one. Exit lazy, exit nvim, the plugin installation path is located:~/.local/share/nvim
directory. Enter nvim again and you will see the welcome screen:
Basic functionality is available and a few uninstalled plugins will continue to be installed.
mason
mason is also a plugin manager focusing on lsp services, dap services, linter and formatter directions, which allows nvim to easily support intelligent presentations in multiple programming languages. It allows nvim to easily support intelligent presentations in multiple programming languages through the:Mason
Initiation:
You can observe the language plug-ins available to the system, those that were installed successfully, and those that failed to be installed, and here you mainly need to deal with the installation of 2 plug-ins.
clangd
As you can see from the above logs, the main reason for the installation failure is the failure to get the clangd packages from the network, so we changed to download them manually:
> wget /clangd/clangd/releases/download/18.1.3/clangd-linux-18.1.
> mv clangd-linux-18.1. ~/.local/share/nvim/mason/packages
> cd ~/.local/share/nvim/mason/packages
> unzip clangd-linux-18.1.
> cd ../bin
> ln -s $PWD/../packages/clangd_18.1.3/bin/clangd clangd
> ./clangd --version
clangd version 18.1.3 (/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu
After unzipping and replacing it in the target directory and setting the command softlink, restart nvim to view it:
The installation was successful, if nvim still shows that clangd is installed, reboot a few more times, or even reboot the machine.
clang-format
View the clang-format error log:
Didn't see a direct reason for the failed installation, so here's a manual download instead:
> wget -c /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
After replacing it in the target directory and setting the command softlink, restart nvim to view it:
The installation was successful. If you want Mason to install clang-format, you need to do the following in addition to the python3 upgrade steps described previously:
> sudo pip3 install wheel
# go into nvim
MasonInstall clang-format
Finally, there are two plug-ins python-lsp-server & gopls not installed successfully, respectively, python and go language lspserver, because this article focuses on the construction of the C/C++ environment, this deviation from the theme will not be repeated, there is a need for partners can be in thenvimdots Ask questions for help in the middle.
You can choose not to load them if you don't want to see them reporting errors every time you start them up, as detailed in the Configuration section.
configure
After the installation of various functional plug-ins, you still need to modify the configuration a bit, in order to facilitate the call neovim, in the bash startup script to add the following content:
alias vi=nvim
alias vim=nvim
This allows you to use vi or vim instead of nvim, which is equivalent to replacing the default vim editor. If you want to call the original vim editor, you need to enter the full path:
> /usr/bin/vi
Before proceeding with the configuration, start by giving nvim a taste of itself, which is mostly done through the:checkhealth
command to do so, here is the complete checkhealth output:
View Code
==============================================================================
hop: require("").check()
Ensuring keys are unique ~
- OK Keys are unique
Checking for deprecated features ~
- OK All good
==============================================================================
lazy: require("").check()
~
- OK Git installed
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found
==============================================================================
lspsaga: require("").check()
report ~
- OK `tree-sitter` found
- OK tree-sitter `markdown` parser found
- OK tree-sitter `markdown_inline` parser found
==============================================================================
luasnip: require("").check()
luasnip ~
- WARNING For Variable/Placeholder-transformations, luasnip requires
the jsregexp library. See `:help |luasnip-lsp-snippets-transformations`| for advice
==============================================================================
mason: require("").check()
~
- OK version v1.10.0
- OK PATH: prepend
- OK Providers:
-api
- OK neovim version >= 0.7.0
[Registries] ~
- OK Registry `/mason-org/mason-registry version: 2024-06-07-fast-test` is installed.
[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`
[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`
[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("").check()
~
- OK **treesitter-nvim** is installed
- OK **TreeSitter jsonc** parser is installed
- WARNING **** 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("").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("").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 "" 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("").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 { , "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; = [p for p in 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.
provider (optional) ~
- : 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
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
==============================================================================
rainbow-delimiters: require("").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("").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
==============================================================================
: require("").check()
- LSP log level : WARN
- Log path: /home/users/yunhai01/.local/state/nvim/
- Log size: 54 KB
: 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)
==============================================================================
: require("").check()
- Nvim runtime ABI version: 14
- OK Parser: bash ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: c ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: cpp ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: css ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: go ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: gomod ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: html ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: javascript ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: json ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: jsonc ABI: 13, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: latex ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: lua ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: make ABI: 13, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: markdown ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- 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/
- OK Parser: rust ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: typescript ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: vimdoc ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: vue ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: yaml ABI: 14, path: /home/users/yunhai01/.local/share/nvim/site/lazy/nvim-treesitter/parser/
- OK Parser: c ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/
- OK Parser: lua ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/
- OK Parser: query ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/
- OK Parser: vim ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/
- OK Parser: vimdoc ABI: 14, path: /ext/tools/squashfs-root/usr/lib/nvim/parser/
==============================================================================
which-key: require("").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//lua/which-key/:406: Invalid buffer id: 97
stack traceback:
[C]: in function 'nvim_buf_get_keymap'
...are/nvim/site/lazy//lua/which-key/:406: in function 'update_keymaps'
...e/nvim/site/lazy//lua/which-key/:15: in function 'check'
[string "luaeval()"]:1: in main chunk
If there are plugins that don't work properly and keep reporting warning boxes, you can find some problems by self-testing.
thematic
The default black background after startup is not bright enough, use the shortcut keys (SPACE + f + c) to bring up the theme switching page:
Select catppuccin-latte here:
Much better. However, after reboot it's back to default, you need to change the following lua configuration (~/.config/nvim/lua/core/):
...
-- 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"
...
Originally I wanted to change the colorscheme option, but then I found that there is a background = dark, try to change this to light to try, after restarting the default theme automatically switched to catppuccin-latte, the following is the effect of real-time theme switching:
It's a bit hard to switch between 2 core CPUs, after all, it's an old machine, just take it for what it's worth~.
status line
When switching themes in the previous section, many scheme packages have problems displaying the status bar, the black piece is not clear, this is due to the status bar using the plugin lualine has its own theme, you need to set it up individually, since lualine is a plugin, their configuration files are in slightly different locations (~/.config/nvim/lua/modules/ configs/ui/):
...
local function custom_theme()
.nvim_create_autocmd("ColorScheme", {
group = .nvim_create_augroup("LualineColorScheme", { clear = true }),
pattern = "*",
callback = function()
has_catppuccin = .colors_name:find("catppuccin") ~= nil
require("lualine").setup({ options = { theme = custom_theme() } })
end,
})
...
Main modificationsrequire("lualine").setup
first linetheme =
value is sufficient, the optional value referencethis one. From the code, for catppuccin-* theme, it will do the status bar synchronization, so it's relatively better and can be a no-brainer choice.
Currently nvimdots has good support for older systems, earlier when I set up the blue theme the status bar looked like this:
Couldn't see it at all, solved this by setting the lualine theme to onenight:
There is no longer a need for a separate setup.
(computer) shortcut key
nvimdots provides rich support for shortcuts, which are generally three-key combinations, e.g. <leader>+f+w to enter a keyword search, where <leader> is definable and currently defaults to the spacebar.
pass (a bill or inspection etc):verbose nmap
All key mappings can be viewed:
To see the individual keys you can add parameters after them, for example by typing:verbose nmap gD
:
The commonly used gD, gd, gh, gf, gr, and K are described. Customized key mappings are located in: ~/.config/nvim/lua/core/
local bind = require("")
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)
There are two keys I'm used to: Ctrl+j to move up one line and Ctrl+k to move down one line. vim maps these keys to Ctrl+e and Ctrl+y, which I've never felt comfortable using, so you can add them manually:
:nmap <C-j> <C-e>
:nmap <C-k> <C-y>
However, restarting nvim doesn't work. You can make this permanent by adding the following to the configuration file above:
-- 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(),
Note that since Ctrl+h/j/k/l is already used by nvimdots, you need to comment out the previous ones to prevent hotkey conflicts:
-- ["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"),
It looks like it's used for window switching (Ctrl+w+h/j/k/l), but it doesn't feel necessary. Note that Ctrl+j and Ctrl+h, and Ctrl+k and Ctrl+l only differ by one:with_noremap()
What does this do? Watch this demo below to get a clear picture:
With :with_noremap(), you can slide multiple rows up and down to achieve the goal of pressing fewer keys.
PS: The new keys still don't work on the new version of nvimdots, I haven't had the energy to look into it yet, so I'll update it when I get through it~.
Programming Language Support
Compared to mainstream IDEs that can only support a few programming languages, the IDE built by neovim+nvimdots is much more powerful and can easily support dozens of languages, which is a boon for cold language developers. Input:LspInfo
View installed language services:
This is the default configuration of nvimdots. Language services can be added or removed by modifying the configuration file (~/.config/nvim/lua/core/):
...
-- Set the language servers that will be installed during bootstrap here.
-- check the below link for all the supported LSPs:
-- /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:
-- /nvimtools//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:
-- /jay-babu//blob/main/lua/mason-nvim-dap/mappings/
---@type string[]
settings["dap_deps"] = {
"codelldb", -- C-Family
"delve", -- Go
"python", -- Python (debugpy)
}
...
The main thing is to modify the lsp_deps array. For example, if you don't need pylsp and gopls and they didn't install, you can just delete them. After restarting nvim, no more annoying warnings.
There is also a list of languages supported by tree-sitter in checkhealth:
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} ~
Each column is a function point, each line is a language, and all checkmarks indicate that all functions are online.
Beautify on save
It would be a shame not to use the various formatters once they are set up, so the default behavior of nvimdots is to disable the automatic formatting of files with the corresponding language formatter. However, when browsing third-party library files or other open-source library code, it's a bit of a red herring to do so, and you can do it with theFormatToggle
You can turn off the default option, but it will be turned on again after restarting nvim, so you need to modify the configuration file (~/.config/nvim/lua/core/):
...
-- 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. |()|
---@type string[]
settings["format_disabled_dirs"] = {
-- Example
"~/format_disabled_dir",
}
...
commander-in-chief (military)format_on_save
Change it to false and you're good to go.
effect
At this point, the neovim-based IDE has been built, and before we can officially start the test, we need to generate a code compilation manifest for the efm-langserver plugin: compile_commands.json.
compile_commands
The contents of this file are the actual command lines passed to the compiler, including the various arguments:
...
{
"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//pfx/include -isystem /usr/local/include -isystem /ext/code/transmission/cmake/../third-party/fast_float/include -isystem /ext/code/transmission/build/third-party//pfx/include -isystem /ext/code/transmission/build/third-party//pfx/include -isystem /ext/code/transmission/build/third-party//pfx/include -isystem /ext/code/transmission/build/third-party//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//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// -c /ext/code/transmission/libtransmission/",
"file": "/ext/code/transmission/libtransmission/"
},
...
In this way, language services such as efm-langserver can use the information here to better understand the code, e.g. which code in preprocessing is in effect, and thus better implement features such as symbol jumping and complementation. Such lists are also used in IDEs like ccls, VSCode, etc. and are not specific to efm-langserver. Generally, the project itself does not contain this kind of list, and you need to generate it separately, which is described below by project type.
- 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/ -t compdb | tee ./compile_commands.json
- ...
cmake, ninja support is better, NDK is a kind of make, also has its own options can be set, for the most primitive make, can only resort to bear command, in addition, ndk-build can also be generated based on this way.
bear
bear is a tool for generating databases containing compile-time options. Normally it takes the output filecompile_commands.json This can be supplied to, for example, the Microsoft C/C++ plug-in for vscode or the YouCompleteMe plug-in for vim, so that the plug-in can correctly parse various dependencies of the current C++ source file, such as header file include paths.
This command is not available by default on CentOS, so you need to install it. The default yum source is not available, so you need to install it from source:
wget /rizsotto/Bear/archive/refs/tags/2.4.
unzip 2.4.
cd Bear-2.4.4
mkdir build; cd build
cmake ..
make
sudo make install
The installation process is also relatively simple, CentOS7 is suitable for older versions, 2.4.4 is tested to work.
transmission
Here's a test from start to finish using tranmission, a well known open source library for BitTorrent network transfers.
git clone --recurse-submodules git@:firedgirl/ transmission
cd transmission
git checkout -b 4. origin/4.
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
Note the addition of the-DCMAKE_EXPORT_COMPILE_COMMANDS=1
option, his role is the same as bear. After the project is compiled, a compile_commands.json file will be generated in the root directory, which has a lot of content, so I won't show it here.link (on a website)。
Move it to the root directory of your project, open neovim, and you can browse it like VSCode. The above transmission is just an example, it can be replaced by any c/c++ open source library. Some platforms don't support the generation of compile_commands.json, so the symbolic jumps are not so accurate, but some function definitions in the file are still supported.
Function
auto-complete
The demo here is for member variables and member functions, but other things like normal variables, function calls, and so on can also be auto-complete.
String lookup
Telescope plugin, underlying based on fzf & rg, shortcut key SPACE + f + w call. The disadvantages are as follows
- Multiple queries for a keyword are inconvenient, you need to enter the keyword each time and traverse from the beginning.
- Jumping to a file and searching for it limits the search to the current directory of the file.
For the second issue, it can be fixed on older versions by modifying the configuration by modifying ~/.config/nvim/lua/core/:
{ "BufEnter", "*", "silent! lcd %:p:h" },
Just comment out the line above. But with the current new version, this configuration is missing, and I haven't taken the time to look into it yet.
Symbol Jump
The diagram above demonstrates several typical jump scenarios:
- gD: declaration, call point jump definition
- K: Cue Definition
- gd: small window display definition
Except for the virtual functions in c++, which can be handled relatively well, the virtual functions can only be determined at runtime which implementation to call, so it's understandable that they can't be skipped over here, but it would be nice if the alternative implementations could be listed so that the user can choose for themselves.
The above picture shows the gh command to find all the call points, in the popup window, the right side lists all the call points by file, when you enter each call point under the file, the left side can be previewed, and enter to jump to the call point. Most of the time, sometimes some symbols can not be found, you have to use the previous string search.
h/cpp file switching
ClangdSwitchSourceHeaderVSplit, based on clangd, shortcut SPACE + h to call it out, the same level can also use ClangdSwitchSourceHeader & ClangdSwitchSourceHeaderSplit, the former is directly replace current The former replaces the current buffer directly, the latter splits the screen horizontally, and you can have SPACE + h point to any of them, depending on your preference. The header files don't have to be in the same directory as the cpp, but can be found by the plugin.
postscript
The first time I got into neovm + nvimdots was in 2022.11, and I recently got a new machine and did it again in 2024.07, and I realized that nvimdots has been updated a lot, so much so that some of the shortcuts and UIs have changed, and some of the porting experience doesn't apply any more, which is a good thing, even though I was very confused for a while. lua-based plugin configuration is booming, and what I write now may not be the same in a year or two. After all, this is the right path, than those who still adhere to vim + gtags + cscope + YouCompleteMe... the old way to be too powerful, and now online information in this regard, far from keeping pace with the progress of the open source community, it is no exaggeration to say that, on the vim to build a modern IDE of the article, as long as more than five years It's no exaggeration to say that articles about vim building modern IDEs that are more than five years old are old, so unless you're studying the history of technology development, there's no need to dig deeper.
lua-based neovim configuration there are many, nvimdots is just one of them, in fact, they use the basic plug-ins are similar, like Lazy, Mason, Lsp, etc., this kind of project is like a glue, will be a variety of scattered small plug-ins integrated together, to achieve the effect of the user out-of-the-box that is, eliminating the need to search for a lot of plug-ins, you have to use a good project! You have a good use of the project, you can also share in the message area ha ~!
Any questions about the use of nvimdots can be answered in theIssue The page asks questions, and some of the questions I asked here were answered very quickly, and some good suggestions were adopted, so I feel a sense of fulfillment! All in all, except for a bunch of Chinese people who are a bit too much for me to handle in English, everything else is fine 😅.
consultation
[1]. Viewing the GLIBC version under Linux (Ubuntu/CentOS)
[2]. Upgrade glibc to 2.18
[3]. Update github's hostsIP via ipaddress
[4]. Can one set std=c99 in GCC as a default? [duplicate]
[5]. yum installs the specified version of the package
[6]. The Cargo Book
[7]. 5 minutes to understand how the userspace file system FUSE works
[8]. ayamir/nvimdots
[9]. Installation and Configuration of the Neovim Code Highlighting Plugin nvim-treesitter
[10]. Getting Started with the Lazy-Nvim Plugin Manager Basics
[11]. Getting Started with neovim Guide (I): Basic Configuration
[12]. My modernized Neovim configuration
[13]. Detailed explanation of nvim built-in LSP system and nvim-cmp based code completion system
[14]. CentOS7 Plugin keeps reporting download failure after installing with script #326
[15]. Scheme cannot be saved after installing CentOS7
[16]. gd/D Cannot jump to definition
[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]. Generate file compile_commands.json
[21]. Android C++ Generate compile_commands.json
[22]. Bear 2.4.4 lite
[23]. How can I traverse functions with jump list?