Vim/zh: Difference between revisions

Ardenet (talk | contribs)
Created page with "如果您需要在添加插件之前运行代码,可以使用 <code>vimrcConfig.beforePlugins</code>(如果您要覆盖 [https://github.com/NixOS/nixpkgs/blob/c3df8057dad986bf7f3928de1b5233fadb52bb15/pkgs/misc/vim-plugins/vim-utils.nix#L264-L267 默认值],请务必包含 <code>set nocompatible</code>)。"
Ardenet (talk | contribs)
Created page with "对于 C/C++ 来说,比 youcompleteme 更好的替代方案是使用 [https://github.com/cquery-project/cquery/ cquery] 并结合 [https://github.com/autozimu/LanguageClient-neovim LanguageClient-neovim]。如果您从 nixpkgs 安装 cquery,它在 nix-shell 中使用时也能找到 C 头文件,因为它使用了一个自定义的 [https://github.com/NixOS/nixpkgs/commit/04f3b76dcec21f2fcba6b1b0afbb3ed224165050#diff-11cdfc0385b9e017089c1ac09c5b838e shell 包装器]。"
 
(2 intermediate revisions by the same user not shown)
Line 373: Line 373:
(python3.withPackages(ps: [
(python3.withPackages(ps: [
   ps.python-language-server
   ps.python-language-server
   <div lang="en" dir="ltr" class="mw-content-ltr">
   # 以下插件为可选插件,它们提供类型检查、导入排序和代码格式化功能。
# the following plugins are optional, they provide type checking, import sorting and code formatting
</div>
   ps.pyls-mypy ps.pyls-isort ps.pyls-black
   ps.pyls-mypy ps.pyls-isort ps.pyls-black
]))
]))
Line 391: Line 389:
=== YouCompleteMe ===
=== YouCompleteMe ===


<div lang="en" dir="ltr" class="mw-content-ltr">
目前 youcompleteme 插件在 Linux 上使用 [https://github.com/NixOS/nixpkgs/blob/8e7b1f2ac2e261d5a644fef860a0d050ea227c06/pkgs/misc/vim-plugins/default.nix#L695 unwrapped clang]。这导致它找不到 <code>stdlib.h</code>。您可以在您的 <code>.ycm_extra_conf.py</code> 文件中添加 [https://github.com/andrewrk/genesis/blob/5f49cd9a8c2b61b9859a22102bc3f732add9461a/.ycm_extra_conf.py 使其正常运行的示例],其工作原理是执行 C/C++ 编译器并使其输出搜索路径列表,其中包括查找 <code>stdlib.h</code> 的搜索路径。
Currently the youcompleteme plugin uses [https://github.com/NixOS/nixpkgs/blob/8e7b1f2ac2e261d5a644fef860a0d050ea227c06/pkgs/misc/vim-plugins/default.nix#L695 unwrapped clang on linux]. This causes it to not find <code>stdlib.h</code>. There is a [https://github.com/andrewrk/genesis/blob/5f49cd9a8c2b61b9859a22102bc3f732add9461a/.ycm_extra_conf.py workaround] you can put in your <code>.ycm_extra_conf.py</code> file, which works by executing the C/C++ compiler and getting it to output the list of search paths - which includes the search path to find <code>stdlib.h</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
对于 C/C++ 来说,比 youcompleteme 更好的替代方案是使用 [https://github.com/cquery-project/cquery/ cquery] 并结合 [https://github.com/autozimu/LanguageClient-neovim LanguageClient-neovim]。如果您从 nixpkgs 安装 cquery,它在 nix-shell 中使用时也能找到 C 头文件,因为它使用了一个自定义的 [https://github.com/NixOS/nixpkgs/commit/04f3b76dcec21f2fcba6b1b0afbb3ed224165050#diff-11cdfc0385b9e017089c1ac09c5b838e shell 包装器]
A better alternative to youcompleteme for C/C++ is to use [https://github.com/cquery-project/cquery/ cquery] in combination with the [https://github.com/autozimu/LanguageClient-neovim LanguageClient-neovim]. It will also find in c header files when used in a nix-shell if you install cquery from nixpkgs as it uses a custom [https://github.com/NixOS/nixpkgs/commit/04f3b76dcec21f2fcba6b1b0afbb3ed224165050#diff-11cdfc0385b9e017089c1ac09c5b838e shell wrapper]
</div>


<span id="gvim_and_gview"></span>
<span id="gvim_and_gview"></span>