Neovim/zh: Difference between revisions

Ardenet (talk | contribs)
mNo edit summary
Ardenet (talk | contribs)
mNo edit summary
Tags: Mobile edit Mobile web edit
 
(11 intermediate revisions by the same user not shown)
Line 20: Line 20:
:''另见: [[Special:MyLanguage/Vim|Vim]]''
:''另见: [[Special:MyLanguage/Vim|Vim]]''


[https://neovim.io/ Neovim]<ref>Neovim Team, "Home - Neovim", Neovim Official Website, Last updated March 2025, Accessed June 2025. https://neovim.io/</ref> 是一款高度可扩展的开源文本编辑器,旨在改进和现代化流行的 [[Special:MyLanguage/Vim|Vim]]<ref>NixOS Wiki Community, "Vim", NixOS Wiki, Last edited 24 February 2025, Accessed June 2025. https://wiki.nixos.org/wiki/Vim</ref> 编辑器。它被设计为 Vim 的无缝衔接替代品,在保持与大多数 Vim 插件和配置的兼容性的同时,提供额外的功能和改进。Neovim 注重可扩展性、易用性和性能。
[https://neovim.io/ Neovim]<ref>Neovim 团队, "Home - Neovim", Neovim 官方网站, 最后更新日期:2025年3月;访问日期:2025年6月。 https://neovim.io/</ref> 是一款高度可扩展的开源文本编辑器,旨在改进和现代化流行的 [[Special:MyLanguage/Vim|Vim]]<ref>NixOS 维基社区, "Vim", NixOS 维基, 最后编辑于 2025 年 2 月 24 日,访问于 2025 年 6 月。 https://wiki.nixos.org/wiki/Vim</ref> 编辑器。它被设计为 Vim 的无缝衔接替代品,在保持与大多数 Vim 插件和配置的兼容性的同时,提供额外的功能和改进。Neovim 注重可扩展性、易用性和性能。


它引入了强大的插件架构,支持异步插件执行,这可以显著提升某些操作的性能。它还内置了终端模拟器,允许用户直接在编辑器中运行 shell 命令。该项目注重代码质量和可维护性,拥有简洁且文档完善的代码库,方便开发者贡献代码。
它引入了强大的插件架构,支持异步插件执行,这可以显著提升某些操作的性能。它还内置了终端模拟器,允许用户直接在编辑器中运行 shell 命令。该项目注重代码质量和可维护性,拥有简洁且文档完善的代码库,方便开发者贡献代码。
Line 107: Line 107:
==== 包的变体 ====
==== 包的变体 ====


<div lang="en" dir="ltr" class="mw-content-ltr">
请查看 [https://github.com/nix-community/neovim-nightly-overlay Neovim Nightly Overlay]<ref>Nix 社区, "neovim-nightly-overlay", GitHub, 最后更新于 2025 年 6 月,访问于 2025 年 6 月。https://github.com/nix-community/neovim-nightly-overlay</ref> 以安装最新的 Neovim nightly 版本。
Have a look at the [https://github.com/nix-community/neovim-nightly-overlay Neovim Nightly Overlay]<ref>Nix Community, "neovim-nightly-overlay", GitHub, Last updated June 2025, Accessed June 2025. https://github.com/nix-community/neovim-nightly-overlay</ref> to install the most recent current nightly version of Neovim.
</div>


您可以通过以下命令运行主版本:
您可以通过以下命令运行主版本:
Line 181: Line 179:
   }
   }


   <div lang="en" dir="ltr" class="mw-content-ltr">
   # tree-sitter 安装语法
# Installing grammars for tree-sitter
   # 选项 1:安装所有语法包
   # Option 1: Install all grammar packages
   pkgs.vimPlugins.nvim-treesitter.withAllGrammars
   pkgs.vimPlugins.nvim-treesitter.withAllGrammars
 
 
   # Option 2: Install specific grammar packages
   # 选项 2:安装特定语法包
   # (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ p.c p.java ]))
   # (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ p.c p.java ]))
</div>


   <div lang="en" dir="ltr" class="mw-content-ltr">
   # 选项 3:不使用 Nix 安装语法
# Option 3: Installing grammars without Nix
# 通过内置命令安装语法包可能会导致错误。
  # Installing grammar packages through the built-in command can lead to errors.
# 以下 Neovim 命令将为 C 编程语言安装语法高亮::TSInstall c
  # The following Neovim command will install syntax highlighting for the C programming language: :TSInstall c
</div>
];}}
];}}


Line 200: Line 194:
==== 框架 ====
==== 框架 ====


<div lang="en" dir="ltr" class="mw-content-ltr">
如果您不想手动配置系统,NixOS 提供了多种预定义配置和社区支持的选项。以下列举其中一些:
If you prefer not to configure your system manually, NixOS offers several predefined configurations and community-supported options. Here are a few of them:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* [https://www.lazyvim.org/ LazyVim]<ref>LazyVim 团队, "入门教程", LazyVim 官方网站, © 2025, 访问于 2025年6月。 https://www.lazyvim.org/</ref>
* [https://www.lazyvim.org/ LazyVim]<ref>LazyVim Team, "Getting Started", LazyVim Official Website, © 2025, Accessed June 2025. https://www.lazyvim.org/</ref>
* [https://astronvim.com/ AstroNvim]<ref>AstroNvim 团队, "AstroNvim", AstroNvim 官方网站, N/A, 访问于 2025年6月。 https://astronvim.com/</ref>
* [https://astronvim.com/ AstroNvim]<ref>AstroNvim Team, "AstroNvim", AstroNvim Official Website, N/A, Accessed June 2025. https://astronvim.com/</ref>
* [https://nvchad.com/ NVChad]<ref>Siduck, "NvChad", NvChad 官方网站, © 2025, 访问于 2025年6月。 https://nvchad.com/</ref>
* [https://nvchad.com/ NVChad]<ref>Siduck, "NvChad", NvChad Official Website, © 2025, Accessed June 2025. https://nvchad.com/</ref>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
默认情况下,LazyVim 会阻止加载非 LazyVim 管理的插件。这包括所有通过 Nix 安装的插件。如果您想同时使用 Nix LazyVim 安装插件,请将以下内容添加到您的 LazyVim 配置中:
LazyVim, by default, will prevent loading plugins that are not managed by LazyVim. This includes all plugins installed via Nix. If you want to install plugins with both Nix and LazyVim, add the following to your LazyVim setup:
</div>


{{code|lang=lua|line=no|1=
{{code|lang=lua|line=no|1=
Line 223: Line 211:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://github.com/folke/lazy.nvim/issues/402#issuecomment-2084997594 源码]
[https://github.com/folke/lazy.nvim/issues/402#issuecomment-2084997594 Source]
</div>


<span id="FHS_wrapper"></span>
<span id="FHS_wrapper"></span>
==== FHS 包装 ====
==== FHS 包装 ====


<div lang="en" dir="ltr" class="mw-content-ltr">
您可以创建自定义的 Neovim FHS 包装器
You can create a custom neovim FHS wrapper
</div>


{{code|lang=nix|line=no|1=
{{code|lang=nix|line=no|1=
Line 251: Line 235:


<!--T:FHS_WRAPPER_SOURCE-->
<!--T:FHS_WRAPPER_SOURCE-->
<div lang="en" dir="ltr" class="mw-content-ltr">
FHS 封装示例基于 nixpkgs 中的一个贡献代码<ref name="nixpkgs-pr-334032">NixOS,“功能:自定义 Neovim FHS 封装”(Pull Request #334032),GitHub,2025 年,访问于 2025 年 6 月。https://github.com/NixOS/nixpkgs/pull/334032</ref>
This FHS wrapper example is based on a contribution to nixpkgs<ref name="nixpkgs-pr-334032">NixOS, "Feature: Custom Neovim FHS Wrapper" (Pull Request #334032), GitHub, 2025, Accessed June 2025. https://github.com/NixOS/nixpkgs/pull/334032</ref>.
有关包含使用类似 FHS 环境设置 <code>mason.nvim</code> 的扩展配置,请参阅此 [https://github.com/NixOS/nixpkgs/issues/281219#issuecomment-2284713258 NixOS/nixpkgs 问题评论]
For an extended configuration that includes setting up <code>mason.nvim</code> with a similar FHS environment, see this [https://github.com/NixOS/nixpkgs/issues/281219#issuecomment-2284713258 NixOS/nixpkgs issue comment].
</div>


== 故障排除 ==
== 故障排除 ==
Line 262: Line 244:
==== lua-language-server: 动态链接可执行文件错误 ====
==== lua-language-server: 动态链接可执行文件错误 ====


<div lang="en" dir="ltr" class="mw-content-ltr">
在您的<code>~/.local/state/nvim/lsp.log</code>文件中,您会看到以下错误:
In your <code>~/.local/state/nvim/lsp.log</code>, you have the following error:
</div>


{{code|lang=text|line=no|1=[ERROR][2025-06-07 23:13:15] ...p/_transport.lua:36 "rpc" "lua-language-server" "stderr" "Could not start dynamically linked executable: /home/incogshift/.local/share/nvim/mason/packages/lua-language-server/libexec/bin/lua-language-server\nNixOS cannot run dynamically linked executables intended for generic\nlinux environments out of the box. For more information, see:\nhttps://nix.dev/permalink/stub-ld\n"}}
{{code|lang=text|line=no|1=[ERROR][2025-06-07 23:13:15] ...p/_transport.lua:36 "rpc" "lua-language-server" "stderr" "Could not start dynamically linked executable: /home/incogshift/.local/share/nvim/mason/packages/lua-language-server/libexec/bin/lua-language-server\nNixOS cannot run dynamically linked executables intended for generic\nlinux environments out of the box. For more information, see:\nhttps://nix.dev/permalink/stub-ld\n"}}


<!--T:LUA_LS_SO_REF-->
<!--T:LUA_LS_SO_REF-->
<div lang="en" dir="ltr" class="mw-content-ltr">
这个问题可以在 Stack Overflow 上找到解决方案<ref name="so-lua-ls-dynlink">Stack Overflow 贡献者,“对‘无法在 NixOS 上启动动态链接可执行文件...’的解答”,Stack Overflow,2025,访问于 2025 年 6 月。https://stackoverflow.com/a/78215911/27134695</ref>
A solution for this issue can be found on Stack Overflow<ref name="so-lua-ls-dynlink">Stack Overflow Contributor, "Answer to 'Could not start dynamically linked executable... on NixOS'", Stack Overflow, 2025, Accessed June 2025. https://stackoverflow.com/a/78215911/27134695</ref>.
</div>


<span id="See_also"></span>
<span id="See_also"></span>