ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.83k stars 451 forks source link

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

Closed goodpaperman closed 1 year ago

goodpaperman commented 1 year ago

Neovim version

NVIM v0.8.1 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3

Operating system/version

CentOS Linux release 7.9.2009 (Core)

Terminal name/version

GNU bash, version 4.2.46

$TERM environment variable

xterm-256color

Branch info

main (Default/Latest)

How to reproduce the issue

sh install.sh nvim

Expected behavior

预期类似知乎中说明的效果

Actual behavior

图片 图片 图片 图片 图片 图片

Additional information

每次进入都报插件下载失败,网络是联通的,github 可访问

goodpaperman commented 1 year ago
图片

补充:今天看 git clone 居然走了 https 协议,但是看 install.sh 中的记录的协议类型是 ssh 没错:

$ cat .config/nvim/lua/core/settings.lua 
local settings = {}
local home = os.getenv("HOME")

settings["use_ssh"] = true
settings["format_disabled_dirs"] = {
    home .. "/format_disabled_dir_under_home",
}

return settings
goodpaperman commented 1 year ago
图片

看错误详情应当是 git 不识别 rebase=false 参数,怀疑是版本低,当前 CentOS7 上默认版本 1.8,升级为 2.38 后大部分插件更新成功:

图片

只有上面两个没成功

ayamir commented 1 year ago

所以上面两个没成功安装的原因是什么?packer安装的详细log是什么?

goodpaperman commented 1 year ago

新手,不清楚怎么看 packer 详细日志。

图片

展开插件失败详情看报这个错,不明就里,时不时在命令提示符处报以下编译错误:

图片

回车后继续报错,几次后停止。怀疑是 gcc 版本低,CentOS7 自带 gcc 4.8.5,不知道这两个插件需要多高的版本

CharlesChiuGit commented 1 year ago

My gcc version is 11.3.0 on Ubuntu and 12.2.0 on Arch, both works fine. Maybe u can try.

CharlesChiuGit commented 1 year ago

u could also refer to nvim-treesitter requirements.

goodpaperman commented 1 year ago

好高呀,我只能用 8.2 试试运气了

goodpaperman commented 1 year ago

升级 gcc 工作量太大,给 gcc 添加 -std=c99 选项后那个错误没有了,看了下 packer 日志 (~/.cache/nvim/packer.nvim.log),有以下 fzf 错误产生:

[ERROR Thu 24 Nov 2022 12:23:00 PM CST 5.2335412132489e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:778: Error running config for telescope.nvim: "...er/opt/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: loop or previous error loading module 'telescope._extensions.fzf'"
[ERROR Thu 24 Nov 2022 12:35:38 PM CST 5.2411301138825e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:778: Error running config for telescope.nvim: "...er/opt/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: loop or previous error loading module 'telescope._extensions.fzf'"
[ERROR Thu 24 Nov 2022 12:36:26 PM CST 5.2416087578854e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:778: Error running config for telescope.nvim: "...er/opt/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: loop or previous error loading module 'telescope._extensions.fzf'"
[ERROR Thu 24 Nov 2022 02:42:54 PM CST 5.3174815132838e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:778: Error running config for telescope.nvim: "...er/opt/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: loop or previous error loading module 'telescope._extensions.fzf'"
ayamir commented 1 year ago

插件fzf的编译安装需要你的PATH里面能找到可执行的make

goodpaperman commented 1 year ago

补充 checkhealth 内容:

efmls-configs: require("efmls-configs.health").check()
========================================================================
  - OK: All checks passed

man: require("man.health").check()
========================================================================
  - OK: plugin/man.vim not in $VIMRUNTIME
  - OK: autoload/man.vim not in $VIMRUNTIME

mason: require("mason.health").check()
========================================================================
## mason.nvim report
  - OK: neovim version >= 0.7.0
  - WARNING: **Go**: not available
  - WARNING: **cargo**: not available
  - WARNING: **luarocks**: not available
  - WARNING: **Ruby**: not available
  - WARNING: **RubyGem**: not available
  - WARNING: **Composer**: not available
  - WARNING: **PHP**: not available
  - ERROR: **npm**: not available
  - ERROR: **node**: not available
  - WARNING: **python3**: not available
  - WARNING: **pip3**: not available
  - WARNING: **javac**: not available
  - WARNING: **java**: not available
  - WARNING: **julia**: not available
  - OK: **wget**: `GNU Wget 1.14 built on linux-gnu.`
  - OK: **curl**: `curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0`
  - OK: **gzip**: `gzip 1.5`
  - OK: **tar**: `tar (GNU tar) 1.26`
  - OK: **bash**: `GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)`
  - OK: **sh**: `Ok`
  - WARNING: **python3_host_prog**: not available
  - WARNING: **python3_host_prog pip**: not available
  - OK: GitHub API rate limit. Used: 3. Remaining: 57. Limit: 60. Reset: Thu 24 Nov 2022 03:50:48 PM CST.

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $SSH_TTY='/dev/pts/0'

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - WARNING: No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.
    - ADVICE:
      - :help |clipboard|

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/bin/python3"
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - INFO: Executable: Not found

## 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)
  - WARNING: `node` and `npm` (or `yarn`, `pnpm`) must be in $PATH.
    - ADVICE:
      - Install Node.js and verify that `node` and `npm` (or `yarn`, `pnpm`) commands work.

## 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

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/yunhai01/.local/state/nvim/lsp.log
  - INFO: Log size: 0 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for help: ABI version 14
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for vim: ABI version 14
goodpaperman commented 1 year ago

补充 make 版本:

$ make --version GNU Make 3.82 Built for x86_64-redhat-linux-gnu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://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.

ayamir commented 1 year ago

多次执行nvim +PackerSync都无法解决问题吗? 另外汇总一下现在还剩下的问题吧。

goodpaperman commented 1 year ago

发现 git clone 老失败,按网上的设置了一下 github 的 hosts 解决,之前有一些问题搞定了,缺的一些命令像 rg、fd、fzf、python3、ruby、node、rpm 都装了一下。现在 PackerSync 仍然是那两个模块安装不成功,错误日志相同:

[ERROR Thu 24 Nov 2022 10:03:50 PM CST 5.5820434359791e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:778: Error running config for telescope.nvim: "...er/opt/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: loop or previous error loading module 'telescope._extensions.fzf'"

checkhealth 输出如下:

efmls-configs: require("efmls-configs.health").check()
========================================================================
  - OK: All checks passed

gitsigns: require("gitsigns.health").check()
========================================================================
  - OK: git version 2.38.1

hop: require("hop.health").check()
========================================================================
## Ensuring keys are unique
  - OK: Keys are unique

## Checking for deprecated features
  - OK: All good

man: require("man.health").check()
========================================================================
  - OK: plugin/man.vim not in $VIMRUNTIME
  - OK: autoload/man.vim not in $VIMRUNTIME

mason: require("mason.health").check()
========================================================================
## mason.nvim report
  - OK: neovim version >= 0.7.0
  - WARNING: **Go**: not available
  - OK: **cargo**: `cargo 1.65.0`
  - WARNING: **luarocks**: not available
  - OK: **Ruby**: `ruby 2.0.0p648 (2015-12-16) [x86_64-linux]`
  - OK: **RubyGem**: `2.0.14.1`
  - WARNING: **Composer**: not available
  - WARNING: **PHP**: not available
  - OK: **npm**: `8.15.0`
  - OK: **node**: `v16.17.0`
  - OK: **python3**: `Python 3.6.8`
  - OK: **pip3**: `pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)`
  - WARNING: **javac**: not available
  - WARNING: **java**: not available
  - WARNING: **julia**: not available
  - OK: **wget**: `GNU Wget 1.14 built on linux-gnu.`
  - OK: **curl**: `curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0`
  - OK: **gzip**: `gzip 1.5`
  - OK: **tar**: `tar (GNU tar) 1.26`
  - OK: **bash**: `GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)`
  - OK: **sh**: `Ok`
  - OK: **python3_host_prog**: `Python 3.6.8`
  - OK: **python3_host_prog pip**: `pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)`
  - OK: GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Thu 24 Nov 2022 11:23:36 PM CST.

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $SSH_TTY='/dev/pts/0'

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - OK: `node` found v16.17.0 (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.

## Parser/Features H L F I J
  - javascript     ✓ ✓ ✓ ✓ ✓
  - rust           ✓ ✓ ✓ ✓ ✓
  - json           ✓ ✓ ✓ ✓ .
  - vim            ✓ ✓ ✓ . ✓
  - lua            ✓ ✓ ✓ ✓ ✓
  - gomod          ✓ . . . ✓
  - c              ✓ ✓ ✓ ✓ ✓
  - help           ✓ . . . ✓
  - typescript     ✓ ✓ ✓ ✓ ✓
  - css            ✓ . ✓ ✓ ✓
  - bash           ✓ ✓ ✓ . ✓
  - python         ✓ ✓ ✓ ✓ ✓
  - vue            ✓ . ✓ ✓ ✓
  - cpp            ✓ ✓ ✓ ✓ ✓
  - go             ✓ ✓ ✓ ✓ ✓
  - html           ✓ ✓ ✓ ✓ ✓
  - make           ✓ . ✓ . ✓
  - latex          ✓ . ✓ . ✓
  - 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)
  - INFO: Using: g:python3_host_prog = "/usr/bin/python3"
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.6.8
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.
      - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

## Node.js provider (optional)
  - INFO: Node.js: v16.17.0
  - INFO: Nvim node.js host: /usr/local/lib/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn/pnpm package is installed: 4.10.1

## 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

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: `notify`
  - INFO: No healthcheck provided

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/yunhai01/.local/state/nvim/lsp.log
  - INFO: Log size: 3 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for bash: ABI version 14
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for cpp: ABI version 14
  - OK: Loaded parser for css: ABI version 13
  - OK: Loaded parser for go: ABI version 14
  - OK: Loaded parser for gomod: ABI version 13
  - OK: Loaded parser for help: ABI version 14
  - OK: Loaded parser for html: ABI version 13
  - OK: Loaded parser for javascript: ABI version 13
  - OK: Loaded parser for json: ABI version 13
  - OK: Loaded parser for latex: ABI version 14
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for make: ABI version 13
  - OK: Loaded parser for python: ABI version 14
  - OK: Loaded parser for rust: ABI version 14
  - OK: Loaded parser for typescript: ABI version 14
  - OK: Loaded parser for vim: ABI version 14
  - OK: Loaded parser for vue: ABI version 13
  - OK: Loaded parser for yaml: ABI version 13
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for help: ABI version 14
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for vim: ABI version 14
CharlesChiuGit commented 1 year ago

telescope內的fzf是需要make去另外build出來的 跟cli tool的fzf不相關 我猜想你可能也需要升級一下make. my make version on Arch and Ubuntu are both 4.3. https://github.com/nvim-telescope/telescope-fzf-native.nvim#make-linux-macos-windows-with-mingw

goodpaperman commented 1 year ago

This extension doesn't exist or is not installed: fzf

找到一个类似的问题,解决方案是重新 make 其中一个模块,搜索文件定位后重新编译:

图片

发现 PackerSync 日志还是报同样的错。make 阶段能成功,感觉不是版本低的锅~

CharlesChiuGit commented 1 year ago

我在想你手動make完之後可能需要把這行comment掉 https://github.com/ayamir/nvimdots/blob/4a066829f5f2caea30ed60e46ffb046604c85c12/lua/modules/tools/plugins.lua#L17

CharlesChiuGit commented 1 year ago

另外你方便整理一下目前還有的error嗎 有點不知道你現在還存在哪些問題? lol

goodpaperman commented 1 year ago

将 run = make 注释掉了,不起作用,我把 libfzf.so 从 build 目录移到上一层目录后,packer 日志不报错了。 但执行 PackerSync 仍有两个模块出错:

图片

缺失这两个插件会导致运行过程中一直报错:

图片

图片

基本就这些吧,关键是不清楚这两个模块为何出错,看 packer 日志 (~/.cache/nvim/packer.nvim.log) 没有信息,展开浮窗信息更困惑了,not a git repository 是什么原因,一般插件会在哪里 clone?我可以去检查下是不是有同名文件夹已存在

CharlesChiuGit commented 1 year ago

packer是把plugin都放在 ~/.local/share/nvim/site/pack/packernot a git repository 我最近在clone其他跟neovim無關的git repo也遇到 明明folder裡就有.git folder 有點莫名其妙的問題 我目前也還沒有解決方法

ayamir commented 1 year ago

这两个插件的仓库位置:

  1. nvim-lspconfig
  2. lspkind.nvim 正常来讲这两个插件clone之后的位置在: ~/.local/share/nvim/site/pack/packer/opt~/.local/share/nvim/site/pack/packer/start image image
goodpaperman commented 1 year ago

果然空了:

[yunhai01@goodcitizen ~]$ ls -lh ~/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig/ total 0 [yunhai01@goodcitizen ~]$ ls -lh ~/.local/share/nvim/site/pack/packer/start/lspkind.nvim/ total 0

goodpaperman commented 1 year ago

手动删除空目录后重新 PackerSync 成功了:

图片
ayamir commented 1 year ago

所以可以close了吗?

goodpaperman commented 1 year ago

零零星星还有一些错误,一些功能也不可用,明天再研究研究

图片 图片
goodpaperman commented 1 year ago

网络方面的问题解决了,这个贴先关了吧,有其它问题再建新贴。

总结一下在老旧系统 (CentOS7) 上搭建现代化 neovim 开发环境需要注意的点:

jqbk commented 1 year ago

网络方面的问题解决了,这个贴先关了吧,有其它问题再建新贴。

总结一下在老旧系统 (CentOS7) 上搭建现代化 neovim 开发环境需要注意的点:

  • 安装 neovim 不要使用 sudo yum install neovim,那个是 0.3 的版本,不支持 packer curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage chmod u+x nvim.appimage ./nvim.appimage sudo ln -s $PWD/squashfs-root/AppRun /usr/local/bin/nvim
  • 安装 git 不要使用 sudo yum install git,那个是 1.8 版本的,不支持 rebase=false 参数,会导致插件下载失败 sudo yum install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm sudo yum install git
  • 设置 github hosts 防止 git 网络访问超时 140.82.114.4 github.com 140.82.114.10 nodeload.github.com 140.82.114.6 api.github.com 140.82.114.10 codeload.github.com 具体 ip 可通过 address.com 反查
  • 修改 gcc 编译参数 系统自带的 gcc 4.8.5 应该够用,只是需要添加 -std=c99 选项,否则会在编译插件时报错。具体操作参考下面这篇文章: https://stackoverflow.com/questions/26599758/can-one-set-std-c99-in-gcc-as-a-default
  • 安装 rg、fd 插件需要用到,rg 为必需,fd 为可选,其中 rg 可通过 yum 直接安装: sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo sudo yum install ripgrep fd 必需通过 cargo 安装: sudo yum install cargo cargo install fd-find 安装后位于 ~/.cargo/bin,需要复制到 /usr/local/bin,单纯添加到 PATH 实测不起作用
  • 安装 efm-langserver lsp server,需要先安装 go sudo yum install go 使用 go 安装 efm-langserver 时会报网络访问错误,需要先设置下代理 go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.io,direct go env -w GOPRIVATE=*.corp.example.com 然后安装 go install github.com/mattn/efm-langserver@latest sudo cp efm-langserver /usr/local/bin
  • 更新 wget 默认版本 1.14 太老了,需要升级到最新版本,否则部分 lsp server 拉取失败 (lua,cpp) 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
  • 安装 sqlite sudo yum install sqlite sqlite-devel scheme 插件后面会用 sqlite 存储配置
  • 安装可显示 icon 的字体 Nerd Font 注意为终端指定安装后的字体 如果不安装可显示 icon 的字体,则l对应的位置会显示问号
  • 安装 nvimdots 按 install 说明安装即可: sh install.sh
  • 安装后 会自动执行 nvim +PackerSync 下载插件,可通过浮窗查看安装过程是否有问题,点开可看错误详情: packer 日志位于:~/.cache/nvim/packer.nvim.log 插件下载路径位于: ~/.local/share/nvim/site/pack/packer/opt/ ~/.local/share/nvim/site/pack/packer/start/ 另外最好执行下 :checkhealth 检查一下,也可以提供很多提示
  • fzf 模块无法加载问题 看 packer 日志会报这个,定位到路径: ~/.local/share/nvim/site/pack/packer/opt/telescope-fzf-native.nvim/build 看是否有 libfzf.so 文件,如果有直接移动到上一级目录,重新执行 PackerSync 即可
  • cpp 语言 gd/D 无效果问题 :mason 查看已安装语言列表,如果没有安装 :MasonInstall clangd 如果 wget 多次失败仍无法安装,可以手动下载这个文件 mv clangd-linux-15.0.3.zip ~/.local/share/nvim/mason/packages unzip clangd-linux-15.0.3.zip cd ../bin ln -s ../packages/clangd-linux-15.0.3/bin/clangd clangd 运行 clangd 报 GLIBC2.18 未安装,按这篇文章提升一下 glibc 版本即可
  • clang-format 安装

    • 自动安装,需要 gcc 版本大于等于 5.1 先更新 python 3.6.8 到 3.8 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 安装 wheel 模块 sudo pip3 install wheel 在 nvim 中更新 mason 模块 MasonInstall clang-format
    • 手动安装 wget -c https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-1d7ec53d/clang-format-10_linux-amd64 mv clang-format-10_linux-amd64 ~/.local/share/nvim/mason/packages chmod u+x clang-format-10_linux-arm64 cd ../bin ln -s ../packages/clang-format-10_linux-amd64 clang-format
    • 配置 重启 nvim 打开文件后 Mason 查看,clang-format 已安装成功 输入 :FormatToogle 关闭保存时自动 format 启动时关闭这一特性:~/.config/nvim/lua/core/settings.lua, settings["format_on_save"] = false 对某些路径关闭这一特性:~/.config/nvim/lua/core/settings.lua 中的 settings["format_disable_dirs"] 中设置路径,目前不支持使用通配符
  • 界面为蓝色 修改主题为 industry:~/.config/nvim/lua/core/init.lua,修改下面这句 vim.api.nvim_command([[colorscheme industry]])
  • 状态栏背景为蓝色 修改主题为 auto: ~/.config/nvim/lua/modules/ui/config.lua,修改下面这句 require("lualine").setup...options=...theme = "onelight" lualine 主题与 nvim 主题不是一套,可参考这篇
  • 创建项目编译数据库,以便跨文件符号跳转

    • cmake:cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1
    • ndk-build:ndk-build GEN_COMPILE_COMMANDS_DB=true
    • others:bear xxxx wget https://github.com/rizsotto/Bear/archive/refs/tags/2.4.4.tar.gz tar xvf 2.4.4.tar.gz make all sudo make install 生成的 compile_commands.json 放在代码根目录,再启动 nvim 经过 clangd indexing 后就可以使用了
  • 映射 Ctrl+j/k 到 Ctrl+e/y 查看键映射: verbose nmap 修改文件:~/.config/nvim/lua/core/mapping.lua,将其中内容替换为:
  -- ["n|<C-h>"] = map_cmd("<C-w>h"):with_noremap(),
  -- ["n|<C-l>"] = map_cmd("<C-w>l"):with_noremap(),
  -- ["n|<C-k>"] = map_cmd("<C-w>k"):with_noremap(),
  -- ["n|<C-j>"] = map_cmd("<C-w>j"):with_noremap(),
  ["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(),

去掉 with_noremap 可以实现一次滚动多行效果,这个由 Ctrl+h/l 来映射

  • 全局搜索 : telescope live_grep [fw] 注意为了防止打开文件后自动切换工作目录缩小搜索范围,可修改文件:~/.config/nvim/lua/core/event.lua 中的配置: -- { "BufEnter", "*", "silent! lcd %:p:h" },
  • 临时关闭编码规范检查 :lua vim.diagnostic.config({virtual_text = false})
  • 切换 c/cc/cpp 与 h 文件 修改文件:~/.config/nvim/lua/core/event.lua
-- "nnoremap <leader>h :ClangdSwitchSourceHeaderVSplit<CR>",
 "nnoremap <leader>h :ClangdSwitchSourceHeader<CR>",

您好,关于gcc -std=c99,我试着在spec文件中修改为:%{std=c99&ansi&trigraphs},但是仍然提示需要c99 mode,想请教下具体如何修改呢?

goodpaperman commented 11 months ago

我检查了一下我的配置,是改成了这个样子:

$ 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}

是将 -std=c99 单独插入在了各个选项中,没有修改之前的选项。 @jqbk