AstroNvim 与 astrocommunity 配置方法

507 阅读2分钟

背景介绍

AstroNvim 作为目前最流行的 Neovim 配置之一,其分离式的目录结构使得个性化配置变得非常便捷,要最大化的利用它并且实现个性化配置,我们需要从整体上去理解它的组织方式。这篇文章就从其项目架构开始介绍基础的配置方法。

AstroNvim 有如下独立的子项目:
  • astrocore
  • astroui
  • astrolsp
  • template
  • astrocommunity

其中 astrocommunity 是面向用户的 Neovim 配置大全,我们可以根据需要从中取得我们想要的插件的配置。它包含的插件非常广泛,并且配置信息组织非常合理,这是值得我们花时间去理解和掌握的。

template 是我们的框架入口,如果我们需要使用上述子项目 astrocommunity,我们应该这样:

image.png

注意,我们一般只会显式的使用子项目 astrocommunity,而不会用到其他项目。因为 asctrocore, astroui 等项目都是作为基础性的、支撑性的项目。astrocommunity 会引用这些项目。

注意看 lazy_setup.lua 中的 "import = "plugins",

image.png

plugins 目录下有许多文件,其实这些都是提供了一个模板,这属于我们自己要进行 customize 的部分,应该放在最后。

image.png

lua/community.lua 文件中,我们可以按如下方式引入自己想要的配置:

return {
  -- Add the community repository of plugin specifications
  "AstroNvim/astrocommunity",
  -- example of importing a plugin
  -- available plugins can be found at https://github.com/AstroNvim/astrocommunity
  { import = "astrocommunity.colorscheme.catppuccin" },
  { import = "astrocommunity.completion.copilot-lua" },
  -- example of importing an entire language pack
  -- these packs can set up things such as Treesitter, Language Servers, additional language specific plugins, and more!
  { import = "astrocommunity.pack.rust" },
  { import = "astrocommunity.pack.python" },
}

好了,这边文章就简单介绍到这里,作为一个入门,如果想要了解更多,还可以继续查阅 官方文档

当然,我后续还会发文更深入探究 community 中的配置项。

如果你喜欢我的文章,欢迎关注我的微信公众号 deliverit。