Project Icon

nvim

轻量灵活的Neovim配置方案 打造高效开发环境

这是一个针对Neovim的全面配置方案,集成了LSP、Treesitter、Telescope等多种插件,支持智能补全、语法分析、快速搜索等功能。该配置适用于多种编程语言,提供代码导航、调试等开发工具,并优化了键位映射以提高操作效率。方案保持了较高的可定制性,适合不同经验水平的Neovim用户使用,有助于提升整体的开发体验。

My Nvim Configuration

screenshot

💻 This configuration works on my NixOS Linux as well as on my macOS. It requires and is tested with Neovim >= 0.10. It should run with Neovim 0.9.5 but I can't recommend it.

Have a look at my rice how my Linux machine is configured and at my mac-setup how my MBP is configured. My dotfiles are also on GitHub.

More Screenshots

Terminal: alacritty

Font: Jetbrains Mono

Leader Key Clusters via which-key

which-key

See ./lua/core/config/ui/which-key.lua for details.

Go development

go-dev

Debugging via DAP

dap

Motivation

There are many great Neovim configurations (see Inspiration), that give you a pleasant experience right out of the box, available. However, I am a long time (Neo)Vim user with a specific workflow and needs. Additionally, I do not have any Lua background and was not willing to spent too much time into that. Therefore, it was quite hard for me to customize and strip down the existing configs to my needs especially because the code is quite sophisticated.

I decided to move to my own fresh Lua based Neovim from my good old vimrc trying to accomplish the following principles.

Principles

  1. Migrate to Lua based alternative plugins respectively use only Lua based plugins (if possible).
  2. Keep the config as maintainable as possible knowing that this would possibly impact the code quality.
  3. Modular and meaningful directory structure and file naming.
  4. Just make it work and not make it beautiful 😃. Of course, Neovim itself must look beautiful, but my focus is not on beautiful code or on utilizing all Lua features.

Features

General ⚙️

Navigation 🧭

Coding 🖥️

Try out

If you have Docker on your system you can try out this configuration.

💡 Due to installing required tools like LSPs, CLI apps, etc. the image is approximately 3 GB large

Dockerhub

There is a GitHub action in place that builds and pushes the Docker image to Dockerhub as allaman/nvim

Just start Neovim in container

docker run --name nvim --rm -it allaman/nvim

Mount a local directory (to ~/mount) and start Neovim

docker run --name nvim --rm -it -v ${HOME}/tmp:/home/nvim/mount allaman/nvim

Start container in bash instead of Neovim

docker run --name nvim --rm -it --entrypoint=/bin/bash allaman/nvim

Build the image

You can also build the image on your own

docker build -t nvim .

Replace allaman/nvim in the former commands with just nvim.

Requirements

There are some tools that are required in order to use some features/plugins:

Run :checkhealth core to check the status.

Tools

For the neo-tree delete functionality:

For Latex functionality:

  • Tectonic (can be changed in config.lua)
  • Skim (can be changed in config.lua)

LSPs, Formatting, Linters, DAP

The following programs should be installed on your system so that the appropriate tools can be installed:

  • Go
  • Python
  • NodeJs > 12
  • Cargo

All other

All other dependencies are managed by Mason. Tools are installed by running :MasonToolsInstall (in vim.fn.std path("data") .. "mason"). Mason requirements must be available on your system.

Bindings

Some bindings can be overwritten in your user config file. See ./lua/core/config/defaults.lua for possible settings.

Modekeybinding
nspaceLeader key
n<c-h | j | k | l>Change window focus (including Tmux panes)
n<leader>TabSwitch to previously opened buffer
n<Tab>Switch to next buffer (bnext)
n<S-Tab>Switch to previous buffer (bprevious)
nstVisual selection with Treesitter hint textobject
vsaAdd surrounding
nsdDelete surrounding
nsrReplace surrounding
n<c-Tab>Start auto completion
n/vgaStart mini.align (align text)
ngccToggle line comment
n/vgcToggle line comment (works with movements like gcip)
nssJump to character(s) (flash.nvim)
i/s<c-j>Luasnip expand/forward
i/s<c-k>Luasnip backward
i<c-h>Luasnip select choice
n<c-n>Toggleterm (opens/hides a full terminal in Neovim)
i<c-l>Move out of closing brackets
n<CR>Start incremental selection
v<Tab>Increment selection
v<S-Tab>Decrement selection
n<c-f>Search buffer
i/v/n/s<c-s>Save file
n<leader>RrToggle Search and Replace (via Spectre)
n<leader>RwSearch (and replace) current word (via Spectre)
n<leader>RfSearch (and replace) in current file (via Spectre)
n<leader>RcReplace current selection (in Spectre)
n<leader>RRReplace all (in Spectre)
n:LtexLang <lang>Set a specific language like "de-DE" for ltex-ls
n<leader>mcEnable GitHub Copilot (if plugin is enabled in your user config)
n<leader>trToggle Overseer (if plugin is enabled in your user config)
n<leader>rOverseerRun (if plugin is enabled in your user config)
n<leader>lfyazi.nvim or lf.nvim (if enabled in your user config)
n<leader>tzToggle distraction free mode (if plugin is enabled in your user config)
n<leader>tFDisable auto formatting (if conform.nvim is enabled in your user config)
n<leader>tLDisable linting (if nvim-lint is enabled in your user config)

Hit <leader> to start which-key which gives you more mappings grouped by topic.

Structure

❯ tree -L 1 .
.
├── after              # file specific settings
├── config-example.lua # user-config file
├── init.lua           # main entry point
├── lazy-lock.json     # Lockfile for Lazy.nvim
├── lua                # lua configuration
├── snippets           # snippets directory (luasnip style)
└── spell              # my spell files linked from another repo
❯ tree -L 1 lua
lua
├── config # Neovim config and user-config handling
├── core   # checkhealth and plugins
└── utils  # utilities
❯ tree -L 1 lua/config
lua/config
├── autocmds.lua # autocmds
├── defaults/    # default configuration
├── init.lua     # entry point
├── lazy.lua     # plugin management
└── mappings.lua # "global" key mappings
❯ tree -L 1 lua/core
lua/core
├── health.lua # :checkhealth core
└── plugins # plugins and their config

Each plugin to be installed is defined in ./lua/core/plugins/ in a separate file.

User configuration

The intention of my Neovim configuration was never to be a fully customizable "distribution" like LunarVim, SpaceVim, etc. but from time to time I like to change my color scheme and the idea of making this configurable came to my mind. Based upon this idea I implemented some further lightweight configuration options that might be useful.

The default configuration can be found in ./lua/config/defaults.

You can overwrite any of this configuration by writing a .nvim_config.lua file that follows the same structure as the default table and pick only those keys that you want to modify. Have a look at my user configuration in my dots repo. The configuration file should be placed in $XDG_CONFIG_HOME, $HOME, or the windows equivalent path.

You can start with cp ./config-example.lua $HOME/.nvim_config.lua.

Remove plugins

You can remove unwanted plugins by just removing the appropriate file in ./lua/core/plugins/. Lazy will take care of removing the plugin. You should also clean up any default configurations in ./lua/config/defaults.

Keep in mind that some plugins are configured to work in conjunction with other plugins. For instance, autopairs is configured in ./lua/core/plugins/treesitter.lua. For now there is no logic implemented that cross-checks such dependencies.

Add plugins

If you want to follow my method adding a plugin is straight forward:

Create a file in ./lua/core/plugins/ following the expected format of Lazy.

Open another instance of Neovim (I always try to keep one running instance of Neovim open in case I messed up my config) and run Lazy sync.

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号